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

  1. Ensure the ley-line configuration is loaded and its MapPositions dictionary is populated before invoking the task.
  2. Check the config file on disk has a valid MapPositions section; restore defaults if absent.
  3. 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

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


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/37d6412b78f055b0. Report an issue: GitHub.