Skip to content

Bug: Swapped divisors in ResultScreen::DrawFinalStats — game completion rate (進行率) calculated incorrectly #395

@CNTianQi233

Description

@CNTianQi233

Summary

The two divisor constants used to compute the game completion rate (進行率) in ResultScreen::DrawFinalStats are swapped compared to the original binary, causing the displayed percentage to be ~2.26× off on non-Extra difficulties.

Affected Code

File: src/ResultScreen.cpp, function ResultScreen::DrawFinalStats

// Current (incorrect):
completion = g_GameManager.difficulty < 4
    ? g_GameManager.counat / 39600.0f
    : g_GameManager.counat / 89500.0f;

Evidence from the Original Binary

Disassembling DrawFinalStats (VA 0x42d35a) in the original v1.02h binary:

; difficulty < 4 (non-Extra)
0x42d3a4: cmp  dword ptr [0x69bcb0], 4    ; g_GameManager.difficulty
0x42d3ab: jge  0x42d3c4                   ; jump to Extra path
0x42d3ad: fild dword ptr [0x69d70c]       ; load counat
0x42d3b9: fdiv dword ptr [0x46bcc8]       ; ÷ [0x46bcc8]

; difficulty >= 4 (Extra)
0x42d3c4: fild dword ptr [0x69d70c]       ; load counat
0x42d3d0: fdiv dword ptr [0x46bcc4]       ; ÷ [0x46bcc4]

Reading the float constants from the .rdata section:

Address Raw bytes Float value
0x46bcc8 0x47aece00 89500.0
0x46bcc4 0x471ab000 39600.0

So the original binary uses:

  • Non-Extra (difficulty < 4): counat / 89500.0
  • Extra (difficulty ≥ 4): counat / 39600.0

The decompiled source has the two constants reversed.

Impact

On non-Extra difficulties, the displayed completion rate is inflated by a factor of 89500 / 39600 ≈ 2.26×. For example, a run that should show ~1.15% is displayed as ~2.60%.

Fix

// Correct (matches original binary):
completion = g_GameManager.difficulty < 4
    ? g_GameManager.counat / 89500.0f
    : g_GameManager.counat / 39600.0f;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions