本文整理汇总了C++中Guild::GetMOTD方法的典型用法代码示例。如果您正苦于以下问题:C++ Guild::GetMOTD方法的具体用法?C++ Guild::GetMOTD怎么用?C++ Guild::GetMOTD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guild
的用法示例。
在下文中一共展示了Guild::GetMOTD方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGuildInfoCommand
static bool HandleGuildInfoCommand(ChatHandler* handler, char const* args)
{
Guild* guild = nullptr;
if (args && args[0] != '\0')
{
if (isNumeric(args))
guild = sGuildMgr->GetGuildById(strtoull(args, nullptr, 10));
else
guild = sGuildMgr->GetGuildByName(args);
}
else if (Player* target = handler->getSelectedPlayerOrSelf())
guild = target->GetGuild();
if (!guild)
return false;
// Display Guild Information
handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), std::to_string(guild->GetId()).c_str()); // Guild Id + Name
std::string guildMasterName;
if (ObjectMgr::GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().ToString().c_str()); // Guild Master
// Format creation date
char createdDateStr[20];
time_t createdDate = guild->GetCreatedDate();
tm localTm;
strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", localtime_r(&createdDate, &localTm));
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMembersCount()); // Number of Members
handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, std::to_string(guild->GetBankMoney() / 100 / 100).c_str()); // Bank Gold (in gold coins)
handler->PSendSysMessage(LANG_GUILD_INFO_LEVEL, guild->GetLevel()); // Level
handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the Day
handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo().c_str()); // Extra Information
return true;
}
示例2: HandlePlayerLogin
void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
{
ObjectGuid 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(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;
}
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty(false);
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_TIMES, 128 );
for(int i = 0; i < 32; ++i)
data << uint32(0);
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
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)" );
}
//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 nonexistent membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = sGuildMgr.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)" );
guild->DisplayGuildBankTabsInfo(this);
//.........这里部分代码省略.........
示例3: HandlePlayerLogin
//.........这里部分代码省略.........
{
ChatHandler(pCurrChar).PSendSysMessage(str_motd.substr(pos).c_str());
}
DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");
/* Attempt to load guild for player */
if (QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD))
{
/* We're in a guild, so set the player's guild data to represent that */
Field* fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
/* Avoid dangling pointers */
delete resultGuild;
}
/* Player thinks they have a guild, but it isn't in the database. Clear that information */
else if (pCurrChar->GetGuildId())
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
/* Player is in a guild
* TODO: Can we move this code into the block above? Not sure why it's down here */
if (pCurrChar->GetGuildId() != 0)
{
/* Get guild based on what we set the player's guild to above */
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
/* More checks to see if they're in a guild? I'm sure this is redundant */
if (guild)
{
/* Build MOTD packet and send it to the player */
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)");
/* Let everyone in the guild know you've just signed in */
guild->BroadcastEvent(GE_SIGNED_ON, pCurrChar->GetObjectGuid(), pCurrChar->GetName());
}
/* If the player is not in a guild */
else
{
sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.",
pCurrChar->GetName(),
pCurrChar->GetGUIDLow(),
pCurrChar->GetGuildId());
/* Set guild to 0 (again) */
pCurrChar->SetInGuild(0);
}
}
/* Don't let the player get stuck logging in with no corpse */
if (!pCurrChar->IsAlive())
{
pCurrChar->SendCorpseReclaimDelay(true);
}
/* Sends information required before the player can be added to the map
* TODO: See if we can send information about game objects here (prevent alt+f4 through object) */
pCurrChar->SendInitialPacketsBeforeAddToMap();
示例4: FullLogin
//.........这里部分代码省略.........
plr->m_CurrentTransporter = pTrans;
pTrans->AddPlayer(plr);
}
}
#endif
if(plr->m_CurrentVehicle)
plr->m_CurrentVehicle->RemovePassenger(plr);
DEBUG_LOG( "WorldSession","Player %s logged in.", plr->GetName());
if(plr->GetTeam() == 1)
sWorld.HordePlayers++;
else
sWorld.AlliancePlayers++;
if(plr->m_FirstLogin && !HasGMPermissions())
OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &plr->myRace->cinematic_id);
DEBUG_LOG( "WorldSession","Created new player for existing players (%s)", plr->GetName() );
// Login time, will be used for played time calc
plr->m_playedtime[2] = uint32(UNIXTIME);
//Issue a message telling all guild members that this player has signed on
if(plr->IsInGuild())
{
Guild *pGuild = plr->m_playerInfo->guild;
if(pGuild)
{
WorldPacket data(50);
data.Initialize(SMSG_GUILD_EVENT);
data << uint8(GUILD_EVENT_MOTD);
data << uint8(0x01);
if(pGuild->GetMOTD())
data << pGuild->GetMOTD();
else
data << uint8(0);
SendPacket(&data);
pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName());
}
}
// Send online status to people having this char in friendlist (excluding GM's)
if(!HasGMPermissions())
_player->Social_TellFriendsOnline();
// send friend list (for ignores)
_player->Social_SendFriendList(7);
// Send revision (if enabled)
#ifdef WIN32
// _player->BroadcastMessage("Core server: ArcEmu %s r%u/%s-Windows-%s (www.github.com/ArcEmudev)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE);
#else
// _player->BroadcastMessage("Core server: ArcEmu %s r%u/%s-%s (www.github.com/ArcEmudev)", MSG_COLOR_WHITE, BUILD_TAG, BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE);
#endif
// Bugs
_player->BroadcastMessage("Bugs: %s%s", MSG_COLOR_LIGHTBLUE, BUG_TRACKER);
if(sWorld.SendStatsOnJoin)
{
_player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u",
MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections);
_player->BroadcastMessage("Server Uptime: |r%s", sWorld.GetUptimeString().c_str());
}
示例5: HandlePlayerLoginOpcode
//.........这里部分代码省略.........
uint32 linecount=0;
string str_motd = sWorld.GetMotd();
string::size_type pos, nextpos;
pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != 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);
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();
示例6: HandlePlayerLogin
//.........这里部分代码省略.........
}
if (pos < str_motd.length())
{
ChatHandler(pCurrChar).PSendSysMessage(str_motd.substr(pos).c_str());
++linecount;
}
DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");
}
if (!alreadyOnline)
{
//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());
}
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about nonexistent 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)");
guild->BroadcastEvent(GE_SIGNED_ON, pCurrChar->GetObjectGuid(), pCurrChar->GetName());
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member of nonexistent 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();
GetMasterPlayer()->SendInitialActionButtons();
//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);
}
示例7: FullLogin
//.........这里部分代码省略.........
else
sWorld.AlliancePlayers++;
if(plr->m_FirstLogin && !HasGMPermissions())
{
uint32 racecinematic = plr->myRace->cinematic_id;
#ifdef USING_BIG_ENDIAN
swap32(&racecinematic);
#endif
OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &racecinematic);
#ifdef _TEST_EXTENDED_FEATURES_
const int classtext[] ={0,5,6,8,9,11,0,4,3,7,0,10};
sWorld.SendLocalizedWorldText(true,"{65}",classtext[ (uint32)plr->getClass() ] , plr->GetName() , (plr->GetTeam() ? "{63}":"{64}") );
#endif
}
sLog.outDetail( "WORLD: Created new player for existing players (%s)", plr->GetName() );
// Login time, will be used for played time calc
plr->m_playedtime[2] = (uint32)UNIXTIME;
//Issue a message telling all guild members that this player has signed on
if(plr->IsInGuild())
{
Guild *pGuild = plr->m_playerInfo->guild;
if(pGuild)
{
WorldPacket data(50);
data.Initialize(SMSG_GUILD_EVENT);
data << uint8(GUILD_EVENT_MOTD);
data << uint8(0x01);
if(pGuild->GetMOTD())
data << pGuild->GetMOTD();
else
data << uint8(0);
SendPacket(&data);
pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName());
}
}
// Send online status to people having this char in friendlist
_player->Social_TellFriendsOnline();
// send friend list (for ignores)
_player->Social_SendFriendList(7);
#ifndef GM_TICKET_MY_MASTER_COMPATIBLE
GM_Ticket * ticket = objmgr.GetGMTicketByPlayer(_player->GetGUID());
if(ticket != NULL)
{
//Send status change to gm_sync_channel
Channel *chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), _player);
if(chn)
{
std::stringstream ss;
ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_ONLINESTATE;
ss << ":" << ticket->guid;
ss << ":1";
chn->Say(_player, ss.str().c_str(), NULL, true);
}
}
#endif
// Send MOTD
示例8: HandlePlayerReconnect
void WorldSession::HandlePlayerReconnect()
{
// stop logout timer if need
LogoutRequest(0);
// set loading flag
m_playerLoading = true;
// reset all visible objects to be able to resend them
_player->m_clientGUIDs.clear();
SetOnline();
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << _player->GetMapId();
data << _player->GetPositionX();
data << _player->GetPositionY();
data << _player->GetPositionZ();
data << _player->GetOrientation();
SendPacket(data);
data.Initialize(SMSG_ACCOUNT_DATA_TIMES, 128);
for (int i = 0; i < 32; ++i)
data << uint32(0);
SendPacket(data);
// Send Spam records
SendExpectedSpamRecords();
SendMotd(_player);
if (_player->GetGuildId() != 0)
{
Guild* guild = sGuildMgr.GetGuildById(_player->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)");
guild->BroadcastEvent(GE_SIGNED_ON, _player->GetObjectGuid(), _player->GetName());
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.", _player->GetName(), _player->GetGUIDLow(), _player->GetGuildId());
_player->SetInGuild(0);
}
}
if (!_player->isAlive())
_player->SendCorpseReclaimDelay(true);
_player->SendInitialPacketsBeforeAddToMap();
_player->GetMap()->CreatePlayerOnClient(_player);
_player->GetSocial()->SendFriendList();
_player->GetSocial()->SendIgnoreList();
_player->SendInitWorldStates(_player->GetZoneId());
_player->CastSpell(_player, 836, TRIGGERED_OLD_TRIGGERED); // LOGINEFFECT
_player->SendEnchantmentDurations(); // must be after add to map
_player->SendItemDurations(); // must be after add to map
// announce group about member online (must be after add to player list to receive announce to self)
if (Group* group = _player->GetGroup())
group->UpdatePlayerOnlineStatus(_player);
// friend status
sSocialMgr.SendFriendStatus(_player, FRIEND_ONLINE, _player->GetObjectGuid(), true);
// show time before shutdown if shutdown planned.
if (sWorld.IsShutdowning())
sWorld.ShutdownMsg(true, _player);
if (sWorld.getConfig(CONFIG_BOOL_ALL_TAXI_PATHS))
_player->SetTaxiCheater(true);
if (_player->isGameMaster())
SendNotification(LANG_GM_ON);
std::string IP_str = GetRemoteAddress();
sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid: %u)",
GetAccountId(), IP_str.c_str(), _player->GetName(), _player->GetGUIDLow());
// sync client auras timer
_player->UpdateClientAuras();
// sync client control (if taxi flying the client is already sync)
if (_player->IsTaxiFlying())
_player->TaxiFlightResume(true);
else if (!_player->IsClientControlled(_player))
_player->UpdateClientControl(_player, false);
// initialize client pet bar if need
_player->SendPetBar();
//.........这里部分代码省略.........
示例9: FullLogin
//.........这里部分代码省略.........
plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false);
plr->m_CurrentTransporter = pTrans;
pTrans->AddPlayer(plr);
}
}
#endif
DEBUG_LOG( "WorldSession","Player %s logged in.", plr->GetName());
if(plr->GetTeam() == 1)
sWorld.HordePlayers++;
else
sWorld.AlliancePlayers++;
if(plr->m_FirstLogin && !HasGMPermissions())
OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &plr->myRace->cinematic_id);
DEBUG_LOG( "WorldSession","Created new player for existing players (%s)", plr->GetName() );
// Login time, will be used for played time calc
plr->m_playedtime[2] = (uint32)UNIXTIME;
//Issue a message telling all guild members that this player has signed on
if(plr->IsInGuild())
{
Guild *pGuild = plr->m_playerInfo->guild;
if(pGuild)
{
WorldPacket data(50);
data.Initialize(SMSG_GUILD_EVENT);
data << uint8(GUILD_EVENT_MOTD);
data << uint8(0x01);
if(pGuild->GetMOTD())
data << pGuild->GetMOTD();
else
data << uint8(0);
SendPacket(&data);
pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName());
}
}
// Send online status to people having this char in friendlist (excluding GM's)
if(!HasGMPermissions())
_player->Social_TellFriendsOnline();
// send friend list (for ignores)
_player->Social_SendFriendList(7);
// Send revision (if enabled)
#ifdef WIN32
_player->BroadcastMessage("Server: %sAscent %s r%u/%s-Win-%s %s(www.ascentemulator.net)", MSG_COLOR_WHITE,
BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE);
#else
_player->BroadcastMessage("Server: %sAscent %s r%u/%s-%s %s(www.ascentemulator.net)", MSG_COLOR_WHITE,
BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE);
#endif
if(sWorld.SendStatsOnJoin)
{
_player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u",
MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections);
_player->BroadcastMessage("Server Uptime: |r%s", sWorld.GetUptimeString().c_str());
}
示例10: FullLogin
//.........这里部分代码省略.........
plr->m_CurrentTransporter = pTrans;
pTrans->AddPlayer(plr);
}
}
#endif
if(plr->GetVehicle())
plr->GetVehicle()->RemovePassenger(plr);
DEBUG_LOG( "WorldSession","Player %s logged in.", plr->GetName());
if(plr->GetTeam() == 1)
sWorld.HordePlayers++;
else
sWorld.AlliancePlayers++;
if(sWorld.SendMovieOnJoin && plr->m_FirstLogin && !HasGMPermissions())
plr->SendCinematic(plr->myRace->cinematic_id);
DEBUG_LOG( "WorldSession","Created new player for existing players (%s)", plr->GetName() );
// Login time, will be used for played time calc
plr->m_playedtime[2] = (uint32)UNIXTIME;
//Issue a message telling all guild members that this player has signed on
if(plr->IsInGuild())
{
Guild *pGuild = plr->m_playerInfo->guild;
if(pGuild)
{
WorldPacket data(SMSG_GUILD_EVENT, 50);
data << uint8(GUILD_EVENT_MOTD);
data << uint8(0x01);
if(pGuild->GetMOTD())
data << pGuild->GetMOTD();
else
data << uint8(0);
SendPacket(&data);
pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName());
}
}
// Send online status to people having this char in friendlist (excluding GM's)
if(!HasGMPermissions())
plr->Social_TellFriendsOnline();
// send friend list (for ignores)
plr->Social_SendFriendList(7);
// Send revision
plr->BroadcastMessage("%sServer:|r%s Sandshroud Hearthstone|r %s r%u-%s-%s", MSG_COLOR_GOLD,
MSG_COLOR_ORANGEY, MSG_COLOR_TORQUISEBLUE, BUILD_REVISION, ARCH, CONFIG);
plr->BroadcastMessage("%sPlease report all bugs to |r%shttp://mantis.sandshroud.org|r", MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE);
plr->BroadcastMessage("%sOnline Players:|r%s %u |r%sPeak:|r%s %u |r%sAccepted Connections:|r%s %u |r", MSG_COLOR_GOLD,
MSG_COLOR_TORQUISEBLUE, sWorld.GetSessionCount(), MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE,
sWorld.PeakSessionCount, MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE, sWorld.mAcceptedConnections);
plr->BroadcastMessage("%sServer Uptime:|r%s %s|r", MSG_COLOR_GOLD, MSG_COLOR_TORQUISEBLUE, sWorld.GetUptimeString().c_str());
// send to gms
if(HasGMPermissions())
sWorld.SendMessageToGMs(this, "%s%s %s (%s) is now online.|r", MSG_COLOR_GOLD, CanUseCommand('z') ? "Admin" : "GameMaster", plr->GetName(), GetAccountNameS(), GetPermissions());
// Send first line of MOTD
WorldPacket datat(SMSG_MOTD, 10);
示例11: HandlePlayerLogin
void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
uint64 playerGuid = holder->GetGuid();
Player* pCurrChar = new Player(this);
// for send server info and strings (config)
ChatHandler chH = ChatHandler(pCurrChar);
// "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;
}
pCurrChar->GetMotionMaster()->Initialize();
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty(false);
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_TIMES, 128);
for (int i = 0; i < 32; i++)
data << uint32(0);
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
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)");
// send server info
if (sWorld.getConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
chH.PSendSysMessage(_FULLVERSION);
DEBUG_LOG("WORLD: Sent server info");
}
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));
//.........这里部分代码省略.........
示例12: 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);
//.........这里部分代码省略.........
示例13: HandlePlayerLogin
//.........这里部分代码省略.........
// send server info
if (sWorld.getConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
chH.PSendSysMessage(_FULLVERSION);
DEBUG_LOG("WORLD: Sent server info");
}
{
// active game events info
std::string active_events = sGameEventMgr.getActiveEventsString();
ChatHandler(this).SendSysMessage(active_events.c_str());//ChatHandler::FillMessageData(&data, this, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), active_events, NULL);
}
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())
示例14: 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;
}
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty(false);
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_TIMES, 128 );
for(int i = 0; i < 32; i++)
data << uint32(0);
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
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)" );
}
//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
//.........这里部分代码省略.........
示例15: FullLogin
//.........这里部分代码省略.........
}
}
#endif
Log.Debug("Login", "Player %s logged in.", plr->GetName());
if(plr->GetTeam() == 1)
sWorld.HordePlayers++;
else
sWorld.AlliancePlayers++;
if(plr->m_FirstLogin && !HasGMPermissions())
{
uint32 racecinematic = plr->myRace->cinematic_id;
#ifdef USING_BIG_ENDIAN
swap32(&racecinematic);
#endif
OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &racecinematic);
}
sLog.outDetail( "WORLD: Created new player for existing players (%s)", plr->GetName() );
// Login time, will be used for played time calc
plr->m_playedtime[2] = (uint32)UNIXTIME;
//Issue a message telling all guild members that this player has signed on
if(plr->IsInGuild())
{
Guild *pGuild = plr->m_playerInfo->guild;
if(pGuild)
{
WorldPacket data(50);
data.Initialize(SMSG_GUILD_EVENT);
data << uint8(GUILD_EVENT_MOTD);
data << uint8(0x01);
if(pGuild->GetMOTD())
data << pGuild->GetMOTD();
else
data << uint8(0);
SendPacket(&data);
pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName());
}
}
// Send online status to people having this char in friendlist
_player->Social_TellFriendsOnline();
// send friend list (for ignores)
_player->Social_SendFriendList(7);
// Send MOTD
_player->BroadcastMessage(sWorld.GetMotd());
// Send revision (if enabled)
#ifdef WIN32
_player->BroadcastMessage("Server: %sAscent %s r%u/%s-Win-%s %s(www.ascentemu.com)", MSG_COLOR_WHITE, BUILD_TAG,
BUILD_REVISION, CONFIG, ARCH, MSG_COLOR_LIGHTBLUE);
#else
_player->BroadcastMessage("Server: %sAscent %s r%u/%s-%s %s(www.ascentemu.com)", MSG_COLOR_WHITE, BUILD_TAG,
BUILD_REVISION, PLATFORM_TEXT, ARCH, MSG_COLOR_LIGHTBLUE);
#endif
if(sWorld.SendStatsOnJoin)
{
_player->BroadcastMessage("Online Players: %s%u |rPeak: %s%u|r Accepted Connections: %s%u",
MSG_COLOR_WHITE, sWorld.GetSessionCount(), MSG_COLOR_WHITE, sWorld.PeakSessionCount, MSG_COLOR_WHITE, sWorld.mAcceptedConnections);
}
//Set current RestState
if( plr->m_isResting) // We are resting at an inn , turn on Zzz
plr->ApplyPlayerRestState(true);
//Calculate rest bonus if there is time between lastlogoff and now
if( plr->m_timeLogoff > 0 && plr->GetUInt32Value(UNIT_FIELD_LEVEL) < plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) // if timelogoff = 0 then it's the first login
{
uint32 currenttime = (uint32)UNIXTIME;
uint32 timediff = currenttime - plr->m_timeLogoff;
//Calculate rest bonus
if( timediff > 0 )
plr->AddCalculatedRestXP(timediff);
}
#ifdef CLUSTERING
plr->SetInstanceID(forced_instance_id);
plr->SetMapId(forced_map_id);
#else
sHookInterface.OnEnterWorld2(_player);
#endif
if(info->m_Group)
info->m_Group->Update();
if(enter_world && !_player->GetMapMgr())
{
plr->AddToWorld();
}
objmgr.AddPlayer(_player);
}