当前位置: 首页>>代码示例>>C++>>正文


C++ WorldPacket::clear方法代码示例

本文整理汇总了C++中WorldPacket::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldPacket::clear方法的具体用法?C++ WorldPacket::clear怎么用?C++ WorldPacket::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorldPacket的用法示例。


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

示例1: Update

void ObjectAccessor::Update(uint32 /*diff*/)
{
    UpdateDataMapType update_players;

    while (!i_objects.empty())
    {
        Object* obj = *i_objects.begin();
        ASSERT(obj && obj->IsInWorld());
        i_objects.erase(i_objects.begin());
        obj->BuildUpdate(update_players);
    }

    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
    for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
    {
        iter->second.BuildPacket(&packet);
        iter->first->GetSession()->SendPacket(&packet);
        packet.clear();                                     // clean the string
    }
}
开发者ID:redlaine,项目名称:InfinityCore-Ark,代码行数:20,代码来源:ObjectAccessor.cpp

示例2: Leave

void Channel::Leave(uint64 p, bool send)
{
    if (!IsOn(p))
    {
        if (send)
        {
            WorldPacket data;
            MakeNotMember(&data);
            SendToOne(&data, p);
        }
    }
    else
    {
        Player *plr = sObjectMgr.GetPlayer(p);

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

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

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

        LeaveNotify(p);

        if (changeowner)
            ChangeOwner();
    }
}
开发者ID:Blumfield,项目名称:ptc2,代码行数:41,代码来源:Channel.cpp

示例3: Leave

