Skip to content

Two UI::MenuModals functions at 100%: ChooseNetworkServiceProvider and FindingNetworkSessions - #474

Open
kotijekriv wants to merge 2 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-A-netmodals-100
Open

kotijekriv wants to merge 2 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-A-netmodals-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

Two more functions at 100%, moved out of our open draft #360, with no header changes and no line for cmake/compiler-flags-gl.txt. One behaviour fix against gynt's draft of the first (below). Both draw a modal of the multiplayer connection screens, and both are from gynt's drafts on his fork's reimpl/UI-MenuModals-development (his closed #252 had earlier versions); each commit credits him as co-author.

  • ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider draws the service-provider modal: its banner, the "You Were Ejected!" notice while it shows, the providers' list in a framed box, and on the modem tab a second framed box below it.
  • FindingNetworkSessions::MenuModalRenderFunction_FindingNetworkSessions draws the modal shown while the game searches for sessions: its banner, the session list's framed box and the searching animation.
Function Address Before After
ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider 0x0047C860 65.1% in the draft PR (5485692, gynt's code with the behaviour fix); gynt's draft 65.32% (968b1ee; 65.13% at 8f37773) 100.0%, off the /GL list and on it
FindingNetworkSessions::MenuModalRenderFunction_FindingNetworkSessions 0x0047D190 66.9% in the draft PR (e01e709, gynt's code restyled); gynt's draft 66.91% (9ae7d0b; 57.97% at e4d0a08, 58.30% at 861024c, 39.1% at 4462f5d) 100.0%, off the /GL list and on it

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie.
  • Full build: an all-on build of the previous cut of this branch on main 0e4a83b (the same code: the cut since changes one comment in FindingNetworkSessions and the commit message, and compiles to the same listing), with both resolver sets on and main's own /GL list (neither file is on it), and with 0x004314E0 (the MapEditorLandscaping_GeneralButtons handler) left out and its resolver off, as in main's baseline: 0 failed of 2,427 compile steps, 99.58 over 2,443 functions. MenuModalRenderFunction_ChooseNetworkServiceProvider and MenuModalRenderFunction_FindingNetworkSessions read 100.0 raw and normalised there too, with no diff entry, and main's Constructor_MenuModal_ChooseNetworkServiceProvider and Constructor_MenuModal_FindingNetworkSessions, which pass these functions' addresses to their modals, go from 93.8 (92.3 normalised) to 100.0, as Constructor_MenuModal_ProgressBarBox did with One more UI::MenuModals function at 100%: ProgressBarBox #467. Two main functions read lower, and it is how reccmp prints a constant, not their code: Menu::handleMenuItems (0x004F6280) reads 97.9 (91.4 normalised) and Menu::Constructor_Menu (0x004F4100) 98.4 (95.2), both 100.0 before. Both compare a menu item's type with the constant 0x11000000, five compares in all; in this build's layout a symbol of our DLL lies at exactly that address, so reccmp prints the constant as that symbol's name on our side, and the instructions are the same on both sides (UI: the single-player game launch at 100% #466 describes the same two readings). Every other function reads exactly what it read before; 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's MenuModalRenderFunction_ProgressBarBox and its constructor, UI: the single-player game launch at 100% #466's LaunchSinglePlayerGameUnk) (unrounded 99.5827 raw and 99.5540 normalised, 2,327 functions at 100.0 raw; with those two at 100.0, 99.5842 and 99.5594, 2,329; main 0e4a83b alone: 99.5788 and 99.5528 over 2,441, 2,325 at 100.0).
  • Our own narrower runs: the 133 files of main's /GL list that exist on main, and one of the two files, off the list: 144 functions, average 99.56. Each function reads 100.0% raw and normalised, with no diff entries, and the same with its file on the list. The other 143 functions read the same as without the file. Those builds had slightly earlier texts (ChooseNetworkServiceProvider with the colour casts, one unused include and shorter comments; FindingNetworkSessions with a shorter comment); quick_diff gives the same instructions, line for line, for these texts. The sources were main's at 3458fea; main's commits since add cmake files and tools, and two other UI functions' files (UI: the single-player game launch at 100% #466, One more UI::MenuModals function at 100%: ProgressBarBox #467).
  • Instructions: the originals' 177 and 138, in their order; reccmp's diffs for the two functions are empty.
  • Please measure with both resolver switches on (the Globals and the function resolvers), as our numbers are.
  • Checks: our local style checker gives 0 ERROR and 1 CHECK (field_0x474, a placeholder name; below); our local fixer finds nothing to change.
  • Not run in game.

The behaviour fix (ChooseNetworkServiceProvider)

  • The modem tab's box reaches from y + 265 to y + 345. The original takes the top first (lea ebx, [edi + 0x109] at 0x0047C9C5) and then moves y on to the bottom (add edi, 0x159).
  • gynt's draft moved y first and then wrote the top as y + 265, which made it y + 610: 345 pixels below where it belongs, and the frame's lines with it. It came in with his 968b1ee (65.32%), which replaced the local of his 8f37773 (65.13%), so the 0.2 points between the two were a changed value. sourcehold's reimpl/UI-MenuModals has the top right.
  • Here the top is y + 265 and the bottom y + 345, the edges of the second frame (below).

What got them to 100%

  • Each frame is written in a block with its four edges as locals. The frames run from x + 40 to x + 460: the outline is one pixel outside that (x + 39 to x + 461), and the dimmed box ends at the scroll bar's column line at x + 440. With left = x + 40, top, right = x + 460 and bottom as int const locals, the box is (left, top, right - 20, bottom), the outline runs from left - 1 to right + 1, and the column is at right - 20. ChooseNetworkServiceProvider has two such frames, the list (y + 85 to y + 165) and the modem tab's box (y + 265 to y + 345); FindingNetworkSessions has one, the session list (y + 85 to y + 285), with the column's two squares (right - 20 to right + 1 at top + 20, right - 19 to right at bottom - 20). A comment on each block says why it is one.
  • ChooseNetworkServiceProvider: that is how the original computes them. It keeps each frame's top in ebx (0x0047C907, 0x0047C9C5). In the list's frame it keeps the left edge less 1 in y's stack slot (0x0047C91C, read back at 0x0047C934, 0x0047C94A and 0x0047C96E) and computes x + 461 again for each line that uses it; in the modem box's it keeps x + 440 in that slot (0x0047C9E3, read back at 0x0047CA5A) and x + 461 in esi (0x0047C9F8). The draft had locals for the list's top, bottom and left edge less 1, wrote the other values out at each call, and moved y and x on for the modem box. There x and y swapped esi and edi, and x + 440 kept ebx, where the original keeps the list's top: quick_diff 0.6780, the same 177 instructions. With only the list's frame in a block, the modem box's top and left edge swap ebx and ebp (0.9435). With both blocks it reads 1.0000. The edges' declaration order does not matter here: both orders we tried (left, top, right, bottom, and One more UI::MenuItems function at 100%: LobbyMenu MapDesc #464's right, left, top, bottom) give the same listing, and so does int without const.
  • FindingNetworkSessions: the same, and there the order matters. x's register becomes the right edge (add ebp, 0x1cc at 0x0047D1C7) and y's the bottom (add edi, 0x11d at 0x0047D1CD), and the left edge less 1 is taken from x's stack slot (0x0047D1EB, 0x0047D1F8) and kept in a slot of its own (0x0047D1FC; a 4-byte frame). In the draft, with the top, the bottom, the right edge and the outline's two edges (right + 1, x + 39) as locals and the box's left edge written out, the right edge did not take x's register, x was not read again, and the function came out four instructions shorter, without that frame (quick_diff 0.6691, 134 instructions against 138). Of the 24 declaration orders of the four edges, the three with left before right, top before bottom and right before bottom give the original's listing: left, top, right, bottom (as here), top, left, right, bottom, and left, right, top, bottom (quick_diff 0.9928, which is quick_diff's display of the % 32 mask; reccmp reads 100.0 for ours). The other 21 keep 138 instructions: with the bottom declared before the right edge only the two additions swap (three orders, 0.9855), and with right before left or bottom before top the registers differ (18 orders, 0.8478 to 0.9638).
  • The banner's text section: main's drawHeaderTextBanner takes an eTextSections since Fix main's build: drawHeaderTextBanner and its 15 callers take eTextSections #387, so both drafts' 76 is TEXT_MULTIPLAYER_CONNECTION (FindingNetworkSessions now includes eTextSections.hpp).
  • ChooseNetworkServiceProvider's other spellings, with the same listing: y - 0x3c is y - 60, the kick timer's test reads timeGetTime() - kickedAtTime > 5000 (the draft had 5000 < ...), an unused include is dropped, and so are the casts on the lines' colour. gynt's newest commit on the file, af1d790 on his reimpl/UI-MenuItems-development (45.8% there), writes that test as DVar2 > 5000 - kickedAtTime, which is a different test; the original subtracts first (sub eax, [kickedAtTime], cmp eax, 0x1388, jbe), as this does.

No line for cmake/compiler-flags-gl.txt

Proposed, not changed here

  • ProtocolDefinedData::field_0x474 (int[32]) is the searching animation's frame table (the checker's CHECK): FindingNetworkSessions draws picture 398 plus entry (tick / 2) % 32 of it. Its 32 values in the exe are 0 to 7, 7, 7, 6 down to 1, then 8 to 15, 15, 15, 14 down to 9: pictures 398 to 413, each run of eight played out and back. Nothing else in the original reads it (one reference, at 0x0047D2E7), and no other code on main. gynt's reimpl/Wilps-2026-10-18 already calls it sessionSearchAnimFrames (8ca7861); that is a header change, so it is left out of this PR.

