Repository navigation
activateProjectileEntity back to 100%: it returns the entity id (header: void to int) - #477
Open
kotijekriv wants to merge 2 commits into
Open
kotijekriv wants to merge 2 commits into
kotijekriv wants to merge 2 commits into
Conversation
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>
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 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.cppcommit. The status line stays as it is (100.0%), and there's no line forcmake/compiler-flags-gl.txt.EntityState::activateProjectileEntityBoth commits credit gynt as co-author.
The header change:
activateProjectileEntityreturnsintsetProjectileEntityValues2and ends withmov eax, esi,pop esi,ret 4(0x004039DD). It returns its argument.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.IMPLEMENTATION_CHEAT_SHEET.md(Return Values, gynt's 4d21de1) gives this function as its example of the fix:voidtointwith a trailingreturn entityID;, 36.4% to 100%, with the signature fixed in the generated header.intwhen gynt named the function (31a03d7, 2026-07-03). sourcehold's Ghidra sync 54f26f5 (2026-08-27) made itvoid. Reimpl/simple functions set 1 #199 (648b0c6, 2026-10-04) brought gynt'sintversion withreturn entityID;(his fd9bec6, 100.0% in its status line, on Reimpl/simple functions set 1 #199's branch, where the header still saidvoid). gynt's dc2fad9 (2026-10-13, an automatic field refactor) then made the definitionvoidto follow the declaration and dropped the return.voidtointin the declaration inMap/Entities/EntityState.hpp, and in the resolver's function type inMap/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 undersrc/OpenSHCand 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 avoidfunction, 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
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./GLlist (this file is not on it), and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,425 compile steps, 99.60 over 2,441 functions.activateProjectileEntityreads 100.0 raw and normalised there, with no diff entry (45.5 in the same build of main), and its calleesetProjectileEntityValues2reads 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'sMenuModalRenderFunction_ProgressBarBoxand its constructor, UI: the single-player game launch at 100% #466'sLaunchSinglePlayerGameUnk), 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)./GLlist (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.Looked at in the same pass
Other functions on main below 85% where the source has nothing to change now:
updateBuildingPlacementRotationPreview(46.2%): the original reusesthisin ecx after callingdetermineBuildingPlacementRotation, so it was built knowing that function. The callee is 0% on main and in Reimpl/TileMapState 100% batch 2 #396 at 68.7%, and both files are already on main's/GLlist.countSiegeEngineUnits(53.8%): the loop's pointer and its scratch value swap edx and ecx. Register allocation only (Compiler randomness: adding Enums and Typedefs causes different bytecode because of different code folding #414).🤖 Generated with Claude Code