本文整理汇总了C++中Guild::BroadcastPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ Guild::BroadcastPacket方法的具体用法?C++ Guild::BroadcastPacket怎么用?C++ Guild::BroadcastPacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guild
的用法示例。
在下文中一共展示了Guild::BroadcastPacket方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendCalendarEventInviteAlert
void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
{
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT);
data << uint64(calendarEvent.GetEventId());
data << calendarEvent.GetTitle();
data.AppendPackedTime(calendarEvent.GetEventTime());
data << uint32(calendarEvent.GetFlags());
data << uint32(calendarEvent.GetType());
data << int32(calendarEvent.GetDungeonId());
data << uint64(invite.GetInviteId());
Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId());
data << uint64(guild ? guild->GetGUID() : 0);
data << uint8(invite.GetStatus());
data << uint8(invite.GetRank());
data.appendPackGUID(calendarEvent.GetCreatorGUID());
data.appendPackGUID(invite.GetSenderGUID());
if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
{
if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId()))
guild->BroadcastPacket(&data);
}
else
if (Player* player = ObjectAccessor::FindPlayer(invite.GetInviteeGUID()))
player->SendDirectMessage(&data);
}
示例2: HandleGuildRenameRequest
void WorldSession::HandleGuildRenameRequest(WorldPacket& recvPacket)
{
uint32 lenght;
std::string newName;
lenght = recvPacket.ReadBits(8);
newName = recvPacket.ReadString(lenght);
Guild* pGuild = GetPlayer()->GetGuild();
if(pGuild)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_NAME);
_guildRenameCallback.SetParam(newName);
stmt->setUInt32(1,pGuild->GetId());
stmt->setString(0,newName);
_guildRenameCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt));
WorldPacket data(SMSG_GUILD_FLAGGED_FOR_RENAME,1);
data.WriteBit(true); // it may send false also, but we don't know how to handle exeptions by the DB layer
data.FlushBits();
pGuild->BroadcastPacket(&data);
}
}
示例3: HandleGuildRemoveOpcode
void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket)
{
std::string plName;
//sLog.outDebug("WORLD: Received CMSG_GUILD_REMOVE");
recvPacket >> plName;
if(!normalizePlayerName(plName))
return;
Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
if(!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_REMOVE))
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
uint64 plGuid;
MemberSlot* slot = guild->GetMemberSlot(plName, plGuid);
if(!slot)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
}
if(slot->RankId == GR_GUILDMASTER)
{
SendGuildCommandResult(GUILD_QUIT_S, "", GUILD_LEADER_LEAVE);
return;
}
//do not allow to kick player with same or higher rights
if(GetPlayer()->GetRank() >= slot->RankId)
{
SendGuildCommandResult(GUILD_QUIT_S, plName, GUILD_RANK_TOO_HIGH_S);
return;
}
guild->DelMember(plGuid);
// Put record into guildlog
guild->LogGuildEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, GetPlayer()->GetGUIDLow(), GUID_LOPART(plGuid), 0);
WorldPacket data(SMSG_GUILD_EVENT, (2+20)); // guess size
data << (uint8)GE_REMOVED;
data << (uint8)2; // strings count
data << plName;
data << GetPlayer()->GetName();
guild->BroadcastPacket(&data);
}
示例4: HandleGuildLeaderOpcode
void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket)
{
std::string name;
Player *oldLeader = GetPlayer();
Guild *guild;
//sLog.outDebug("WORLD: Received CMSG_GUILD_LEADER");
recvPacket >> name;
if(!normalizePlayerName(name))
return;
guild = objmgr.GetGuildById(oldLeader->GetGuildId());
if (!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if( oldLeader->GetGUID() != guild->GetLeader())
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
uint64 newLeaderGUID;
MemberSlot* slot = guild->GetMemberSlot(name, newLeaderGUID);
if (!slot)
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
}
guild->SetLeader(newLeaderGUID);
guild->ChangeRank(oldLeader->GetGUID(), GR_OFFICER);
WorldPacket data(SMSG_GUILD_EVENT, (2+20)); // guess size
data << (uint8)GE_LEADER_CHANGED;
data << (uint8)2; // strings count
data << oldLeader->GetName();
data << name.c_str();
guild->BroadcastPacket(&data);
//sLog.outDebug("WORLD: Sent (SMSG_GUILD_EVENT)");
}
示例5: HandleGuildLeaveOpcode
void WorldSession::HandleGuildLeaveOpcode(WorldPacket& /*recvPacket*/)
{
std::string plName;
Guild *guild;
//sLog.outDebug("WORLD: Received CMSG_GUILD_LEAVE");
guild = objmgr.GetGuildById(_player->GetGuildId());
if(!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if(_player->GetGUID() == guild->GetLeader() && guild->GetMemberSize() > 1)
{
SendGuildCommandResult(GUILD_QUIT_S, "", GUILD_LEADER_LEAVE);
return;
}
if(_player->GetGUID() == guild->GetLeader())
{
guild->Disband();
return;
}
plName = _player->GetName();
guild->DelMember(_player->GetGUID());
// Put record into guildlog
guild->LogGuildEvent(GUILD_EVENT_LOG_LEAVE_GUILD, _player->GetGUIDLow(), 0, 0);
WorldPacket data(SMSG_GUILD_EVENT, (2+10)); // guess size
data << (uint8)GE_LEFT;
data << (uint8)1; // strings count
data << plName;
guild->BroadcastPacket(&data);
//sLog.outDebug("WORLD: Sent (SMSG_GUILD_EVENT)");
SendGuildCommandResult(GUILD_QUIT_S, guild->GetName(), GUILD_PLAYER_NO_MORE_IN_GUILD);
}
示例6: LogoutPlayer
//.........这里部分代码省略.........
if(BattleGround *bg = _player->GetBattleGround())
bg->EventPlayerLoggedOut(_player);
///- Teleport to home if the player is in an invalid instance
if(!_player->m_InstanceValid && !_player->isGameMaster())
_player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
{
if(BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i))
{
_player->RemoveBattleGroundQueueId(bgQueueTypeId);
sBattleGroundMgr.m_BattleGroundQueues[ bgQueueTypeId ].RemovePlayer(_player->GetGUID(), true);
}
}
///- Reset the online field in the account table
// no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage
//No SQL injection as AccountID is uint32
loginDatabase.PExecute("UPDATE account SET online = 0 WHERE id = '%u'", GetAccountId());
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
Guild *guild = objmgr.GetGuildById(_player->GetGuildId());
if(guild)
{
guild->LoadPlayerStatsByGuid(_player->GetGUID());
guild->UpdateLogoutTime(_player->GetGUID());
WorldPacket data(SMSG_GUILD_EVENT, (1+1+12+8)); // name limited to 12 in character table.
data<<(uint8)GE_SIGNED_OFF;
data<<(uint8)1;
data<<_player->GetName();
data<<_player->GetGUID();
guild->BroadcastPacket(&data);
}
///- Remove pet
_player->RemovePet(NULL,PET_SAVE_AS_CURRENT, true);
///- empty buyback items and save the player in the database
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
if(Save)
{
uint32 eslot;
for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++)
{
eslot = j - BUYBACK_SLOT_START;
_player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+eslot*2,0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+eslot,0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+eslot,0);
}
_player->SaveToDB();
}
///- Leave all channels before player delete...
_player->CleanupChannels();
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
_player->UninviteFromGroup();
// remove player from the group if he is:
// a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
_player->RemoveFromGroup();
///- Remove the player from the world
示例7: HandlePlayerLogin
//.........这里部分代码省略.........
}
QueryResultAutoPtr resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if (resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
}
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if (pCurrChar->GetGuildId() != 0)
{
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
if (guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<pCurrChar->GetGUID();
guild->BroadcastPacket(&data);
DEBUG_LOG("WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)");
// Increment online members of the guild
guild->IncOnlineMemberCount();
}
else
{
// remove wrong guild data
sLog.outLog(LOG_DEFAULT, "ERROR: Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetInGuild(0);
}
}
if (!pCurrChar->isAlive())
pCurrChar->SendCorpseReclaimDelay(true);
pCurrChar->SendInitialPacketsBeforeAddToMap();
//Show cinematic at the first time that player login
if (!pCurrChar->getCinematic())
{
pCurrChar->setCinematic(true);
if(ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
{
pCurrChar->SendCinematicStart(rEntry->CinematicSequence);
// send new char string if not empty
if (!sWorld.GetNewCharString().empty())
chH.PSendSysMessage(sWorld.GetNewCharString().c_str());
}
}
示例8: HandlePlayerLogin
//.........这里部分代码省略.........
}
QueryResult_AutoPtr resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if (resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
}
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if (pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if (guild)
{
data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1));
data << uint8(GE_MOTD);
data << uint8(1);
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<pCurrChar->GetGUID();
guild->BroadcastPacket(&data);
DEBUG_LOG("WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)");
// Increment online members of the guild
guild->IncOnlineMemberCount();
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member of invalid guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetInGuild(0);
}
}
if (!pCurrChar->isAlive())
pCurrChar->SendCorpseReclaimDelay(true);
pCurrChar->SendInitialPacketsBeforeAddToMap();
//Show cinematic at the first time that player login
if (!pCurrChar->getCinematic())
{
pCurrChar->setCinematic(1);
if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
{
pCurrChar->SendCinematicStart(rEntry->CinematicSequence);
// send new char string if not empty
if (!sWorld.GetNewCharString().empty())
chH.PSendSysMessage("%s", sWorld.GetNewCharString().c_str());
}
}
示例9: HandlePlayerLoginOpcode
void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
{
m_playerLoading = true;
uint64 playerGuid = 0;
DEBUG_LOG( "WORLD: Recvd Player Logon Message" );
recv_data >> playerGuid;
Player* plr = new Player(this);
ASSERT(plr);
plr->SetSession(this);
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if(!plr->LoadFromDB(GUID_LOPART(playerGuid)))
{
m_playerLoading = false;
return;
}
//plr->_RemoveAllItemMods();
//set a count of unread mails:
QueryResult *resultMails = sDatabase.PQuery("SELECT COUNT(id) FROM `mail` WHERE `receiver` = '%u' AND `checked` = 0", GUID_LOPART(playerGuid));
if (resultMails)
{
Field *fieldMail = resultMails->Fetch();
plr->unReadMails = fieldMail[0].GetUInt8();
delete resultMails;
}
else
plr->unReadMails = 0;
SetPlayer(plr);
WorldPacket data( SMSG_ACCOUNT_DATA_MD5, (80) );
for(int i = 0; i < 80; i++)
data << uint8(0);
SendPacket(&data);
Player *pCurrChar = GetPlayer();
pCurrChar->LoadIgnoreList();
pCurrChar->SendFriendlist();
pCurrChar->SendIgnorelist();
sChatHandler.FillSystemMessageData(&data, this, sWorld.GetMotd());
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MESSAGECHAT)" );
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<(uint8)0<<(uint8)0<<(uint8)0;
guild->BroadcastPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetUInt32Value(PLAYER_GUILDID,0);
pCurrChar->SetUInt32ValueInDB(PLAYER_GUILDID,0,pCurrChar->GetGUID());
}
}
// home bind stuff
Field *fields;
QueryResult *result7 = sDatabase.PQuery("SELECT COUNT(`guid`) FROM `character_homebind` WHERE `guid` = '%u'", GUID_LOPART(playerGuid));
if (result7)
{
int cnt;
fields = result7->Fetch();
cnt = fields[0].GetUInt32();
if ( cnt > 0 )
{
QueryResult *result4 = sDatabase.PQuery("SELECT `map`,`zone`,`position_x`,`position_y`,`position_z` FROM `character_homebind` WHERE `guid` = '%u'", GUID_LOPART(playerGuid));
assert(result4);
fields = result4->Fetch();
data.Initialize (SMSG_BINDPOINTUPDATE, 5*4);
data << fields[2].GetFloat() << fields[3].GetFloat() << fields[4].GetFloat();
data << fields[0].GetUInt32();
data << fields[1].GetUInt32();
SendPacket (&data);
//.........这里部分代码省略.........
示例10: HandleGuildLeaderOpcode
void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket, 1);
std::string name;
Player *newLeader;
uint64 newLeaderGUID;
uint32 newLeaderGuild;
Player *oldLeader = GetPlayer();
Guild *guild;
//sLog.outDebug("WORLD: Received CMSG_GUILD_LEADER");
recvPacket >> name;
if(name.empty())
return;
normalizePlayerName(name);
//CharacterDatabase.escape_string(name); // prevent SQL injection - normal name don't must changed by this call
newLeader = ObjectAccessor::Instance().FindPlayerByName(name.c_str());
if(newLeader)
{
newLeaderGUID = newLeader->GetGUID();
newLeaderGuild = newLeader->GetGuildId();
}
else
{
newLeaderGUID = objmgr.GetPlayerGUIDByName(name);
newLeaderGuild = Player::GetGuildIdFromDB(newLeaderGUID);
}
guild = objmgr.GetGuildById(oldLeader->GetGuildId());
if(!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
else if(!newLeaderGUID)
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND);
return;
}
if(oldLeader->GetGuildId() != newLeaderGuild)
{
SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
}
if(oldLeader->GetGUID() != guild->GetLeader())
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
guild->SetLeader(newLeaderGUID);
guild->ChangeRank(oldLeader->GetGUID(), GR_OFFICER);
WorldPacket data(SMSG_GUILD_EVENT, (2+20)); // guess size
data << (uint8)GE_LEADER_CHANGED;
data << (uint8)2;
data << oldLeader->GetName();
data << name.c_str();
guild->BroadcastPacket(&data);
//sLog.outDebug("WORLD: Sent (SMSG_GUILD_EVENT)");
}
示例11: HandleGuildDemoteOpcode
void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket, 1);
std::string plName;
uint64 plGuid;
uint32 plGuildId;
uint32 plRankId;
Player *player;
Guild *guild;
//sLog.outDebug("WORLD: Received CMSG_GUILD_DEMOTE");
recvPacket >> plName;
if(plName.empty())
return;
normalizePlayerName(plName);
//CharacterDatabase.escape_string(plName); // prevent SQL injection - normal name don't must changed by this call
player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str());
guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
if(player)
{
plGuid = player->GetGUID();
plGuildId = player->GetGuildId();
plRankId = player->GetRank();
}
else
{
plGuid = objmgr.GetPlayerGUIDByName(plName);
plGuildId = Player::GetGuildIdFromDB(plGuid);
plRankId = Player::GetRankFromDB(plGuid);
}
if(!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if( !plGuid )
{
SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_FOUND);
return;
}
if(plGuid == GetPlayer()->GetGUID())
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_NAME_INVALID);
return;
}
if(GetPlayer()->GetGuildId() != plGuildId)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S);
return;
}
if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_DEMOTE))
{
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return;
}
if((plRankId+1) >= guild->GetNrRanks() || plRankId <= this->GetPlayer()->GetRank())
return;
guild->ChangeRank(plGuid, (plRankId+1));
WorldPacket data(SMSG_GUILD_EVENT, (2+30)); // guess size
data << (uint8)GE_DEMOTION;
data << (uint8)3;
data << GetPlayer()->GetName();
data << plName;
data << guild->GetRankName(plRankId+1);
guild->BroadcastPacket(&data);
}
示例12: HandlePlayerLogin
//.........这里部分代码省略.........
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if(resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild;
}
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<pCurrChar->GetGUID();
guild->BroadcastPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );
// Increment online members of the guild
guild->IncOnlineMemberCount();
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetInGuild(0);
}
}
if(!pCurrChar->isAlive())
pCurrChar->SendCorpseReclaimDelay(true);
pCurrChar->SendInitialPacketsBeforeAddToMap();
//Show cinematic at the first time that player login
if( !pCurrChar->getCinematic() )
{
pCurrChar->setCinematic(1);
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace());
if(rEntry)
{
data.Initialize( SMSG_TRIGGER_CINEMATIC,4 );
data << uint32(rEntry->startmovie);
SendPacket( &data );
}
}
示例13: HandlePlayerLogin
void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
uint64 playerGuid = holder->GetGuid();
Player* pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize();
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if(!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
{
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
return;
}
else
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty();
WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ();
data << pCurrChar->GetOrientation();
SendPacket(&data);
data.Initialize( SMSG_ACCOUNT_DATA_MD5, 128 );
for(int i = 0; i < 32; i++)
data << uint32(0);
SendPacket(&data);
pCurrChar->SendFriendlist();
pCurrChar->SendIgnorelist();
// added in 2.2.0
data.Initialize(SMSG_VOICE_SYSTEM_STATUS, 2);
data << uint8(2); // unknown value
data << uint8(0); // enable(1)/disable(0) voice chat interface in client
SendPacket(&data);
// Send MOTD
{
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
data << (uint32)0;
uint32 linecount=0;
std::string str_motd = sWorld.GetMotd();
std::string::size_type pos, nextpos;
pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
{
if (nextpos != pos)
{
data << str_motd.substr(pos,nextpos-pos);
linecount++;
}
pos = nextpos+1;
}
if (pos<str_motd.length())
{
data << str_motd.substr(pos);
linecount++;
}
data.put(0, linecount);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<pCurrChar->GetGUID();
guild->BroadcastPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetUInt32Value(PLAYER_GUILDID,0);
//.........这里部分代码省略.........
示例14: HandlePlayerLogin
//.........这里部分代码省略.........
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if(resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild;
}
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<pCurrChar->GetGUID();
guild->BroadcastPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );
// Increment online members of the guild
guild->IncOnlineMemberCount();
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetInGuild(0);
}
}
data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4);
data << uint32(0);
data << uint32(0);
SendPacket(&data);
if(!pCurrChar->isAlive())
pCurrChar->SendCorpseReclaimDelay(true);
pCurrChar->SendInitialPacketsBeforeAddToMap();
//Show cinematic at the first time that player login
if( !pCurrChar->getCinematic() )
{
pCurrChar->setCinematic(1);
if(ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
{
if (cEntry->CinematicSequence)
pCurrChar->SendCinematicStart(cEntry->CinematicSequence);
示例15: HandlePlayerLoginOpcode
//.........这里部分代码省略.........
}
pos = nextpos+1;
}
if (pos<str_motd.length())
{
data << str_motd.substr(pos);
linecount++;
}
data.put(0, linecount);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
data<<(uint8)GE_SIGNED_ON;
data<<(uint8)1;
data<<pCurrChar->GetName();
data<<pCurrChar->GetGUID();
guild->BroadcastPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-signed-on (SMSG_GUILD_EVENT)" );
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
pCurrChar->SetUInt32Value(PLAYER_GUILDID,0);
pCurrChar->SetUInt32ValueInDB(PLAYER_GUILDID,0,pCurrChar->GetGUID());
}
}
// rest_start
// home bind stuff
{
QueryResult *result4 = sDatabase.PQuery("SELECT `map`,`zone`,`position_x`,`position_y`,`position_z` FROM `character_homebind` WHERE `guid` = '%u'", GUID_LOPART(playerGuid));
if (result4)
{
Field *fields = result4->Fetch();
_player->m_homebindMapId = fields[0].GetUInt32();
_player->m_homebindZoneId = fields[1].GetUInt16();
_player->m_homebindX = fields[2].GetFloat();
_player->m_homebindY = fields[3].GetFloat();
_player->m_homebindZ = fields[4].GetFloat();
delete result4;
}
else
{
int plrace = GetPlayer()->getRace();
int plclass = GetPlayer()->getClass();
QueryResult *result5 = sDatabase.PQuery("SELECT `map`,`zone`,`position_x`,`position_y`,`position_z` FROM `playercreateinfo` WHERE `race` = '%u' AND `class` = '%u'", plrace, plclass);