Skip to content

activateProjectileEntity back to 100%: it returns the entity id (header: void to int) - #477

Open
kotijekriv wants to merge 2 commits into
sourcehold:mainfrom
kotijekriv:reimpl/main-A-round2-100
Open

kotijekriv wants to merge 2 commits into
sourcehold:mainfrom
kotijekriv:reimpl/main-A-round2-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

One function on main that reads 45.5% in a full build of main with every resolver on, although its status line says 100%. Its declaration says void, and the original returns a value. This PR has one header commit and one .cpp commit. The status line stays as it is (100.0%), and there's no line for cmake/compiler-flags-gl.txt.

Function Address Reimplemented by Full build of main (raw / normalised) Now
EntityState::activateProjectileEntity 0x004039B0 gynt (#199) 45.5% / 45.5% 100.0% / 100.0%

Both commits credit gynt as co-author.

The header change: activateProjectileEntity returns int

  • Evidence: the original keeps the entity id in esi across the call to setProjectileEntityValues2 and ends with mov eax, esi, pop esi, ret 4 (0x004039DD). It returns its argument.
  • Its one call, at 0x00408864 in updateEntities (0x004087C0, not on main), ignores it: the next instruction it reaches (0x00408880) reloads eax. So nothing on the calling side changes. No file on main calls it through the resolver.
  • Main's IMPLEMENTATION_CHEAT_SHEET.md (Return Values, gynt's 4d21de1) gives this function as its example of the fix: void to int with a trailing return entityID;, 36.4% to 100%, with the signature fixed in the generated header.
  • How main lost it: the declaration was int when gynt named the function (31a03d7, 2026-07-03). sourcehold's Ghidra sync 54f26f5 (2026-08-27) made it void. Reimpl/simple functions set 1 #199 (648b0c6, 2026-10-04) brought gynt's int version with return entityID; (his fd9bec6, 100.0% in its status line, on Reimpl/simple functions set 1 #199's branch, where the header still said void). gynt's dc2fad9 (2026-10-13, an automatic field refactor) then made the definition void to follow the declaration and dropped the return.
  • The change: void to int in the declaration in Map/Entities/EntityState.hpp, and in the resolver's function type in Map/Entities/EntityState.func.hpp. It is one header change, in a commit of its own (b93e27c). Main's declaration check fails on a changed header under src/OpenSHC and labels the PR, so this PR waits for the change to reach main through the Ghidra sync, as the other declaration-change PRs do.

The function

  • return entityID; at the end again, as in gynt's fd9bec6 and in Reimpl/simple functions set 1 #199 before dc2fad9. As a void function, ours had no reason to keep the id past the call. It loaded the id into edx, without the original's push and pop of esi.

Measured

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), the struct resolvers and the function resolvers enabled locally (not committed), and sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie.
  • Full build: an all-on build of the previous cut of this branch on main 0e4a83b (the same code: the cuts since change only the commit messages), 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.60 over 2,441 functions. activateProjectileEntity reads 100.0 raw and normalised there, with no diff entry (45.5 in the same build of main), and its callee setProjectileEntityValues2 reads 100.0 as before. No other function reads differently with the header change. Its one caller in the exe, EntityState::updateEntities (0x004087C0, its call at 0x00408864), is not reimplemented on main, so it has no reading, and no source calls the function through its resolver. 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), and every other function reads exactly what it read before (unrounded 99.6011 raw and 99.5751 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 narrower run: main's /GL list (the 133 files that exist) and this file, with the header change: the function reads 100.0% raw and normalised with no diff entry, and every other function reads as in the same build without the file.
  • Checks: our local style checker gives 0 ERROR and 1 CHECK (the header change, named above). Our local fixer finds nothing to change.
  • Not run in game.

Looked at in the same pass

Other functions on main below 85% where the source has nothing to change now:

🤖 Generated with Claude Code

kotijekriv and others added 2 commits November 23, 2026 05:36
The original returns its argument: it keeps the entity id in esi across the call to setProjectileEntityValues2 and
ends with `mov eax, esi` before `ret 4` (0x004039DD). Its one call, at 0x00408864 in updateEntities (0x004087C0,
not on main), ignores it: the next instruction it reaches (0x00408880) reloads eax. The declaration was int when
Gynt named the function (31a03d7, 2026-07-03); sourcehold's Ghidra sync 54f26f5 (2026-08-27) made it void.
sourcehold#199 (648b0c6, 2026-10-04) brought Gynt's int version with `return entityID;` (his fd9bec6, 2026-09-30, 100.0%
in its status line, on sourcehold#199's branch, where the header still said void), against that void; his dc2fad9
(2026-10-13, an automatic field refactor) then made the definition void and dropped the return, and since then our
build has had no reason to keep the id past the call. Main's IMPLEMENTATION_CHEAT_SHEET.md (Return Values, Gynt's
4d21de1) gives this function as its example of the fix: void to int with `return entityID;`, 36.4% to 100%, with
the signature fixed in the generated header. This changes the declaration in EntityState.hpp and the resolver's
function type in EntityState.func.hpp; no file on main uses the result.

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

With the header's int (the commit before), the function ends with `return entityID;` again, as in Gynt's fd9bec6
and in sourcehold#199 before dc2fad9 removed it: the original keeps the id in esi across the call to
setProjectileEntityValues2 and returns it (`mov eax, esi`, `pop esi`, `ret 4` at 0x004039DD). As a void function
ours had no reason to keep the id past the call: it loaded it into edx, without the original's push and pop of esi,
and a full build of main with every resolver on read 45.5%.

Measured with the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1...5387ac5a), the struct
resolvers on and every function resolver of the build list on, sourcehold's reccmp with --resolve-wrapped-calls
--ignore-security-cookie: a build of main's /GL list (the 133 files that exist) and this file, with the header
commit, reads 100.0% raw and normalised, no differing line; every other function reads as in the same build without
the file. The file is not on the /GL list, and this does not add it.

The function is Gynt's (on main since sourcehold#199); besides the return type and the `return`, the text is main's.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 23, 2026

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

declaration/type change This requires changes to the generated/exported types or definitions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant