/* Sog 游戏基础库 2016 by zouwei */ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using ProtoCSStruct; using Sog; using Sog.Data; namespace Realmlist { // 内存中的realmUidData public class RealmUidDataOnMem:DataSeqSave { public int realmId; public int openTime; public int visibleTime; public int isFull; // 是否满员 public bool isLoad; // 当uid数量超出proto中的数组长度时, 会出现 playerCount > uidList.Count public int playerCount; public SortedList uidList = new SortedList(); public int lastQueryDBTime; public void AddUid(long uid, int maxPlayerNum) { if (! isLoad) { TraceLog.Error("RealmUidDataOnMem.AddUid realmId {0} not load", realmId); return; } if (uidList.TryGetValue(uid, out int tmp)) { return; } // 当uid数量超出proto中的数组长度时, 会出现 playerCount > uidList.Count if (uidList.Count < maxPlayerNum) { uidList.Add(uid, 1); } playerCount++; if (playerCount >= maxPlayerNum) { isFull = 1; } MakeDirty(); } } public class RealmlistServerData : IServerDataObj { public ServerApp m_app; public StructPacketSender m_packetSender; public Dictionary m_playerTable = new Dictionary(); // realm已分配玩家数量, realmId -> uidData public Dictionary realmUidDataTable = new Dictionary(); // gate在线信息, gateserverId -> online public Dictionary gateOnlineDict = new Dictionary(); public Dictionary dbRealmConfigs = new Dictionary(); //tick时间放这里,免的一hotfix就会全部重新数数上报在线,出bug public long m_oneSecondMs; public long m_5SecondMs; public int HadGetDBRealmCfg = 0; public RealmlistServerData(ServerApp app) { m_app = app; m_packetSender = new StructPacketSender(); m_packetSender.Init(app.ServerID, app.GetCluster()); } public override int GetDataType() { return RealmlistServerDataObjType.RealmlistServerData; } } }