• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IsConstant函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IsConstant函数的典型用法代码示例。如果您正苦于以下问题:C++ IsConstant函数的具体用法?C++ IsConstant怎么用?C++ IsConstant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsConstant函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: MakePlayerAlreadyMember

void Channel::Join(uint64 p, const char *pass)
{
    WorldPacket data;
    
    std::string worldChatChannelName = sWorld->GetWorldChatChannelName();
    uint64 worldChatOwnerGuid = sWorld->GetWorldChatOwnerGuid();
    uint64 worldChatIdleGuid = sWorld->GetWorldChatIdleGuid();
    
    if (IsOn(p))
    {
        if ( m_name != worldChatChannelName )
        {
            if (!IsConstant())
            {
                MakePlayerAlreadyMember(&data, p);
                SendToOne(&data, p);
            }
            return;
        }
    }

    if (IsBanned(p))
    {
        MakeBanned(&data);
        SendToOne(&data, p);
        return;
    }

    if (m_password.length() > 0 && strcmp(pass, m_password.c_str()))
    {
        MakeWrongPassword(&data);
        SendToOne(&data, p);
        return;
    }

    Player* player = ObjectAccessor::FindPlayer(p);

    if (player)
    {
        if (HasFlag(CHANNEL_FLAG_LFG) &&
            sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup())
        {
            MakeNotInLfg(&data);
            SendToOne(&data, p);
            return;
        }

        player->JoinedChannel(this);
    }

    if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
    {
        MakeJoined(&data, p);
        SendToAll(&data);
    }

    data.clear();

    PlayerInfo pinfo;
    pinfo.player = p;
    pinfo.flags = MEMBER_FLAG_NONE;
    players[p] = pinfo;

    MakeYouJoined(&data);
    SendToOne(&data, p);

    JoinNotify(p);

    if ( m_name != worldChatChannelName )
    {
        if (!IsConstant() && !m_ownerGUID)
        {
            SetOwner(p, (players.size() > 1 ? true : false));
            players[p].SetModerator(true);
        }
    } 
    else 
    {
        if ( p == worldChatOwnerGuid )
        {
            SetOwner(worldChatOwnerGuid, true);
            players[worldChatOwnerGuid].SetModerator(true);
        }
        else 
        {
            SetOwner(worldChatIdleGuid, true);
            players[worldChatIdleGuid].SetModerator(true);
        }
    }
}
开发者ID:Anonymus123,项目名称:AtomicCore-3.3.5a,代码行数:90,代码来源:Channel.cpp


示例2: MakeNotMember

void Channel::Leave(uint64 p, bool send)
{
    std::string worldChatChannelName = sWorld->GetWorldChatChannelName();
    uint64 worldChatOwnerGuid = sWorld->GetWorldChatOwnerGuid();
    uint64 worldChatIdleGuid = sWorld->GetWorldChatIdleGuid();
    
    if (!IsOn(p))
    {
        if (send)
        {
            WorldPacket data;
            MakeNotMember(&data);
            SendToOne(&data, p);
        }
    }
    else
    {
        Player* player = ObjectAccessor::FindPlayer(p);

        if (send)
        {
            WorldPacket data;
            MakeYouLeft(&data);
            SendToOne(&data, p);
            if (player)
                player->LeftChannel(this);
            data.clear();
        }

        bool changeowner = players[p].IsOwner();

        players.erase(p);
        if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
        {
            WorldPacket data;
            MakeLeft(&data, p);
            SendToAll(&data);
        }

        LeaveNotify(p);

        if (!IsConstant())
        {
            // Update last_used timestamp in db
            UpdateChannelUseageInDB();

            // If the channel owner left and there are still players inside, pick a new owner
            if (changeowner && m_ownership && !players.empty())
            {
                if ( m_name != worldChatChannelName )
                {
                    uint64 newowner = !players.empty() ? players.begin()->second.player : 0;
                    players[newowner].SetModerator(true);
                    SetOwner(newowner);
                }
                else
                {
                    if ( IsOn(worldChatOwnerGuid) ) 
                    {
                         uint64 newowner = worldChatOwnerGuid;
                        players[newowner].SetModerator(true);
                        SetOwner(newowner);
                    }
                    else
                    {
                        uint64 newowner = worldChatIdleGuid;
                        players[newowner].SetModerator(true);
                        SetOwner(newowner);
                    }
                }
            }
        }
    }
}
开发者ID:Anonymus123,项目名称:AtomicCore-3.3.5a,代码行数:74,代码来源:Channel.cpp


示例3: MakeNotMember

