aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/CharacterHandler.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-01-08 21:16:53 +0100
committerShauren <shauren.trinity@gmail.com>2023-01-08 21:16:53 +0100
commitd791afae1dfcfaf592326f787755ca32d629e4d3 (patch)
tree54dc9916ede5800e110a2f0edff91530811fbdb8 /src/server/game/Handlers/CharacterHandler.cpp
parentb6820a706f46f18b9652fcd9806e4bec8805d29d (diff)
Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api)
Diffstat (limited to 'src/server/game/Handlers/CharacterHandler.cpp')
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index c4d6cd0f21d..df8d7dd4aa8 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -423,13 +423,13 @@ void WorldSession::HandleCharEnum(CharacterDatabaseQueryHolder const& holder)
if (std::vector<UF::ChrCustomizationChoice>* customizationsForChar = Trinity::Containers::MapGetValuePtr(customizations, charInfo.Guid.GetCounter()))
charInfo.Customizations = std::move(*customizationsForChar);
- TC_LOG_INFO("network", "Loading char guid %s from account %u.", charInfo.Guid.ToString().c_str(), GetAccountId());
+ TC_LOG_INFO("network", "Loading char guid {} from account {}.", charInfo.Guid.ToString(), GetAccountId());
if (!charEnum.IsDeletedCharacters)
{
if (!ValidateAppearance(Races(charInfo.RaceID), Classes(charInfo.ClassID), Gender(charInfo.SexID), MakeChrCustomizationChoiceRange(charInfo.Customizations)))
{
- TC_LOG_ERROR("entities.player.loading", "Player %s has wrong Appearance values (Hair/Skin/Color), forcing recustomize", charInfo.Guid.ToString().c_str());
+ TC_LOG_ERROR("entities.player.loading", "Player {} has wrong Appearance values (Hair/Skin/Color), forcing recustomize", charInfo.Guid.ToString());
charInfo.Customizations.clear();
@@ -645,7 +645,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(charCreate.CreateInfo->Class);
if (!classEntry)
{
- TC_LOG_ERROR("network", "Class (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", charCreate.CreateInfo->Class, GetAccountId());
+ TC_LOG_ERROR("network", "Class ({}) not found in DBC while creating new char for account (ID: {}): wrong DBC files or cheater?", charCreate.CreateInfo->Class, GetAccountId());
SendCharCreate(CHAR_CREATE_FAILED);
return;
}
@@ -653,7 +653,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(charCreate.CreateInfo->Race);
if (!raceEntry)
{
- TC_LOG_ERROR("network", "Race (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", charCreate.CreateInfo->Race, GetAccountId());
+ TC_LOG_ERROR("network", "Race ({}) not found in DBC while creating new char for account (ID: {}): wrong DBC files or cheater?", charCreate.CreateInfo->Race, GetAccountId());
SendCharCreate(CHAR_CREATE_FAILED);
return;
}
@@ -662,14 +662,14 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
RaceUnlockRequirement const* raceExpansionRequirement = sObjectMgr->GetRaceUnlockRequirement(charCreate.CreateInfo->Race);
if (!raceExpansionRequirement)
{
- TC_LOG_ERROR("entities.player.cheat", "Account %u tried to create character with unavailable race %u", GetAccountId(), charCreate.CreateInfo->Race);
+ TC_LOG_ERROR("entities.player.cheat", "Account {} tried to create character with unavailable race {}", GetAccountId(), charCreate.CreateInfo->Race);
SendCharCreate(CHAR_CREATE_FAILED);
return;
}
if (raceExpansionRequirement->Expansion > GetAccountExpansion())
{
- TC_LOG_ERROR("entities.player.cheat", "Expansion %u account:[%d] tried to Create character with expansion %u race (%u)",
+ TC_LOG_ERROR("entities.player.cheat", "Expansion {} account:[{}] tried to Create character with expansion {} race ({})",
GetAccountExpansion(), GetAccountId(), raceExpansionRequirement->Expansion, charCreate.CreateInfo->Race);
SendCharCreate(CHAR_CREATE_EXPANSION);
return;
@@ -677,7 +677,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
//if (raceExpansionRequirement->AchievementId && !)
//{
- // TC_LOG_ERROR("entities.player.cheat", "Expansion %u account:[%d] tried to Create character without achievement %u race (%u)",
+ // TC_LOG_ERROR("entities.player.cheat", "Expansion {} account:[{}] tried to Create character without achievement {} race ({})",
// GetAccountExpansion(), GetAccountId(), raceExpansionRequirement->AchievementId, charCreate.CreateInfo->Race);
// SendCharCreate(CHAR_CREATE_ALLIED_RACE_ACHIEVEMENT);
// return;
@@ -688,7 +688,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
{
if (raceClassExpansionRequirement->ActiveExpansionLevel > GetExpansion() || raceClassExpansionRequirement->AccountExpansionLevel > GetAccountExpansion())
{
- TC_LOG_ERROR("entities.player.cheat", "Account:[%d] tried to create character with race/class %u/%u without required expansion (had %u/%u, required %u/%u)",
+ TC_LOG_ERROR("entities.player.cheat", "Account:[{}] tried to create character with race/class {}/{} without required expansion (had {}/{}, required {}/{})",
GetAccountId(), uint32(charCreate.CreateInfo->Race), uint32(charCreate.CreateInfo->Class), GetExpansion(), GetAccountExpansion(),
raceClassExpansionRequirement->ActiveExpansionLevel, raceClassExpansionRequirement->AccountExpansionLevel);
SendCharCreate(CHAR_CREATE_EXPANSION_CLASS);
@@ -699,7 +699,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
{
if (classExpansionRequirement->MinActiveExpansionLevel > GetExpansion() || classExpansionRequirement->AccountExpansionLevel > GetAccountExpansion())
{
- TC_LOG_ERROR("entities.player.cheat", "Account:[%d] tried to create character with race/class %u/%u without required expansion (had %u/%u, required %u/%u)",
+ TC_LOG_ERROR("entities.player.cheat", "Account:[{}] tried to create character with race/class {}/{} without required expansion (had {}/{}, required {}/{})",
GetAccountId(), uint32(charCreate.CreateInfo->Race), uint32(charCreate.CreateInfo->Class), GetExpansion(), GetAccountExpansion(),
classExpansionRequirement->ActiveExpansionLevel, classExpansionRequirement->AccountExpansionLevel);
SendCharCreate(CHAR_CREATE_EXPANSION_CLASS);
@@ -708,7 +708,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
}
else
{
- TC_LOG_ERROR("entities.player.cheat", "Expansion %u account:[%d] tried to Create character for race/class combination that is missing requirements in db (%u/%u)",
+ TC_LOG_ERROR("entities.player.cheat", "Expansion {} account:[{}] tried to Create character for race/class combination that is missing requirements in db ({}/{})",
GetAccountExpansion(), GetAccountId(), uint32(charCreate.CreateInfo->Race), uint32(charCreate.CreateInfo->Class));
SendCharCreate(CHAR_CREATE_EXPANSION_CLASS);
return;
@@ -718,7 +718,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
{
if (raceEntry->GetFlags().HasFlag(ChrRacesFlag::NPCOnly))
{
- TC_LOG_ERROR("network", "Race (%u) was not playable but requested while creating new char for account (ID: %u): wrong DBC files or cheater?", charCreate.CreateInfo->Race, GetAccountId());
+ TC_LOG_ERROR("network", "Race ({}) was not playable but requested while creating new char for account (ID: {}): wrong DBC files or cheater?", charCreate.CreateInfo->Race, GetAccountId());
SendCharCreate(CHAR_CREATE_DISABLED);
return;
}
@@ -744,7 +744,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
// prevent character creating with invalid name
if (!normalizePlayerName(charCreate.CreateInfo->Name))
{
- TC_LOG_ERROR("entities.player.cheat", "Account:[%d] but tried to Create character with empty [name] ", GetAccountId());
+ TC_LOG_ERROR("entities.player.cheat", "Account:[{}] but tried to Create character with empty [name] ", GetAccountId());
SendCharCreate(CHAR_NAME_NO_NAME);
return;
}
@@ -971,7 +971,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateCharact
{
if (success)
{
- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Create Character: %s %s", GetAccountId(), GetRemoteAddress().c_str(), newChar->GetName().c_str(), newChar->GetGUID().ToString().c_str());
+ TC_LOG_INFO("entities.player.character", "Account: {} (IP: {}) Create Character: {} {}", GetAccountId(), GetRemoteAddress(), newChar->GetName(), newChar->GetGUID().ToString());
sScriptMgr->OnPlayerCreate(newChar.get());
sCharacterCache->AddCharacterCacheEntry(newChar->GetGUID(), GetAccountId(), newChar->GetName(), newChar->GetNativeGender(), newChar->GetRace(), newChar->GetClass(), newChar->GetLevel(), false);
@@ -1041,7 +1041,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPackets::Character::CharDelete& c
return;
}
- TC_LOG_INFO("entities.player.character", "Account: %u, IP: %s deleted character: %s, %s, Level: %u", accountId, GetRemoteAddress().c_str(), name.c_str(), charDelete.Guid.ToString().c_str(), level);
+ TC_LOG_INFO("entities.player.character", "Account: {}, IP: {} deleted character: {}, {}, Level: {}", accountId, GetRemoteAddress(), name, charDelete.Guid.ToString(), level);
// To prevent hook failure, place hook before removing reference from DB
sScriptMgr->OnPlayerDelete(charDelete.Guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete.
@@ -1064,18 +1064,18 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPackets::Character::PlayerLogin&
{
if (PlayerLoading() || GetPlayer() != nullptr)
{
- TC_LOG_ERROR("network", "Player tries to login again, AccountId = %d", GetAccountId());
+ TC_LOG_ERROR("network", "Player tries to login again, AccountId = {}", GetAccountId());
KickPlayer("WorldSession::HandlePlayerLoginOpcode Another client logging in");
return;
}
m_playerLoading = playerLogin.Guid;
- TC_LOG_DEBUG("network", "Character %s logging in", playerLogin.Guid.ToString().c_str());
+ TC_LOG_DEBUG("network", "Character {} logging in", playerLogin.Guid.ToString());
if (!IsLegitCharacterForAccount(playerLogin.Guid))
{
- TC_LOG_ERROR("network", "Account (%u) can't login with that character (%s).", GetAccountId(), playerLogin.Guid.ToString().c_str());
+ TC_LOG_ERROR("network", "Account ({}) can't login with that character ({}).", GetAccountId(), playerLogin.Guid.ToString());
KickPlayer("WorldSession::HandlePlayerLoginOpcode Trying to login with a character of another account");
return;
}
@@ -1186,7 +1186,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
chH.PSendSysMessage(GitRevision::GetFullVersion());
}
- //QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, `rank` FROM guild_member WHERE guid = '%u'", pCurrChar->GetGUIDLow());
+ //QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, `rank` FROM guild_member WHERE guid = '{}'", pCurrChar->GetGUIDLow());
if (PreparedQueryResult resultGuild = holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GUILD))
{
Field* fields = resultGuild->Fetch();
@@ -1253,7 +1253,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
}
ObjectAccessor::AddObject(pCurrChar);
- //TC_LOG_DEBUG("Player %s added to Map.", pCurrChar->GetName().c_str());
+ //TC_LOG_DEBUG("Player {} added to Map.", pCurrChar->GetName());
if (pCurrChar->GetGuildId())
{
@@ -1262,7 +1262,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
else
{
// remove wrong guild data
- TC_LOG_ERROR("misc", "Player %s (%s) marked as member of not existing guild (id: " UI64FMTD "), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUID().ToString().c_str(), pCurrChar->GetGuildId());
+ TC_LOG_ERROR("misc", "Player {} ({}) marked as member of not existing guild (id: {}), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUID().ToString(), pCurrChar->GetGuildId());
pCurrChar->SetInGuild(UI64LIT(0));
}
}
@@ -1441,8 +1441,8 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
if (pCurrChar->IsGameMaster())
SendNotification(LANG_GM_ON);
- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Login Character: [%s] %s Level: %d, XP: %u/%u (%u left)",
- GetAccountId(), GetRemoteAddress().c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUID().ToString().c_str(), pCurrChar->GetLevel(),
+ TC_LOG_INFO("entities.player.character", "Account: {} (IP: {}) Login Character: [{}] {} Level: {}, XP: {}/{} ({} left)",
+ GetAccountId(), GetRemoteAddress(), pCurrChar->GetName(), pCurrChar->GetGUID().ToString(), pCurrChar->GetLevel(),
_player->GetXP(), _player->GetXPForNextLevel(), std::max(0, (int32)_player->GetXPForNextLevel() - (int32)_player->GetXP()));
if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED))
@@ -1526,7 +1526,7 @@ void WorldSession::HandleTutorialFlag(WorldPackets::Misc::TutorialSetFlag& packe
uint8 index = uint8(packet.TutorialBit >> 5);
if (index >= MAX_ACCOUNT_TUTORIAL_VALUES)
{
- TC_LOG_ERROR("network", "CMSG_TUTORIAL_FLAG received bad TutorialBit %u.", packet.TutorialBit);
+ TC_LOG_ERROR("network", "CMSG_TUTORIAL_FLAG received bad TutorialBit {}.", packet.TutorialBit);
return;
}
uint32 flag = GetTutorialInt(index);
@@ -1543,7 +1543,7 @@ void WorldSession::HandleTutorialFlag(WorldPackets::Misc::TutorialSetFlag& packe
SetTutorialInt(i, 0x00000000);
break;
default:
- TC_LOG_ERROR("network", "CMSG_TUTORIAL_FLAG received unknown TutorialAction %u.", packet.Action);
+ TC_LOG_ERROR("network", "CMSG_TUTORIAL_FLAG received unknown TutorialAction {}.", packet.Action);
return;
}
}
@@ -1601,8 +1601,8 @@ void WorldSession::HandleCharRenameOpcode(WorldPackets::Character::CharacterRena
{
if (!IsLegitCharacterForAccount(request.RenameInfo->Guid))
{
- TC_LOG_ERROR("network", "Account %u, IP: %s tried to rename character %s, but it does not belong to their account!",
- GetAccountId(), GetRemoteAddress().c_str(), request.RenameInfo->Guid.ToString().c_str());
+ TC_LOG_ERROR("network", "Account {}, IP: {} tried to rename character {}, but it does not belong to their account!",
+ GetAccountId(), GetRemoteAddress(), request.RenameInfo->Guid.ToString());
KickPlayer("WorldSession::HandleCharRenameOpcode rename character from a different account");
return;
}
@@ -1677,8 +1677,8 @@ void WorldSession::HandleCharRenameCallBack(std::shared_ptr<WorldPackets::Charac
CharacterDatabase.CommitTransaction(trans);
- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Changed name to: %s",
- GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), renameInfo->Guid.ToString().c_str(), renameInfo->NewName.c_str());
+ TC_LOG_INFO("entities.player.character", "Account: {} (IP: {}) Character:[{}] ({}) Changed name to: {}",
+ GetAccountId(), GetRemoteAddress(), oldName, renameInfo->Guid.ToString(), renameInfo->NewName);
SendCharRename(RESPONSE_SUCCESS, renameInfo.get());
@@ -1799,8 +1799,8 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPackets::Character::CharCustom
{
if (!IsLegitCharacterForAccount(packet.CustomizeInfo->CharGUID))
{
- TC_LOG_ERROR("entities.player.cheat", "Account %u, IP: %s tried to customise %s, but it does not belong to their account!",
- GetAccountId(), GetRemoteAddress().c_str(), packet.CustomizeInfo->CharGUID.ToString().c_str());
+ TC_LOG_ERROR("entities.player.cheat", "Account {}, IP: {} tried to customise {}, but it does not belong to their account!",
+ GetAccountId(), GetRemoteAddress(), packet.CustomizeInfo->CharGUID.ToString());
KickPlayer("WorldSession::HandleCharCustomize Trying to customise character of another account");
return;
}
@@ -1911,8 +1911,8 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<WorldPackets::Cha
SendCharCustomize(RESPONSE_SUCCESS, customizeInfo.get());
- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s), Character[%s] (%s) Customized to: %s",
- GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), customizeInfo->CharGUID.ToString().c_str(), customizeInfo->CharName.c_str());
+ TC_LOG_INFO("entities.player.character", "Account: {} (IP: {}), Character[{}] ({}) Customized to: {}",
+ GetAccountId(), GetRemoteAddress(), oldName, customizeInfo->CharGUID.ToString(), customizeInfo->CharName);
}
void WorldSession::HandleEquipmentSetSave(WorldPackets::EquipmentSet::SaveEquipmentSet& saveEquipmentSet)
@@ -2020,7 +2020,7 @@ void WorldSession::HandleUseEquipmentSet(WorldPackets::EquipmentSet::UseEquipmen
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
- TC_LOG_DEBUG("entities.player.items", "%s: ContainerSlot: %u, Slot: %u", useEquipmentSet.Items[i].Item.ToString().c_str(), useEquipmentSet.Items[i].ContainerSlot, useEquipmentSet.Items[i].Slot);
+ TC_LOG_DEBUG("entities.player.items", "{}: ContainerSlot: {}, Slot: {}", useEquipmentSet.Items[i].Item.ToString(), useEquipmentSet.Items[i].ContainerSlot, useEquipmentSet.Items[i].Slot);
// check if item slot is set to "ignored" (raw value == 1), must not be unequipped then
if (useEquipmentSet.Items[i].Item == ignoredItemGuid)
@@ -2074,8 +2074,8 @@ void WorldSession::HandleCharRaceOrFactionChangeOpcode(WorldPackets::Character::
{
if (!IsLegitCharacterForAccount(packet.RaceOrFactionChangeInfo->Guid))
{
- TC_LOG_ERROR("entities.player.cheat", "Account %u, IP: %s tried to factionchange character %s, but it does not belong to their account!",
- GetAccountId(), GetRemoteAddress().c_str(), packet.RaceOrFactionChangeInfo->Guid.ToString().c_str());
+ TC_LOG_ERROR("entities.player.cheat", "Account {}, IP: {} tried to factionchange character {}, but it does not belong to their account!",
+ GetAccountId(), GetRemoteAddress(), packet.RaceOrFactionChangeInfo->Guid.ToString());
KickPlayer("WorldSession::HandleCharFactionOrRaceChange Trying to change faction of character of another account");
return;
}
@@ -2300,7 +2300,7 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa
stmt->setUInt16(1, 2464);
break;
default:
- TC_LOG_ERROR("entities.player", "Could not find language data for race (%u).", factionChangeInfo->RaceID);
+ TC_LOG_ERROR("entities.player", "Could not find language data for race ({}).", factionChangeInfo->RaceID);
SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo.get());
return;
}
@@ -2538,8 +2538,8 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa
knownTitles.push_back(*thisMask);
else
{
- TC_LOG_WARN("entities.player", "%s has invalid title data '%s' - skipped, this may result in titles being lost",
- GetPlayerInfo().c_str(), std::string(token).c_str());
+ TC_LOG_WARN("entities.player", "{} has invalid title data '{}' - skipped, this may result in titles being lost",
+ GetPlayerInfo(), token);
knownTitles.push_back(0);
}
}
@@ -2605,7 +2605,7 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa
CharacterDatabase.CommitTransaction(trans);
- TC_LOG_DEBUG("entities.player", "%s (IP: %s) changed race from %u to %u", GetPlayerInfo().c_str(), GetRemoteAddress().c_str(), oldRace, factionChangeInfo->RaceID);
+ TC_LOG_DEBUG("entities.player", "{} (IP: {}) changed race from {} to {}", GetPlayerInfo(), GetRemoteAddress(), oldRace, factionChangeInfo->RaceID);
SendCharFactionChange(RESPONSE_SUCCESS, factionChangeInfo.get());
}
@@ -2614,13 +2614,13 @@ void WorldSession::HandleRandomizeCharNameOpcode(WorldPackets::Character::Genera
{
if (!Player::IsValidRace(packet.Race))
{
- TC_LOG_ERROR("misc", "Invalid race (%u) sent by accountId: %u", packet.Race, GetAccountId());
+ TC_LOG_ERROR("misc", "Invalid race ({}) sent by accountId: {}", packet.Race, GetAccountId());
return;
}
if (!Player::IsValidGender(packet.Sex))
{
- TC_LOG_ERROR("misc", "Invalid gender (%u) sent by accountId: %u", packet.Sex, GetAccountId());
+ TC_LOG_ERROR("misc", "Invalid gender ({}) sent by accountId: {}", packet.Sex, GetAccountId());
return;
}