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.
98 lines
2.7 KiB
98 lines
2.7 KiB
1 month ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
using Sog;
|
||
|
|
||
|
namespace Realmlist
|
||
|
{
|
||
|
public static class RealmlistServerUtils
|
||
|
{
|
||
|
//配置数据
|
||
|
//public static RealmListConfig m_openGameList;
|
||
|
|
||
|
//<大区名称,<realmId,RealmInfo>>
|
||
|
//这个可以先clear后add,是固定数据
|
||
|
//public static Dictionary<string, SortedDictionary<int, RealmInfo>> m_realmInfoMap = new Dictionary<string, SortedDictionary<int, RealmInfo>>();
|
||
|
|
||
|
//<大区名称,RealmList id>
|
||
|
//public static Dictionary<string,List<int>> m_realmInfoKeys = new Dictionary<string, List<int>>();
|
||
|
|
||
|
|
||
|
public static RealmlistServerData GetRealmlistServerData()
|
||
|
{
|
||
|
return ServerDataObjMgr.GetDataObj<RealmlistServerData>(RealmlistServerDataObjType.RealmlistServerData);
|
||
|
}
|
||
|
|
||
|
public static ProtoCSStructPacker GetProtoPacker()
|
||
|
{
|
||
|
return ProtoPackerFactory.Instance.GetProtoCSStructPacker();
|
||
|
}
|
||
|
|
||
|
public static StructPacketSender GetPacketSender()
|
||
|
{
|
||
|
return GetRealmlistServerData().m_packetSender;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
public static long GetTimeSecond()
|
||
|
{
|
||
|
return GetRealmlistServerData().m_app.Time.GetTimeSecond();
|
||
|
}
|
||
|
|
||
|
public static uint GetAppID()
|
||
|
{
|
||
|
return GetRealmlistServerData().m_app.ServerID;
|
||
|
}
|
||
|
|
||
|
public static ServerApp GetApp()
|
||
|
{
|
||
|
return GetRealmlistServerData().m_app;
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取服务器配置方法
|
||
|
/// </summary>
|
||
|
public static RealmlistServerConfig GetServerConfig()
|
||
|
{
|
||
|
return (RealmlistServerConfig)ServerConfigMgr.Instance.m_serverConfig;
|
||
|
}
|
||
|
|
||
|
public static PlayerRealmInfo GetCreatePlayerInfo(int accountType, string accountID)
|
||
|
{
|
||
|
var table = GetRealmlistServerData().m_playerTable;
|
||
|
string accountKey = AccountUtils.CalcAccountKey(accountType, accountID);
|
||
|
|
||
|
PlayerRealmInfo player;
|
||
|
if (! table.TryGetValue(accountKey, out player))
|
||
|
{
|
||
|
player = new PlayerRealmInfo(accountType, accountID);
|
||
|
table.Add(accountKey, player);
|
||
|
}
|
||
|
|
||
|
return player;
|
||
|
}
|
||
|
|
||
|
public static bool CheckRealmCanVisible(RealmInfo realm)
|
||
|
{
|
||
|
if (CheckRealmOpen(realm) == false)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
long nowSec = GetTimeSecond();
|
||
|
return realm.visibleTimeSec <= nowSec;
|
||
|
}
|
||
|
|
||
|
public static bool CheckRealmOpen(RealmInfo realm)
|
||
|
{
|
||
|
long nowSec = GetTimeSecond();
|
||
|
return realm.openTimeSec <= nowSec;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|