Remade who list processing

Port From (https://github.com/TrinityCore/TrinityCore/commit/07d02d744f9ac82b0543559a15ace7b3035fdb99)
This commit is contained in:
hondacrx
2019-08-15 22:35:09 -04:00
parent df61f03a98
commit c39cc34ed9
4 changed files with 116 additions and 31 deletions
+81
View File
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Text;
using Framework.Constants;
using Game.Entities;
using Game.Guilds;
namespace Game.DataStorage
{
public class WhoListPlayerInfo
{
public WhoListPlayerInfo(ObjectGuid guid, Team team, AccountTypes security, uint level, Class clss, Race race, uint zoneid, byte gender, bool visible, bool gamemaster, string playerName, string guildName, ObjectGuid guildguid)
{
Guid = guid;
Team = team;
Security = security;
Level = level;
Class = (byte)clss;
Race = (byte)race;
ZoneId = zoneid;
Gender = gender;
IsVisible = visible;
IsGamemaster = gamemaster;
PlayerName = playerName;
GuildName = guildName;
GuildGuid = guildguid;
}
public ObjectGuid Guid { get; }
public Team Team { get; }
public AccountTypes Security { get; }
public uint Level { get; }
public byte Class { get; }
public byte Race { get; }
public uint ZoneId { get; }
public byte Gender { get; }
public bool IsVisible { get; }
public bool IsGamemaster { get; }
public string PlayerName { get; }
public string GuildName { get; }
public ObjectGuid GuildGuid { get; }
}
public class WhoListStorageManager : Singleton<WhoListStorageManager>
{
List<WhoListPlayerInfo> _whoListStorage;
WhoListStorageManager()
{
_whoListStorage = new List<WhoListPlayerInfo>();
}
public void Update()
{
// clear current list
_whoListStorage.Clear();
var players = Global.ObjAccessor.GetPlayers();
foreach (var player in players)
{
if (player.GetMap() == null || player.GetSession().PlayerLoading())
continue;
string playerName = player.GetName();
string guildName = Global.GuildMgr.GetGuildNameById((uint)player.GetGuildId());
Guild guild = player.GetGuild();
ObjectGuid guildGuid = ObjectGuid.Empty;
if (guild)
guildGuid = guild.GetGUID();
_whoListStorage.Add(new WhoListPlayerInfo(player.GetGUID(), player.GetTeam(), player.GetSession().GetSecurity(), player.getLevel(),
player.GetClass(), player.GetRace(), player.GetZoneId(), player.m_playerData.NativeSex, player.IsVisible(),
player.IsGameMaster(), playerName, guildName, guildGuid));
}
}
public List<WhoListPlayerInfo> GetWhoList() { return _whoListStorage; }
}
}