void Channel::Leave(uint64 p, bool send)
{
    if(!IsOn(p))
    {
        if(send)
        {
            WorldPacket data;
            MakeNotMember(&data);
            SendToOne(&data, p);
        }
    }
    else
    {
        if(send)
        {
            WorldPacket data;
            MakeYouLeft(&data);
            SendToOne(&data, p);
            Player *plr = objmgr.GetPlayer(p);
            if(plr)
                plr->LeftChannel(this);
            data.clear();
        }

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

        players.erase(p);
        if(m_announce)
        {
            WorldPacket data;
            MakeLeft(&data, p);
            SendToAll(&data);
        }

        if(changeowner)
        {
            uint64 newowner = !players.empty() ? players.begin()->second.player : 0;
            SetOwner(newowner);
        }
    }
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:41,代码来源:Channel.cpp

示例4: Invite

void Channel::Invite(uint64 p, const char *newname)
{
    if(!IsOn(p))
    {
        WorldPacket data;
        MakeNotMember(&data);
        SendToOne(&data, p);
    }
    else
    {
        Player *newp = objmgr.GetPlayer(newname);
        if(!newp)
        {
            WorldPacket data;
            MakePlayerNotFound(&data, newname);
            SendToOne(&data, p);
        }
        else if(IsOn(newp->GetGUID()))
        {
            WorldPacket data;
            MakePlayerAlreadyMember(&data, newp->GetGUID());
            SendToOne(&data, p);
        }
        else
        {
            WorldPacket data;
            if(!newp->HasInIgnoreList(p))
            {
                MakeInvite(&data, p);
                SendToOne(&data, newp->GetGUID());
                data.clear();
            }
            MakePlayerInvited(&data, newp->GetGUID());
            SendToOne(&data, p);
        }
    }
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:37,代码来源:Channel.cpp

示例5: guard

void
ObjectAccessor::Update(uint32 diff)
{
    UpdateDataMapType update_players;
    {
        Guard guard(i_updateGuard);
        while(!i_objects.empty())
        {
            Object* obj = *i_objects.begin();
            assert(obj && obj->IsInWorld());
            i_objects.erase(i_objects.begin());
            _buildUpdateObject(obj, update_players);
            obj->ClearUpdateMask(false);
        }
    }

    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
    for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
    {
        iter->second.BuildPacket(&packet);
        iter->first->GetSession()->SendPacket(&packet);
        packet.clear();                                     // clean the string
    }
}
开发者ID:MilchBuby,项目名称:riboncore,代码行数:24,代码来源:ObjectAccessor.cpp

示例6: Second

void
World::ShuttingDownMsg()
{
	if(m_ShutdownTimer <= 0)
		raise(SIGINT);
	char msg[256];
	std::stringstream ss;
	WorldPacket data;

	sprintf((char*)msg, "[Server] Shutdown in %d seconds", m_ShutdownTimer);
	SendWorldWideText( msg );

	data.Initialize(SMSG_SERVER_MESSAGE);
	ss << m_ShutdownTimer << " Second(s).";
	data << uint32(1) << ss.str().c_str() << (uint8)0x00;
	SendGlobalMessage( &data );

	data.clear();
	ss.clear();

	sLog.outColor(3);
	sLog.outString("[Server] Shutdown in %d seconds...\n", m_ShutdownTimer);
	sLog.outColor(2);
}
开发者ID:vata,项目名称:prebcwow,代码行数:24,代码来源:World.cpp

示例7: Join

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

示例8: HandleMessagechatOpcode

void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
{
    WorldPacket data;

    Log::getSingleton().outDebug("CHAT: packet received");

    uint32 type;
    uint32 lang;

    recv_data >> type;
    recv_data >> lang;

    switch(type)
    {
        case CHAT_MSG_SAY:
        {
            std::string msg = "";
            recv_data >> msg;

            if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
                break;

            sChatHandler.FillMessageData( &data, this, type, LANG_UNIVERSAL, NULL, msg.c_str() );
            GetPlayer()->SendMessageToSet( &data, true );
        } break;
        case CHAT_MSG_CHANNEL:
        {
            std::string channel = "", msg = "";
            recv_data >> channel;
            recv_data >> msg;
            Channel *chn = channelmgr.GetChannel(channel.c_str(),GetPlayer()); if(chn) chn->Say(GetPlayer(),msg.c_str());
        } break;
        case CHAT_MSG_WHISPER:
        {
            std::string to = "", msg = "";
            recv_data >> to >> msg;
            sChatHandler.FillMessageData(&data, this, type, LANG_UNIVERSAL, NULL, msg.c_str() );
            Player *player = objmgr.GetPlayer(to.c_str());
            if(!player)
            {
                data.clear();
                msg = "Player '";
                msg += to.c_str();
                msg += "' is not online (Names are case sensitive)";
                sChatHandler.FillSystemMessageData( &data, this ,msg.c_str() );
                SendPacket(&data);
                break;
            }
            player->GetSession()->SendPacket(&data);
            // Sent the to Users id as the channel, this should be fine as it's not used for wisper
            sChatHandler.FillMessageData(&data, this, CHAT_MSG_WHISPER_INFORM, LANG_UNIVERSAL, ((char *)(player->GetGUID())), msg.c_str() );
            SendPacket(&data);
        } break;
        case CHAT_MSG_YELL:
        {
            std::string msg = "";
            recv_data >> msg;

            if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
                break;

            sChatHandler.FillMessageData(&data, this, type, LANG_UNIVERSAL, NULL, msg.c_str() );
            SendPacket(&data);
            sWorld.SendGlobalMessage(&data, this);
        } break;
        case CHAT_MSG_PARTY:
        {
            std::string msg = "";
            recv_data >> msg;

            if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
                break;

            if (GetPlayer()->IsInGroup())
            {
                Group *group = objmgr.GetGroupByLeader(GetPlayer()->GetGroupLeader());
                if (group)
                    group->BroadcastToGroup(this, msg);
            }
        }
        default:
            Log::getSingleton().outError("CHAT: unknown msg type %u, lang: %u", type, lang);
    }
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:84,代码来源:ChatHandler.cpp

示例9: Creature

void
Spell::Effect_Summon_Pet(uint32 i)
{
	WorldPacket data;
	if(m_caster->GetUInt64Value(UNIT_FIELD_SUMMON) != 0)//If there is already a summon
	{
		Creature *OldSummon = objmgr.GetObject<Creature>(m_caster->GetUInt64Value(UNIT_FIELD_SUMMON));
		if(!OldSummon)
		{
				m_caster->SetUInt64Value(UNIT_FIELD_SUMMON, 0);
				sLog.outError("Warning!Old Summon could not be found!");
		} else {
				data.clear();
				data.Initialize(SMSG_DESTROY_OBJECT);
				data << OldSummon->GetGUID();
				OldSummon->SendMessageToSet (&data, true);

			if (OldSummon->GetMapCell()) 
				OldSummon->GetMapCell()->RemoveObject (OldSummon);

			OldSummon->RemoveFromMap();
			OldSummon->RemoveFromWorld();
			OldSummon->DeleteFromDB();

			objmgr.RemoveObject_Free(OldSummon);
		}
	}

	//Create new summon
	Creature *NewSummon = new Creature();
	CreatureTemplate *SummonInfo = objmgr.GetCreatureTemplate(m_spellInfo->EffectMiscValue[i]);
	if(SummonInfo == NULL)
	{
		sLog.outError("No Minion found for CreatureTemplate %u", m_spellInfo->EffectMiscValue[i]);
		return;
	}
	NewSummon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), SummonInfo->Name.c_str(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), m_caster->GetOrientation());
	NewSummon->SetLevel(m_caster->GetLevel());
	NewSummon->SetUInt32Value(UNIT_FIELD_DISPLAYID, SummonInfo->Model);
	NewSummon->SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, SummonInfo->Model);
	NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID());
	NewSummon->SetUInt32Value(UNIT_NPC_FLAGS , 0);
	NewSummon->SetUInt32Value(UNIT_FIELD_HEALTH , 28 + 30 * m_caster->GetLevel());
	NewSummon->SetUInt32Value(UNIT_FIELD_MAXHEALTH , 28 + 30 * m_caster->GetLevel());
	NewSummon->SetFaction(m_caster->GetFaction());
	NewSummon->SetScale( SummonInfo->Size );
	NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0,2048); 
	NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NONE);
	NewSummon->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, SummonInfo->Attack[0]); 
	NewSummon->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME+1, SummonInfo->Attack[1]); 
	NewSummon->SetUInt32Value(UNIT_FIELD_BOUNDINGRADIUS, SummonInfo->BoundingRadius); 
	NewSummon->SetUInt32Value(UNIT_FIELD_COMBATREACH, SummonInfo->CombatReach); 
	NewSummon->SetMinDamage((float)SummonInfo->Damage[0]); 
	NewSummon->SetMaxDamage((float)SummonInfo->Damage[1]);
	NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_PETNUMBER, NewSummon->GetGUIDLow()); 
	NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,5); 
	NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000); 
	NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); 
	NewSummon->SetUInt32Value(UNIT_FIELD_STAT0,22);
	NewSummon->SetUInt32Value(UNIT_FIELD_STAT1,22); //////////TODO: GET THE RIGHT INFORMATIONS FOR THIS!!!
	NewSummon->SetUInt32Value(UNIT_FIELD_STAT2,25); 
	NewSummon->SetUInt32Value(UNIT_FIELD_STAT3,28); 
	NewSummon->SetUInt32Value(UNIT_FIELD_STAT4,27); 
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+0,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+1,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+2,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+3,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+4,0); 
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+5,0);
	NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+6,0);
	NewSummon->SetUInt32Value(UNIT_FIELD_ATTACK_POWER,24);
	NewSummon->SetUInt32Value(UNIT_FIELD_BASE_MANA, SummonInfo->MaxMana); 
	NewSummon->SetUInt32Value(OBJECT_FIELD_ENTRY, SummonInfo->Entry);
	NewSummon->SetPosition(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), m_caster->GetOrientation());
	NewSummon->SetZoneId(m_caster->GetZoneId());

	NewSummon->SaveToDB();

	objmgr.AddObject( NewSummon );
	NewSummon->PlaceOnMap();
	NewSummon->AddToWorld();

	m_caster->SetUInt64Value(UNIT_FIELD_SUMMON, NewSummon->GetGUID());
	sLog.outDebug("New Pet has guid %u", NewSummon->GetGUID());

	if(objmgr.GetObject<Player>(m_caster->GetGUID()) )//if the caster is a player
	{
		data.clear();
		data.Initialize(SMSG_PET_SPELLS);
		data << (uint64)NewSummon->GetGUID() << uint32(0x00000101) << uint32(0x00000000) << uint32(0x07000001) << uint32(0x07000002);
		data << uint32(0x02000000) << uint32(0x07000000) << uint32(0x04000000) << uint32(0x03000000) << uint32(0x06000002) << uint32(0x05000000);
		data << uint32(0x06000000) << uint32(0x06000001) << uint8(0x02)/*Number of spells*/ << uint32(3110)/*SpellID1*/ << uint32(6307)/*SpellID2*/;
		((Player*)m_caster)->GetSession()->SendPacket(&data);
	}
}
开发者ID:vata,项目名称:prebcwow,代码行数:97,代码来源:SpellEffects.cpp