void Channel::LeaveChannel(Player* player, bool send)
{
    uint64 guid = player->GetGUID();
    if (!IsOn(guid))
    {
        if (send)
        {
            WorldPacket data;
            MakeNotMember(&data);
            SendToOne(&data, guid);
        }
        return;
    }

    if (send)
    {
        WorldPacket data;
        MakeYouLeft(&data);
        SendToOne(&data, guid);
        player->LeftChannel(this);
        data.clear();
    }

    bool changeowner = playersStore[guid].IsOwner();

    playersStore.erase(guid);
    if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
                       !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
    {
        WorldPacket data;
        MakeLeft(&data, guid);
        SendToAll(&data);
    }

    RemoveWatching(player);
    LeaveNotify(player);

    if (!IsConstant())
    {
        // Update last_used timestamp in db
        UpdateChannelUseageInDB();

        // If the channel owner left and there are still playersStore inside, pick a new owner
        if (changeowner && _ownership)
        {
            if (!playersStore.empty())
            {
                uint64 newowner = 0;
                for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
                {
                    newowner = itr->second.player;
                    if (!itr->second.plrPtr->GetSession()->GetSecurity())
                        break;
                }
                SetOwner(newowner);
            }
            else
                SetOwner(0);
        }
    }
}
开发者ID:Keader,项目名称:Sunwell,代码行数:61,代码来源:Channel.cpp


示例4: MakePlayerAlreadyMember

void Channel::Join(ObjectGuid p, const char *pass)
{
    WorldPacket data;
    if (IsOn(p))
    {
        if(!IsConstant())                                   // non send error message for built-in channels
        {
            MakePlayerAlreadyMember(&data, p);
            SendToOne(&data, p);
        }
        return;
    }

    if (IsBanned(p))
    {
        MakeBanned(&data);
        SendToOne(&data, p);
        return;
    }

    if(m_password.length() > 0 && strcmp(pass, m_password.c_str()))
    {
        MakeWrongPassword(&data);
        SendToOne(&data, p);
        return;
    }

    Player *plr = sObjectMgr.GetPlayer(p);

    if(plr)
    {
        if(HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() <= SEC_CURATOR )
        {
            MakeNotInLfg(&data);
            SendToOne(&data, p);
            return;
        }

        if(plr->GetGuildId() && (GetFlags() == 0x38))
            return;

        plr->JoinedChannel(this);
    }

    if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL) ))
    {
        MakeJoined(&data, p);
        SendToAll(&data);
    }

    data.clear();

    PlayerInfo& pinfo = m_players[p];
    pinfo.player = p;
    pinfo.flags = 0;

    MakeYouJoined(&data);
    SendToOne(&data, p);

    JoinNotify(p);

    // if no owner first logged will become
    if(!IsConstant() && !m_ownerGuid)
    {
        SetOwner(p, (m_players.size() > 1 ? true : false));
        m_players[p].SetModerator(true);
    }
}
开发者ID:Calixa,项目名称:murlocs_434,代码行数:68,代码来源:Channel.cpp


示例5: MakePlayerAlreadyMember

