protected override void OnEntryFileOvered(LuaTable entryTbl) { // load params LuaTable tbl = LuaReadHelper.GetSubTable(entryTbl, "__ClientParams"); if(null == tbl) { Debug.LogError("找不到参数表__ClientParams!!!"); return; } ServerHostCenterHost = LuaReadHelper.ReadUtf8String(tbl, "ServerHostCenterHost"); if (!LuaReadHelper.ReadNumber(tbl, "ServerHostCenterPort", out ServerHostCenterPort)) { Debug.LogError("读取参数 ServerHostCenterPort 失败!!!"); return; } ServerHostLoginAccount = LuaReadHelper.ReadUtf8String(tbl, "ServerHostLoginAccount"); ServerHostLoginPassword = LuaReadHelper.ReadUtf8String(tbl, "ServerHostLoginPassword"); }
public bool ReadTable(LuaTable tbl) { // KEY Index Dictionary <string, int> headerKeyDict = LuaReadHelper.ReadHeaderKey(tbl, "HK"); Dictionary <string, int> headerDataDict = LuaReadHelper.ReadHeaderKey(tbl, "HD"); if (null == headerKeyDict || null == headerDataDict) { return(false); } TKey tKey = new TKey(); TVal tVal = new TVal(); if (headerKeyDict.Count != tKey.Count || headerDataDict.Count != tVal.Count) { return(false); } tKey = default(TKey); tVal = default(TVal); // DATA LuaTable hTbl = LuaReadHelper.GetSubTable(tbl, "DATA"); if (null == hTbl) { return(false); } for (int i = 0; i < hTbl.ArrayPart.Length; ++i) { StkId stkID = hTbl.ArrayPart[i]; if ((null == stkID) || (default(TValue) == stkID.V)) { continue; } if (!stkID.V.TtIsTable()) { continue; } if (!ReadTableData(stkID)) { return(false); } } for (int i = 0; i < hTbl.HashPart.Length; ++i) { StkId stkID = hTbl.HashPart[i].Val; if ((null == stkID) || (default(TValue) == stkID.V)) { continue; } if (!stkID.V.TtIsTable()) { continue; } if (!ReadTableData(stkID)) { return(false); } } OnTableReadOvered(); return(true); }
public bool ReadTableData(StkId stkID) { LuaTable subTbl = stkID.V.OValue as LuaTable; LuaTable subKeyTbl = LuaReadHelper.GetSubTable(subTbl, "K"); if (null == subKeyTbl) { return(false); } TKey tKey = new TKey(); TVal tVal = new TVal(); tKey.Holder = this; tVal.Holder = this; int keyCount = 0; for (int c = 0; c < subKeyTbl.ArrayPart.Length; ++c) { if ((null == subKeyTbl.ArrayPart[c]) || (default(TValue) == subKeyTbl.ArrayPart[c].V)) { continue; } keyCount++; } if (keyCount != tKey.Count) { return(false); } tKey.Init(subKeyTbl.ArrayPart); OnKeyLoaded(tKey); LuaTable subDataTbl = LuaReadHelper.GetSubTable(subTbl, "D"); if (null == subDataTbl) { return(false); } int valCount = 0; for (int c = 0; c < subDataTbl.ArrayPart.Length; ++c) { if ((null == subDataTbl.ArrayPart[c]) || (default(TValue) == subDataTbl.ArrayPart[c].V)) { continue; } valCount++; } if (valCount != tVal.Count) { return(false); } if (tVal is ConstLuaTable.ValDesc) { tVal.Init(subDataTbl.ArrayPart, tKey); } else { tVal.Init(subDataTbl.ArrayPart); } OnDataLoaded(tKey, tVal); if (mTableDatas.ContainsKey(tKey)) { Debug.LogError(string.Format("读取数据表时出现相同的索引[{0}]", tKey.ToString())); return(false); } mTableDatas.Add(tKey, tVal); return(true); }