using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Sog; namespace World { public static class DBServerIDUtils { /// /// gamedbserver暂时不支持多个,如果需要支持多个,请参考accountdb的算法 /// public static int DBServerCount = 1; public static void Init(ServerApp app) { //DBServerCount = app.GetCluster().GetChannelCount((int)ServerType.GameDb); TraceLog.Debug("DBServerIDUtils.Init DBServerCount is {0}", DBServerCount); } public static uint GetGameDBServerID( long userId) { int dbIndex; //根据uid dbIndex = (int)(userId % DBServerCount); return ServerIDUtils.GetLevel1ServerIDByType(WorldServerUtils.GetAppID(), (int)ServerType.GameDb, dbIndex + 1); } public static uint GetGameDBServerID(PlayerInfoWorld playerInfo) { return GetGameDBServerID(playerInfo.UserID); } } }