Repository navigation
Reimplement 8 UI::MenuItems functions at 100% - #349
Merged
Merged
Conversation
Moved here unchanged from the draft sourcehold#328 (reimpl/UI-MenuItems-3-development-2, 13fbfea). It was 100% before the header sync a9401a7 and 92.3% on sourcehold#328's base 72b2732, where MSVC stopped sharing the tails of its two number calls. On main 57d3334 it compiles to the original's 100 instructions again, with the shared tail. quick_diff is left with its own artefacts only: the jump-table spelling, the colour immediates, the picture table's address written as its base less 14, and ret / ret 0. reccmp: 99.2% raw and 100% normalized, where only the picture table's address differs (reccmp shows it as an offset into DAT_GMImageHeaders), which the project records as 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original ends with push 1 / call RecordTutorialPlayerAction / pop ecx (0x00434200 to 0x00434207). Declared (int, ...), our function tail-calls through its own argument slot instead (mov [esp + 4], 1 / jmp), which MSVC can only do when the function has a named parameter. Only the menu tables refer to it (six dwords, no call), and like WaitingForHost_ConnectToLobby it never reads an argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LobbyMenu_SkirmishTypeAndBalance plays them when the balance changes: 256 at either end (buttons 10 and 14), 255 one step from even (11 and 13) and 254 at even (12); the pushes are at 0x0042A888, 0x0042A8A1 and 0x0042A8B5. The draft wrote them as (SoundEffectID)0x100 and as SEID_UNIT_DAMAGE3 | SEID_PEOPLE_ARE_COMING_TO_THE_CASTLE (248 | 7) and SEID_UNIT_DAMAGE3 | SEID_ARROW_KILL (248 | 6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. On main's headers it compiles to the original's 41 instructions, and quick_diff differs only in its own ret / ret 0. The style pass names the parameter and the button ranges, and the three sound effects by the names the previous commit adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. Rewritten without the decompiler's gotos, it keeps the original's 85 instructions. quick_diff's differences are its own: ret / ret 0, and the tail jump to MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface at 0x004D9A4F, which our listing writes as jmp trampoline<4603888> (0x00463FF0) and quick_diff does not count as a function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moved from the draft sourcehold#318 (reimpl/batch2-development 49a51e7), 92.6% there. The search for a siege unit now sets a flag and leaves the loop, so its exit jumps past the clearing as the original's does (jg at 0x00442DE3 to 0x00442E64) instead of testing p == end after the loop: quick_diff 0.9753 -> 0.9807. A goto, a flag over the pointer loop and a flag over an index loop all measure the same; the index loop reads best. What is left is quick_diff's own: the security cookie, the timeGetTime import call, ret / ret 0, and the 11 bytes of alignment before the copy loop at 0x00442EA5, which the original's assembler wrote as a jmp over the filler. The style pass replaces the pointer loops with index loops over the 21 counts and returns early for maps that are not sieges. Clean alone build: reccmp 98.9% raw and 100% normalized. The two raw differences are one address, the end of the siege search loops (cmp eax, 0x00B95B1C, one past DAT_SiegeInformationArray), which reccmp resolves to the next global in the original and to our array's end in the DLL; the project records that as 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 74.1% there. The label is drawn in two calls with the same colour, one per hover state, and the position goes through two locals computed before them: MSVC then merges the two calls but for the text ID's push (the jne at 0x0047E45D). One call is quick_diff 0.8136, the position inside each arm 0.5479, this form 0.9375, which leaves only the colour immediate and ret / ret 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moved from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development c1c152b), 89.9% there. With the header taking no parameters (previous commit) the closing RecordTutorialPlayerAction(1) is a call again rather than a tail call: quick_diff 0.9343 -> 0.9710, left with the jump-table spelling and ret / ret 0. The comments now say what -1000 does, and that the frame-rate formula makes up for only part of the slowdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 77.4% there. The cases now come in the original's order, 1, 2/3, 4, 7, 5, 6, as in LobbyMenu_MapSelectScrollbar on main: the original lays the blocks out in that order (case 7's store at 0x00442FDA sits between case 4 and case 5). quick_diff then differs only in its own jump-table spelling and ret / ret 0. The style pass names the parameters as the LobbyMenu scrollbar does and writes - 13 and ++ / --. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 73.6% there, after main's renames (isNameEntryActive). Each case now computes the text's position, fetches the text and draws it itself: MSVC merges the copies of cases 0 to 3 into one tail but for the push of the text's index, as the original has push 5 / push 6 / push 7 / push 0 before its shared tail at 0x0047CDE7; case 4 keeps its own call and the surface reset. With one call after the switch the index goes through a register (quick_diff 0.9365); this form is 0.9664, which leaves the jump-table spelling, the colour immediates and ret / ret 0. The cursor's bottom is written DAT_ButtonY + DAT_ButtonH - 4, the order of the original's lea (0.9030 -> 0.9365 by itself). == TRUE stays: the original compares with 1, and a truthiness test is 0.9365. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
… 254-256) into reimpl/UI-MenuItems-9-100 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
It was undefined4. Every store is 0 or 1: the toggle xor [0x00B960C8], 1 at 0x0042D81F, 0 at 0x0042D855 (edx, 0 in that handler) and 0x00448DC2 (ebx), 1 at 0x00442E66; the decompilation agrees (SingleplayerMapChoice's MapTable stores 1, ButtonsAndHands toggles it and stores 0, SingleplayerMapChoice_Prepare stores 0), and every read compares with 0 (spawnQueuedReinforcementWaves, LaunchSinglePlayerGameUnk). A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. Its one user in the code, this PR's MenuItemActionHandler_SingleplayerMapChoice_MapTable (0x00442C30), stores 1 and compiles the same (quick_diff 0.9807 before and after); main has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was undefined4. Its one store, at 0x004D972A (MenuView_RankingGames_Prepare), copies GameSynchronyState.currentGameMode (0x0191DD80, a GameModeInt), and its one read, in MenuItemActionHandler_RankingGames_Main, copies it back. Both are on main and compile the same; the copy no longer converts between unsigned and int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was undefined4. It is a count that can go below 0: MenuView_CrusadeMap_Prepare (0x004D8CB0) stores 3 (0x004D8D48), decrements it once per mission skipped with the chicken and stores the result (0x004D8DD5), then clamps it at 0 with a signed test (cmp edx, edi / jge at 0x004D8DDB); 0x004D8F3B subtracts from it in memory. Main's user, MenuItemRenderFunction_General_CrusadeMapAndEndscreen, tests it with a signed > 0 through an (int) cast, which the next commit drops; it compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was undefined4. MenuItemActionHandler_RankingGames_Main (0x004D9730) is its only writer: it stores 1 at 0x004D995F when a new column is picked and 1 - descending at 0x004D9970 / 0x004D9976 when the same column is picked again, so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was undefined4. Its only store, in MenuItemActionHandler_InGameMenu_TriggerPlaceWallCommand at 0x0043803E, writes the result of a sete (0x00438034), so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… no longer needs DAT_SkirmishTrailRelated1 is an int since the commit before this one, so the signed > 0 test needs no cast. It compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The global is a BOOLEnum since the header commit before this one. Same code (quick_diff 0.9807 before and after). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
The sync types DAT_SH1_SiegeAdvancedMode as int where 0bc6102 had BOOLEnum, and DAT_StoredGameMode as int where d4c1b5e had GameModeInt: main's headers are taken, and MenuItemActionHandler_SingleplayerMapChoice_MapTable stores 1 instead of TRUE. No file of this branch uses DAT_StoredGameMode. MissionDefinedData and DAT_SkirmishTrailRelated1 are on main as this branch had them, and TileMapState merges cleanly, so the branch no longer changes any header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
gynt
approved these changes
Nov 7, 2026
gynt
added a commit
to gynt/OpenSHC
that referenced
this pull request
Nov 25, 2026
…#327 and sourcehold#328, with two header changes (sourcehold#417) * reimplement: SHC_3BB0A8C1_0x004708F0 100.0% Reimplemented, register allocation only (sourcehold#414) WindowAndDirectDraw::reinitWindow, moved out of our draft sourcehold#313 with one comment line added. The draft came from gynt's version on his fork's reimpl/UI-Rendering-development (3768087 at 56.90%, a8b64eb at 56.9%, and 63cc49f of 2026-10-25, his newest commit on the file) and reached 80.4% in 685b039. Register allocation only, per sourcehold#414: reccmp reads 80.4 (normalized 80.5), and the 56 instructions of both sides are the same instructions in the same order with the same memory operands. What differs is which of eax, ecx and edx holds each reload of windowHandle (and the address of the second corner) before it is pushed: eleven lines. if/else, nested and early-return shapes of the two branches all compile to the same code. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00493E20 100.0% Reimplemented VideoOptions::MenuItemActionHandler_VideoOptions_Main, rewritten from the listing on top of gynt's draft: aae2c08 (57.14%, his fork's development), cd76e7f (57.7%, upstream's reimpl/UI-MenuItems), 8725ec5 (61.5%, his fork's reimpl/UI-MenuItems-development) and 8ca7861 of 2026-10-27, his newest commit on the file (his fork's reimpl/Wilps-2026-10-18: the same code with newer field names). Our mechanical pass b2d7696 in draft sourcehold#328 read 61.5% as well. What the match needed: - case 11 keeps the resolution in a local through the loop and stores it once after it; the draft worked on the field, which stores it in every round; - case 18 reads the new resolution once and calls setExtraActiveModalDialog in every arm of the chain, in the original's order of arms. The draft set two position locals and called once, which shares the pushes. Two neighbouring arms with the same position joined by || read 0.8055 in quick_diff, so each resolution has its arm; - popModalDialog is called at the end of case 18 and in case 17: the compiler shares the one tail jump; - no goto and no position locals are left, and the loop is a for with its exit test in the header (a BOOLEnum that stands in for the original's do-while): the compiler puts the test at the end of the round, where the original has it. Names instead of numbers: CT_WINDOWS_LIKE_CURSOR, CT_ANI_CURSOR and SS_NORMAL. The parameter is button, as in most handlers on main; the buttons have no enum, so each case says what it does. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004C0CF0 100.0% Reimplemented SiegeAttackingForceAndStartGoods::MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main, rewritten from the listing on top of gynt's draft: ce671d7 and 37bf917 (40.1%, upstream's reimpl/UI-MenuItems), f0479fc, b83dff2 and d7600c8 (44.39% to 52.82%, his fork's reimpl/UI-MenuItems), then 25b481a (54.75%), 9743554 (52.49%) and 6aa5d32 of 2026-11-02, his newest commit on the file (his fork's reimpl/UI-MenuItems-development). Our mechanical pass 7b18743 and 53bea5f in draft sourcehold#328 read 53.8%. What the match needed: - one if / else-if chain with the draw buffer set back once, at the end. The draft returned from every arm, each with its own store; written once, the compiler copies the store into the arms as the original has it, and esi is pushed before the first branch; - renderGM for a unit's picture is written in both arms that draw one (rows 20 to 29 and 40 to 49). Shared after the chain it reads 0.7479 in quick_diff; - the row is -1 - button (or esi, -1 / sub esi, eax), not -button - 1; - every amount is drawn by a call in each arm of the colour test. One call with the colour as a ?: reads 0.9320 (neg / sbb / and / add for the colour), with a colour local 0.9608. Behaviour: none of the draft's forms differed in what they draw. Readability, all measured equal: rows 20 to 29 read SEC_SiegeInformation[index - 20] and rows 40 to 49 SEC_Section1067.siegeEngineCounts[index - 40] (the draft indexed SEC_StartingResources[index + 5] for both, which is the same address); the picture's height comes from DAT_GMImageHeaders as in TriggerInvasion_Main, not from a cast on PTR_ARRAY_Unknown_UnitGMHeights; index >= 40 && index < 50 for the unsigned range test. reccmp: 99.2% raw. The two lines that differ are the picture table's address 0x00B98782 (imh[first + picture - 1] .height), 14 bytes before DAT_GMImageHeaders: reccmp prints it as a number on the original's side and, on ours, as an offset from whichever variable of our DLL lies there (Instance<int,15544744>+2, DAT_ButtonX's instance). Only the name of the resolved address differs, which the project records as 100% (TriggerInvasion_Main in sourcehold#349 has the same two lines). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * headers: DAT_SentOrRequestedGoodsAmount is an int The amount the send / request goods dialog works with is compared as a signed value wherever it is read in MenuItemActionHandler_AlliesSendAndRequestGoods_Main (0x004B14C0): - 0x004B15E6: mov ecx, [0x00DF428C] / test ecx, ecx / jle: no amount chosen. An unsigned test would be je; - 0x004B16ED: mov ecx, [0x00DF428C] / cmp eax, ecx / jge against the room getResourceSpace returned; - 0x004B183A: cmp [the player's gold], esi / jge, and 0x004B1863 jl, 0x004B1870 cmp eax, esi / jge, with the amount in esi. As undefined4 (unsigned) each of these needs an (int) cast. Its only user on main, MenuItemActionHandler_Allies_Main (0x004B12D0), assigns to it and stays at 100.0% with the change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004B14C0 100.0% Reimplemented AlliesSendAndRequestGoods::MenuItemActionHandler_AlliesSendAndRequestGoods_Main, rewritten from the listing on top of gynt's draft: c7cfed8 and 8ee5623 (32.9%, upstream's reimpl/UI-MenuItems), cbc63a3, 17cbc68 and df54f4e (56.22% to 57.83%, his fork's reimpl/UI-MenuItems), 8725ec5 (58.2%) and 0e551f6 of 2026-11-02, his newest commit on the file (his fork's reimpl/UI-MenuItems-development). Our 1f29978 in draft sourcehold#328 read 60.5%. Behaviour, where the draft differed from the original: - buttons 21 and 50 to 53 return after their one store, and any other button but 100 returns after opening the allies dialog. The draft went on from each of them into button 100's path; - button 102 (cancel) queues its command only when the send dialog is open and DAT_00df4284 is set. The draft queued it always; - when a request fails for want of a building or of room, the original plays at most the one warning that fits the fail state and closes the dialog. The draft played the third warning in every case and, after a missing building, went on to the room test; - a request that is accepted queues the command and closes the dialog; the draft also played the "goods not sent" clip after it; - button 100 does nothing after the request path. The draft fell into the send path. What the match needed: - button 100 holds the whole confirm path and the other buttons' activateModalDialog comes last, which puts the return block where the original has it (with the test turned round it read 0.9305 in quick_diff); - the request path is one if / else-if chain that closes the dialog once at its end, with the five command stores and queueCommand written in both arms that send. The "not enough" arm comes first in the second (accepted first reads 0.9732); - good <= -1, as the original compares with -1 (good < 0 reads 0.9923); - the send path has one local for the resource, one for the type it is stored as, and one for the amount. Uses the header commit before this one (the amount is an int), so no cast on it is left. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * headers: IngameInvasionEventItemContent has an int at 0xA4 MenuItemActionHandler_General_EventSlider (0x004B9E50) reads the four bytes at 0xA4 as one int, the highest value of the invasion's slider: mov eax, dword ptr [0x01667EEC] at 0x004B9E86 (DAT_MapPropertiesState's invasionEventContent + 0xA4), which it then stores to *maxValue and clamps field_0xa8 with. The header had them as undefined1 padding_0xa4[4], which needs *(int*)&...padding_0xa4[0] to read. Named field_0xa4 like its neighbours field_0xa0 and field_0xa8; the struct's size and layout are unchanged, and nothing on main names the padding. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004B9E50 100.0% Reimplemented General::MenuItemActionHandler_General_EventSlider, from gynt's draft: cbdee60 and 7c31877 (45.3%, upstream's reimpl/UI-MenuItems), d0aa6c7 and 899dcd2 (55.93% and 69.21%, his fork's reimpl/UI-MenuItems), 514b907 (83.26%) and dd1a7c4 of 2026-11-02, his newest commit on the file (his fork's reimpl/UI-MenuItems-development). Our 2001534 and bddd6be in draft sourcehold#327 read 88.0%. What the match needed, on top of the draft: - the two range tests against the limit compare *currentValue > limit (cmp [ecx], eax / jle); the draft had limit < *currentValue, which swaps the operands; - in the repeat slider's switch, case 7 comes before case 4, as it already did in the months slider's. That alone took it from register names only (0.9322 in quick_diff, the three small blocks of the months slider on rotated registers) to every instruction. Readability, all measured equal: the lists of cases that only break are gone from both switches on the slider; the two step cases use ++ and --, as the invasion slider's do, and no longer the limit's local; no cast on the byte fields, read or written; the parameters are slider and scrollbarEvent, as main's other slider handlers have the second; the amount sliders' cases are written as their event type plus one (the function compares the type with slider - 1). Uses the header commit before this one (the invasion's limit is an int field). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0042D140 100.0% Reimplemented SinglePlayerMapChoice::MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands, rewritten from the listing on top of gynt's draft: 582f0a0 and 6918f23 (14.3%, upstream's reimpl/UI-MenuItems), 47663d0 (29.50%, his fork's development), 1ff44c3 to eaf674d (20.55% to 44.64%, his fork's reimpl/UI-MenuItems), b4b1f65 (45.29%) and dd1a7c4 of 2026-11-02, his newest commit on the file (his fork's reimpl/UI-MenuItems-development). Our dcaa477, 53bea5f and 07a33e2 in draft sourcehold#328 read 46.8%. Behaviour: unchanged. The draft cleared DAT_ButtonUnknownZero after the switch for buttons 2 and 65; here each of the two clears it itself, before its call, as the original does. The draft's gotos into a shared text call are gone. What the match needed: - every case breaks to one store of the draw buffer at the end (the compiler copies it into the arms, with pop edi before it, as the original has it); the draft stored and returned in every arm; - each text is drawn by a call of its own in each arm of the colour test, and renderBasicButton is called in each of button 74's three arms and button 77's two; - case 78 is written out with its own store and return: the original's switch has a table entry for it, though it ends in the same block as the default (with a plain break, or left to the default, the range check reads cmp eax, 178 where the original has 179); - the map-index sum in button 65 is DAT_MapSelectionScrollOffset + DAT_MapSelectionRelativeSelected: the other order loads the two fields the other way round (reccmp 99.6%; quick_diff does not see it). Readability, measured equal: X + W / 2 and X + W - 10 for the text positions. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004708F0 80.4% Reimplemented, register choice only WindowAndDirectDraw::reinitWindow's status line carries its measured percentage instead of 100% (the review asked for the lower percentage with a remark). A narrow build of this branch's head c6df741, both resolver sets on, sourcehold's reccmp with --ignore-security-cookie: 80.4% raw, 80.5% normalised. Both sides have the same 56 instructions in the same order with the same memory operands; the difference is which of eax, ecx and edx loads this->windowHandle in front of the SetFocus, ClientToScreen and UpdateWindow calls (sourcehold#414). The code is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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.
Eight UI::MenuItems functions at 100%, each with its status line: the invasion trigger screen, the in-game menu's map scrolling, the skirmish type and balance buttons, the rankings screen, the single-player map table and its scrollbar, the "waiting for host" button and the text input display.
Three come from our drafts, which drop them in the same push: TriggerInvasion from #328, Scrolling from #327 and MapTable from #318. The other five continue gynt's drafts on his fork's
reimpl/UI-MenuItems(the branch of PR #254). Every commit body says what changed against the draft and why. No header change is left: gynt's Ghidra sync eef6f66 took this PR's five header changes into main, two of them with a different type, which this PR now follows (below), and main is merged in (e5c6b15). Its first two header changes are on main since gynt's sync 8125c61, and main is merged in.Other PRs: the ready #348 and #352, and the drafts #313, #318, #321, #327 and #328.
Built on top of
main(7621d4f) with the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a). The branch was built clean on its own, with the struct and function resolvers enabled locally (not committed), using sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. None of it has been run in game.It went through the same checks as #346: a fresh-eyes review of every file (behaviour checked against the original's disassembly, texts against cr.tex; its points applied and measured),
openshc-pr-checkwith no errors, andstatus_regression.py, which finds nothing below a known score on main or any fork.Header changes
Update: all five are on main since eef6f66. Main has
DAT_SH1_SiegeAdvancedModeandDAT_StoredGameModeas plainints rather than theBOOLEnumandGameModeIntbelow, and this PR follows main: MapTable stores1, and nothing on the branch usesDAT_StoredGameMode. Every function measures as in the table. The evidence below is kept for the record.Every user compiles the same (quick_diff before and after: main's RankingGames_Main 0.9506, RankingGames_Prepare 0.9091, CrusadeMapAndEndscreen 0.9464 and TriggerPlaceWallCommand 0.9748, which came in #351; this PR's MapTable 0.9807).
DAT_SH1_SiegeAdvancedModeis aBOOLEnum(0bc6102): stores^1at 0x0042D81F, 0 at 0x0042D855 / 0x00448DC2 and 1 at 0x00442E66; it's only read with== 0. MapTable storesTRUE(9b3d5a0).DAT_StoredGameModeis aGameModeInt(d4c1b5e): its one store copiesGameSynchronyState::currentGameMode(0x004D972A), and its one read copies it back.DAT_SkirmishTrailRelated1is anint(18f83c2): a count that goes below 0 (stores at 0x004D8D48 / 0x004D8DD5,subat 0x004D8F3B, clamped withjgeat 0x004D8DDB); CrusadeMapAndEndscreen drops its(int)cast (df6428e).MissionDefinedData::descendingis aBOOLEnum(b78dc7c): stores 1 at 0x004D995F, and1 - descendingat 0x004D9970 / 0x004D9976.TileMapState::wallDragButtonUpis aBOOLEnum(67b91e0): its one store (0x0043803E) writes asete(0x00438034).On main since 8125c61
MenuItemActionHandler_InGameMenu_Scrolling()takes no parameters (commit 181b559). The original ends withpush 1 / call RecordTutorialPlayerAction / pop ecx(0x00434200-0x00434207) and never reads an argument; it is referenced only by six menu-table dwords (0x005F4B6C, 0x005FA79C, 0x0060613C, 0x0060622C, 0x0060636C, 0x006081BC) and never called directly. Declared(int, ...), MSVC tail-calls through the argument slot instead (mov [esp + 4], 1 / jmp; quick_diff 0.9343 -> 0.9710 with the change). Main declares 16 such handlers(), for example WaitingForHost_ConnectToLobby.SEID_UNKNOWN_0xFE/0xFF/0x100(254-256) (commit 1572310): SkirmishTypeAndBalance plays them when the balance changes, 256 at either end (buttons 10 and 14), 255 one step from even (11, 13), 254 at even (12). They're pushed at 0x0042A888, 0x0042A8A1 and 0x0042A8B5, and setUpSFXToPlayUnk indexes the 270-entryDAT_SoundStructures2with them. The names follow the enum's existingSEID_UNKNOWN_0x101, next to main's new 0xFB and 0xFD.Behaviour compared with the drafts
None of the eight changes behaviour; each does what its draft did and what the original does.
RecordTutorialPlayerAction(1)is a call again.param_1 - 1U <= 2isbutton >= 1 && button <= 3(the same set), and the sound IDs, written(SoundEffectID)0x100and as ORs of unrelated names in the draft, now have names.MenuItemRenderFunction_TriggerInvasion_MainDAT_GMImageHeaders(as 0x004B92D0 on main).MenuItemActionHandler_InGameMenu_ScrollingMenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalanceMenuItemRenderFunction_RankingGames_MainDAT_00ed3124to 1 and 2 and back to 0.MenuItemActionHandler_SingleplayerMapChoice_MapTableMenuItemRenderFunction_WaitingForHost_ButtonMenuItemActionHandler_SingleplayerMapChoice_ScrollbarMenuItemRenderFunction_TextInputDisplayKept as they are, and why
Each was measured; a one-line comment in the code says why.
== TRUE, since the original compares with 1.break, so the loop's exit jumps past the clearing as the original's does (jg 0x00442DE3 -> 0x00442E64; testing for the end after the loop: 0.9807 -> 0.9753). The siege army's 21 unit counts are read as one array, as the original does (nested[7][3]searches: 0.9807 -> 0.8696), andSEC_SiegeInformationas 20 ints.Proposed, not changed here
DAT_SiegeInformationArrayis read here asint[21]rather thanint[7][3], andSiegeUnitCountsasint[20](an array view would help). Index 10 is overwritten with 70% of the tunnelers right after the copy. (int[7][3]is right: main's SomeSiegeRelatedCopying indexes it[unit][value]; the flat view here is a code choice.)DAT_00ed3124-> something likerankingFilterUnk(0, 1, 2);DAT_00ed27a0->rankingHoveredHeaderUnk(button 20 clears it, a hovered header 20-31 stores itself).INT_00b95b74->mapDescriptionHeight(the height renderMultilineTextUnk mode 1 measures; MapDescriptionScrollbar's maximum is this - 231), andDAT_00b960f4->mapDescriptionScrollOffset.DAT_MapMissionType(buttons 66/67/68 set 0/1/2; 2 is siege) needs an enum of its own, since MapType2's numbering differs.RecordTutorialPlayerAction(int action): actions 1 (the view scrolled), 2 (rotation), 3, 4, 5 and 17 could be an enum.GameCore::isNameEntryActivereads inverted (as in Reimplement 5 UI::MenuItems SaveLoadMap and Unused functions at 100% #341 and Reimplement 6 UI::MenuItems text button renders at 100% #345): TextInputDisplay's field 3, the title box, is hidden while it is 1.gynt's other commits on these functions
Each commit body names the commits it continues. gynt has more on the same functions on his fork, and they are credited here too: his best-scoring commit on the address and his newest one on the file, where the body doesn't name them. Where one of them is at 100%, his version already matched the original, and a fix this text describes for that function was only against the earlier draft it names.
MenuItemRenderFunction_TriggerInvasion_MainMenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalanceMenuItemRenderFunction_RankingGames_MainMenuItemActionHandler_SingleplayerMapChoice_MapTableMenuItemRenderFunction_WaitingForHost_ButtonMenuItemActionHandler_InGameMenu_ScrollingMenuItemActionHandler_SingleplayerMapChoice_ScrollbarMenuItemRenderFunction_General_TextInputDisplay🤖 Generated with Claude Code