Core/Misc: Moved CharacterInfo out of world to separate class
Port From (https://github.com/TrinityCore/TrinityCore/commit/ad4e63bae145ae49b584ab2fc621660430cec0d3)
This commit is contained in:
@@ -35,6 +35,7 @@ using Game.Scenarios;
|
||||
using Game.Scripting;
|
||||
using Game.SupportSystem;
|
||||
using Game.Services;
|
||||
using Game.Cache;
|
||||
|
||||
public static class Global
|
||||
{
|
||||
@@ -93,6 +94,7 @@ public static class Global
|
||||
public static AreaTriggerDataStorage AreaTriggerDataStorage { get { return AreaTriggerDataStorage.Instance; } }
|
||||
public static CharacterTemplateDataStorage CharacterTemplateDataStorage { get { return CharacterTemplateDataStorage.Instance; } }
|
||||
public static ConversationDataStorage ConversationDataStorage { get { return ConversationDataStorage.Instance; } }
|
||||
public static CharacterCache CharacterCacheStorage { get { return CharacterCache.Instance; } }
|
||||
|
||||
//Misc
|
||||
public static ConditionManager ConditionMgr { get { return ConditionManager.Instance; } }
|
||||
|
||||
@@ -201,7 +201,11 @@ public class ObjectAccessor : Singleton<ObjectAccessor>
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
public Player FindPlayerByLowGUID(ulong lowguid)
|
||||
{
|
||||
ObjectGuid guid = ObjectGuid.Create(HighGuid.Player, lowguid);
|
||||
return FindPlayer(guid);
|
||||
}
|
||||
// this returns Player even if he is not in world, for example teleporting
|
||||
public Player FindConnectedPlayer(ObjectGuid guid)
|
||||
{
|
||||
|
||||
@@ -193,74 +193,6 @@ namespace Game
|
||||
dynamicFlags = data.dynamicflags;
|
||||
}
|
||||
}
|
||||
public static ObjectGuid GetPlayerGUIDByName(string name)
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GUID_BY_NAME);
|
||||
stmt.AddValue(0, name);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
|
||||
if (!result.IsEmpty())
|
||||
return ObjectGuid.Create(HighGuid.Player, result.Read<ulong>(0));
|
||||
|
||||
return ObjectGuid.Empty;
|
||||
}
|
||||
public static bool GetPlayerNameByGUID(ObjectGuid guid, out string name)
|
||||
{
|
||||
name = "";
|
||||
|
||||
Player player = Global.ObjAccessor.FindConnectedPlayer(guid);
|
||||
if (player)
|
||||
{
|
||||
name = player.GetName();
|
||||
return true;
|
||||
}
|
||||
|
||||
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(guid);
|
||||
if (characterInfo == null)
|
||||
return false;
|
||||
|
||||
name = characterInfo.Name;
|
||||
return true;
|
||||
}
|
||||
public static bool GetPlayerNameAndClassByGUID(ObjectGuid guid, out string name, out byte _class)
|
||||
{
|
||||
name = "";
|
||||
_class = 0;
|
||||
|
||||
Player player = Global.ObjAccessor.FindConnectedPlayer(guid);
|
||||
if (player)
|
||||
{
|
||||
name = player.GetName();
|
||||
_class = (byte)player.GetClass();
|
||||
return true;
|
||||
}
|
||||
|
||||
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(guid);
|
||||
if (characterInfo != null)
|
||||
{
|
||||
name = characterInfo.Name;
|
||||
_class = (byte)characterInfo.ClassID;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static Team GetPlayerTeamByGUID(ObjectGuid guid)
|
||||
{
|
||||
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(guid);
|
||||
if (characterInfo != null)
|
||||
return Player.TeamForRace(characterInfo.RaceID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
public static uint GetPlayerAccountIdByGUID(ObjectGuid guid)
|
||||
{
|
||||
CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(guid);
|
||||
if (characterInfo != null)
|
||||
return characterInfo.AccountId;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ResponseCodes CheckPlayerName(string name, LocaleConstant locale, bool create = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user