示例10: HandleAuctionPlaceBid


//.........这里部分代码省略.........
            {
                data << cnt;
            }
            else
            {
                data << uint32(50);
            }
            uint32 cnter = 1;
            for (itr = pl->GetBidBegin(); itr != pl->GetBidEnd(); itr++)
            {
                AuctionEntry *ae = objmgr.GetAuction((*itr)->AuctionID);
                if ((ae->auctioneer = GUID_LOPART(guid)) && (cnter < 33))
                {
                    data << ae->Id;
                    Item *it = objmgr.GetAItem(ae->item);
                    data << it->GetUInt32Value(OBJECT_FIELD_ENTRY);
                    data << uint32(0);
                    data << uint32(0);
                    data << uint32(0);
                    data << uint32(1);
                    data << uint32(0);
                    data << it->GetUInt64Value(ITEM_FIELD_OWNER);
                    data << ae->bid;
                    data << uint32(0);
                    data << ae->buyout;
                    data << uint32((ae->time - time(NULL)) * 1000);
                    data << uint64(0);
                    data << ae->bid;
                    cnter++;
                }
            }
            data << cnt;
            SendPacket(&data);
            data.clear();
            data.Initialize( SMSG_AUCTION_LIST_RESULT );
            data << uint32(0);
            data << uint32(0);
            SendPacket(&data);
        }
        else
        {
            pl->SetUInt32Value(PLAYER_FIELD_COINAGE,(pl->GetUInt32Value(PLAYER_FIELD_COINAGE) - ah->buyout));
            Mail *m = new Mail;
            m->messageID = objmgr.GenerateMailID();
            m->sender = ah->owner;
            m->reciever = pl->GetGUIDLow();
            m->subject = "You won an item!";
            m->body = "";
            m->checked = 0;
            m->COD = 0;
            m->money = 0;
            m->item = ah->item;
            m->time = time(NULL) + (29 * 3600);

            Item *it = objmgr.GetAItem(ah->item);

            objmgr.AddMItem(it);
            std::stringstream ss;
            ss << "INSERT INTO mailed_items (guid, data) VALUES ("
                << it->GetGUIDLow() << ", '";     // TODO: use full guids
            for(uint16 i = 0; i < it->GetValuesCount(); i++ )
            {
                ss << it->GetUInt32Value(i) << " ";
            }
            ss << "' )";
            sDatabase.Execute( ss.str().c_str() );
开发者ID:Artea,项目名称:mangos-svn,代码行数:67,代码来源:AuctionHouse.cpp

示例11: Join

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

示例12: switch

void
WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
{
    WorldPacket data;

    sLog.outDebug("CHAT: packet received");

    uint32 type;
    uint32 lang;

    recv_data >> type;
    recv_data >> lang;
    switch(type)
    {
        case CHAT_MSG_SAY:
		{
			std::string msg, t;
            recv_data >> msg;

			t = msg;
            if (sChatHandler.ParseCommands (t.c_str(), this) > 0)
				break;
			// If you want universal chatting use this instead of following line
            //sChatHandler.FillMessageData( &data, this, type, LANG_UNIVERSAL, NULL, msg.c_str() );
			sChatHandler.FillMessageData( &data, this, CHAT_MSG_SAY, lang, NULL, msg.c_str() );
            GetPlayer()->SendMessageToSet( &data, true );
			sLog.outChat(lang, GetPlayer()->GetName(), "Say", msg.c_str());
        } break;
        
		case CHAT_MSG_CHANNEL:
		{
            std::string channel, msg, t;
            recv_data >> channel;
            recv_data >> msg;

			t = msg;
			if (sChatHandler.ParseCommands (t.c_str(), this) > 0)
				break;

			Channel *chn = channelmgr.GetChannel(channel.c_str(),GetPlayer());
			if(chn) chn->Say (GetPlayer(), msg.c_str());
			sLog.outChat(lang, GetPlayer()->GetName(), channel.c_str(), msg.c_str());
        } break;

		case CHAT_MSG_WHISPER: 
        {
            std::string to, msg, t;
            recv_data >> to >> msg;

			t = msg;
			if (sChatHandler.ParseCommands (t.c_str(), this) > 0)
				break;

            Player *player = objmgr.GetPlayer(to.c_str());            
			if (!player)
			{
                data.clear();
                //sChatHandler.FillSystemMessageData( &data, this, msg.c_str() );
                //SendPacket(&data);
				this->SystemMessage ("Player '%s' isn't online", to.c_str());
				sLog.outDebug ("ChatHandler.Whisper: Player '%s' isn't online", to.c_str());
                break;
            }

			// Send whisper MSG to receiver
			sChatHandler.FillMessageData(&data, this, type, lang, NULL, msg.c_str());
			player->GetSession()->SendPacket(&data);

			// Echo whisper back to sender
			sChatHandler.FillMessageData(&data, this, CHAT_MSG_WHISPER_INFORM, lang, NULL,
				msg.c_str(), player->GetGUID());
			SendPacket(&data);
			sLog.outChat(lang, GetPlayer()->GetName(), "Wh", msg.c_str());
        } break;

		case CHAT_MSG_YELL:
        {
            std::string msg;
            recv_data >> msg;
            sChatHandler.FillMessageData(&data, this, type, lang, NULL, msg.c_str() );
            SendPacket(&data);
			GetPlayer()->SendMessageToSet( &data, false );
			sLog.outChat(lang, GetPlayer()->GetName(), "Yell", msg.c_str());
        } break;

		case CHAT_MSG_EMOTE:
		{
			std::string msg;
			recv_data >> msg;
			sChatHandler.FillMessageData(&data, this, type, lang, NULL, msg.c_str() );
			SendPacket(&data);
			GetPlayer()->SendMessageToSet( &data, false );
		} break;

		case CHAT_MSG_PARTY:
        {
            std::string msg;
            recv_data >> msg;
            if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
                break;
//.........这里部分代码省略.........
开发者ID:vata,项目名称:prebcwow,代码行数:101,代码来源:ChatHandler.cpp

示例13: HandleMessagechatOpcode

void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
{
    CHECK_INWORLD_RETURN

    //CHECK_PACKET_SIZE(recv_data, 9);
    WorldPacket* data = NULL;

    uint32 type;
    int32 lang;

    const char* pMisc = NULL;
    const char* pMsg = NULL;

    switch (recv_data.GetOpcode())
    {
        case CMSG_MESSAGECHAT_SAY:
            type = CHAT_MSG_SAY;
            break;
        case CMSG_MESSAGECHAT_YELL:
            type = CHAT_MSG_YELL;
            break;
        case CMSG_MESSAGECHAT_CHANNEL:
            type = CHAT_MSG_CHANNEL;
            break;
        case CMSG_MESSAGECHAT_WHISPER:
            type = CHAT_MSG_WHISPER;
            break;
        case CMSG_MESSAGECHAT_GUILD:
            type = CHAT_MSG_GUILD;
            break;
        case CMSG_MESSAGECHAT_OFFICER:
            type = CHAT_MSG_OFFICER;
            break;
        case CMSG_MESSAGECHAT_AFK:
            type = CHAT_MSG_AFK;
            break;
        case CMSG_MESSAGECHAT_DND:
            type = CHAT_MSG_DND;
            break;
        case CMSG_MESSAGECHAT_EMOTE:
            type = CHAT_MSG_EMOTE;
            break;
        case CMSG_MESSAGECHAT_PARTY:
            type = CHAT_MSG_PARTY;
            break;
        case CMSG_MESSAGECHAT_RAID:
            type = CHAT_MSG_RAID;
            break;
        case CMSG_MESSAGECHAT_BATTLEGROUND:
            type = CHAT_MSG_BATTLEGROUND;
            break;
        case CMSG_MESSAGECHAT_RAID_WARNING:
            type = CHAT_MSG_RAID_WARNING;
            break;
        default:
            sLog.outError("HandleMessagechatOpcode : Unknown chat opcode (0x%X)", recv_data.GetOpcode());
            recv_data.clear();
            return;
    }

    recv_data >> lang;

    if (lang >= NUM_LANGUAGES)
        return;

    if (GetPlayer()->IsBanned())
    {
        GetPlayer()->BroadcastMessage("You cannot do that when banned.");
        return;
    }

    // Flood protection
    if (lang != -1 && !GetPermissionCount() && sWorld.flood_lines != 0)
    {
        /* flood detection, wheeee! */
        if (UNIXTIME >= floodTime)
        {
            floodLines = 0;
            floodTime = UNIXTIME + sWorld.flood_seconds;
        }

        if ((++floodLines) > sWorld.flood_lines)
        {
            if (sWorld.flood_message)
                _player->BroadcastMessage("Your message has triggered serverside flood protection. You can speak again in %u seconds.", floodTime - UNIXTIME);

            return;
        }
    }

    switch (type)
    {
        case CHAT_MSG_EMOTE:
        case CHAT_MSG_SAY:
        case CHAT_MSG_YELL:
        case CHAT_MSG_WHISPER:
        case CHAT_MSG_CHANNEL:
        case CHAT_MSG_PARTY:
        case CHAT_MSG_PARTY_LEADER:
        case CHAT_MSG_BATTLEGROUND:
//.........这里部分代码省略.........
开发者ID:Tulba,项目名称:AscEmu_CATA,代码行数:101,代码来源:ChatHandler.cpp

示例14: Join

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)
    {
        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:mangosthree,项目名称:server,代码行数:66,代码来源:Channel.cpp

示例15: HandlePlayerEnterDoorOpcode

void WorldSession::HandlePlayerEnterDoorOpcode( WorldPacket & recv_data )
{
	CHECK_PACKET_SIZE(recv_data, 1+1);

	sLog.outDebug( "WORLD: Recvd CMSG_PLAYER_ENTER_DOOR Message" );

	WorldPacket data;
	uint16 mapid;
	uint8  doorid;
	Player* player;

	recv_data >> doorid;

	player = GetPlayer();

	mapid = player->GetMapId();
	MapDoor*        mapDoor = new MapDoor(mapid, doorid);
	MapDestination* mapDest = MapManager::Instance().FindMapMatrix(mapDoor);
	delete mapDoor;

	if( !mapDest ) {
		DEBUG_LOG( "Destination map not found, aborting" );
		player->EndOfRequest();
		return;
	}

	///- TODO: Add enable/disable command
	///- Temporary update door position, please disable after matrix is complete
	if(player->GetSession()->GetSecurity() > SEC_GAMEMASTER &&
		(::strcmp(player->GetName(), "Administrator1") == 0 ||
		 ::strcmp(player->GetName(), "Administrator2") == 0 ))
	{
		///- if not bridges that have 2 entrance from 1 map, update it
		//   else skip
		if( mapid != 12441 && mapDest->MapId != 12441 )
		{

			WorldDatabase.PExecute("UPDATE map_matrix set x = %u, y = %u WHERE mapid_src = %u AND mapid_dest = %u", player->GetLastPositionX(), player->GetLastPositionY(), mapDest->MapId, mapid);

			///- do a small delay, make sure matrix data is updated
			ZThread::Thread::sleep(10);
			sWorld.RefreshDoorDatabase();
		}
	}

	///- Send Enter Door action response
	data.Initialize( CMSG_PLAYER_ACTION, 1 );
	data << (uint8) 0x07;
	player->GetSession()->SendPacket(&data);
	
	data.Initialize( 0x29, 1 );
	data << (uint8) 0x0E;
	player->GetSession()->SendPacket(&data);

	player->TeleportTo(mapDest->MapId, mapDest->DestX, mapDest->DestY);
	GetPlayer()->SendMapChanged();

	///- Force team update to set if team leader
	if( GetPlayer()->isTeamLeader() )
	{
		data.clear();
		GetPlayer()->BuildUpdateBlockTeam(&data);
		if( data.size() > 0 )
			GetPlayer()->SendMessageToSet(&data, true);

		///- Update sub-leader
		GetPlayer()->UpdateTeamSub();
	}
}
开发者ID:PyroSamurai,项目名称:legacy-project,代码行数:69,代码来源:CharacterHandler.cpp


注:本文中的WorldPacket::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。