Skip to content

AI: someChatMessageSelection back to 100% - #479

Open
kotijekriv wants to merge 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/main-B-round51b-100
Open

kotijekriv wants to merge 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/main-B-round51b-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

One function on main that its status has at 100% ("one reordered push edi") and that a full build with both resolver sets on reads at 99.2% (95.8% normalised). It is gynt's code from #261, and the commit credits him as co-author. No header changes.

Function Address Full build of main Now
AICState::someChatMessageSelection 0x004D10B0 99.2% / 95.8% 100.0% / 100.0%

What changed

  • The first test (in the in-game menu, in a single-player skirmish) is an early return that clears aiTauntResponseTimeWindow itself. The original pushes edi in front of the player loop's set-up (0x004D1107); ours pushed it behind. With the clear written in both exits instead of once at the end, the push lands where the original has it. No other shape tried moved the push, and some made the listing worse: the declarations in four other orders, candidateCount declared or zeroed elsewhere, the loop counters in other forms, the player test split or written with continue, the clear at the other exits. The rest of the body is one indentation level out.
  • The checker's style rules, which compile to the same listing: the menu test by truthiness, prefix steps, %=, a loop for the eight receiver flags, the player and receiver loops bounded by countof, the locals declared where they are first set (candidates too), and the loop comment cut to one line. The four unused using lines and the BOOLEnum.hpp include are gone.
  • The status line drops "one reordered push edi".

Measured

  • Setup: the bundled MSVC1400-SP1 against the Steam 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).
  • Narrow build: this file on main 0e4a83b: 100.0 raw and normalised, with no diff line.
  • Full build: an all-on build of this commit alone on main 0e4a83b, with both resolver sets on and main's own /GL list (this file is not on it), and with 0x004314E0 (the MapEditorLandscaping_GeneralButtons handler) left out and its resolver off, as in main's baseline: 0 failed of 2,425 compile steps, 99.58 over 2,441 functions. someChatMessageSelection reads 100.0 raw and normalised there, with no diff entry (99.2 / 95.8 in the same build of main), and its callee queueCommand reads what it reads on main (99.1 / 95.2; Four functions on main back to 100%: two signed tick compares, a selection slot and a load order #478 brings it to 100%). 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, and 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.5776 raw and 99.5490 normalised, 2,324 functions at 100.0 raw; with those two at 100.0, 99.5791 and 99.5545, 2,326; main 0e4a83b alone: 99.5788 and 99.5528 over 2,441, 2,325 at 100.0).
  • Not run in game.

Checks

Our local style checker gives 0 ERROR and 2 CHECK: SG 8 (the player loop steps by 4), which main's style-lint bot will post once, and its notice. The one-line comment on the loop gives the reason. A plain 1..8 loop reads 61.0% here (40.9% normalised, in a narrow build): MSVC unrolls all eight and folds every index into an absolute address, where the original keeps the index in a register. gynt's comment on main had measured the same (0.92 to 0.67) on the function's earlier shape.

🤖 Generated with Claude Code

… return

AICState::someChatMessageSelection (0x004D10B0) read 99.2% (95.8% normalised) in a full build of main: the
original pushes edi in front of the player loop's set-up (0x004D1107), ours behind it. Written as an early return
that clears aiTauntResponseTimeWindow itself, the first test (in the in-game menu, in a single-player skirmish)
moves the push to the original's place: the clear is written in both exits instead of once at the end. The rest is
gynt's code from sourcehold#261, one indentation level out, with the checker's style rules applied: the menu test by
truthiness, prefix steps, `%=`, a loop for the eight receiver flags, both loops bounded by `countof`, the locals
declared where they are first set, the loop comment cut to one line, and the unused `using` lines and the BOOLEnum
include dropped. These compile to the same listing. The status line drops "one reordered push edi".

Measured on main 0e4a83b with both resolver sets on: 100.0% raw and normalised in a narrow build of this text and
in a full build of it. A plain 1..8 player loop reads 61.0% (40.9% normalised) in a narrow build.
Not run in game.

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

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

1 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 1 reimplemented .cpp file(s) in this PR.

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.

rule what it asks hits
8 Let the compiler unroll 1
Where

Rule 8 — Let the compiler unroll

  • src/OpenSHC/AI/AICState/someChatMessageSelection.cpp:39 — loop steps by 4; try the plain loop and let MSVC unroll

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