diff --git a/CREDITS.md b/CREDITS.md index 9bb1caeb9d..6dbdbefa02 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -621,6 +621,7 @@ This page lists all the individual contributions to the project by their author. - 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 - Attack and damage technos underground + - 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 9481f2e0f9..a8961c10a1 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -477,6 +477,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) 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..35c0bd6f6e 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -2671,3 +2672,30 @@ DEFINE_HOOK(0x74431F, UnitClass_ReadyToNextMission_HuntCheck, 0x6) GET(UnitClass*, pThis, ESI); return pThis->GetCurrentMission() != Mission::Hunt ? 0 : 0x744329; } + +#pragma region InfBlockTreeFix + +DEFINE_HOOK(0x52182A, InfantryClass_MarkAllOccupationBits_SetOwnerIdx, 0x6) +{ + GET(CellClass*, pCell, ESI); + CellExt::ExtMap.Find(pCell)->InfantryCount++; + return 0; +} + +DEFINE_HOOK(0x5218C2, InfantryClass_UnmarkAllOccupationBits_ResetOwnerIdx, 0x6) +{ + enum { Reset = 0x5218CC, NoReset = 0x5218D3 }; + + GET(CellClass*, pCell, ESI); + GET(DWORD, newFlag, ECX); + + 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 || pExt->InfantryCount == 0 ? Reset : NoReset; +} + +#pragma endregion \ No newline at end of file