void Channel::JoinChannel(Player* player, std::string const& pass)
{
    ObjectGuid const& guid = player->GetGUID();
    if (IsOn(guid))
    {
        // Do not send error message for built-in channels
        if (!IsConstant())
        {
            WorldPackets::Channel::ChannelNotify notify;
            MakePlayerAlreadyMember(notify, guid);
            player->SendDirectMessage(notify.Write());
        }
        return;
    }

    if (IsBanned(guid))
    {
        WorldPackets::Channel::ChannelNotify notify;
        MakeBanned(notify);
        player->SendDirectMessage(notify.Write());
        return;
    }

    if (!_password.empty() && pass != _password)
    {
        WorldPackets::Channel::ChannelNotify notify;
        MakeWrongPassword(notify);
        player->SendDirectMessage(notify.Write());
        return;
    }

    if (HasFlag(CHANNEL_FLAG_LFG) &&
        sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
        AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC
        player->GetGroup())
    {
        WorldPackets::Channel::ChannelNotify notify;
        MakeNotInLfg(notify);
        player->SendDirectMessage(notify.Write());
        return;
    }

    player->JoinedChannel(this);

    if (_announce && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
    {
        WorldPackets::Channel::ChannelNotify notify;
        MakeJoined(notify, guid);
        SendToAll(notify.Write());
    }

    PlayerInfo playerInfo;
    playerInfo.PlayerGuid = guid;
    _playersStore[guid] = playerInfo;

    /*
    WorldPackets::Channel::ChannelNotify notify;
    MakeYouJoined(notify);
    player->SendDirectMessage(notify.Write());
    */

    WorldPackets::Channel::ChannelNotifyJoined notify;
    //notify.ChannelWelcomeMsg = "";
    notify.ChatChannelID = _channelId;
    //notify.InstanceID = 0;
    notify._ChannelFlags = _flags;
    notify._Channel = _name;
    player->SendDirectMessage(notify.Write());

    JoinNotify(player);

    // Custom channel handling
    if (!IsConstant())
    {
        // Update last_used timestamp in db
        if (!_playersStore.empty())
            UpdateChannelUseageInDB();

        // If the channel has no owner yet and ownership is allowed, set the new owner.
        if (_ownerGUID.IsEmpty() && _ownership)
        {
            SetOwner(guid, _playersStore.size() > 1);
            _playersStore[guid].SetModerator(true);
        }
    }
}
开发者ID:Rastrian,项目名称:DeathCore_6.x-1,代码行数:86,代码来源:Channel.cpp


示例6: GetSel

void CTWScriptEdit::FormatTextRange(int nStart, int nEnd)
{
	if (nStart >= nEnd)
		return;

	m_bInForcedChange = TRUE;

	CHARRANGE crOldSel;

	GetSel(crOldSel);
	LockWindowUpdate();
	HideSelection(TRUE, FALSE);

	WCHAR *pBuffer = NULL;
	try {
		SetSel(nStart, nEnd);
		//pBuffer = new WCHAR[nEnd - nStart + 1];
		CHAR* pBuffer2 = new CHAR[nEnd - nStart + 1];
		long nLen = GetSelText(pBuffer2);
		pBuffer = GetUnicode(pBuffer2);
		ASSERT(nLen <= nEnd - nStart);

		pBuffer[nLen] = 0;

		WCHAR *pStart, *pPtr;
		pStart = pPtr = pBuffer;

		WCHAR* pSymbolStart = NULL;
		SymbolColor ic;

		while (*pPtr != 0) {
			WCHAR ch = *pPtr;

			if (ch == m_chComment && (m_chComment2 == 0 || pPtr[1] == m_chComment2)) {
				pSymbolStart = pPtr;
				do {
					ch = *(++pPtr);
				} while (ch != 0 && ch != '\r');
				ic = m_icComment;
			} else if (IsStringQuote(ch)) { // Process strings
				pSymbolStart = pPtr;
				WCHAR ch1 = ch;
				do {
					ch = *(++pPtr);
				} while (ch != 0 && ch != ch1 && ch != '\r');
				if (ch == ch1) pPtr++;
				ic = m_icString;
			} else if (_istdigit(ch)) { // Process numbers
				pSymbolStart = pPtr;
				wcstod(pSymbolStart, &pPtr);
				ic = m_icNumber;
			} else if (_istalpha(ch) || ch == '_') { // Process keywords
				pSymbolStart = pPtr;
				do {
					ch = *(++pPtr);
				} while (_istalnum(ch) || ch == '_');
				*pPtr = 0;
				int nPos = IsKeyword(pSymbolStart);
				if (nPos >= 0) {
					ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, 
								m_strKeywords.Mid(nPos+1, pPtr - pSymbolStart));
					if (wcsicmp(m_strComment, pSymbolStart) == 0) {
						*pPtr = ch;
						*pSymbolStart = m_chComment;
						if (pSymbolStart[1] != 0 && m_chComment2 != 0)
							pSymbolStart[1] = m_chComment2;
						pPtr = pSymbolStart;
						pSymbolStart = NULL;
						continue;
					}
					ic = m_icKeyword;
				} else {
					nPos = IsConstant(pSymbolStart);
					if (nPos >= 0) {
							ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, 
										m_strConstants.Mid(nPos+1, pPtr - pSymbolStart));
						ic = m_icConstant;
					} else {
						pSymbolStart = NULL;
					}
				}
				*pPtr = ch;
			} else {
				pPtr++;
			}

			if (pSymbolStart != NULL) {
				ASSERT(pSymbolStart < pPtr);
				SetFormatRange(nStart + pStart - pBuffer, nStart + pSymbolStart - pBuffer, FALSE, RGB(0,0,0));
				SetFormatRange(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, ic.bBold, ic.clrColor);
				pStart = pPtr;
				pSymbolStart = 0;
			} else if (*pPtr == 0)
				SetFormatRange(nStart + pStart - pBuffer, nStart + pPtr - pBuffer, FALSE, RGB(0,0,0));
		}

	} catch(...){}

	//delete [] pBuffer;

//.........这里部分代码省略.........
开发者ID:gitrider,项目名称:wxsj2,代码行数:101,代码来源:TWScriptEdit.cpp


示例7: MakePlayerAlreadyMember