Other PRs

🤖 Generated with Claude Code

kotijekriv and others added 2 commits November 23, 2026 00:53
ChooseNetworkServiceProvider::MenuModalRenderFunction_ChooseNetworkServiceProvider, moved out of our draft sourcehold#360
(5485692, 65.1%), from Gynt's draft (968b1ee at 65.32% on his fork's reimpl/UI-MenuModals-development; his
closed sourcehold#252 had an earlier version). One behaviour fix against his draft, already in sourcehold#360: the modem tab's second
box reaches from y + 265 to y + 345; his draft moved y on to the bottom first and then drew the top at y + 265 from
there (y + 610). The original takes the top first (0x0047C9C5), as sourcehold's reimpl/UI-MenuModals has it and as
this does.

Both frames, the list's (y + 85 to y + 165) and the modem tab's (y + 265 to y + 345), run from x + 40 to x + 460:
the outline is one pixel outside that (x + 39 to x + 461), and the dimmed box ends at the scroll bar's column line
at x + 440. Each is written in a block with its four edges as int const locals (left = x + 40, top, right = x +
460, bottom) and every coordinate written from them. The original keeps each frame's top in ebx (0x0047C907,
0x0047C9C5). In the list's frame it keeps the left edge less 1 in y's stack slot (0x0047C91C, read back at
0x0047C934, 0x0047C94A and 0x0047C96E) and computes x + 461 again for each line that uses it; in the modem box's it
keeps x + 440 in that slot (0x0047C9E3) and x + 461 in esi (0x0047C9F8). In the draft x and y swapped esi and edi,
and x + 440 kept ebx, where the original keeps the list's top (quick_diff 0.6780, 177 instructions against 177).
With only the list's frame in a block, the modem box's top and left edge swap ebx and ebp (0.9435); with both
blocks the listing is the original's (1.0000). Both orders tried for the edges (left, top, right, bottom and right,
left, top, bottom) give the same listing, and so does int without const. A comment on each block says why it is
one.

