Skip to content

Commit 7287692

Browse files
authored
Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner (#1934)
some effects: CLEG CARRIER LastTarget set by Override_Mission (such as retaliation)
1 parent 14c934f commit 7287692

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ This page lists all the individual contributions to the project by their author.
635635
- Fix an issue that the AI would enter a combat state when its building receiving damage from friendly units or damage not greater than 0
636636
- Fix an issue that the techno with weapon with `AA=yes` and `AG=no` would not auto targeting units that are falling, such as paratroopers
637637
- Dehardcode the `ZAdjust` of warhead anim
638+
- Fix an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner
638639
- **solar-III (凤九歌)**
639640
- Target scanning delay customization (documentation)
640641
- Skip target scanning function calling for unarmed technos (documentation)

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
271271
- Reactivate unused trigger events 2, 53, and 54.
272272
- Fixed the bug that vehicle fall on infantry will make all cell content has been removed.
273273
- Fixed `MovementZone=Subterannean` harvesters being unable to find docks if in area enclosed by water, cliffs etc.
274+
- Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner.
274275

275276
## Fixes / interactions with other extensions
276277

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ New:
458458
- Fast access structure (by FlyStar)
459459
- Toggle off laser trail and shake effects (by Ollerus)
460460
- [Dehardcode the `ZAdjust` of warhead anim](Fixed-or-Improved-Logics.md#dehardcode-the-zadjust-of-warhead-anim) (by TaranDahl)
461+
- Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner (by TaranDahl)
461462
462463
Vanilla fixes:
463464
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Misc/Hooks.BugFixes.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,3 +2818,52 @@ DEFINE_HOOK(0x54CC9C, JumpjetLocomotionClass_ProcessCrashing_DropFix, 0x5)
28182818

28192819
return fallOnSomething ? SkipGameCode2 : SkipGameCode;
28202820
}
2821+
2822+
#pragma region ClearTargetOnOwnerChanged
2823+
2824+
DEFINE_HOOK(0x70D4A0, AbstractClass_ClearTargetToMe_ClearManagerTarget, 0x5)
2825+
{
2826+
GET(AbstractClass*, pThis, ECX);
2827+
2828+
for (const auto pTemporal : TemporalClass::Array)
2829+
{
2830+
if (pTemporal->Target == pThis)
2831+
pTemporal->LetGo();
2832+
}
2833+
2834+
// WW don't clear target if the techno has airstrike manager.
2835+
// No idea why, but for now we respect it and don't handle the airstrike target.
2836+
//for (const auto pAirstrike : AirstrikeClass::Array)
2837+
//{
2838+
// if (pAirstrike->Target == pThis)
2839+
// pAirstrike->ClearTarget();
2840+
//}
2841+
2842+
for (const auto pSpawn : SpawnManagerClass::Array)
2843+
{
2844+
if (pSpawn->Target == pThis)
2845+
pSpawn->ResetTarget();
2846+
}
2847+
2848+
if (const auto pTechno = abstract_cast<TechnoClass*>(pThis))
2849+
pTechno->LastTarget = nullptr;
2850+
2851+
if (const auto pFoot = abstract_cast<FootClass*>(pThis))
2852+
pFoot->LastDestination = nullptr;
2853+
2854+
return 0;
2855+
}
2856+
2857+
DEFINE_HOOK(0x70D4FD, AbstractClass_ClearTargetToMe_ClearLastTarget, 0x6)
2858+
{
2859+
GET(TechnoClass*, pTechno, ESI);
2860+
GET(const bool, shouldClear, ECX);
2861+
GET(AbstractClass*, pThis, EBP);
2862+
2863+
if (pTechno->LastTarget == pThis && shouldClear)
2864+
pTechno->LastTarget = nullptr;
2865+
2866+
return 0;
2867+
}
2868+
2869+
#pragma endregion

0 commit comments

Comments
 (0)