void Channel::JoinChannel(Player* player, std::string const& pass)
{
    uint64 guid = player->GetGUID();
    if (IsOn(guid))
    {
        // Do not send error message for built-in channels
        if (!IsConstant())
        {
            WorldPacket data;
            MakePlayerAlreadyMember(&data, guid);
            SendToOne(&data, guid);
        }
        return;
    }

    if (IsBanned(guid))
    {
        WorldPacket data;
        MakeBanned(&data);
        SendToOne(&data, guid);
        return;
    }

    if (!_password.empty() && pass != _password)
    {
        WorldPacket data;
        MakeWrongPassword(&data);
        SendToOne(&data, guid);
        return;
    }

    if (HasFlag(CHANNEL_FLAG_LFG) &&
        sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
        AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC
        player->GetGroup())
    {
        WorldPacket data;
        MakeNotInLfg(&data);
        SendToOne(&data, guid);
        return;
    }

    player->JoinedChannel(this);

    if (_announce && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
    {
        WorldPacket data;
        MakeJoined(&data, guid);
        SendToAll(&data);
    }

    PlayerInfo pinfo;
    pinfo.player = guid;
    pinfo.flags = MEMBER_FLAG_NONE;
    playersStore[guid] = pinfo;

    WorldPacket data;
    MakeYouJoined(&data);
    SendToOne(&data, guid);

    JoinNotify(guid);

    // Custom channel handling
    if (!IsConstant())
    {
        // Update last_used timestamp in db
        if (!playersStore.empty())
            UpdateChannelUseageInDB();

        // If the channel has no owner yet and ownership is allowed, set the new owner.
        if (!_ownerGUID && _ownership)
        {
            SetOwner(guid, playersStore.size() > 1);
            playersStore[guid].SetModerator(true);
        }
    }
}
开发者ID:Ayik0,项目名称:DeathCore_5.4.8,代码行数:77,代码来源:Channel.cpp


示例8: IsConstant

bool UNiagaraNodeInput::IsExposedConstant()const
{
	return bExposeWhenConstant && IsConstant();
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:4,代码来源:NiagaraNodeInput.cpp


示例9: MakePlayerAlreadyMember

void Channel::Join(Player* player, const char* password)
{
    ObjectGuid guid = player->GetObjectGuid();

    WorldPacket data;
    if (IsOn(guid))
    {
        if (!IsConstant())                                  // non send error message for built-in channels
        {
            MakePlayerAlreadyMember(&data, guid);
            SendToOne(&data, guid);
        }
        return;
    }

    if (IsBanned(guid))
    {
        MakeBanned(&data);
        SendToOne(&data, guid);
        return;
    }

    if (m_password.length() > 0 && strcmp(password, m_password.c_str()))
    {
        MakeWrongPassword(&data);
        SendToOne(&data, guid);
        return;
    }

    if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && player->GetSession()->GetSecurity() == SEC_PLAYER &&
            (player->GetGroup() || player->m_lookingForGroup.Empty()))
    {
        MakeNotInLfg(&data);
        SendToOne(&data, guid);
        return;
    }

    if (player->GetGuildId() && (GetFlags() == 0x38))
        return;

    // join channel
    player->JoinedChannel(this);

    if (m_announce && (player->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL)))
    {
        MakeJoined(&data, guid);
        SendToAll(&data);
    }

    data.clear();

    PlayerInfo& pinfo = m_players[guid];
    pinfo.player = guid;
    pinfo.flags = MEMBER_FLAG_NONE;

    MakeYouJoined(&data);
    SendToOne(&data, guid);

    JoinNotify(guid);

    // if no owner first logged will become
    if (!IsConstant() && !m_ownerGuid)
    {
        SetOwner(guid, (m_players.size() > 1 ? true : false));
        m_players[guid].SetModerator(true);
    }
}
开发者ID:249CAAFE40,项目名称:mangos-tbc,代码行数:67,代码来源:Channel.cpp


示例10: if

/** Saves the first derivative of the sequence starting at Iter in the back *this
 *  \param Iter: Iterator to function to differentiate.
 *  \param Var: Variable to differentiate with respect to.
 *  \param Trigonemetry: Differentiate trigonometric functions as radians og degrees.
 *  \param Level: Indicates the number os times the function has been called recursive. To prevent infinite loops.
 *  \throw EFuncError: Thrown if differentiation fails.
 */
