Repository navigation
UI: the crusader trail's mission intro screen at 100% - #455
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
MenuViews::CrusadeMissionIntro::MenuView_CrusadeMissionIntro_DoEveryFrame, the crusader trail's mission intro screen: the map preview with the keeps, the lords' gold, the mission's number and name, and the opponents sorted by team. Written from the original's listing. gynt's best is b4fa695 on his fork's archive/UI-MenuViews-merged-full (53.54%, "Style pass"; its status line reads 53.5%); his closed sourcehold#253 has 35.8%, and his later 1958ae8 ("Early returns", 42.04%, on reimpl/UI-MenuViews-development, now 45.0% at 466d2ea) has the three returns already. His 08c492b on reimpl/UI-MenuItems-development (38.6%) writes the id test as `<= 0`, where the original compares with 1 (0x004DE193), so it stays `id < 1` here. One behaviour fix against b4fa695: when the current trail is complete (extreme 20, war chest 30, first edition 50 missions) the original draws "Crusader Trail Completed!" and returns (three copies, 0x004DD7F7 to 0x004DD8E2); b4fa695 draws the text and then the whole screen as well. Everything else it does the way the original does. What the match needed: - The title written out per trail and per font: the number, "." and name six times over, as the original has them (its six arms end in two shared tails, one per font). With one copy and the font in a local, the function came out at 588 instructions to the original's 822. - The position (y, then x) of the completed-trail message, of the lords' texts and of the mission's name in locals right before each call, and the name's index for the width test and for the name itself. Written inline, the compiler merges the three message copies the original keeps, hands the scratch registers out in another order from the lords' texts on, and the six title arms do not share their tails. - The opponents' list in the original's two paths: the team stored in each arm of the game-suspended test, and the no-lord arm counting and continuing on its own. With one count after the test the entries are walked through one pointer where the original walks one per field. - The time tests compare the map time first, as the original does. - avatarX copied from listX after rowY: copied straight after listX, the border height is read only once (the original reads it twice). - The rows' previous team in its own variable, set with the draw buffer before the two positions: with the sort's variable reused, listX, avatarY and the previous team take other stack slots. Measured in a narrow build on main 3458fea of this file alone (main is now 812d149: sourcehold#399 and sourcehold#398 add only the optional function-visibility units, off by default), struct resolvers and its resolver on: 100.0% raw and normalised, no diff entry. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.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 24 — Declare variables upon first use
|
This branch has not been deployed
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%, written from the original's listing with gynt's draft beside it. No header changes. One behaviour fix against his best-scoring draft, one he also made on a later branch (below).
MenuViews::CrusadeMissionIntro::MenuView_CrusadeMissionIntro_DoEveryFramegynt's best, 53.54%, is b4fa695 ("Style pass", 2026-10-25) on his fork's archive/UI-MenuViews-merged-full, from after he closed #253 (reimpl/UI-MenuViews), which has the function at 35.8% (2dd4786). Two days later he found the missing returns himself: 1958ae8 ("Early returns", 42.04%) on his reimpl/UI-MenuViews-development, which has the function at 45.0% (466d2ea). His 08c492b on reimpl/UI-MenuItems-development (38.6%) writes the id test as
<= 0; the original compares with 1 (0x004DE193), so it staysid < 1here.Measured
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. The struct resolvers and the function resolvers are enabled locally (not committed). In the full build 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) is left out and its resolver stays off, as in main's baseline.tools/, cmake: optional wrapper units built from function-visibility.txt #399's 02fab42 the optional function-visibility units, off by default, and cmake: function-visibility.txt, which callers must see which callees' bodies #398 one line to the optional units' list). The new function reads 100.0 raw and normalised there too. Unrounded, the average is 99.5802 against 99.5759 (normalised 99.5535 / 99.5492; 2,324 at 100.0 raw against 2,322). One main function moves, up:Global::Init::Constructor_MenuView_CrusadeMissionIntro(0x0059A9A0) goes from 90.0 to 100.0 raw and normalised, because the only difference on main, the callback it pushes (a trampoline to 0x004DD7B0 against the original's bare address), now pairs with this function. main already records it as 100% with Reimplement 176 static initializers and GetStringBasedOnHardcodedMaps #405's remark ("counted: only the pushed callback address is unnamed in the original"). All 174 of Reimplement 176 static initializers and GetStringBasedOnHardcodedMaps #405's static constructors carry that remark, and 137 of them already read 100.0 raw in main's own all-on build and keep it, so the status line is left as it is. No other function changes.lea ecx, [ecx],nop, twolea esp, [esp]), in its order; reccmp's diff for the function is empty. The function has no switch table.The behaviour fix
The function draws the mission intro screen of a crusader trail: the map's preview with the keeps, the lords' starting gold, the mission's number and name, and the opponents sorted by team.
RenderGfxHelperUnk, which both paths call). With 20 extreme missions, 30 war chest missions or 50 first-edition missions done, it draws "Crusader Trail Completed!" and returns (three copies, 0x004DD7F7 to 0x004DD8E2). gynt's b4fa695 draws the message and then the whole screen as well; his later 1958ae8 ("Early returns") adds the three returns, as this file has them.In play, the draft's screen for a finished trail went on past the message: it loaded the campaign data for the mission after the trail's last (when the game is not suspended), drew the boxes over the message, and titled them with the next name in the list: "51. First Step" (the war chest's first mission) after the first edition, "81. Look Out" (the extreme trail's first) after the war chest, and "21. MP-Divided" (a multiplayer map) after the extreme trail.
Read block by block against the listing, b4fa695 does everything else the way the original does.
What got it to 100%
getText: the position (y, then x) of the completed-trail message, of the lords' texts and of the mission's name, and the name's index for the width test and for the name itself. Written inline, the compiler merges the three message copies the original keeps, hands the scratch registers out in another order from the lords' texts on, and the six title arms (three trails, two fonts) do not share their tails as the original's do.cmp [time], reg; jledoes.Things in the file that look odd and are the original's
teams[id - 1]in the rows), while the no-lord flags are stored and read by player id. Kept as the original has it (the two agree while every player from 1 up to that id takes part).sorted[k + 1]and the rows readsorted[n]from 1.= 0puts axorwhere the original loads the slot, so a comment says so). main's style-lint bot will post one finding for it.section1127) is written twice, before and after the avatar, as the original tests it twice.Checker CHECKs (not changed)
MissionDefinedData::field_0xaf8, a byte; when it is 0 the screen draws nothing.RenderingDefinedData::field_0x53bb4, read as pairs by(balance + intensity * 5)and drawn as the human's and the computer lords' gold (times 3 on the extreme trail).INT_00eb9ae8, 0 until the map header is read;CHAR_ARRAY_00eb0ab0, the name passed toReadMapHeaderFromFile.lowestTeam, declared without a value: see "look odd" above. (The three arrays and the struct's array have no initialiser either; the loops below them zero them, as the original zeroes them store by store.)(int)casts onGameCorefields: see below.Header finding (nothing changed here)
GameCore::mapTimeInTicksis auintandGameCore::section1127adword, but the original compares them signed (jle), so the code casts both toint. Retyping them would drop the casts; not done here, since every user would need measuring.section1127is stored together withmapTimeInTicks(0x00441771, 0x004C63DB) and read elsewhere asmapTimeInTicks - section1127(0x004AC570), so it looks like the map time at a starting point.🤖 Generated with Claude Code