Skip to content

Commit a1144e3

Browse files
committed
Fix AllDestroyed TEvent in Ra2Mode
1 parent 050f923 commit a1144e3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/Spawner/Ra2Mode.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <BuildingClass.h>
2525
#include <CellClass.h>
2626
#include <HouseClass.h>
27+
#include <InfantryClass.h>
2728
#include <LoadOptionsClass.h>
2829

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

245246
return 0x73E3DB + 0x6;
246247
}
248+
249+
// Additionally check alive infantry in the allied transport
250+
// and also check ActiveAircraftTypes
251+
// https://github.com/CnCNet/cncnet-yr-client-package/issues/349
252+
DEFINE_HOOK(0x71F1A2, TEventClass_Execute_AllDestroyed, 0x6)
253+
{
254+
if (!Ra2Mode::IsEnabled())
255+
return 0;
256+
257+
if (!SessionClass::IsCampaign())
258+
return 0;
259+
260+
enum { AllDestroyed = 0x71F1B1, HasAlive = 0x71F163 };
261+
GET(HouseClass*, pHouse, ESI);
262+
263+
if (pHouse->ActiveAircraftTypes.GetTotal() > 0)
264+
return HasAlive;
265+
266+
if (pHouse->ActiveInfantryTypes.GetTotal() > 0)
267+
return HasAlive;
268+
269+
for (auto pItem : *InfantryClass::Array)
270+
{
271+
if (pItem->InLimbo && pHouse == pItem->GetOwningHouse() && pHouse->IsAlliedWith(pItem->Transporter))
272+
return HasAlive;
273+
}
274+
275+
return AllDestroyed;
276+
}

0 commit comments

Comments
 (0)