From b93e27c80f673298142888682ed287f388bc540b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 05:36:09 +0100 Subject: [PATCH 1/2] header: EntityState::activateProjectileEntity returns int 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 (31a03d7631, 2026-07-03); sourcehold's Ghidra sync 54f26f558a (2026-08-27) made it void. #199 (648b0c6d2, 2026-10-04) brought Gynt's int version with `return entityID;` (his fd9bec665, 2026-09-30, 100.0% in its status line, on #199's branch, where the header still said void), against that void; his dc2fad9196 (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 4d21de1e6a) 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 Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/Entities/EntityState.func.hpp | 2 +- src/OpenSHC/Map/Entities/EntityState.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Map/Entities/EntityState.func.hpp b/src/OpenSHC/Map/Entities/EntityState.func.hpp index f12ac89710..935bea9c9c 100644 --- a/src/OpenSHC/Map/Entities/EntityState.func.hpp +++ b/src/OpenSHC/Map/Entities/EntityState.func.hpp @@ -137,7 +137,7 @@ namespace Map { &EntityState::removeEntityFromTileLinkedList) removeEntityFromTileLinkedList; - MACRO_FUNCTION_RESOLVER(void (EntityState::*)(int), false, Address::SHC_3BB0A8C1_0x004039B0, + MACRO_FUNCTION_RESOLVER(int (EntityState::*)(int), false, Address::SHC_3BB0A8C1_0x004039B0, &EntityState::activateProjectileEntity) activateProjectileEntity; diff --git a/src/OpenSHC/Map/Entities/EntityState.hpp b/src/OpenSHC/Map/Entities/EntityState.hpp index 44e6a57a96..e39834a266 100644 --- a/src/OpenSHC/Map/Entities/EntityState.hpp +++ b/src/OpenSHC/Map/Entities/EntityState.hpp @@ -110,7 +110,7 @@ namespace Map { void removeEntityFromTileLinkedList(int param_1); - void activateProjectileEntity(int entityID); + int activateProjectileEntity(int entityID); void deleteEntity(uint entityID); From 629d8082ca65ff15d15e66c6b3eab3d62b865bb5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 05:36:10 +0100 Subject: [PATCH 2/2] reimplement: SHC_3BB0A8C1_0x004039B0 100.0% returns the entity id, as the original With the header's int (the commit before), the function ends with `return entityID;` again, as in Gynt's fd9bec665 and in #199 before dc2fad9196 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 #199); besides the return type and the `return`, the text is main's. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../Map/Entities/EntityState/activateProjectileEntity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/Map/Entities/EntityState/activateProjectileEntity.cpp b/src/OpenSHC/Map/Entities/EntityState/activateProjectileEntity.cpp index 8dfb0432c8..e53a30d15f 100644 --- a/src/OpenSHC/Map/Entities/EntityState/activateProjectileEntity.cpp +++ b/src/OpenSHC/Map/Entities/EntityState/activateProjectileEntity.cpp @@ -11,12 +11,13 @@ namespace Map { using OpenSHC::Map::Entities::EntityTypeShort; // FUNCTION: STRONGHOLDCRUSADER 0x004039B0 - void EntityState::activateProjectileEntity(int entityID) + int EntityState::activateProjectileEntity(int entityID) { this->entityArray[entityID].logicalState = 2; this->entityArray[entityID].field_0xa8 = 1; MACRO_CALL_MEMBER(OpenSHC::Map::Entities::EntityState_Func::setProjectileEntityValues2, this)( entityID, (EntityType)this->entityArray[entityID].entityType2); + return entityID; } }