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.
256 lines
6.5 KiB
256 lines
6.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Sog
|
|
{
|
|
public static class TableIndexCalc
|
|
{
|
|
/// <summary>
|
|
/// 帐号表的数量
|
|
/// </summary>
|
|
public const int AccountTableCount = 100;
|
|
|
|
/// <summary>
|
|
/// name表数量
|
|
/// </summary>
|
|
public const int NameTableCount = 10;
|
|
|
|
/// <summary>
|
|
/// 角色表的数量(由于是分服的,10够了,全区全服的游戏请改成至少100张)
|
|
/// </summary>
|
|
public const int RoleTableCount = 100;
|
|
|
|
/// <summary>
|
|
/// 战斗回放记录表数量
|
|
/// </summary>
|
|
public const int BattleReplayTableCount = 100;
|
|
|
|
/// <summary>
|
|
/// 关卡记录表数量
|
|
/// </summary>
|
|
public const int MainlandRecordTableCount = 10;
|
|
|
|
/// <summary>
|
|
/// 公会表数量
|
|
/// </summary>
|
|
public const int UnionTableCount = 10;
|
|
|
|
/// <summary>
|
|
/// 公会角色表数量
|
|
/// </summary>
|
|
public const int UnionRoleTableCount = 10;
|
|
|
|
// 支付表
|
|
public const int PayTableCount = 10;
|
|
|
|
//兑换码兑换记录表全服的
|
|
public const int ExchangeRecordTableCount = 100;
|
|
|
|
//普通兑换码兑换记录表全服的
|
|
public const int CommonExchangeRecordTableCount = 100;
|
|
|
|
/// <summary>
|
|
/// 全局领地表数量
|
|
/// </summary>
|
|
public const int WorldHomeTableCount = 100;
|
|
|
|
/// <summary>
|
|
/// 全局赛马表
|
|
/// </summary>
|
|
public const int RacehorseTableCount = 10;
|
|
|
|
|
|
/// <summary>
|
|
/// 航海贸易用户信息
|
|
/// </summary>
|
|
public const int TradeTableCount = 10;
|
|
|
|
|
|
/// <summary>
|
|
/// petpvp用户信息
|
|
/// </summary>
|
|
public const int PetPvpPlayerTableCount = 10;
|
|
|
|
public const int NewPeakArenaTableCount = 50;
|
|
|
|
public static int CalcAccountTableIndex(int accountType, string accountID)
|
|
{
|
|
string strHash = AccountUtils.CalcAccountKey(accountType, accountID);
|
|
|
|
int index = AccountUtils.HashStringForIndex(strHash) % AccountTableCount;
|
|
|
|
//为了直观,0放到第100张表
|
|
if(index == 0)
|
|
{
|
|
index = AccountTableCount;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
public static int CalcNameTableIndex(int accountType, string accountID)
|
|
{
|
|
//暂时先用,应该没问题
|
|
string strHash = AccountUtils.CalcAccountKey(accountType, accountID);
|
|
|
|
int index = AccountUtils.HashStringForIndex(strHash) % NameTableCount;
|
|
|
|
//为了直观,0放到第10张表
|
|
if (index == 0)
|
|
{
|
|
index = NameTableCount;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
public static int CalcRoleTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % RoleTableCount);
|
|
|
|
//由于表刚好是10张,为了直观,0放到第10张表
|
|
if (index == 0)
|
|
{
|
|
index = RoleTableCount;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
public static int CalcBattleReplayTableIndex(long battleid)
|
|
{
|
|
int index = (int)(battleid % BattleReplayTableCount);
|
|
if (index == 0)
|
|
{
|
|
index = BattleReplayTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
public static int CalcMainlandRecordTableIndex(int mainlandId)
|
|
{
|
|
int index = mainlandId % MainlandRecordTableCount;
|
|
if (index == 0)
|
|
{
|
|
index = MainlandRecordTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
public static int CalcUnionTableIndex(int realmId)
|
|
{
|
|
int index = realmId % UnionTableCount;
|
|
if (index == 0)
|
|
{
|
|
index = UnionTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
public static int CalcUnionRoleTableIndex(int realmId)
|
|
{
|
|
int index = realmId % UnionRoleTableCount;
|
|
if (index == 0)
|
|
{
|
|
index = UnionRoleTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
public static int CalcPayTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % PayTableCount);
|
|
|
|
if (index == 0)
|
|
{
|
|
index = PayTableCount;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
|
|
public static int CalcExchangeRecordIndex(int codeIndex)
|
|
{
|
|
int index = (int)(codeIndex % ExchangeRecordTableCount);
|
|
|
|
//为了直观,0放到第100张表
|
|
if (index == 0)
|
|
{
|
|
index = ExchangeRecordTableCount;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
public static int CalcCommonExchangeRecordIndex(int codeIndex)
|
|
{
|
|
int index = (int)(codeIndex % CommonExchangeRecordTableCount);
|
|
|
|
//为了直观,0放到第100张表
|
|
if (index == 0)
|
|
{
|
|
index = CommonExchangeRecordTableCount;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
public static int CalcWorldHomeTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % WorldHomeTableCount);
|
|
if (index == 0)
|
|
{
|
|
index = WorldHomeTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
public static int CalcRacehorseTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % RacehorseTableCount);
|
|
if (index == 0)
|
|
{
|
|
index = RacehorseTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
public static int CalcTradeTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % TradeTableCount);
|
|
if (index == 0)
|
|
{
|
|
index = TradeTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
public static int CalcPetPvpPlayerTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % PetPvpPlayerTableCount);
|
|
if (index == 0)
|
|
{
|
|
index = PetPvpPlayerTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
public static int CalcNewPeakArenaPlayerTableIndex(long uid)
|
|
{
|
|
int index = (int)(uid % NewPeakArenaTableCount);
|
|
if (index == 0)
|
|
{
|
|
index = NewPeakArenaTableCount;
|
|
}
|
|
return index;
|
|
}
|
|
}
|
|
}
|
|
|