Skip to content

Commit

Permalink
Fix Ares' InitialPayload for teams spawned by trigger actions (#1283)
Browse files Browse the repository at this point in the history
[Ares](Ares-Developers/Ares@1b8b66f)
marked its initialpayload already created for units spawned by trigger
actions because of the mutex.
  • Loading branch information
chaserli authored Dec 28, 2024
1 parent 3a54e85 commit c5b894e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ This page lists all the individual contributions to the project by their author.
- Ares' Abductor weapon fix
- Suppress Ares' swizzle warning when parsing tags and taskforces
- Better fix for Ares academy not working on the initial payloads of vehicles built from a war factory
- Fix Ares' InitialPayload for teams spawned by trigger actions
- Misc code refactor & maintenance, CN doc fixes, bugfixes
- **FlyStar**
- Campaign load screen PCX support
Expand Down
2 changes: 1 addition & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed Ares' Abductor weapon leaves permanent placement stats when abducting moving vehicles.
- Suppressed Ares' swizzle warning when parsing `Tags` and `TaskForces` (typically begin with `[Developer fatal]Pointer 00000000 declared change to both`).
- Fixed Academy *(Ares feature)* not working on the initial payloads *(Ares feature)* of vehicles built from a war factory.

- Fixed Ares' InitialPayload not being created for vehicles spawned by trigger actions.
## Aircraft

### Carryall pickup voice
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ Fixes / interactions with other extensions:
- Fixed Ares' Abductor weapon leaves permanent placement stats when abducting moving vehicles (by Trsdy)
- Suppressed Ares' swizzle warning when parsing `Tags` and `TaskForces` (by Trsdy)
- Fixed Academy *(Ares feature)* not working on the initial payloads *(Ares feature)* of vehicles built from a war factory (by Trsdy, supersedes Aephiex impl.)
- Fixed Ares' InitialPayload not being created for vehicles spawned by trigger actions (by Trsdy)
</details>
### 0.3.0.1
Expand Down
26 changes: 23 additions & 3 deletions src/Ext/Team/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
#include "Body.h"

#include <Utilities/AresHelper.h>

// Bugfix: TAction 7,80,107.
DEFINE_HOOK(0x65DF81, TeamTypeClass_CreateMembers_LoadOntoTransport, 0x7)
DEFINE_HOOK(0x65DF67, TeamTypeClass_CreateMembers_LoadOntoTransport, 0x6)
{
if(!AresHelper::CanUseAres) // If you're not using Ares you don't deserve a fix
return 0;

GET(FootClass* const, pPayload, EAX);
GET(FootClass* const, pTransport, ESI);
GET(TeamClass* const, pTeam, EBP);
GET(TeamTypeClass const*, pThis, EBX);

auto unmarkPayloadCreated = [](FootClass* member){reinterpret_cast<char*>(member->align_154)[0x9E] = false;};

if (!pTransport)
{
for (auto pNext = pPayload;
pNext && pNext != pTransport && pNext->Team == pTeam;
pNext = abstract_cast<FootClass*>(pNext->NextObject))
unmarkPayloadCreated(pNext);

return 0x65DFE8;
}

unmarkPayloadCreated(pTransport);

if (!pPayload || !pThis->Full)
return 0x65E004;

const bool isTransportOpenTopped = pTransport->GetTechnoType()->OpenTopped;
FootClass* pGunner = nullptr;
Expand All @@ -29,6 +50,5 @@ DEFINE_HOOK(0x65DF81, TeamTypeClass_CreateMembers_LoadOntoTransport, 0x7)
if (pTransport->GetTechnoType()->Gunner && pGunner)
pTransport->ReceiveGunner(pGunner);

// Ares' CreateInitialPayload doesn't work here
return 0x65DF8D;
}

0 comments on commit c5b894e

Please sign in to comment.