mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Core/Misc: Moved CharacterInfo out of world to separate class
This commit is contained in:
@@ -28,6 +28,7 @@ EndScriptData */
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
|
||||
class arena_commandscript : public CommandScript
|
||||
{
|
||||
@@ -83,7 +84,7 @@ public:
|
||||
|
||||
if (type == 2 || type == 3 || type == 5 )
|
||||
{
|
||||
if (Player::GetArenaTeamIdFromCharacterInfo(target->GetGUID(), type) != 0)
|
||||
if (sCharacterCache->GetCharacterArenaTeamIdByGuid(target->GetGUID(), type) != 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, target->GetName().c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -273,7 +274,7 @@ public:
|
||||
|
||||
arena->SetCaptain(targetGuid);
|
||||
|
||||
CharacterInfo const* oldCaptainNameData = sWorld->GetCharacterInfo(arena->GetCaptain());
|
||||
CharacterCacheEntry const* oldCaptainNameData = sCharacterCache->GetCharacterCacheByGuid(arena->GetCaptain());
|
||||
if (!oldCaptainNameData)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "ObjectAccessor.h"
|
||||
@@ -307,7 +308,7 @@ public:
|
||||
|
||||
if (!target)
|
||||
{
|
||||
ObjectGuid fullGuid = sWorld->GetCharacterGuidByName(name);
|
||||
ObjectGuid fullGuid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
if (fullGuid.IsEmpty())
|
||||
{
|
||||
handler->SendSysMessage(LANG_BANINFO_NOCHARACTER);
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PlayerDump.h"
|
||||
@@ -208,7 +209,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (sWorld->GetCharacterGuidByName(delInfo.name))
|
||||
if (sCharacterCache->GetCharacterGuidByName(delInfo.name))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.guid.GetCounter(), delInfo.accountId);
|
||||
return;
|
||||
@@ -223,7 +224,7 @@ public:
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
|
||||
stmt->setUInt32(0, delInfo.guid.GetCounter());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
sWorld->AddCharacterInfo(delInfo.guid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
|
||||
sCharacterCache->AddCharacterCacheEntry(delInfo.guid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
|
||||
}
|
||||
|
||||
static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler)
|
||||
@@ -326,7 +327,7 @@ public:
|
||||
if (handler->HasLowerSecurity(NULL, targetGuid))
|
||||
return false;
|
||||
|
||||
sObjectMgr->GetPlayerNameByGUID(targetGuid, playerOldName);
|
||||
sCharacterCache->GetCharacterNameByGuid(targetGuid, playerOldName);
|
||||
}
|
||||
|
||||
if (!normalizePlayerName(newName))
|
||||
@@ -383,15 +384,14 @@ public:
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
sWorld->UpdateCharacterInfo(targetGuid, newName);
|
||||
sWorld->UpdateCharacterGuidByName(targetGuid, playerOldName, newName);
|
||||
sCharacterCache->UpdateCharacterData(targetGuid, newName);
|
||||
|
||||
handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str());
|
||||
|
||||
if (WorldSession* session = handler->GetSession())
|
||||
{
|
||||
if (Player* player = session->GetPlayer())
|
||||
sLog->outCommand(session->GetAccountId(), "GM %s (Account: %u) forced rename %s to player %s (Account: %u)", player->GetName().c_str(), session->GetAccountId(), newName.c_str(), playerOldName.c_str(), sObjectMgr->GetPlayerAccountIdByGUID(targetGuid));
|
||||
sLog->outCommand(session->GetAccountId(), "GM %s (Account: %u) forced rename %s to player %s (Account: %u)", player->GetName().c_str(), session->GetAccountId(), newName.c_str(), playerOldName.c_str(), sCharacterCache->GetCharacterAccountIdByGuid(targetGuid));
|
||||
}
|
||||
else
|
||||
sLog->outCommand(0, "CONSOLE forced rename '%s' to '%s' (%s)", playerOldName.c_str(), newName.c_str(), targetGuid.ToString().c_str());
|
||||
@@ -447,7 +447,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromCharacterInfo(targetGuid);
|
||||
int32 oldlevel = target ? target->getLevel() : sCharacterCache->GetCharacterLevelByGuid(targetGuid);
|
||||
int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
|
||||
|
||||
if (newlevel < 1)
|
||||
@@ -564,7 +564,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(playerNameStr, nullptr, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(targetGuid);
|
||||
CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(targetGuid);
|
||||
if (!characterInfo)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
@@ -616,7 +616,7 @@ public:
|
||||
sWorld->UpdateRealmCharCount(oldAccountId);
|
||||
sWorld->UpdateRealmCharCount(newAccountId);
|
||||
|
||||
sWorld->UpdateCharacterInfoAccount(targetGuid, newAccountId);
|
||||
sCharacterCache->UpdateCharacterAccountId(targetGuid, newAccountId);
|
||||
|
||||
handler->PSendSysMessage(LANG_CHANGEACCOUNT_SUCCESS, targetName.c_str(), accountName.c_str());
|
||||
|
||||
@@ -863,14 +863,14 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
characterGuid = sWorld->GetCharacterGuidByName(characterName);
|
||||
characterGuid = sCharacterCache->GetCharacterGuidByName(characterName);
|
||||
if (characterGuid.IsEmpty())
|
||||
{
|
||||
handler->PSendSysMessage(LANG_NO_PLAYER, characterName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid);
|
||||
accountId = sCharacterCache->GetCharacterAccountIdByGuid(characterGuid);
|
||||
}
|
||||
|
||||
std::string accountName;
|
||||
@@ -901,7 +901,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromCharacterInfo(targetGuid);
|
||||
int32 oldlevel = target ? target->getLevel() : sCharacterCache->GetCharacterLevelByGuid(targetGuid);
|
||||
int32 addlevel = levelStr ? atoi(levelStr) : 1;
|
||||
int32 newlevel = oldlevel + addlevel;
|
||||
|
||||
@@ -999,7 +999,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sObjectMgr->GetPlayerAccountIdByGUID(ObjectGuid(HighGuid::Player, guid)))
|
||||
if (sCharacterCache->GetCharacterAccountIdByGuid(ObjectGuid(HighGuid::Player, guid)))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, guid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -1058,10 +1058,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
guid = sWorld->GetCharacterGuidByName(name);
|
||||
guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
}
|
||||
|
||||
if (!sObjectMgr->GetPlayerAccountIdByGUID(guid))
|
||||
if (!sCharacterCache->GetCharacterAccountIdByGuid(guid))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "LFG.h"
|
||||
@@ -340,7 +341,7 @@ public:
|
||||
ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args)));
|
||||
|
||||
// ... and try to extract a player out of it.
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, nameTarget))
|
||||
{
|
||||
playerTarget = ObjectAccessor::FindPlayer(parseGUID);
|
||||
guidTarget = parseGUID;
|
||||
|
||||
@@ -29,6 +29,7 @@ EndScriptData */
|
||||
#include "GuildMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include <iomanip>
|
||||
|
||||
class guild_commandscript : public CommandScript
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
|
||||
return false;
|
||||
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromCharacterInfo(targetGuid);
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(targetGuid);
|
||||
if (!guildId)
|
||||
return false;
|
||||
|
||||
@@ -186,7 +187,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name))
|
||||
return false;
|
||||
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromCharacterInfo(targetGuid);
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(targetGuid);
|
||||
if (!guildId)
|
||||
return false;
|
||||
|
||||
@@ -275,7 +276,7 @@ public:
|
||||
handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name
|
||||
|
||||
std::string guildMasterName;
|
||||
if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(guild->GetLeaderGUID(), guildMasterName))
|
||||
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master
|
||||
|
||||
// Format creation date
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "LFGMgr.h"
|
||||
@@ -80,7 +81,7 @@ public:
|
||||
|
||||
ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args)));
|
||||
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, nameTarget))
|
||||
{
|
||||
playerTarget = ObjectAccessor::FindPlayer(parseGUID);
|
||||
guidTarget = parseGUID;
|
||||
|
||||
@@ -29,6 +29,7 @@ EndScriptData */
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "CharacterCache.h"
|
||||
#include <iostream>
|
||||
|
||||
class list_commandscript : public CommandScript
|
||||
@@ -476,7 +477,7 @@ public:
|
||||
|
||||
ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args)));
|
||||
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, targetName))
|
||||
{
|
||||
target = ObjectAccessor::FindPlayer(parseGUID);
|
||||
targetGuid = parseGUID;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "AccountMgr.h"
|
||||
@@ -175,7 +176,7 @@ public:
|
||||
{
|
||||
case HighGuid::Player:
|
||||
{
|
||||
object = sObjectMgr->GetPlayerByLowGUID(guidLow);
|
||||
object = ObjectAccessor::FindPlayerByLowGUID(guidLow);
|
||||
if (!object)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
@@ -810,7 +811,7 @@ public:
|
||||
{
|
||||
case HighGuid::Player:
|
||||
{
|
||||
object = sObjectMgr->GetPlayerByLowGUID(guidLow);
|
||||
object = ObjectAccessor::FindPlayerByLowGUID(guidLow);
|
||||
if (!object)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
@@ -1529,7 +1530,7 @@ public:
|
||||
ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args)));
|
||||
|
||||
// ... and make sure we get a target, somehow.
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, targetName))
|
||||
{
|
||||
target = ObjectAccessor::FindPlayer(parseGUID);
|
||||
targetGuid = parseGUID;
|
||||
@@ -1936,7 +1937,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
|
||||
|
||||
// find only player from same account if any
|
||||
if (!target)
|
||||
@@ -2005,7 +2006,7 @@ public:
|
||||
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
|
||||
|
||||
// find only player from same account if any
|
||||
if (!target)
|
||||
@@ -2562,7 +2563,7 @@ public:
|
||||
if (targetName)
|
||||
{
|
||||
// Check for offline players
|
||||
ObjectGuid guid = sWorld->GetCharacterGuidByName(name);
|
||||
ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
if (guid.IsEmpty())
|
||||
{
|
||||
handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -95,8 +96,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectGuid targetGuid = sWorld->GetCharacterGuidByName(target);
|
||||
uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
|
||||
ObjectGuid targetGuid = sCharacterCache->GetCharacterGuidByName(target);
|
||||
uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
|
||||
// Target must exist and have administrative rights
|
||||
if (!AccountMgr::HasPermission(accountId, rbac::RBAC_PERM_COMMANDS_BE_ASSIGNED_TICKET, realm.Id.Realm))
|
||||
{
|
||||
@@ -394,7 +395,7 @@ public:
|
||||
else
|
||||
{
|
||||
ObjectGuid guid = ticket->GetAssignedToGUID();
|
||||
uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid);
|
||||
uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid);
|
||||
security = AccountMgr::GetSecurity(accountId, realm.Id.Realm);
|
||||
}
|
||||
|
||||
@@ -455,7 +456,7 @@ public:
|
||||
if (Player* player = ObjectAccessor::FindPlayerByName(name))
|
||||
guid = player->GetGUID();
|
||||
else
|
||||
guid = sWorld->GetCharacterGuidByName(name);
|
||||
guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
|
||||
// Target must exist
|
||||
if (guid.IsEmpty())
|
||||
|
||||
@@ -212,7 +212,7 @@ class StartLaunchEvent : public BasicEvent
|
||||
|
||||
bool Execute(uint64 /*time*/, uint32 /*diff*/) override
|
||||
{
|
||||
Player* player = sObjectMgr->GetPlayerByLowGUID(_lowGuid);
|
||||
Player* player = ObjectAccessor::FindPlayerByLowGUID(_lowGuid);
|
||||
if (!player || !player->GetVehicle())
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user