diff --git a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs index a29815d..8b24fd2 100644 --- a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs +++ b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs @@ -157,6 +157,11 @@ namespace Luban.Job.Cfg.Defs return _recordsByTables[table.FullName]; } + public List GetAllTables() + { + return Types.Values.Where(t => t is DefTable).Cast().ToList(); + } + public List GetExportTables() { return Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList(); diff --git a/src/Luban.Job.Cfg/Source/JobController.cs b/src/Luban.Job.Cfg/Source/JobController.cs index 493a129..4a1f4cc 100644 --- a/src/Luban.Job.Cfg/Source/JobController.cs +++ b/src/Luban.Job.Cfg/Source/JobController.cs @@ -178,7 +178,7 @@ namespace Luban.Job.Cfg timer.StartPhase("validate"); var validateCtx = new ValidatorContext(ass, args.ValidateRootDir); - await validateCtx.ValidateTables(exportTables); + await validateCtx.ValidateTables(ass.GetAllTables()); timer.EndPhaseAndLog(); } } diff --git a/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs b/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs index f3cd294..49eaa73 100644 --- a/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs +++ b/src/Luban.Job.Cfg/Source/Utils/DataLoaderUtil.cs @@ -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) { var ctx = agent; - List exportTables = ass.Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList(); + List exportTables = ass.Types.Values.Where(t => t is DefTable).Cast().ToList(); //&& ct.NeedExport.Select(t => (DefTable)t) var genDataTasks = new List(); var outputDataFiles = new ConcurrentBag(); long genDataStartTime = Bright.Time.TimeUtil.NowMillis; diff --git a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs index 952c799..d2e41de 100644 --- a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs +++ b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs @@ -58,7 +58,7 @@ namespace Luban.Job.Cfg.Validators case ETableMode.MAP: { var recordMap = assembly.GetTableDataInfo(ct).FinalRecordMap; - if (/*recordMap != null &&*/ recordMap.ContainsKey(key)) + if (recordMap.ContainsKey(key)) { return; } @@ -139,10 +139,10 @@ namespace Luban.Job.Cfg.Validators { throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 不存在"); } - if (!ct.NeedExport) - { - throw new Exception($"type:'{hostTypeName}' field:'{fieldName}' ref 引用的表:'{actualTable}' 没有导出"); - } + //if (!ct.NeedExport) + //{ + // throw new Exception($"type:'{hostTypeName}' field:'{fieldName}' ref 引用的表:'{actualTable}' 没有导出"); + //} if (ct.IsOneValueTable) { if (string.IsNullOrEmpty(fieldName)) @@ -167,8 +167,10 @@ namespace Luban.Job.Cfg.Validators } else if (ct.IsMapTable) { - if (first && Tables.Count == 1) + if (first && Tables.Count == 1 && ct.NeedExport) { + // 只引用一个表时才生成ref代码。 + // 如果被引用的表没有导出,生成ref没有意义,还会产生编译错误 GenRef = true; } if (!string.IsNullOrEmpty(indexName))