diff --git a/CREDITS.md b/CREDITS.md index b03e2047e8..63ad043d55 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -51,6 +51,8 @@ This page lists all the individual contributions to the project by their author. - Warhead activation target health thresholds - MP saves support for quicksave command and savegame trigger action - Ported XNA CnCNet Client MP save handling + - Open-topped buildings + - Building unload self-attack fix - **Uranusian (Thrifinesma)**: - Mind Control enhancement - Custom warhead splash list diff --git a/YRpp b/YRpp index 5af96790ce..9b02e66c58 160000 --- a/YRpp +++ b/YRpp @@ -1 +1 @@ -Subproject commit 5af96790ce73e4ea068a390c60c124dccbc220e1 +Subproject commit 9b02e66c58cc9a07c7935f25f4db053b87f612b7 diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 7eb711a26b..71566a367a 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -262,6 +262,8 @@ 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 `OpenTopped` to work with buildings. +- Fixed buildings giving an order to attack self when unloading (manifested with opentopped buildings and garrisons leaving buildings sometimes). ## Fixes / interactions with other extensions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index ad79881e07..79f26a5719 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -473,6 +473,8 @@ Vanilla fixes: - `DeployingAnim` using unit drawer now also tint accordingly with the unit (by Starkku) - Jumpjets in air now can correctly spawn missiles (by TaranDahl) - Fixed an issue that the currently hovered planning node not update up-to-date, such as using hotkeys to select technos (by CrimRecya) +- Fixed `OpenTopped` to work with buildings (by Kerbiter) +- Fixed buildings giving an order to attack self when unloading (manifested with opentopped buildings and garrisons leaving buildings sometimes) (by Kerbiter) 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/Techno/Body.Update.cpp b/src/Ext/Techno/Body.Update.cpp index da6be50161..7c41c36770 100644 --- a/src/Ext/Techno/Body.Update.cpp +++ b/src/Ext/Techno/Body.Update.cpp @@ -1130,6 +1130,7 @@ void TechnoExt::ExtData::UpdateTypeData_Foot() // Update open topped state of potential passengers if transport's OpenTopped value changes. // OpenTopped does not work properly with buildings to begin with which is why this is here rather than in the Techno update one. + // TODO move to non-foot since we now have proper building open-topped support if (pThis->Passengers.NumPassengers > 0) { const bool toOpenTopped = pCurrentType->OpenTopped; diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 0a11a8b9af..9bd2b8c688 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2657,3 +2657,76 @@ DEFINE_HOOK(0x741A66, UnitClass_SetDestination_JJVehFix, 0x5) } #pragma endregion + +#pragma region OpenTopped on buildings + +DEFINE_HOOK(0x51A320, InfantryClass_PerCellProcess_SubmitToOpenToppedOnBuildingEnter, 0x7) +{ + GET(BuildingClass* const, pBuilding, EDI); + GET(InfantryClass* const, pThis, ESI); + + if (pBuilding->Type->OpenTopped) + pBuilding->EnteredOpenTopped(pThis); + + // there's no opentopped infantry... yet :P + if (pThis->Type->OpenTopped) + pThis->SetTargetForPassengers(nullptr); + + // where's Multfinite's cncnet5 cli... erm, I mean, fixup of the stolen relative address instructions??? + // return 0; + + R->EAX(pBuilding->IsAbsorbAllowed()); + return 0x51A327; +} + +DEFINE_HOOK(0x73A2F4, UnitClass_PerCellProcess_SubmitToOpenToppedOnBuildingEnter, 0x6) +{ + GET(UnitClass* const, pThis, EBP); + GET(BuildingClass* const, pBuilding, EBX); + + if (pBuilding->Type->OpenTopped) + pBuilding->EnteredOpenTopped(pThis); + + if (pThis->Type->OpenTopped) + pThis->SetTargetForPassengers(nullptr); + + return 0; +} + +DEFINE_HOOK(0x44DBA9, BuildingClass_MissionUnload_DisableOpenToppedForUnloading, 0x6) +{ + GET(BuildingClass* const, pThis, EBP); + GET(FootClass* const, pFoot, ESI); + + if (pThis->Type->OpenTopped) + pThis->ExitedOpenTopped(pFoot); + + if (pThis->Type->OpenTopped && pFoot->Owner != pThis->Owner) + pFoot->SetTarget(nullptr); + + return 0; +} + +// misleading WW name, Drop_Debris also handles survivors +DEFINE_HOOK(0x442D97, BuildingClass_DropDebris_DisableOpenTopped, 0x6) +{ + GET(BuildingClass* const, pThis, ECX); + + if (pThis->Type->OpenTopped) + pThis->MarkPassengersAsExited(); + + return 0; +} + +#pragma endregion + +// previously the building was given as a target for the unload order, unlike unit unload order which uses null target +DEFINE_HOOK_AGAIN(0x443557, BuildingClass_ActiveClickWith_NullTargetForUnload, 0x0) +DEFINE_HOOK(0x443534, BuildingClass_ActiveClickWith_NullTargetForUnload, 0x0) +{ + GET(BuildingClass* const, pThis, EBX); + + R->EAX(pThis->ClickedMission(Mission::Unload, nullptr, nullptr, nullptr)); + + return R->Origin() + 17; +} \ No newline at end of file