Repository navigation
UI: the chat dialog's buttons at 100% - #472
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
MenuItemActionHandler_Chat_MostButtons, the chat dialog's buttons: a negative button sends the message to that one player only, 31 to everyone, 32 to nobody, 35 to the own team. 33 sends the message and closes the dialog, as 34 does without sending; a message that is empty or only spaces is neither sent nor closes it. 69 opens the allies dialog. The sender always gets the message too. Written from the original's instructions, with gynt's draft beside it for the reads: his best is 59.60% (ab1c46e on his fork's reimpl/UI-MenuItems), the newest 6aa5d32 on reimpl/UI-MenuItems-development. Behaviour against the draft, in every version: case 33's space-skipping loop. In ab1c46e, 8725ec5 and 6aa5d32 the loop returns after its first pass, so a message that starts with a space and is longer than one character returns at once: it is not sent, the dialog stays open, and the sender's flag is not set. In 51c5f22 to 637c6b0 and a4de844 (the 42.2% file, sourcehold#254's), e1c66a1, 8c21931, 9205629 and 8ca7861 it has no return, so a message of spaces only is sent and the dialog closes. The original sends only a message with a character other than a space, and sets the sender's flag either way. The receiver flags are written TRUE / FALSE (they hold only 0 or 1). What the match needed: one counter for all the loops (a counter per loop swaps the text scan's address registers); the negative button's arm without a return of its own, ending in the sender's store behind the switch as the cases do (with a return there the constant 1 is built from the 0 register); its index written as `buttonID < 0 ? -buttonID : buttonID` (a plain -buttonID is folded into the address); the cases in the original's order (35 before 33). Measured in a narrow build of this file on main 0e4a83b with both resolver sets on: 100.0% raw and normalised. 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 23 — Prefer if-else over ternary
|
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 for the names. No header changes. One behaviour fix against every version of his draft (below).
Chat::MenuItemActionHandler_Chat_MostButtonsgynt's draft goes back to 51c5f22 (2026-10-02, "reimplement: SHC_3BB0A8C1_0x0048F590 42.22% Style pass, asm differs"). The same file is a4de844 (42.2%) on his fork's reimpl/UI-MenuItems, which is what #254 had when it closed, and it is also on sourcehold's own reimpl/UI-MenuItems. He took it further on that branch: e1c66a1 (2026-10-08, 47.09%), 8c21931 (57.57%) and ab1c46e (2026-10-11, "reimplement: SHC_3BB0A8C1_0x0048F590 59.60% Style pass, asm differs"), the best score. The newest version is 6aa5d32 (2026-11-02, "style: rule 11 across UI/MenuItems, and a scaled-pointer bug it exposed") on reimpl/UI-MenuItems-development. 19 other branches of his fork (reimpl/UI-Core-100 among them) have the 42.2% file as 637c6b0 (2026-10-06).
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).TRUE/FALSEand adds comments, and compiles to the same listing), with both resolver sets on, and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,426 compile steps, 99.58 over 2,442 functions. The new function reads 100.0 raw and normalised there too, with no diff entry. Against main's baseline build (made at f489b72, 2,439 functions) the only other differences are main's own since then: One more UI::MenuModals function at 100%: ProgressBarBox #467'sMenuModalRenderFunction_ProgressBarBoxand UI: the single-player game launch at 100% #466'sLaunchSinglePlayerGameUnkread 100.0, andConstructor_MenuModal_ProgressBarBoxreads 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).lea ecx, [ecx]at 0x0048F76D), in its order; the switch's byte table (0x0048F81C, 39 entries for the buttons 31 to 69) and jump table (0x0048F800, 7 entries) are the original's, entry for entry.What the function does
It handles the chat dialog's buttons. A negative button sends the next message to that one player only (all nine receiver flags cleared, that player's set), 31 to everyone, 32 to nobody (the chat menu's eight player buttons pass -1 to -8; no button of it passes 32), and 35 to the own team (the players whose team is the sender's). 33 sends the message and closes the dialog, as 34 does without sending; a message that is empty or only spaces is neither sent nor closes it. 69 opens the allies dialog, with the Genie's "Your allies" when the Genie voice is on. Whatever the button, the sender's own flag is set at the end.
Behaviour against the draft
Read block by block against every version of gynt's draft. One difference, in the send button (33), in two forms:
The rest does what the draft does. The draft's case 35 sets the sender's flag inside its last team test as well; that store is redundant, as the flag is set behind the switch either way.
What got it to 100%
Each of these was measured against the alternative it names:
[edx + eax](counter first) instead of the original's[eax + edx]. Whereiis declared without a value makes no difference; a fresh counter in each loop does.lea edi, [ebx + 1]where the original hasmov edi, 1).buttonID < 0 ? -buttonID : buttonID. The arm already knows that the button is negative, so this compiles to the original'sneg eaxand an indexed store. A plain-buttonIDis folded into the address (base - 4 * buttonID, five instructions instead of two), and so is the same negation in a local or through anunsignedcast. Declared in front of the clears, a local keeps theneg, but in the wrong place.abs(buttonID)puts itscdq/xorin front of the clears.Things in the file that look odd and are the original's
int i;at the top, used by all six loops: see above.Checker CHECKs (not changed)
MenuItemActionHandler_InGameMenu_MainButtonstake their button numbers as numbers too). They come from the chat menu's item table (MenuItems_Chat, 0x00603108): -1 to -8 for the eight player buttons, then 31, 69, 35, 33 and 34. No button passes 32.Proposed, not changed here
GameSynchronyState::DAT_ChatMessageReceiverArrayholds only 0 or 1 (this function,SendMessageToPlayer's^= 1, and the chat dialog's render function tests it as a flag), so it is writtenTRUE/FALSEhere. The header keepsint[9]: as aBOOLEnum[9],SendMessageToPlayer's^= 1would not compile. Main'sSendMessageToPlayerstill writes= 1to the same array and is not changed here.MenuItemActionHandler_Chat_RecipientAndSendButtons.DAT_ChatTauntOrMessageisundefined4but holds an int: 0 for the typed text (here), 1 to 20 for a taunt, and 10000 at 0x004296E9, 0x00429EC1, 0x0042A027 and 0x0042A407.🤖 Generated with Claude Code