using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Sog; namespace Realmlist { public static class RealmlistServerUtils { //配置数据 //public static RealmListConfig m_openGameList; //<大区名称,> //这个可以先clear后add,是固定数据 //public static Dictionary> m_realmInfoMap = new Dictionary>(); //<大区名称,RealmList id> //public static Dictionary> m_realmInfoKeys = new Dictionary>(); public static RealmlistServerData GetRealmlistServerData() { return ServerDataObjMgr.GetDataObj(RealmlistServerDataObjType.RealmlistServerData); } public static ProtoCSStructPacker GetProtoPacker() { return ProtoPackerFactory.Instance.GetProtoCSStructPacker(); } public static StructPacketSender GetPacketSender() { return GetRealmlistServerData().m_packetSender; } public static long GetTimeSecond() { return GetRealmlistServerData().m_app.Time.GetTimeSecond(); } public static uint GetAppID() { return GetRealmlistServerData().m_app.ServerID; } public static ServerApp GetApp() { return GetRealmlistServerData().m_app; } /// /// 获取服务器配置方法 /// public static RealmlistServerConfig GetServerConfig() { return (RealmlistServerConfig)ServerConfigMgr.Instance.m_serverConfig; } public static PlayerRealmInfo GetCreatePlayerInfo(int accountType, string accountID) { var table = GetRealmlistServerData().m_playerTable; string accountKey = AccountUtils.CalcAccountKey(accountType, accountID); PlayerRealmInfo player; if (! table.TryGetValue(accountKey, out player)) { player = new PlayerRealmInfo(accountType, accountID); table.Add(accountKey, player); } return player; } public static bool CheckRealmCanVisible(RealmInfo realm) { if (CheckRealmOpen(realm) == false) { return false; } long nowSec = GetTimeSecond(); return realm.visibleTimeSec <= nowSec; } public static bool CheckRealmOpen(RealmInfo realm) { long nowSec = GetTimeSecond(); return realm.openTimeSec <= nowSec; } } }