From de7c5f63ec14dd92efb03b7aa17d6b7443af1dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Fri, 3 Oct 2025 23:57:50 +0800 Subject: [PATCH 1/6] code --- src/Ext/Cell/Body.cpp | 1 + src/Ext/Cell/Body.h | 1 + src/Misc/Hooks.BugFixes.cpp | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/src/Ext/Cell/Body.cpp b/src/Ext/Cell/Body.cpp index 2c04e51bc9..64612cf6b1 100644 --- a/src/Ext/Cell/Body.cpp +++ b/src/Ext/Cell/Body.cpp @@ -15,6 +15,7 @@ void CellExt::ExtData::Serialize(T& Stm) Stm .Process(this->RadSites) .Process(this->RadLevels) + .Process(this->InfantryCount) ; } diff --git a/src/Ext/Cell/Body.h b/src/Ext/Cell/Body.h index fc1dfae4d8..49692be63f 100644 --- a/src/Ext/Cell/Body.h +++ b/src/Ext/Cell/Body.h @@ -36,6 +36,7 @@ class CellExt public: std::vector RadSites {}; std::vector RadLevels { }; + int InfantryCount{ 0 }; ExtData(CellClass* OwnerObject) : Extension(OwnerObject) { } diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 26e7458488..138c3b8ccd 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -2671,3 +2672,44 @@ DEFINE_HOOK(0x74431F, UnitClass_ReadyToNextMission_HuntCheck, 0x6) GET(UnitClass*, pThis, ESI); return pThis->GetCurrentMission() != Mission::Hunt ? 0 : 0x744329; } + +#pragma region InfBlockTreeFix + +DEFINE_HOOK(0x47E91F, CellClass_AddContent_CountInfantry, 0x6) +{ + GET(CellClass*, pThis, EBX); + GET(ObjectClass*, pContent, EBP); + + if (pContent->WhatAmI() == AbstractType::Infantry) + CellExt::ExtMap.Find(pThis)->InfantryCount++; + + return 0; +} + +DEFINE_HOOK_AGAIN(0x47EAEA, CellClass_RemoveContent_CountInfantry, 0x6); +DEFINE_HOOK(0x47EACF, CellClass_RemoveContent_CountInfantry, 0x6) +{ + GET(CellClass*, pThis, EDI); + GET(ObjectClass*, pContent, ESI); + + if (pContent->WhatAmI() == AbstractType::Infantry) + CellExt::ExtMap.Find(pThis)->InfantryCount--; + + return 0; +} + +DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) +{ + enum { Reset = 0x5218CC, NoReset = 0x5218D3 }; + + GET(CellClass*, pThis, ESI); + GET(DWORD, newFlag, ECX); + + pThis->OccupationFlags = newFlag; + + // Vanilla check only the flag to decide if the InfantryOwnerIndex should be reset. + // But the tree take one of the flag bit. So if a infantry walk through a cell with a tree, the InfantryOwnerIndex won't be reset. + return (newFlag & 0x1C) == 0 || CellExt::ExtMap.Find(pThis)->InfantryCount <= 1 ? Reset : NoReset; +} + +#pragma endregion \ No newline at end of file From f727d0419918130b68239b5fe509487a01c11360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Sat, 4 Oct 2025 12:04:53 +0800 Subject: [PATCH 2/6] Update Hooks.BugFixes.cpp --- src/Misc/Hooks.BugFixes.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 138c3b8ccd..101c2ea21b 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2674,7 +2674,7 @@ DEFINE_HOOK(0x74431F, UnitClass_ReadyToNextMission_HuntCheck, 0x6) } #pragma region InfBlockTreeFix - +/* DEFINE_HOOK(0x47E91F, CellClass_AddContent_CountInfantry, 0x6) { GET(CellClass*, pThis, EBX); @@ -2711,5 +2711,24 @@ DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) // But the tree take one of the flag bit. So if a infantry walk through a cell with a tree, the InfantryOwnerIndex won't be reset. return (newFlag & 0x1C) == 0 || CellExt::ExtMap.Find(pThis)->InfantryCount <= 1 ? Reset : NoReset; } +*/ + +DEFINE_HOOK(0x71C17B, TerrainClass_MarkAllOccupationBits_Mark, 0x5) +{ + enum { SkipGameCode = 0x71C193 }; + GET(CellClass*, pCell, EAX); + pCell->OccupationFlags |= 0x2; + R->BL(0); + return SkipGameCode; +} + +DEFINE_HOOK(0x71C0DB, TerrainClass_UnarkAllOccupationBits_Mark, 0x5) +{ + enum { SkipGameCode = 0x71C0F3 }; + GET(CellClass*, pCell, EAX); + pCell->OccupationFlags &= ~0x2u; + R->BL(0); + return SkipGameCode; +} #pragma endregion \ No newline at end of file From 89ebb57c0c4c691b2c9154bbd5ffb5a0e8a50dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Tue, 7 Oct 2025 09:09:57 +0800 Subject: [PATCH 3/6] Revert "Update Hooks.BugFixes.cpp" This reverts commit f727d0419918130b68239b5fe509487a01c11360. --- src/Misc/Hooks.BugFixes.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 101c2ea21b..138c3b8ccd 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2674,7 +2674,7 @@ DEFINE_HOOK(0x74431F, UnitClass_ReadyToNextMission_HuntCheck, 0x6) } #pragma region InfBlockTreeFix -/* + DEFINE_HOOK(0x47E91F, CellClass_AddContent_CountInfantry, 0x6) { GET(CellClass*, pThis, EBX); @@ -2711,24 +2711,5 @@ DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) // But the tree take one of the flag bit. So if a infantry walk through a cell with a tree, the InfantryOwnerIndex won't be reset. return (newFlag & 0x1C) == 0 || CellExt::ExtMap.Find(pThis)->InfantryCount <= 1 ? Reset : NoReset; } -*/ - -DEFINE_HOOK(0x71C17B, TerrainClass_MarkAllOccupationBits_Mark, 0x5) -{ - enum { SkipGameCode = 0x71C193 }; - GET(CellClass*, pCell, EAX); - pCell->OccupationFlags |= 0x2; - R->BL(0); - return SkipGameCode; -} - -DEFINE_HOOK(0x71C0DB, TerrainClass_UnarkAllOccupationBits_Mark, 0x5) -{ - enum { SkipGameCode = 0x71C0F3 }; - GET(CellClass*, pCell, EAX); - pCell->OccupationFlags &= ~0x2u; - R->BL(0); - return SkipGameCode; -} #pragma endregion \ No newline at end of file From d0cbc8aabb8e2050d4233066fb75ac5061d0884e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Tue, 7 Oct 2025 09:20:33 +0800 Subject: [PATCH 4/6] Update Hooks.BugFixes.cpp --- src/Misc/Hooks.BugFixes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 138c3b8ccd..fcda7615eb 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -2709,7 +2709,7 @@ DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) // Vanilla check only the flag to decide if the InfantryOwnerIndex should be reset. // But the tree take one of the flag bit. So if a infantry walk through a cell with a tree, the InfantryOwnerIndex won't be reset. - return (newFlag & 0x1C) == 0 || CellExt::ExtMap.Find(pThis)->InfantryCount <= 1 ? Reset : NoReset; + return (newFlag & 0x1C) == 0 || CellExt::ExtMap.Find(pThis)->InfantryCount == 0 ? Reset : NoReset; } #pragma endregion \ No newline at end of file From 24e7c4db5908c0e97ac8fc20336dc7a3dce27674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Tue, 7 Oct 2025 12:07:12 +0800 Subject: [PATCH 5/6] Update Hooks.BugFixes.cpp --- src/Misc/Hooks.BugFixes.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index fcda7615eb..35c0bd6f6e 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2675,26 +2675,10 @@ DEFINE_HOOK(0x74431F, UnitClass_ReadyToNextMission_HuntCheck, 0x6) #pragma region InfBlockTreeFix -DEFINE_HOOK(0x47E91F, CellClass_AddContent_CountInfantry, 0x6) +DEFINE_HOOK(0x52182A, InfantryClass_MarkAllOccupationBits_SetOwnerIdx, 0x6) { - GET(CellClass*, pThis, EBX); - GET(ObjectClass*, pContent, EBP); - - if (pContent->WhatAmI() == AbstractType::Infantry) - CellExt::ExtMap.Find(pThis)->InfantryCount++; - - return 0; -} - -DEFINE_HOOK_AGAIN(0x47EAEA, CellClass_RemoveContent_CountInfantry, 0x6); -DEFINE_HOOK(0x47EACF, CellClass_RemoveContent_CountInfantry, 0x6) -{ - GET(CellClass*, pThis, EDI); - GET(ObjectClass*, pContent, ESI); - - if (pContent->WhatAmI() == AbstractType::Infantry) - CellExt::ExtMap.Find(pThis)->InfantryCount--; - + GET(CellClass*, pCell, ESI); + CellExt::ExtMap.Find(pCell)->InfantryCount++; return 0; } @@ -2702,14 +2686,16 @@ DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) { enum { Reset = 0x5218CC, NoReset = 0x5218D3 }; - GET(CellClass*, pThis, ESI); + GET(CellClass*, pCell, ESI); GET(DWORD, newFlag, ECX); - pThis->OccupationFlags = newFlag; + pCell->OccupationFlags = newFlag; + auto pExt = CellExt::ExtMap.Find(pCell); + pExt->InfantryCount--; // Vanilla check only the flag to decide if the InfantryOwnerIndex should be reset. // But the tree take one of the flag bit. So if a infantry walk through a cell with a tree, the InfantryOwnerIndex won't be reset. - return (newFlag & 0x1C) == 0 || CellExt::ExtMap.Find(pThis)->InfantryCount == 0 ? Reset : NoReset; + return (newFlag & 0x1C) == 0 || pExt->InfantryCount == 0 ? Reset : NoReset; } #pragma endregion \ No newline at end of file From 3d371be8fd62b061ef062235a3085c644ce1c12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=AA=E5=91=B3=E9=BA=BB=E9=85=B1?= <93972760+TaranDahl@users.noreply.github.com> Date: Tue, 7 Oct 2025 12:20:54 +0800 Subject: [PATCH 6/6] docs --- CREDITS.md | 1 + docs/Fixed-or-Improved-Logics.md | 1 + docs/Whats-New.md | 1 + 3 files changed, 3 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index 2b09c3b8e4..d3b448a9b2 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -620,6 +620,7 @@ This page lists all the individual contributions to the project by their author. - Fix an issue that jumpjet infantries' shadow is always drawn even if they are cloaked - Fix an issue that technos head to building's dock even they are not going to dock - Fix an issue that the jumpjet vehicles cannot stop correctly after going berserk + - Fix an issue that infantry walking through a cell containing a tree would cause it to be impassable to other houses - **solar-III (凤九歌)** - Target scanning delay customization (documentation) - Skip target scanning function calling for unarmed technos (documentation) diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 4133e50f2e..26b15aed17 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -263,6 +263,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - `DeployingAnim` using unit drawer now also tint accordingly with the unit. - Fixed an issue that jumpjets in air can not correctly spawn missiles. - Fixed an issue that the currently hovered planning node not update up-to-date, such as using hotkeys to select technos. +- Fixed an issue that infantry walking through a cell containing a tree would cause it to be impassable to other houses. ## Fixes / interactions with other extensions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 06ea6a6365..899697222f 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -476,6 +476,7 @@ Vanilla fixes: - Fixed an issue that jumpjet infantries' shadow is always drawn even if they are cloaked (by TaranDahl) - Fixed an issue that technos head to building's dock even they are not going to dock (by TaranDahl) - Fixed an issue that the jumpjet vehicles cannot stop correctly after going berserk (by TaranDahl) +- Fixed an issue that infantry walking through a cell containing a tree would cause it to be impassable to other houses (by TaranDahl) Phobos fixes: - Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)