feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) + game logic (GameFix/GameDAL/ServerData) + network layer (NetWorkMessage) + data layer (ObjectModel) + utilities (MrWu/Core/Config/CloudAPI/dll) + adapters (zyxAdapter/base) .NET 8.0 C# solution, 16 projects, 958 source files
This commit is contained in:
83
Config/Code/TingConfigCategory.cs
Normal file
83
Config/Code/TingConfigCategory.cs
Normal file
@ -0,0 +1,83 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Luban;
|
||||
|
||||
|
||||
namespace Server.Config
|
||||
{
|
||||
public partial class TingConfigCategory : ConfigSingleton<TingConfigCategory>
|
||||
{
|
||||
public const string TableName = Tables.TingConfigCategory;
|
||||
|
||||
private readonly System.Collections.Generic.Dictionary<int, TingConfig> _dataMap;
|
||||
private readonly System.Collections.Generic.List<TingConfig> _dataList;
|
||||
|
||||
public TingConfigCategory()
|
||||
{
|
||||
_dataMap = new System.Collections.Generic.Dictionary<int, TingConfig>();
|
||||
_dataList = new System.Collections.Generic.List<TingConfig>();
|
||||
|
||||
this.ReLoadData();
|
||||
}
|
||||
|
||||
public sealed override void ReLoadData()
|
||||
{
|
||||
// 备份旧数据,以便加载失败时回滚
|
||||
var oldDataList = new System.Collections.Generic.List<TingConfig>(_dataList);
|
||||
|
||||
_dataMap.Clear();
|
||||
_dataList.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
byte[] data = TableManager.Instance.GetTableData(TableName);
|
||||
LoadData(new ByteBuf(data));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 加载失败,回滚到旧数据
|
||||
_dataMap.Clear();
|
||||
_dataList.Clear();
|
||||
foreach (var item in oldDataList)
|
||||
{
|
||||
_dataList.Add(item);
|
||||
_dataMap.Add(item.Id, item);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
protected sealed override void LoadData(ByteBuf _buf)
|
||||
{
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
{
|
||||
TingConfig _v;
|
||||
_v = TingConfig.DeserializeTingConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.Id, _v);
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Dictionary<int, TingConfig> DataMap => _dataMap;
|
||||
public System.Collections.Generic.List<TingConfig> DataList => _dataList;
|
||||
|
||||
public TingConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public TingConfig Get(int key) => _dataMap[key];
|
||||
public TingConfig this[int key] => _dataMap[key];
|
||||
|
||||
public bool Contain(int key) => _dataMap.ContainsKey(key);
|
||||
|
||||
|
||||
partial void PostInit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user