Skip to content

Commit

Permalink
Fix AllDestroyed TEvent in Ra2Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Belonit committed Mar 27, 2024
1 parent 050f923 commit a1144e3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Spawner/Ra2Mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <BuildingClass.h>
#include <CellClass.h>
#include <HouseClass.h>
#include <InfantryClass.h>
#include <LoadOptionsClass.h>

bool Ra2Mode::Enabled = false;
Expand Down Expand Up @@ -244,3 +245,32 @@ DEFINE_HOOK(0x73E3DB, UnitClass_MissionUnload__CheckPowerBeforeOrePurifier, 0x6)

return 0x73E3DB + 0x6;
}

// Additionally check alive infantry in the allied transport
// and also check ActiveAircraftTypes
// https://github.com/CnCNet/cncnet-yr-client-package/issues/349
DEFINE_HOOK(0x71F1A2, TEventClass_Execute_AllDestroyed, 0x6)
{
if (!Ra2Mode::IsEnabled())
return 0;

if (!SessionClass::IsCampaign())
return 0;

enum { AllDestroyed = 0x71F1B1, HasAlive = 0x71F163 };
GET(HouseClass*, pHouse, ESI);

if (pHouse->ActiveAircraftTypes.GetTotal() > 0)
return HasAlive;

if (pHouse->ActiveInfantryTypes.GetTotal() > 0)
return HasAlive;

for (auto pItem : *InfantryClass::Array)
{
if (pItem->InLimbo && pHouse == pItem->GetOwningHouse() && pHouse->IsAlliedWith(pItem->Transporter))
return HasAlive;
}

return AllDestroyed;
}

0 comments on commit a1144e3

Please sign in to comment.