You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.6 KiB
94 lines
2.6 KiB
/*
|
|
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<long, int> uidList = new SortedList<long, int>();
|
|
|
|
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<string, PlayerRealmInfo> m_playerTable = new Dictionary<string, PlayerRealmInfo>();
|
|
|
|
// realm已分配玩家数量, realmId -> uidData
|
|
public Dictionary<int, RealmUidDataOnMem> realmUidDataTable = new Dictionary<int, RealmUidDataOnMem>();
|
|
|
|
// gate在线信息, gateserverId -> online
|
|
public Dictionary<uint, int> gateOnlineDict = new Dictionary<uint, int>();
|
|
|
|
public Dictionary<int, OneDBRealmConfig> dbRealmConfigs = new Dictionary<int, OneDBRealmConfig>();
|
|
|
|
//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;
|
|
}
|
|
}
|
|
}
|
|
|