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.
38 lines
1.2 KiB
38 lines
1.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
|
|
namespace Game
|
|
{
|
|
public static class GameDBServerIDUtils
|
|
{
|
|
/// <summary>
|
|
/// gamedbserver暂时不支持多个,如果需要支持多个,请参考accountdb的算法
|
|
/// </summary>
|
|
public static int DBServerCount = 1;
|
|
|
|
public static void Init(ServerApp app)
|
|
{
|
|
//DBServerCount = app.GetCluster().GetChannelCount((int)ServerType.GameDb);
|
|
|
|
TraceLog.Debug("GameDBServerIDUtils.Init DBServerCount is {0}", DBServerCount);
|
|
}
|
|
|
|
public static uint GetServerIDByUid(long userId)
|
|
{
|
|
int dbIndex = (int)(userId % DBServerCount);
|
|
return GetServerIDByIndex(dbIndex + 1);
|
|
}
|
|
public static uint GetServerIDByIndex(int dbIndex)
|
|
{
|
|
return ServerIDUtils.GetLevel1ServerIDByType(GameServerUtils.GetAppID(), (int)ServerType.GameDb, (int)dbIndex);
|
|
}
|
|
public static uint GetGameDBServerID(int dbIndex)
|
|
{
|
|
return ServerIDUtils.GetLevel1ServerIDByType(GameServerUtils.GetAppID(), (int)ServerType.GameDb, (int)dbIndex);
|
|
}
|
|
}
|
|
}
|
|
|