Core/Packets: converted CMSG_GENERATE_RANDOM_CHARACTER_NAME, SMSG_GENERATE_RANDOM_CHARACTER_NAME_RESULT, CMSG_CHAR_DELETE, SMSG_CREATE_CHAR, SMSG_DELETE_CHAR and CMSG_PLAYER_LOGIN to packet class
This commit is contained in:
1 parent
f05c460dbc
commit
ce5d28617d
6 files changed
+168
-77
No files matched your search
@@ -665,17 +665,15 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
||||
}));
|
||||
}
|
||||
|
||||
void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleCharDeleteOpcode(WorldPackets::Character::CharDelete& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
recvData >> guid;
|
||||
// Initiating
|
||||
uint32 initAccountId = GetAccountId();
|
||||
|
||||
// can't delete loaded character
|
||||
if (ObjectAccessor::FindPlayer(guid))
|
||||
if (ObjectAccessor::FindPlayer(packet.Guid))
|
||||
{
|
||||
sScriptMgr->OnPlayerFailedDelete(guid, initAccountId);
|
||||
sScriptMgr->OnPlayerFailedDelete(packet.Guid, initAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -684,25 +682,25 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
|
||||
std::string name;
|
||||
|
||||
// is guild leader
|
||||
if (sGuildMgr->GetGuildByLeader(guid))
|
||||
if (sGuildMgr->GetGuildByLeader(packet.Guid))
|
||||
{
|
||||
sScriptMgr->OnPlayerFailedDelete(guid, initAccountId);
|
||||
sScriptMgr->OnPlayerFailedDelete(packet.Guid, initAccountId);
|
||||
SendCharDelete(CHAR_DELETE_FAILED_GUILD_LEADER);
|
||||
return;
|
||||
}
|
||||
|
||||
// is arena team captain
|
||||
if (sArenaTeamMgr->GetArenaTeamByCaptain(guid))
|
||||
if (sArenaTeamMgr->GetArenaTeamByCaptain(packet.Guid))
|
||||
{
|
||||
sScriptMgr->OnPlayerFailedDelete(guid, initAccountId);
|
||||
sScriptMgr->OnPlayerFailedDelete(packet.Guid, initAccountId);
|
||||
SendCharDelete(CHAR_DELETE_FAILED_ARENA_CAPTAIN);
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||
CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(packet.Guid);
|
||||
if (!characterInfo)
|
||||
{
|
||||
sScriptMgr->OnPlayerFailedDelete(guid, initAccountId);
|
||||
sScriptMgr->OnPlayerFailedDelete(packet.Guid, initAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -713,31 +711,31 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
|
||||
// prevent deleting other players' characters using cheating tools
|
||||
if (accountId != initAccountId)
|
||||
{
|
||||
sScriptMgr->OnPlayerFailedDelete(guid, initAccountId);
|
||||
sScriptMgr->OnPlayerFailedDelete(packet.Guid, initAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("entities.player.character", "Account: %d, IP: %s deleted character: %s, %s, Level: %u", accountId, GetRemoteAddress().c_str(), name.c_str(), guid.ToString().c_str(), level);
|
||||
TC_LOG_INFO("entities.player.character", "Account: %d, IP: %s deleted character: %s, %s, Level: %u", accountId, GetRemoteAddress().c_str(), name.c_str(), packet.Guid.ToString().c_str(), level);
|
||||
|
||||
// To prevent hook failure, place hook before removing reference from DB
|
||||
sScriptMgr->OnPlayerDelete(guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete.
|
||||
sScriptMgr->OnPlayerDelete(packet.Guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete.
|
||||
// Shouldn't interfere with character deletion though
|
||||
|
||||
if (sLog->ShouldLog("entities.player.dump", LOG_LEVEL_INFO)) // optimize GetPlayerDump call
|
||||
{
|
||||
std::string dump;
|
||||
if (PlayerDumpWriter().GetDump(guid.GetCounter(), dump))
|
||||
sLog->outCharDump(dump.c_str(), accountId, guid.GetRawValue(), name.c_str());
|
||||
if (PlayerDumpWriter().GetDump(packet.Guid.GetCounter(), dump))
|
||||
sLog->outCharDump(dump.c_str(), accountId, packet.Guid.GetRawValue(), name.c_str());
|
||||
}
|
||||
|
||||
sGuildFinderMgr->RemoveAllMembershipRequestsFromPlayer(guid);
|
||||
sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid);
|
||||
Player::DeleteFromDB(guid, accountId);
|
||||
sGuildFinderMgr->RemoveAllMembershipRequestsFromPlayer(packet.Guid);
|
||||
sCalendarMgr->RemoveAllPlayerEventsAndInvites(packet.Guid);
|
||||
Player::DeleteFromDB(packet.Guid, accountId);
|
||||
|
||||
SendCharDelete(CHAR_DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandlePlayerLoginOpcode(WorldPackets::Character::PlayerLogin& packet)
|
||||
{
|
||||
if (PlayerLoading() || GetPlayer() != nullptr)
|
||||
{
|
||||
@@ -746,32 +744,11 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectGuid playerGuid;
|
||||
m_playerLoading = packet.Guid;
|
||||
|
||||
TC_LOG_DEBUG("network", "WORLD: Recvd Player Logon Message");
|
||||
playerGuid[2] = recvData.ReadBit();
|
||||
playerGuid[3] = recvData.ReadBit();
|
||||
playerGuid[0] = recvData.ReadBit();
|
||||
playerGuid[6] = recvData.ReadBit();
|
||||
playerGuid[4] = recvData.ReadBit();
|
||||
playerGuid[5] = recvData.ReadBit();
|
||||
playerGuid[1] = recvData.ReadBit();
|
||||
playerGuid[7] = recvData.ReadBit();
|
||||
|
||||
recvData.ReadByteSeq(playerGuid[2]);
|
||||
recvData.ReadByteSeq(playerGuid[7]);
|
||||
recvData.ReadByteSeq(playerGuid[0]);
|
||||
recvData.ReadByteSeq(playerGuid[3]);
|
||||
recvData.ReadByteSeq(playerGuid[5]);
|
||||
recvData.ReadByteSeq(playerGuid[6]);
|
||||
recvData.ReadByteSeq(playerGuid[1]);
|
||||
recvData.ReadByteSeq(playerGuid[4]);
|
||||
|
||||
m_playerLoading = playerGuid;
|
||||
|
||||
if (!IsLegitCharacterForAccount(playerGuid))
|
||||
if (!IsLegitCharacterForAccount(packet.Guid))
|
||||
{
|
||||
TC_LOG_ERROR("network", "Account (%u) can't login with that character (%s).", GetAccountId(), playerGuid.ToString().c_str());
|
||||
TC_LOG_ERROR("network", "Account (%u) can't login with that character (%s).", GetAccountId(), packet.Guid.ToString().c_str());
|
||||
KickPlayer();
|
||||
return;
|
||||
}
|
||||
@@ -2299,16 +2276,16 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
||||
|
||||
void WorldSession::SendCharCreate(ResponseCodes result)
|
||||
{
|
||||
WorldPacket data(SMSG_CHAR_CREATE, 1);
|
||||
data << uint8(result);
|
||||
SendPacket(&data);
|
||||
WorldPackets::Character::CreateChar packet;
|
||||
packet.Code = result;
|
||||
SendPacket(packet.Write());
|
||||
}
|
||||
|
||||
void WorldSession::SendCharDelete(ResponseCodes result)
|
||||
{
|
||||
WorldPacket data(SMSG_CHAR_DELETE, 1);
|
||||
data << uint8(result);
|
||||
SendPacket(&data);
|
||||
WorldPackets::Character::DeleteChar packet;
|
||||
packet.Code = result;
|
||||
SendPacket(packet.Write());
|
||||
}
|
||||
|
||||
void WorldSession::SendCharRename(ResponseCodes result, CharacterRenameInfo const* renameInfo)
|
||||
@@ -2375,31 +2352,25 @@ void WorldSession::SendBarberShopResult(BarberShopResult result)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleRandomizeCharNameOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleRandomizeCharNameOpcode(WorldPackets::Character::GenerateRandomCharacterName& packet)
|
||||
{
|
||||
uint8 gender, race;
|
||||
|
||||
recvData >> race;
|
||||
recvData >> gender;
|
||||
|
||||
if (!Player::IsValidRace(race))
|
||||
if (!Player::IsValidRace(packet.Race))
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Invalid race (%u) sent by accountId: %u", race, GetAccountId());
|
||||
TC_LOG_ERROR("misc", "Invalid race (%u) sent by accountId: %u", packet.Race, GetAccountId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Player::IsValidGender(gender))
|
||||
if (!Player::IsValidGender(packet.Sex))
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Invalid gender (%u) sent by accountId: %u", gender, GetAccountId());
|
||||
TC_LOG_ERROR("misc", "Invalid gender (%u) sent by accountId: %u", packet.Sex, GetAccountId());
|
||||
return;
|
||||
}
|
||||
|
||||
std::string const& name = sDBCManager.GetRandomCharacterName(race, gender);
|
||||
WorldPacket data(SMSG_RANDOMIZE_CHAR_NAME, 10);
|
||||
data.WriteBit(0); // unk
|
||||
data.WriteBits(name.size(), 7);
|
||||
data.WriteString(name);
|
||||
SendPacket(&data);
|
||||
std::string const& name = sDBCManager.GetRandomCharacterName(packet.Race, packet.Sex);
|
||||
WorldPackets::Character::GenerateRandomCharacterNameResult nameResult;
|
||||
nameResult.Success = true;
|
||||
nameResult.Name = name;
|
||||
SendPacket(nameResult.Write());
|
||||
}
|
||||
|
||||
void WorldSession::HandleReorderCharacters(WorldPacket& recvData)
|
||||
|
||||
Reference in new issue
Block a user