【修复】修复ref只包含一个refgroup,同时refgroup只包含一个表时,错误判定为需要genRef,导致生成代码出错的bug

main
walon 2022-01-03 12:51:46 +08:00
parent fc1cb23974
commit c009d54d26
1 changed files with 3 additions and 1 deletions

View File

@ -127,6 +127,7 @@ namespace Luban.Job.Cfg.Validators
} }
var assembly = ((DefField)def).Assembly; var assembly = ((DefField)def).Assembly;
bool anyRefGroup = false;
foreach (var table in Tables) foreach (var table in Tables)
{ {
var (actualTable, indexName, ignoreDefault) = ParseRefString(table); var (actualTable, indexName, ignoreDefault) = ParseRefString(table);
@ -152,13 +153,14 @@ namespace Luban.Job.Cfg.Validators
} }
CompileTable(def, subTable, refIndex, ignoreDefault && refIgnoreDefault); CompileTable(def, subTable, refIndex, ignoreDefault && refIgnoreDefault);
} }
anyRefGroup = true;
} }
else else
{ {
throw new Exception($"结构:'{hostTypeName}' 字段:'{fieldName}' ref:'{actualTable}' 不存在"); throw new Exception($"结构:'{hostTypeName}' 字段:'{fieldName}' ref:'{actualTable}' 不存在");
} }
} }
if (_compiledTables.Count == 1 && (_compiledTables[0].Table is DefTable t && t.IsMapTable && t.NeedExport)) if (!anyRefGroup && _compiledTables.Count == 1 && (_compiledTables[0].Table is DefTable t && t.IsMapTable && t.NeedExport))
{ {
// 只引用一个表时才生成ref代码。 // 只引用一个表时才生成ref代码。
// 如果被引用的表没有导出生成ref没有意义还会产生编译错误 // 如果被引用的表没有导出生成ref没有意义还会产生编译错误