{"record":{"id":"493a9e4a2bf9b4f4","repo":"babalae/better-genshin-impact","slug":"getbigmapscale","errorCode":null,"errorMessage":"当前未处于大地图界面，不能使用GetBigMapScale方法","messagePattern":"当前未处于大地图界面，不能使用GetBigMapScale方法","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/BgiVision/BvStatus.cs","lineNumber":214,"sourceCode":"\n    /// <summary>\n    /// 大地图界面是否在地底\n    /// 鼠标悬浮在地下图标或者处于切换动画的时候可能会误识别\n    /// </summary>\n    /// <param name=\"captureRa\"></param>\n    /// <returns></returns>\n    public static bool BigMapIsUnderground(ImageRegion captureRa)\n    {\n        using var ra = captureRa.Find(RecognitionAssets.Get(\"QuickTeleport\", \"MapUndergroundSwitchButton\", captureRa));\n        return ra.IsExist();\n    }\n\n    public static double GetBigMapScale(ImageRegion region)\n    {\n        using var scaleRa = region.Find(RecognitionAssets.Get(\"QuickTeleport\", \"MapScaleButton\", region));\n        if (scaleRa.IsEmpty())\n        {\n            throw new Exception(\"当前未处于大地图界面，不能使用GetBigMapScale方法\");\n        }\n\n        // 原先这里的起止区间和config里写死的值差1\n        var start = TaskContext.Instance().Config.TpConfig.ZoomStartY;\n        var end = TaskContext.Instance().Config.TpConfig.ZoomEndY;\n        var cur = (scaleRa.Y + scaleRa.Height / 2.0) * TaskContext.Instance().SystemInfo.ZoomOutMax1080PRatio; // 转换到1080p坐标系,主要是小于1080p的情况\n\n        return (end * 1.0 - cur) / (end - start);\n    }\n\n    public static MotionStatus GetMotionStatus(ImageRegion captureRa)\n    {\n        using var spaceRa = captureRa.Find(ElementRecognition.Get(\"SpaceKey\", captureRa));\n        var spaceExist = spaceRa.IsExist();\n        using var xRa = captureRa.Find(ElementRecognition.Get(\"XKey\", captureRa));\n        var xExist = xRa.IsExist();\n        if (spaceExist)\n        {","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/BgiVision/BvStatus.cs#L196-L232","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Always call BvStatus.IsInBigMapUi(captureRa) before GetBigMapScale and only proceed if it returns true.","Add a retry/wait loop with a short delay to let the map UI fully render before checking scale.","Verify the capture region covers the bottom-right area where the zoom scale button appears."],"exampleFix":"// before\ndouble scale = BvStatus.GetBigMapScale(captureRa);\n\n// after\nif (!BvStatus.IsInBigMapUi(captureRa))\n{\n    // wait for map to load or abort\n    return;\n}\ndouble scale = BvStatus.GetBigMapScale(captureRa);","handlingStrategy":"validation","validationCode":"if (!BvStatus.IsInBigMapUi(captureRa))\n{\n    // not on the map — do not call GetBigMapScale\n    return;\n}","typeGuard":"static bool CanGetBigMapScale(ImageRegion ra) => BvStatus.IsInBigMapUi(ra);","tryCatchPattern":"try { var scale = BvStatus.GetBigMapScale(region); }\ncatch (Exception ex) when (ex.Message.Contains(\"GetBigMapScale\")) { /* wait for map, retry */ }","preventionTips":["Always call IsInBigMapUi before GetBigMapScale.","Add a small delay after navigation to let the map UI render before reading scale."],"tags":["vision","map","precondition","template-matching"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}