Repository navigation
One more UI function at 100%: StatusMenus::RenderStatusMenu_Chimp - #463
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
StatusMenus::RenderStatusMenu_Chimp, from Gynt's draft (67318e1 at 56.7% on his fork's reimpl/UI-StatusMenus-development). That draft is the decompiler's output and computes what the original computes; no behaviour is changed against it. His earlier copies (47.57% at c8bfbb7; 49.6% at 9ec9106, his closed sourcehold#251) go on after switching back to the build menu for an empty slot; he recovered that return in 109e64f (51.5%, sourcehold's reimpl/UI-StatusMenus), and it is here as in the original (0x00447A84). Rewritten against the original instructions: - the flag for a newly selected unit is cleared in front of the getPeasantGmID call (the original zeroes its register there, 0x00447A8C) and set behind it, as in his 56.7% draft; - the name text is most likely TextManager::renderTextFromTextGroup (0x00424470), inlined. Its body is renderTextToScreen(getTextStringInGroupAtOffset(group, index), x, y, ...), and the original has these two calls in both arms of the ghost test with the outer arguments pushed once in front of the branch (from 0x00447AD2), the lookup's this loaded in front of it too (0x00447AF1) and the first name's index in edx. Written out as the two nested calls the instructions are the same, but the three temporaries get their registers in another order and this cannot be loaded in front of the branch (87.5%). Called through its resolver the function is not inlined in our builds (75.7% with a copy of it in the build, both files on the /GL list; quick_diff 0.8593 with its body in the same unit). So the file has an inline static copy of it, with its name, its parameter types and its body and the text manager global in place of this, as Gynt's draft sourcehold#373 has copies of ViewportRenderState::xyAreValid in three files; inline, static inline and __forceinline give the same listing; - the current-action call is written at the end of both arms: the original evaluates its coordinates in each arm (0x00447B98, 0x00447BC5) and shares the push of the unit and the call (0x00447BDF). 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), this file and our own copy of TextManager::renderTextFromTextGroup (not part of this commit; this file does not call it), all off the list, with every resolver of those files on: 145 functions, average 99.57. The function 100.0% raw and normalised, no differing line, and the same with both files on the list. The other 143 functions of main's list read the same as without the two files. Both builds had an earlier text of this file (one unused include more, other comments, and other names for the copy and for two locals); quick_diff gives the same 195 instructions, line for line, for that text and for this one. The sources are main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 more function at 100%, with no header changes and no line for
cmake/compiler-flags-gl.txt. No behaviour change against gynt's 56.7% draft, which has a return that his older copies miss (below).StatusMenus::RenderStatusMenu_Chimpdraws the panel of the selected unit: its picture, its first name, surname and unit type (a ghost has the type only, the five animals no type), what it is doing, and for most unit types a comment, which a newly selected unit also speaks. It is from gynt's draft on his fork'sreimpl/UI-StatusMenus-development, and the commit credits him as co-author.StatusMenus::RenderStatusMenu_Chimp/GLlist and on itMeasured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie./GLlist and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,424 compile steps, 99.58 over 2,440 functions, against 99.58 over 2,439 for main alone (built at f489b72; 3458fea only adds files undertools/, and cmake: optional wrapper units built from function-visibility.txt #399 and cmake: function-visibility.txt, which callers must see which callees' bodies #398 add the optional function-visibility units, off by default).RenderStatusMenu_Chimpreads 100.0 raw and normalised there too, with no diff entry. Every main function reads exactly what it read before (unrounded 99.5761 against 99.5759 raw, 99.5494 against 99.5492 normalised; 2,323 against 2,322 functions at 100.0 raw)./GLlist that exist on main, this file, and one file that this PR does not contain (our own copy ofTextManager::renderTextFromTextGroup, which this file does not call; see below), all off the list: 145 functions, average 99.57. The function reads 100.0% raw and normalised, with no diff entries, and the same with both files on the list. The other 143 functions of main's list read the same as without the two files. Both builds had an earlier text of this file (one unused include more, other comments, and other names for the copy and for two locals); quick_diff gives the same 195 instructions, line for line, for that text and for this one. The sources were main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off.Against the drafts
gynt's 56.7% draft (67318e1) and the copy with other global names on his reimpl/Wilps-2026-10-18 (8ca7861) are the decompiler's output and compute what the original computes: the same tests on the unit type, the same texts at the same places, the comment chosen once and spoken for a newly selected unit. Nothing in their control flow is changed here.
His earlier copies do not return when the selected slot no longer holds a unit. They switch back to the build menu, then go on to draw the panel for the empty slot. These are c8bfbb7 (47.57%, carried with his style passes on most of his fork's UI branches, where the status line reads 47.6%) and 9ec9106 (49.6%, #251's head). He recovered the return himself in 109e64f ("Return recovered", 51.5%, on sourcehold's reimpl/UI-StatusMenus), as the original has it (0x00447A84). It is here too.
What got it to 100%
The function is rewritten against the original instructions, in two steps on our dev branch (not public): 87.5%, then 100.0%.
getPeasantGmIDcall (the original zeroes its register there, 0x00447A8C), and set behind it, as in gynt's 56.7% draft (our 87.5% text had it behind the call).TextManager::renderTextFromTextGroup(0x00424470), inlined (87.5% to 100.0%, together with the other two points). That function's whole body isrenderTextToScreen(getTextStringInGroupAtOffset(group, index), x, y, ...), and the original has exactly these two calls in both arms of the ghost test, with three signs that they come from one inlined call each: the seven outer arguments are pushed once, in front of the branch (0x00447AD2 to 0x00447AF0); the lookup'sthisis loaded in front of the branch too (0x00447AF1); and the first name's index is inedx, the third scratch register, with the coordinates ineaxandecx(0x00447AC7, 0x00447ACC, 0x00447AFC). Written out by hand as the two nested calls, the instructions are the same, but the compiler gives the three temporaries their registers in another order (the coordinates inedxandeax, the index inecx), so it cannot loadthisin front of the branch, and everything behind follows (87.5%). As far as we can tell, an inlined call binds its arguments as the callee's parameters first, and that is what changes the order. The argument temporaries of Reimplement 68 UI::BuildingMenus functions that are 100% #302's BuildingMenus files (the seven outer arguments as locals in push order, here in front of the ghost test, and the two nested calls in each arm) do not give it either: quick_diff 0.8359, the same 195 instructions with other registers./GLlist, the call stays a call (75.7%).inline staticcopy of that function, with its name, its parameter types and its body, and the text manager global in place ofthis(the object both calls here are made on). The two name texts call it, and a comment says what it is. This is the cheat sheet's "Detecting inlined functions" pattern, and gynt's open draft Reimpl/path finding state development #373 has the same case: itsfindOwnedGatehouse,findPathUsingClimbingWithHeightMargin16andsetupBabyTreeLocationInfoeach have aninline staticcopy ofViewportRenderState::xyAreValid("inlined copy of ViewportRenderState::xyAreValid"), a function that is on main at 100%.inline,static inlineand__forceinlinegive the same listing.quick_diff reads 1.0000: 195 instructions against 195.
No line for
cmake/compiler-flags-gl.txt/GLlist, and 100.0% on it too (the same build with the lines added). So it needs no line.cmake/function-visibility.txt(cmake: function-visibility.txt, which callers must see which callees' bodies #398) either. SeeingrenderTextFromTextGroup's body does not make the compiler inline a call through its resolver: with the body in the same unit, as cmake: optional wrapper units built from function-visibility.txt #399's wrapper units build it, quick_diff reads 0.8593 (196 instructions, the call stays), and with both files on the/GLlist reccmp reads 75.7%. The manifest names none of the function's callees.Kept as they are
inline staticcopy ofrenderTextFromTextGroup: see above. It makes 0x00424470's two calls, with its arguments, as reimplement OpenSHC::Text::TextManager and OpenSHC::Text::UserTextHandler #265's file does. When reimplement OpenSHC::Text::TextManager and OpenSHC::Text::UserTextHandler #265 lands the copy stays, as Reimpl/path finding state development #373's copies ofxyAreValidstay with that function on main: through the resolver the call is not inlined (see the/GLsection above). If a resolver call can be inlined one day, the two name texts become calls ofTextManager::renderTextFromTextGroup.getPeasantGmIDand picture calls. A comment in the code says so.getPeasantGmIDcall whose result is dropped: the function only returns a GM ID, and the original calls it and drops the result (0x00447A8E). A comment in the code says so.1for the loaded picture, and the positions and font sizes, are plain numbers. Picture 1 is the unit type's sketch: the building and status menu's Prepare (0x00446C00) loads the unit type'schimppicture first and its_sketch.tgxsecond (0x00447098). A comment in the code says so.What some placeholders hold (nothing changed here)
INT_00b96124: the unit this panel showed last; when it differs from the selected unit, the unit counts as newly selected. The building and status menu's Prepare (0x00446C00) clears it (0x00447139). gynt's reimpl/Wilps-2026-10-18 has it asg_statusMenuLastUnitId.DAT_00b95b6c: the number of the comment text, -1 while none is chosen; the same Prepare sets it to -1 (0x00447009). gynt's Wilps branch:g_statusMenuChimpCommentId. It isundefined4in the header, compared with -1 here, and holds anint.INT_00b98458: set to the comment's number when the comment is spoken. Nothing in the exe reads it (this store, 0x00447CE1, is its only reference). gynt's Wilps branch:g_lastPlayedChimpCommentId.Unit::rng1_to_70: the surname's number in the surname texts, 0 for a unit without one (gynt's Wilps branch:surnameIndex, the local's name here).TEXT_PEASANT_NAMESare first names ("Harry", "Bob"),TEXT_PEASANT_SURNAMESsurnames,TEXT_CHIMP_NAMESthe unit types ("Peasant", "Woodcutter"),TEXT_CHIMP_COMMENTthe comments ("Morning, your lordship.").Other PRs
TextManager::renderTextFromTextGroupat 100.0%. It changes neithergetTextStringInGroupAtOffset's norrenderTextToScreen's declaration, which the copy here calls, so the two don't conflict, and nothing here needs to change when it lands.🤖 Generated with Claude Code