babalae/better-genshin-impact · error · Exception
地图位置配置缺失
Error message
地图位置配置缺失
What it means
Thrown by FindLeyLineOutcrop when _configData is null or _configData.MapPositions is null. The runtime ley-line configuration that maps each country to candidate map coordinates was never loaded, so the task cannot decide where to look.
Source
Thrown at BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropTask.cs:821
continue;
}
sourceNode.Next.Add(new NodeRoute { Target = edge.Target, Route = edge.Route });
targetNode.Prev.Add(edge.Source);
}
return new NodeData
{
Nodes = nodes,
Indexes = raw.Indexes
};
}
private async Task FindLeyLineOutcrop(string country, string type)
{
if (_configData?.MapPositions == null)
{
throw new Exception("地图位置配置缺失");
}
if (!_configData.MapPositions.TryGetValue(country, out var positions) || positions.Count == 0)
{
throw new Exception($"未找到国家 {country} 的位置信息");
}
await _returnMainUiTask.Start(_ct);
await _tpTask.OpenBigMapUi();
await _tpTask.MoveMapTo(positions[0].X, positions[0].Y, MapTypes.Teyvat.ToString());
var found = await LocateLeyLineOutcrop(type);
if (found)
{
return;
}
for (var i = 1; i < positions.Count; i++)View on GitHub (pinned to a7cb36712d)
Solutions
- Ensure the ley-line configuration is loaded and its MapPositions dictionary is populated before invoking the task.
- Check the config file on disk has a valid MapPositions section; restore defaults if absent.
- If MapPositions is optional in your build, provide a fallback/default mapping instead of throwing.
Example fix
// before
if (_configData?.MapPositions == null)
{
throw new Exception("地图位置配置缺失");
}
// after
if (_configData is null || _configData.MapPositions is null || _configData.MapPositions.Count == 0)
{
throw new InvalidOperationException("地图位置配置缺失:请确认地脉配置已加载且包含 MapPositions");
} Defensive patterns
Strategy: validation
Validate before calling
if (_configData is null || _configData.MapPositions is null)
{
throw new InvalidOperationException("地脉配置未加载或缺少 MapPositions,请先加载配置");
} Type guard
bool HasMapPositions(LeyLineConfig? c) => c?.MapPositions is { Count: > 0 }; Prevention
- Load and assert the ley-line config (with MapPositions) at task start, before any FindLeyLineOutcrop call.
- Unit-test config deserialization to guarantee MapPositions is populated.
- Fail fast at startup rather than mid-task.
When it happens
Trigger: FindLeyLineOutcrop(country, type) runs before the ley-line config (containing MapPositions) has been initialized, or the config object failed to deserialize its MapPositions member.
Common situations: Task started without loading the ley-line config; config file missing or the MapPositions section removed; a code path skipped the LoadConfig step.
Related errors
- 未找到国家 {country} 的位置信息
- 未找到名称为 {objectName} 的 RecognitionObject 配置
- 对象 {objectName} 缺少 template 配置
- 表达式 {expression} 未返回 Rect
- 变量 {name} 存在循环引用
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/37d6412b78f055b0.
Report an issue: GitHub.