On main since sourcehold#387 drawHeaderTextBanner takes an eTextSections: the banner's 76 is TEXT_MULTIPLAYER_CONNECTION. y -
0x3c is written y - 60, and the kick timer's test the other way round (timeGetTime() - kickedAtTime > 5000), with
the same listing; an unused include is dropped, and so are the casts on the lines' colour (the same listing).
Gynt's newest commit on the file, af1d790 on his reimpl/UI-MenuItems-development (2026-11-02, 45.8% there),
writes that test as `DVar2 > 5000 - kickedAtTime`, which is a different test; the original subtracts first (`sub
eax`, `cmp eax, 0x1388`, `jbe`), as this does.

No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too. reccmp in a
build of main's whole /GL list (the 133 files that exist) and this file, off the list, with every resolver of those
files on: 144 functions, average 99.56. The function 100.0% raw and normalised, no differing line; the other 143
functions read the same as without the file. That build had the casts, the include and shorter comments; quick_diff
gives the same 177 instructions, line for line, for this text. The sources were main's at 3458fea; main's commits
since add cmake files and tools, and two other UI functions' files (sourcehold#466, sourcehold#467).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FindingNetworkSessions::MenuModalRenderFunction_FindingNetworkSessions, moved out of our draft sourcehold#360 (e01e709,
66.9%), from Gynt's draft (9ae7d0b at 66.91% on his fork's reimpl/UI-MenuModals-development, "orig spills one
local"; before it 57.97% at e4d0a08, 58.30% at 861024c and 39.1% at 4462f5d / 70f15af; his closed sourcehold#252
had an earlier version). The draft computes what the original computes; no behaviour is changed against it.

The session list's frame (a dimmed box, its outline, the scroll bar's column and the column's two squares) is
written in a block with its four edges as int const locals, declared left, top, right, bottom (left = x + 40, top =
y + 85, right = x + 460, bottom = y + 285), and every coordinate is written from them. That is how the original
computes them: x's register becomes the right edge (add ebp, 0x1cc at 0x0047D1C7) and y's the bottom (add edi, 0x11d
at 0x0047D1CD), and the left edge less 1 is taken from x's stack slot (0x0047D1EB, 0x0047D1F8) and kept in a slot of
its own (0x0047D1FC). In the draft, with the top, the bottom, the right edge and the outline's two edges (right + 1,
x + 39) as locals and the box's left edge written out, the right edge did not take x's register, x was not read
again, and the function came out four instructions shorter, without the 4-byte frame (quick_diff 0.6691, 134
instructions against 138). Of the 24 declaration orders, the three with left before right, top before bottom and
right before bottom give the original's listing (left, top, right, bottom as here; top, left, right, bottom; left,
right, top, bottom). The other 21 keep 138 instructions: with the bottom declared before the right edge only the two
additions swap (3 orders, quick_diff 0.9855); with right before left or bottom before top the registers differ (18
orders, 0.8478 to 0.9638). A comment on the block says why it is one.

On main since sourcehold#387 drawHeaderTextBanner takes an eTextSections: the banner's 76 is TEXT_MULTIPLAYER_CONNECTION, and
eTextSections.hpp is included.

No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too.

reccmp in a build of main's whole /GL list (the 133 files that exist) and this file, off the list, with every
resolver of those files on: 144 functions, average 99.56. The function 100.0% raw and normalised, no differing
line; the other 143 functions read the same as without the file. That build had a shorter comment on the block;
quick_diff gives the same 138 instructions, line for line, for this text. The sources were main's at 3458fea;
main's commits since add cmake files and tools, and two other UI functions' files (sourcehold#466, sourcehold#467).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant