Skip to content

One more Map::Units function at 100%: UpdateSiegeTent - #473

Open
kotijekriv wants to merge 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/units-D-siegetent-100
Open

kotijekriv wants to merge 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/units-D-siegetent-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

One more function at 100%, with no header changes. Units::UpdateSiegeTent is from gynt's units branch
reimpl/map-units-updatefunctions (his draft #204; his #286, merged into that branch as c933f79, took this
file's body from reimpl/Wilps-2026-10-18), and the commit credits him as co-author.

Function Address Before After
Units::UpdateSiegeTent 0x005307B0 gynt's draft 69.44% (8d684a9) 100.0%, under /GL

What got it to 100%. One store moved and one written twice:

  • The ULS_TRANSITIONING store stands in front of the fixedRng & 2 test, as in the original (0x005307FA). The
    draft wrote it in both arms, so the merged store landed behind the test.
  • With one store in front of the if, MSVC turns the type into a branch-free select (sbb): so the state_2 store
    (US_FIRE_WEAPONUnk) is written in both arms behind the type store. The compiler merges the two copies into one
    store behind the join (0x0053082C) and keeps the original's branches (0x0053080B / 0x00530816).
  • The frame >= 4 test after & 3 can never be true, but the original compares and stores it (0x005307D1): it
    stays, with a fixme: comment.
  • Names: buildingEntryInfos[BEIE_KEEP] for the keep's entry (y is read before x, hence the two locals).
    field_0x3bc has no better name in this tree; in gynt's catapult, ballista and fire-ballista drafts it is set to
    -40 .. -200 and counted up before firing, so it is probably the siege engines' reload cooldown (reset here so a
    new engine can fire at once).

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 this commit on main 0e4a83b, with both resolver sets on and the branch's own /GL list (main's plus the one line this commit adds), and with 0x004314E0 (the MapEditorLandscaping_GeneralButtons handler) left out and its resolver off, as in main's baseline: 0 failed of 2,426 compile steps, 99.58 over 2,442 functions. UpdateSiegeTent reads 100.0 raw and normalised there too, with no diff entry. No main function reads differently: 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 UI: the single-player game launch at 100% #466's LaunchSinglePlayerGameUnk at 100.0 and Constructor_MenuModal_ProgressBarBox at 100.0 (93.8 before One more UI::MenuModals function at 100%: ProgressBarBox #467); 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).
  • Our own narrower run: real builds of our units stack's head (Reimplement 47 UnitsState functions at 100% and restyle 28 more #378 and the units on it; every header this file
    includes is the same there as on main 0e4a83b, and its one callee, calculatePreferredRelativeOrientation,
    is reimplemented in neither). With this file and its /GL line: UpdateSiegeTent 100.0% raw and normalised, no
    diff entries, 345 functions, none of the other 344 reading differently from the build without it.
  • Not run in game.

Checks: openshc-pr-check gives 0 ERROR and 1 CHECK: field_0x3bc is a placeholder name (see above).

Other PRs

🤖 Generated with Claude Code

Units::UpdateSiegeTent, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; the
file's commits there: 609ef6d, the 69.44% import, then his 2fe31a8, 8d684a9 at 69.44%, 974c32f's
clang-format, and c933f79, his PR 286 merged into that branch, which took this file's body from
reimpl/Wilps-2026-10-18). It reads a true 100.0 / 100.0. The statements are his; what the text needed is where
two of them stand.

1. The ULS_TRANSITIONING store stands in front of the `fixedRng & 2` test, as in the original (0x005307FA, the
   test at 0x00530803). The draft wrote it in both arms so that the type stays a branch, and the compiler then
   placed the merged store behind the test. Written once in front of the if, the type becomes a branch-free select
   (sbb) unless the arms hold more than the one store: so the state_2 store, behind the keep reads in the draft,
   is written in both arms behind the type store. The compiler merges the two copies into the one store behind
   the join (0x0053082C) and keeps the branches (0x0053080B / 0x00530816).
2. The names of this tree: field_0x3bc; the keep's entry as playerDataArray[1].buildingEntryInfos[BEIE_KEEP]
   (yEntry 0x0115F888 and xEntry 0x0115F884 are read in that order, hence the two locals); state_2's 6 as
   US_FIRE_WEAPONUnk (changeUnitType, 0x0053E6C0, copies state_2 into the new engine's state).
3. The `frame >= 4` test after `& 3` is never true, but the original compares and stores it (0x005307D1), so it
   stays, with a fixme comment; `(fixedRng + 1) & 3` in parentheses, `animationCycleNumber++`, const locals.

Measured with real builds of the units stack's head 6e3de74062 (the headers this file includes are the same there
as on main 0e4a83b; its one callee, calculatePreferredRelativeOrientation, is reimplemented in neither), the
whole build list plus this file and its /GL line, BUILD_OK each: UpdateSiegeTent 100.0 raw / 100.0 normalised,
no diff entry, 345 functions; none of the other 344 reads differently. The text before the review's text
fixes (the two enum names, the comments, const locals) read the same.

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