void TFuncData::AddDif(TConstIterator Iter, const TElem &Var, TTrigonometry Trigonometry, unsigned Level)
{
  if(*Iter == Var)
    Data.push_back(TElem(CodeNumber, 1));
  else if(Iter->Ident == CodeRand)
		throw EFuncError(ecNotDifAble, L"rand");
  else if(IsConstant(*Iter))
    Data.push_back(TElem(CodeNumber, 0.0));
	else
	{
		if(!ContainsElem(Iter, Var))
		{
			Data.push_back(TElem(CodeNumber, 0.0));
			return;
		}
		switch(Iter->Ident)
		{
			case CodeIf:
			case CodeIfSeq:
			{
				//f(x)=if(a1,b1,a2,b2, ... , an,bn [,c])
				//f'(x)=if(a1,b1',a2,b2', ... , an, bn' [,c'])
				Data.push_back(*Iter); //CodeIf with same number of arguments
				unsigned Arguments = FunctionArguments(*Iter);
				++Iter;
				for(unsigned I = 0; I < Arguments-1; I++)
				{
					TConstIterator End = FindEnd(Iter);
					if(I % 2)
						AddDif(Iter, Var, Trigonometry, Level);
					else
						Data.insert(Data.end(), Iter, End);
					Iter = End;
				}
				AddDif(Iter, Var, Trigonometry, Level);
				break;
			}

			case CodeMin:
			case CodeMax:
			{
				//f(x)=min(a1,a2,a3, ... , an) f'(x)=if(a1<a2 and a1<a3 ...,a1', a2<a1 and a2<a3 ...,a2',
				unsigned Arguments = Iter->Arguments;
				Data.push_back(TElem(CodeIf, 2*Arguments-1, 0));
				TConstIterator Param = Iter + 1;
				for(unsigned I = 0; I < Arguments-1; I++)
				{
					TConstIterator End = FindEnd(Param);
					for(unsigned J = 0; J < Arguments-2; J++)
						Data.push_back(CodeAnd);

					TConstIterator Param2 = Iter+1;
					for(unsigned J = 0; J < Arguments; J++)
					{
						if(J != I)
						{
							Data.push_back(TElem(Iter->Ident == CodeMin ? cmLess : cmGreater));
							Data.insert(Data.end(), Param, End);
							Data.insert(Data.end(), Param2, FindEnd(Param2));
						}
						Param2 = FindEnd(Param2);
					}

					AddDif(Param, Var, Trigonometry, Level);
					Param = End;
				}
				AddDif(Param, Var, Trigonometry, Level);
				break;
			}

			case CodeCustom:
			{
				if(Level > MaxDifLevel)
					throw EFuncError(ecRecursiveDif);
				boost::shared_ptr<TBaseCustomFunc> Func = boost::any_cast<boost::shared_ptr<TBaseCustomFunc> >(Iter->Value);
				if(Func)
					AddDif(Func->GetFuncData()->Data.begin(), Var, Trigonometry, Level + 1);
				else
					throw EFuncError(ecSymbolNotFound, Iter->Text);
				break;
			}
			case CodeDNorm:
			{
				std::vector<std::wstring> ArgNames;
				ArgNames.push_back(L"x");
				ArgNames.push_back(L"x2");
				ArgNames.push_back(L"x3");
				TFuncData Temp(FunctionDefinition(CodeDNorm), ArgNames);
				TFuncData Temp2;
				std::vector<std::vector<TElem> > Args(3);
				CopyReplaceArgs(Args.front(), Iter + 1, std::vector<std::vector<TElem> >());
				if(Iter->Arguments > 2)
				{
//.........这里部分代码省略.........
开发者ID:q2apro,项目名称:graph-padowan,代码行数:101,代码来源:Differentiate.cpp


示例11: builder

void Channel::LeaveChannel(Player* player, bool send)
{
    ObjectGuid const& guid = player->GetGUID();
    if (!IsOn(guid))
    {
        if (send)
        {
            NotMemberAppend appender;
            ChannelNameBuilder<NotMemberAppend> builder(this, appender);
            SendToOne(builder, guid);
        }
        return;
    }

    player->LeftChannel(this);

    if (send)
    {
        /*
        YouLeftAppend appender;
        ChannelNameBuilder<YouLeftAppend> builder(this, appender);
        SendToOne(builder, guid);
        */

        auto builder = [&](LocaleConstant locale)
        {
            LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);

            WorldPackets::Channel::ChannelNotifyLeft* notify = new WorldPackets::Channel::ChannelNotifyLeft();
            notify->Channel = GetName(localeIdx);
            notify->ChatChannelID = 0;
            //notify->Suspended = false;
            return notify;
        };

        SendToOne(builder, guid);
    }

    PlayerInfo& info = _playersStore.at(guid);
    bool changeowner = info.IsOwner();
    _playersStore.erase(guid);

    if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
    {
        LeftAppend appender(guid);
        ChannelNameBuilder<LeftAppend> builder(this, appender);
        SendToAll(builder);
    }

    LeaveNotify(player);

    if (!IsConstant())
    {
        // Update last_used timestamp in db
        UpdateChannelUseageInDB();

        // If the channel owner left and there are still playersStore inside, pick a new owner
        // do not pick invisible gm owner unless there are only invisible gms in that channel (rare)
        if (changeowner && _ownershipEnabled && !_playersStore.empty())
        {
            PlayerContainer::iterator itr;
            for (itr = _playersStore.begin(); itr != _playersStore.end(); ++itr)
            {
                if (!itr->second.IsInvisible())
                    break;
            }

            if (itr == _playersStore.end())
                itr = _playersStore.begin();

            ObjectGuid const& newowner = itr->first;
            itr->second.SetModerator(true);

            SetOwner(newowner);

            // if the new owner is invisible gm, set flag to automatically choose a new owner
            if (itr->second.IsInvisible())
                _isOwnerInvisible = true;
        }
    }
}
开发者ID:Lyill,项目名称:TrinityCore,代码行数:81,代码来源:Channel.cpp


示例12: appender

void Channel::JoinChannel(Player* player, std::string const& pass)
{
    ObjectGuid const& guid = player->GetGUID();
    if (IsOn(guid))
    {
        // Do not send error message for built-in channels
        if (!IsConstant())
        {
            PlayerAlreadyMemberAppend appender(guid);
            ChannelNameBuilder<PlayerAlreadyMemberAppend> builder(this, appender);
            SendToOne(builder, guid);
        }
        return;
    }

    if (IsBanned(guid))
    {
        BannedAppend appender;
        ChannelNameBuilder<BannedAppend> builder(this, appender);
        SendToOne(builder, guid);
        return;
    }

    if (!_channelPassword.empty() && pass != _channelPassword)
    {
        WrongPasswordAppend appender;
        ChannelNameBuilder<WrongPasswordAppend> builder(this, appender);
        SendToOne(builder, guid);
        return;
    }

    if (HasFlag(CHANNEL_FLAG_LFG) &&
        sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
        AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC
        player->GetGroup())
    {
        NotInLFGAppend appender;
        ChannelNameBuilder<NotInLFGAppend> builder(this, appender);
        SendToOne(builder, guid);
        return;
    }

    player->JoinedChannel(this);

    if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
    {
        JoinedAppend appender(guid);
        ChannelNameBuilder<JoinedAppend> builder(this, appender);
        SendToAll(builder);
    }

    bool newChannel = _playersStore.empty();

    PlayerInfo& playerInfo = _playersStore[guid];
    playerInfo.SetInvisible(!player->isGMVisible());

    /*
    YouJoinedAppend appender;
    ChannelNameBuilder<YouJoinedAppend> builder(this, appender);
    SendToOne(builder, guid);
    */

    auto builder = [&](LocaleConstant /*locale*/)
    {
        WorldPackets::Channel::ChannelNotifyJoined* notify = new WorldPackets::Channel::ChannelNotifyJoined();
        //notify->ChannelWelcomeMsg = "";
        notify->ChatChannelID = _channelId;
        //notify->InstanceID = 0;
        notify->_ChannelFlags = _channelFlags;
        notify->_Channel = _channelName;
        return notify;
    };

    SendToOne(builder, guid);

    JoinNotify(player);

    // Custom channel handling
    if (!IsConstant())
    {
        // Update last_used timestamp in db
        if (!_playersStore.empty())
            UpdateChannelUseageInDB();

        // If the channel has no owner yet and ownership is allowed, set the new owner.
        // or if the owner was a GM with .gm visible off
        // don't do this if the new player is, too, an invis GM, unless the channel was empty
        if (_ownershipEnabled && (newChannel || !playerInfo.IsInvisible()) && (_ownerGuid.IsEmpty() || _isOwnerInvisible))
        {
            _isOwnerInvisible = playerInfo.IsInvisible();

            SetOwner(guid, !newChannel && !_isOwnerInvisible);
            playerInfo.SetModerator(true);
        }
    }
}
开发者ID:Lyill,项目名称:TrinityCore,代码行数:96,代码来源:Channel.cpp


示例13: MakePlayerAlreadyMember

void Channel::Join(uint64 p, const char *pass)
{
    WorldPacket data;
    if(IsOn(p))
    {
        if(!IsConstant())                                   // non send error message for built-in channels
        {
            MakePlayerAlreadyMember(&data, p);
            SendToOne(&data, p);
        }
        return;
    }

    if(IsBanned(p))
    {
        MakeBanned(&data);
        SendToOne(&data, p);
        return;
    }

    if(m_password.length() > 0 && strcmp(pass, m_password.c_str()))
    {
        MakeWrongPassword(&data);
        SendToOne(&data, p);
        return;
    }

    Player *plr = objmgr.GetPlayer(p);

    if(plr)
    {
        if(HasFlag(CHANNEL_FLAG_LFG) &&
            sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER &&
            (plr->GetGroup() || plr->m_lookingForGroup.Empty()) )
        {
            MakeNotInLfg(&data);
            SendToOne(&data, p);
            return;
        }

        if(plr->GetGuildId() && (GetFlags() == 0x38))
            return;

        plr->JoinedChannel(this);
    }

    if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ))
    {
        MakeJoined(&data, p);
        SendToAll(&data);
    }

    data.clear();

    PlayerInfo pinfo;
    pinfo.player = p;
    pinfo.flags = MEMBER_FLAG_NONE;
    players[p] = pinfo;

    MakeYouJoined(&data);
    SendToOne(&data, p);

    JoinNotify(p);

    // if no owner first logged will become
    if(!IsConstant() && !m_ownerGUID)
    {
        SetOwner(p, (players.size() > 1 ? true : false));
        players[p].SetModerator(true);        
    }
    /*
    else if(!IsConstant() && m_ownerGUID && plr && m_ownerGUID == plr->GetGUID() ))
    {
        SetOwner(p, (players.size() > 1 ? true : false));
        players[p].SetModerator(true);
    }*/
}
开发者ID:pfchrono,项目名称:mangos-mods,代码行数:77,代码来源:Channel.cpp


示例14: MakePlayerAlreadyMember

void Channel::Join(uint64 p, const char *pass)
{
    WorldPacket data;
    if (IsOn(p))
    {
        if (!IsConstant())                                   // non send error message for built-in channels
        {
            MakePlayerAlreadyMember(&data, p);
            SendToOne(&data, p);
        }
        return;
    }

    Player *plr = sObjectMgr.GetPlayer(p);

    if ((!plr || !plr->isGameMaster()) && !IsConstant() && m_name != "world" && m_name != "engworld" && m_name != "handel")
    {
        uint32 limitCount = sWorld.getConfig(CONFIG_PRIVATE_CHANNEL_LIMIT);

        if (limitCount && players.size() > limitCount)
        {
            MakeInvalidName(&data);
            SendToOne(&data, p);
            return;
        }
    }

    if (!m_ownerGUID && (!plr || !plr->CanSpeak())) // muted players can't create new channels
    {
        MakeBanned(&data);//no idea what to send
        SendToOne(&data, p);
        return;
    }

    if (IsBanned(p) && (!plr || !plr->isGameMaster()))
    {
        MakeBanned(&data);
        SendToOne(&data, p);
        return;
    }

    if (m_password.length() > 0 && strcmp(pass, m_password.c_str()) && (!plr || !plr->isGameMaster()))
    {
        MakeWrongPassword(&data);
        SendToOne(&data, p);
        return;
    }

    if (plr)
    {
        if (IsLFG() &&
            sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !plr->GetSession()->HasPermissions(PERM_GMT) &&
            plr->m_lookingForGroup.Empty())
        {
            MakeNotInLfg(&data);
            SendToOne(&data, p);
            return;
        }

        if (plr->GetGuildId() && (GetFlags() == 0x38))
            return;

        plr->JoinedChannel(this);
    }

    if (m_announce && (!plr || !plr->GetSession()->HasPermissions(PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
    {
        //MakeJoined(&data, p);
        //SendToAll(&data);
    }

    data.clear();

    PlayerInfo pinfo;
    pinfo.player = p;
    pinfo.flags = 0;
    players[p] = pinfo;

    MakeYouJoined(&data);
    SendToOne(&data, p);

    JoinNotify(p);

    // if no owner first logged will become
    if (!IsConstant() && !m_ownerGUID)
    {
        SetOwner(p, (players.size() > 1 ? true : false));
        players[p].SetModerator(true);
    }
}
开发者ID:Blumfield,项目名称:ptc2,代码行数:90,代码来源:Channel.cpp


示例15: lock

JSBool
XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface)
{
    if(IsConstant())
    {
        const nsXPTConstant* constant;
        if(NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &constant)))
            return JS_FALSE;

        const nsXPTCMiniVariant& mv = *constant->GetValue();

        // XXX Big Hack!
        nsXPTCVariant v;
        v.flags = 0;
        v.type = constant->GetType();
        memcpy(&v.val, &mv.val, sizeof(mv.val));

        jsval resultVal;

        if(!XPCConvert::NativeData2JS(ccx, &resultVal, &v.val, v.type,
                                      nsnull, nsnull, nsnull))
            return JS_FALSE;

        {   // scoped lock
            XPCAutoLock lock(ccx.GetRuntime()->GetMapLock());
            mVal = resultVal;
            mFlags |= RESOLVED;
        }

        return JS_TRUE;
    }
    // else...

    // This is a method or attribute - we'll be needing a function object

    intN argc;
    intN flags;
    JSNative callback;

    if(IsMethod())
    {
        const nsXPTMethodInfo* info;
        if(NS_FAILED(iface->GetInterfaceInfo()->GetMethodInfo(mIndex, &info)))
            return JS_FALSE;

        // Note: ASSUMES that retval is last arg.
        argc = (intN) info->GetParamCount();
        if(argc && info->GetParam((uint8)(argc-1)).IsRetval())
            argc-- ;

        flags = 0;
        callback = XPC_WN_CallMethod;
    }
    else
    {
        if(IsWritableAttribute())
            flags = JSFUN_GETTER | JSFUN_SETTER;
        else
            flags = JSFUN_GETTER;
        argc = 0;
        callback = XPC_WN_GetterSetter;
    }

    // We need to use the safe context for this thread because we don't want
    // to parent the new (and cached forever!) function object to the current
    // JSContext's global object. That would be bad!

    JSContext* cx = ccx.GetSafeJSContext();
    if(!cx)
        return JS_FALSE;

    const char *memberName = iface->GetMemberName(ccx, this);

    jsrefcount suspendDepth = 0;
    if(cx != ccx) {
        // Switching contexts, suspend the old and enter the new request.
        suspendDepth = JS_SuspendRequest(ccx);
        JS_BeginRequest(cx);
    }

    JSFunction *fun = JS_NewFunction(cx, callback, argc, flags, nsnull,
                                     memberName);

    if(suspendDepth) {
        JS_EndRequest(cx);
        JS_ResumeRequest(ccx, suspendDepth);
    }

    if(!fun)
        return JS_FALSE;

    JSObject* funobj = JS_GetFunctionObject(fun);
    if(!funobj)
        return JS_FALSE;

    AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(funobj));

    STOBJ_CLEAR_PARENT(funobj);
    STOBJ_CLEAR_PROTO(funobj);

//.........这里部分代码省略.........
开发者ID:jdahlin,项目名称:jslint,代码行数:101,代码来源:xpcwrappednativeinfo.cpp


示例16: SimplifyData

/** Optimizes the data elements starting from Iter, which points into list.
 *  \param List: Elements to optimize.
 *  \param Iter: Element to start optimization at. If Iter is erased, Iter is updated to point to the element that is replacing it.
 *  \return An iterator to the element following Iter, jumping over parameters.
 */
std::list<TElem>::iterator SimplifyData(std::list<TElem> &List, std::list<TElem>::iterator &Iter)
{
  std::list<TElem>::iterator Begin1 = Iter;
  ++Begin1;

  if(IsConstant(*Iter))
    return Begin1;
  std::list<TElem>::iterator End;
  std::list<TElem>::iterator Begin2 = SimplifyData(List, Begin1);
  if(IsFunction1P(*Iter))
    End = Begin2;
  else if(IsFunction2P(*Iter))
    End = SimplifyData(List, Begin2);
  else if(IsFunction3P(*Iter))
  {
    std::list<TElem>::iterator Begin3 = SimplifyData(List, Begin2);
    End = SimplifyData(List, Begin3);
  }
  else if(IsFunctionVariableP(*Iter))
  {
    End = Begin1;
    for(unsigned I = 0; I < Iter->Arguments; I++)
      End = SimplifyData(List, End);   //Simplify each argument
    return End;
  }
  else
    throw EFuncError(ecInternalError);

  for(unsigned I = 0; I < TableSize; I++)
  {
    const TSimplify &Entry = SimplifyTable(I);
    if(*Iter == Entry.Function && (Entry.Par1 == CodeIgnore || *Begin1 == Entry.Par1) &&
      (Entry.Par2 == CodeIgnore || *Begin2 == Entry.Par2 ||
      (Entry.Par2 == CodePar1 && IsEqual(Begin1, Begin2))))
    {
      bool RemovePar1 = true;
      bool RemovePar2 = true;
      std::list<TElem>::iterator Pos = Begin1;

      for(int N = 0; N < 4; N++)
        switch(Entry.Result[N].Ident)
        {
          case CodePar1:
            RemovePar1 = false;
            Pos = Begin2;
            break;

          case CodePar2:
            RemovePar2 = false;
            break;

          case CodePar1Par:
            List.erase(Begin1++);
            RemovePar1 = false;
            Pos = Begin2;
            break;

          case CodePar2Par:
            List.erase(Begin2++);
            RemovePar2 = false;
            break;

          case CodeNull:
            break;

          default:
            List.insert(Pos, Entry.Result[N]);
        }

      if(RemovePar1)
        List.erase(Begin1, Begin2);
      if(RemovePar2)
        List.erase(Begin2, End);
      List.erase(Iter++);
      return End;
    }
 }

  if(Iter->Ident == CodeSub && Begin1->Ident == CodeNumber && Begin2->Ident == CodeNumber)
  {
    *Iter = TElem(CodeNumber, boost::any_cast<long double>(Begin1->Value) - boost::any_cast<long double>(Begin2->Value));
    List.erase(Begin1, End);
  }
  else if(Iter->Ident == CodeAdd && Begin1->Ident == CodeNumber && Begin2->Ident == CodeNumber)
  {
    *Iter = TElem(CodeNumber, boost::any_cast<long double>(Begin1->Value) + boost::any_cast<long double>(Begin2->Value));
    List.erase(Begin1, End);
  }
  else if(Iter->Ident == CodeMul)
  {
    //5*2 = 10
    if(Begin1->Ident == CodeNumber && Begin2->Ident == CodeNumber)
    {
      Begin1->Value = boost::any_cast<long double>(Begin1->Value) * boost::any_cast<long double>(Begin2->Value);
      List.erase(Iter);
//.........这里部分代码省略.........
开发者ID:q2apro,项目名称:graph-padowan,代码行数:101,代码来源:Simplify.cpp


示例17: MakeNotifyPacket

// done 0x03
void Channel::MakeYouLeft(WorldPacket *data)
{
    MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE);
    *data << uint32(GetChannelId());
    *data << uint8(IsConstant());
}
开发者ID:hodobaj,项目名称:Darkcore,代码行数:7,代码来源:Channel.cpp


示例18: MakePlayerAlreadyMember

void Channel::JoinChannel(Player* player, std::string const& pass)
{
    uint64 guid = player->GetGUID();
    if (IsOn(guid))
    {
        // Do not send error message for built-in channels
        if (!IsConstant())
        {
            WorldPacket data;
            MakePlayerAlreadyMember(&data, guid);
            SendToOne(&data, guid);
        }
        return;
    }

    if (IsBanned(guid))
    {
        WorldPacket data;
        MakeBanned(&data);
        SendToOne(&data, guid);
        return;
    }

    if (!_password.empty() && pass != _password)
    {
        WorldPacket data;
        MakeWrongPassword(&data);
        SendToOne(&data, guid);
        return;
    }

    if (HasFlag(CHANNEL_FLAG_LFG) &&
        sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
        AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) &&
        player->GetGroup())
    {
        WorldPacket data;
        MakeNotInLfg(&data);
        SendToOne(&data, guid);
        return;
    }

    player->JoinedChannel(this);

    if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
                       !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
    {
        WorldPacket data;
        MakeJoined(&data, guid);
        SendToAll(&data);
    }

    PlayerInfo pinfo;
    pinfo.player = guid;
    pinfo.flags = MEMBER_FLAG_NONE;
    pinfo.lastSpeakTime = 0;
    pinfo.plrPtr = player;

    playersStore[guid] = pinfo;

    if (_channelRights.joinMessage.length())
        ChatHandler(player->GetSession()).PSendSysMessage("%s", _channelRights.joinMessage.c_str());

    WorldPacket data;
    MakeYouJoined(&data);
    SendToOne(&data, guid);

    JoinNotify(player);

    // Custom channel handling
    if (!IsConstant())
    {
        // Update last_used timestamp in db
        if  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsContextLost函数代码示例发布时间:2022-05-30
下一篇:
C++ IsConnectionIdle函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap