Repository navigation
UI: openBuildingStatusMenuForBuildingID at 100%, out of the draft #313 - #484
Merged
Merged
Conversation
AlphaAndButtonSurface::openBuildingStatusMenuForBuildingID comes out of our draft sourcehold#313, where it stood at 86.1%. That version is restructured from gynt's: his 8f3342a (53.1%, after bbc6d12 at 53.08%), and his newest reimplement commit on the file, 63cc49f (2026-10-25, on his fork's reimpl/UI-Rendering-development). The function's logic is his: the two switches, the menu tabs, the statue's jump to the menu and the countdown call. sourcehold#313 reordered the second switch's cases to the original's block layout (cb62724) and cleaned up the decompiler's names and gotos. Its one differing instruction was the second argument of the extendResourceCountdownForPlayerBuildingsOfType call (0x004633BD): the original pushes esi, which holds 1 from 0x00463344 on, and the draft pushed the immediate 1. The 1 that reaches the menu is the barracks' tab: BT_BARRACKS is the one arm of the second switch that does not set the menu tab. With `menuTab = 1` as the initial value the compiler pushes the immediate. Declared without a value and set to 1 in the barracks' arm, the 1 stays in esi and the call pushes esi, as in the original. The menu tab is still set on every path to the menu (MSVC's C4701 stays quiet with the warning on), and a one-line comment says why it has no initial value. The one goto left, the statue's jump past the call to the menu, gets a one-line comment: with an if around the call instead, the match is lost. The status line is 100.0%. The menu tabs are main's UI::Enums::BuildingsAndStatusMenuTabType names; the siege tent's 28, which has none, stays a number with a comment. menuTab is an int, as main's other menu tab locals are. The casts that convert nothing in the two findParticularBuilding calls and the tutorial call are gone, as main passes these fields. The keep's and the granary's arms read the current player through the global in all three indices; the local that held it went, so the goto no longer jumps past an initialised local. The same listing as with the numbers, the casts and the local. Measured: with the precompiled header, quick_diff gives the original's 280 instructions. A narrow real build (main's /GL list and this file, with the struct resolvers and its function resolvers on, sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie) reads 100.0% raw and normalised with no differing line, and every other function reads as in the same build without it. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 1 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 1 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 20 — Keep nesting low; no
|
This was referenced Nov 23, 2026
gynt
requested changes
Nov 24, 2026
…pass for by break, no goto The review asked whether the goto is necessary. It is not. The body from the ownership test to the end of the second switch now sits in a `for (;;)` that runs once: the unowned statue's arm leaves it with `break` where it jumped to the label, and the other paths to the menu reach the `break` at its end. No switch encloses the statue's arm, so its break leaves the loop; the breaks in the two switches still leave only their switch. The control flow is the goto's, and so is the code: on this head merged with main 7c2e4d6 the quick listing is the same as the head's, 280 instructions against the original's 280, quick_diff 1.0000 (the head reads 100.0 in a real build). `do { ... } while (0)` reads the same; the style guide asks for a for loop. The goto-free forms that do not match: a bool or an int flag set in the statue arm, the first switch in an else and the countdown call and the second switch under `if (!flag)`, 0.9875 (279 instructions); measured before, if / else with `if (menuTab != 89)` around the call 0.9663 and the tail written out in the statue arm 0.8983. The loop's body is one level deeper, so clang-format re-wraps three statements, and the comment on someone else's building is reworded to stay on one line. Nothing else changes. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One function at 100%, from our draft #313, where it stood at 86.1%. One
.cppand its status line. No header change, and no line forcmake/compiler-flags-gl.txt.AlphaAndButtonSurface::openBuildingStatusMenuForBuildingID#313's version is restructured from gynt's. It started from his 8f3342a (53.1%, after bbc6d12 at 53.08%), and his newest reimplement commit on the file is 63cc49f (2026-10-25, on his fork's reimpl/UI-Rendering-development). The function's logic is his:
The commit credits him as co-author.
The last instruction: the barracks' 1
extendResourceCountdownForPlayerBuildingsOfType,pushat 0x004633BD). The original pushesesi, which holds 1 from 0x00463344 on. The draft pushed the immediate 1.BT_BARRACKSis the one arm of the second switch that does not set the menu tab; every other arm sets it or returns. WithmenuTab = 1as the initial value, the compiler pushes the immediate. The draft tried the argument asmenuTab,TRUE,1uor(dword)1, anintmenu tab, and two definitions of it, and all of them gave the same push.esi, and the call pushesesi, as in the original: quick_diff gives the original's 280 instructions. This is a source handle for the classtools/compiler-internals/msvc-backend.mddescribes in "A defect class: which constant gets the callee-saved register": the constant gets the register once the variable that also holds it has no initial value.ifaround the call and the second switch instead gives 0.9663: the gatehouse compare's block moves. Writing the menu's tail out in the statue's arm gives 0.8983.Written as main writes it
UI::Enums::BuildingsAndStatusMenuTabTypenames, as main'sSelectBuySellGoodsandMainButtonshandlers do forbuildingandstatusmenuMenuTabToSwitchTo. The siege tent's tab, 28, has no name there and stays a number, with a comment.BT_BATTERINGRAMgets 60,BASMTT_SIEGETENT_SIEGETOWER, andBT_SIEGETOWERgets 61,BASMTT_SIEGETENT_BATTERINGRAM;BT_CAMPGROUNDgets 43,BASMTT_CAMPFIRE, andBT_CAMPFIRE(with the parade grounds) gets 52,BASMTT_TRAININGGROUNDS.menuTabis anint, as main's other menu-tab locals are.findParticularBuildingcalls and the tutorial call pass the building's fields as main's other calls do. The tutorial call keeps its(BuildingType), which ashortneeds.Measured
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), the struct resolvers and the function resolvers enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.menuTabasint, reads the current player from the global in both arms and changes comments; its whole listing is the same in a narrow real build), with both resolver sets on and main's own/GLlist (this file is not on it), and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,426 compile steps, 99.58 over 2,442 functions.openBuildingStatusMenuForBuildingIDreads 100.0 raw and normalised there, with no diff entry, and its five callees (findParticularBuilding,closeHelpDialogAndReturnToMenu,switchToMenuView,extendResourceCountdownForPlayerBuildingsOfTypeandSetTutorialBuildingActionState) read 100.0 as before; no reimplemented function calls it. Against main's own build (made at f489b72, 2,439 functions) the only other changes are main's since then (One more UI::MenuModals function at 100%: ProgressBarBox #467'sMenuModalRenderFunction_ProgressBarBoxand its constructor, UI: the single-player game launch at 100% #466'sLaunchSinglePlayerGameUnk), and every other function reads exactly what it read before (unrounded 99.5790 raw and 99.5529 normalised, 2,326 functions at 100.0 raw; main 0e4a83b alone: 99.5788 and 99.5528 over 2,441, 2,325 at 100.0)./GLlist (the 133 files that exist) and this file, with its resolver on. The function reads 100.0% raw and normalised with no diff entry, and every other function reads as in the same build without it.field_0x2c6, read twice. Our local fixer finds nothing to change.🤖 Generated with Claude Code