【修复】修复ref了不属于当前导出分组的table时,生成报错的bug。

【修复】修复未进行完整生成,只生成导出分组表,导致一些ref检查出错的bug。
main
walon 2021-12-05 17:52:42 +08:00
parent 19656437cb
commit 1377eb828d
4 changed files with 15 additions and 8 deletions

View File

@ -157,6 +157,11 @@ namespace Luban.Job.Cfg.Defs
return _recordsByTables[table.FullName]; return _recordsByTables[table.FullName];
} }
public List<DefTable> GetAllTables()
{
return Types.Values.Where(t => t is DefTable).Cast<DefTable>().ToList();
}
public List<DefTable> GetExportTables() public List<DefTable> GetExportTables()
{ {
return Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList(); return Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList();

View File

@ -178,7 +178,7 @@ namespace Luban.Job.Cfg
timer.StartPhase("validate"); timer.StartPhase("validate");
var validateCtx = new ValidatorContext(ass, args.ValidateRootDir); var validateCtx = new ValidatorContext(ass, args.ValidateRootDir);
await validateCtx.ValidateTables(exportTables); await validateCtx.ValidateTables(ass.GetAllTables());
timer.EndPhaseAndLog(); timer.EndPhaseAndLog();
} }
} }

View File

@ -167,7 +167,7 @@ namespace Luban.Job.Cfg.Utils
public static async Task LoadCfgDataAsync(IAgent agent, DefAssembly ass, string dataDir, string patchName, string patchDataDir, string inputConvertDataDir) public static async Task LoadCfgDataAsync(IAgent agent, DefAssembly ass, string dataDir, string patchName, string patchDataDir, string inputConvertDataDir)
{ {
var ctx = agent; var ctx = agent;
List<DefTable> exportTables = ass.Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList(); List<DefTable> exportTables = ass.Types.Values.Where(t => t is DefTable).Cast<DefTable>().ToList(); //&& ct.NeedExport.Select(t => (DefTable)t)
var genDataTasks = new List<Task>(); var genDataTasks = new List<Task>();
var outputDataFiles = new ConcurrentBag<FileInfo>(); var outputDataFiles = new ConcurrentBag<FileInfo>();
long genDataStartTime = Bright.Time.TimeUtil.NowMillis; long genDataStartTime = Bright.Time.TimeUtil.NowMillis;

View File

@ -58,7 +58,7 @@ namespace Luban.Job.Cfg.Validators
case ETableMode.MAP: case ETableMode.MAP:
{ {
var recordMap = assembly.GetTableDataInfo(ct).FinalRecordMap; var recordMap = assembly.GetTableDataInfo(ct).FinalRecordMap;
if (/*recordMap != null &&*/ recordMap.ContainsKey(key)) if (recordMap.ContainsKey(key))
{ {
return; return;
} }
@ -139,10 +139,10 @@ namespace Luban.Job.Cfg.Validators
{ {
throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 不存在"); throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 不存在");
} }
if (!ct.NeedExport) //if (!ct.NeedExport)
{ //{
throw new Exception($"type:'{hostTypeName}' field:'{fieldName}' ref 引用的表:'{actualTable}' 没有导出"); // throw new Exception($"type:'{hostTypeName}' field:'{fieldName}' ref 引用的表:'{actualTable}' 没有导出");
} //}
if (ct.IsOneValueTable) if (ct.IsOneValueTable)
{ {
if (string.IsNullOrEmpty(fieldName)) if (string.IsNullOrEmpty(fieldName))
@ -167,8 +167,10 @@ namespace Luban.Job.Cfg.Validators
} }
else if (ct.IsMapTable) else if (ct.IsMapTable)
{ {
if (first && Tables.Count == 1) if (first && Tables.Count == 1 && ct.NeedExport)
{ {
// 只引用一个表时才生成ref代码。
// 如果被引用的表没有导出生成ref没有意义还会产生编译错误
GenRef = true; GenRef = true;
} }
if (!string.IsNullOrEmpty(indexName)) if (!string.IsNullOrEmpty(indexName))