Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ This page lists all the individual contributions to the project by their author.
- 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
- 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
- Dehardcode the `ZAdjust` of warhead anim
- Fix an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner
- **solar-III (凤九歌)**
- Target scanning delay customization (documentation)
- Skip target scanning function calling for unarmed technos (documentation)
Expand Down
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Reactivate unused trigger events 2, 53, and 54.
- Fixed the bug that vehicle fall on infantry will make all cell content has been removed.
- Fixed `MovementZone=Subterannean` harvesters being unable to find docks if in area enclosed by water, cliffs etc.
- Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner.

## Fixes / interactions with other extensions

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ New:
- Fast access structure (by FlyStar)
- Toggle off laser trail and shake effects (by Ollerus)
- [Dehardcode the `ZAdjust` of warhead anim](Fixed-or-Improved-Logics.md#dehardcode-the-zadjust-of-warhead-anim) (by TaranDahl)
- Fixed an issue where some effects pointing to a unit were not properly cleared when the unit changed its owner (by TaranDahl)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
49 changes: 49 additions & 0 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2818,3 +2818,52 @@ DEFINE_HOOK(0x54CC9C, JumpjetLocomotionClass_ProcessCrashing_DropFix, 0x5)

return fallOnSomething ? SkipGameCode2 : SkipGameCode;
}

#pragma region ClearTargetOnOwnerChanged

DEFINE_HOOK(0x70D4A0, AbstractClass_ClearTargetToMe_ClearManagerTarget, 0x5)
{
GET(AbstractClass*, pThis, ECX);

for (const auto pTemporal : TemporalClass::Array)
{
if (pTemporal->Target == pThis)
pTemporal->LetGo();
}

// WW don't clear target if the techno has airstrike manager.
// No idea why, but for now we respect it and don't handle the airstrike target.
//for (const auto pAirstrike : AirstrikeClass::Array)
//{
// if (pAirstrike->Target == pThis)
// pAirstrike->ClearTarget();
//}

for (const auto pSpawn : SpawnManagerClass::Array)
{
if (pSpawn->Target == pThis)
pSpawn->ResetTarget();
}

if (const auto pTechno = abstract_cast<TechnoClass*>(pThis))
pTechno->LastTarget = nullptr;

if (const auto pFoot = abstract_cast<FootClass*>(pThis))
pFoot->LastDestination = nullptr;

return 0;
}

DEFINE_HOOK(0x70D4FD, AbstractClass_ClearTargetToMe_ClearLastTarget, 0x6)
{
GET(TechnoClass*, pTechno, ESI);
GET(const bool, shouldClear, ECX);
GET(AbstractClass*, pThis, EBP);

if (pTechno->LastTarget == pThis && shouldClear)
pTechno->LastTarget = nullptr;

return 0;
}

#pragma endregion