babalae/better-genshin-impact · error · Exception

当前未处于大地图界面,不能使用GetBigMapScale方法

Error message

当前未处于大地图界面,不能使用GetBigMapScale方法

What it means

Thrown as a generic Exception by BvStatus.GetBigMapScale when the template match for MapScaleButton returns empty (scaleRa.IsEmpty()). The method assumes the caller has already confirmed the game is on the big map screen; the absence of the scale button means that precondition is violated. This is a precondition/precondition-violation error, not a runtime OCR failure — IsInBigMapUi should be checked first.

Source

Thrown at BetterGenshinImpact/GameTask/Common/BgiVision/BvStatus.cs:214

    /// <summary>
    /// 大地图界面是否在地底
    /// 鼠标悬浮在地下图标或者处于切换动画的时候可能会误识别
    /// </summary>
    /// <param name="captureRa"></param>
    /// <returns></returns>
    public static bool BigMapIsUnderground(ImageRegion captureRa)
    {
        using var ra = captureRa.Find(RecognitionAssets.Get("QuickTeleport", "MapUndergroundSwitchButton", captureRa));
        return ra.IsExist();
    }

    public static double GetBigMapScale(ImageRegion region)
    {
        using var scaleRa = region.Find(RecognitionAssets.Get("QuickTeleport", "MapScaleButton", region));
        if (scaleRa.IsEmpty())
        {
            throw new Exception("当前未处于大地图界面,不能使用GetBigMapScale方法");
        }

        // 原先这里的起止区间和config里写死的值差1
        var start = TaskContext.Instance().Config.TpConfig.ZoomStartY;
        var end = TaskContext.Instance().Config.TpConfig.ZoomEndY;
        var cur = (scaleRa.Y + scaleRa.Height / 2.0) * TaskContext.Instance().SystemInfo.ZoomOutMax1080PRatio; // 转换到1080p坐标系,主要是小于1080p的情况

        return (end * 1.0 - cur) / (end - start);
    }

    public static MotionStatus GetMotionStatus(ImageRegion captureRa)
    {
        using var spaceRa = captureRa.Find(ElementRecognition.Get("SpaceKey", captureRa));
        var spaceExist = spaceRa.IsExist();
        using var xRa = captureRa.Find(ElementRecognition.Get("XKey", captureRa));
        var xExist = xRa.IsExist();
        if (spaceExist)
        {

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Always call BvStatus.IsInBigMapUi(captureRa) before GetBigMapScale and only proceed if it returns true.
  2. Add a retry/wait loop with a short delay to let the map UI fully render before checking scale.
  3. Verify the capture region covers the bottom-right area where the zoom scale button appears.

Example fix

// before
double scale = BvStatus.GetBigMapScale(captureRa);

// after
if (!BvStatus.IsInBigMapUi(captureRa))
{
    // wait for map to load or abort
    return;
}
double scale = BvStatus.GetBigMapScale(captureRa);
Defensive patterns

Strategy: validation

Validate before calling

if (!BvStatus.IsInBigMapUi(captureRa))
{
    // not on the map — do not call GetBigMapScale
    return;
}

Type guard

static bool CanGetBigMapScale(ImageRegion ra) => BvStatus.IsInBigMapUi(ra);

Try / catch

try { var scale = BvStatus.GetBigMapScale(region); }
catch (Exception ex) when (ex.Message.Contains("GetBigMapScale")) { /* wait for map, retry */ }

Prevention

When it happens

Trigger: Calling GetBigMapScale(region) while the game is on a different screen (character menu, inventory, loading screen, domain interior). The captured screenshot region does not contain the map zoom-scale button UI element.

Common situations: A teleport or auto-path task called GetBigMapScale before the map fully loaded (timing issue). The task flow navigated away from the map unexpectedly. The screenshot capture region is misconfigured and crops out the scale button area.

Related errors


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