diff options
| author | Peter Keresztes Schmidt <carbenium@outlook.com> | 2020-09-10 13:10:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-10 13:10:01 +0200 |
| commit | 8985fc4046e9a9b43d873e4d7b89a71afb910517 (patch) | |
| tree | 91148b643416974c4823c11cb22044eb981db199 /src/server/scripts | |
| parent | 0769d7726975a2fc848972a53f71efc4b6463e72 (diff) | |
Core/ChatCommands: Drop PlayerIdentifier's cast operators which could return nullptr (PR #25431)
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/Commands/cs_character.cpp | 19 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 2 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index f6ea4cb27c3..44a00c871e1 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -248,7 +248,6 @@ public: Player const* target = player->GetConnectedPlayer(); LocaleConstant loc = handler->GetSessionDbcLocale(); - std::string const& targetName = player->GetName(); char const* knownStr = handler->GetTrinityString(LANG_KNOWN); // Search in CharTitles.dbc @@ -268,7 +267,7 @@ public: if (target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->MaskID) activeStr = handler->GetTrinityString(LANG_ACTIVE); - std::string titleName = Trinity::StringFormat(name, targetName.c_str()); + std::string titleName = Trinity::StringFormat(name, player->GetName().c_str()); // send title in "id (idx:idx) - [namedlink locale]" format if (handler->GetSession()) @@ -377,7 +376,7 @@ public: if (handler->HasLowerSecurity(nullptr, player->GetGUID())) return false; - handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(player->GetName()).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); @@ -404,7 +403,7 @@ public: } else { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(player->GetName()).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE)); stmt->setUInt32(1, player->GetGUID().GetCounter()); @@ -428,7 +427,7 @@ public: } else { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(player->GetName()).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION)); stmt->setUInt32(1, player->GetGUID().GetCounter()); @@ -452,7 +451,7 @@ public: } else { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(player->GetName()).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE)); stmt->setUInt32(1, player->GetGUID().GetCounter()); @@ -716,10 +715,10 @@ public: static bool HandleCharacterEraseCommand(ChatHandler* handler, PlayerIdentifier player) { uint32 accountId; - if (player.IsConnected()) + if (Player* target = player.GetConnectedPlayer()) { - accountId = player->GetSession()->GetAccountId(); - player->GetSession()->KickPlayer("HandleCharacterEraseCommand GM Command deleting character"); + accountId = target->GetSession()->GetAccountId(); + target->GetSession()->KickPlayer("HandleCharacterEraseCommand GM Command deleting character"); } else accountId = sCharacterCache->GetCharacterAccountIdByGuid(player); @@ -775,7 +774,7 @@ public: } if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL - handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(player->GetName()).c_str(), newlevel); + handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player).c_str(), newlevel); return true; } diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 3fbda540a10..d3db0520bee 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1901,7 +1901,7 @@ public: stmt->setString(3, muteReasonStr); LoginDatabase.Execute(stmt); - std::string nameLink = handler->playerLink(player->GetName()); + std::string nameLink = handler->playerLink(*player); if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD)) sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), muteTime, muteReasonStr.c_str()); if (target) |
