Skip to content

Commit adffe12

Browse files
committed
Fix SW hook without Ares and fix incorrect WhatAmI in ~TechnoExtData
1 parent 1487071 commit adffe12

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

src/Ext/SWType/FireSuperWeapon.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ void SWTypeExt::FireSuperWeaponExt(SuperClass* pSW, const CellStruct& cell)
4848
int index = 0;
4949
int TagCount = pTags->Count;
5050

51-
while (true)
51+
while (TagCount > 0 && index < TagCount)
5252
{
53-
if (TagCount <= 0 || index >= TagCount)
54-
break;
55-
5653
const auto pTag = pTags->GetItem(index);
5754

5855
// don't be confused as to why (TechnoClass*)(pSW) is there, it's something very much needed..

src/Ext/SWType/Hooks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ DEFINE_HOOK(0x6CC390, SuperClass_Launch, 0x6)
2121
// Ares hooked at 0x6CC390 and jumped to 0x6CDE40
2222
// If a super is not handled by Ares however, we do it at the original entry point
2323
DEFINE_HOOK_AGAIN(0x6CC390, SuperClass_Place_FireExt, 0x6)
24-
DEFINE_HOOK(0x6CDE40, SuperClass_Place_FireExt, 0x4)
24+
DEFINE_HOOK(0x6CDE40, SuperClass_Place_FireExt, 0x5)
2525
{
2626
GET(SuperClass* const, pSuper, ECX);
2727
GET_STACK(CellStruct const* const, pCell, 0x4);

src/Ext/Techno/Body.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ TechnoExt::ExtData::~ExtData()
1919
auto const pTypeExt = this->TypeExtData;
2020
auto const pType = pTypeExt->OwnerObject();
2121
auto pThis = this->OwnerObject();
22-
auto const whatAmI = pThis->WhatAmI();
22+
// Besides BuildingClass, calling pThis->WhatAmI() here will only result in AbstractType::None
23+
auto const whatAmI = pType->WhatAmI();
2324

2425
if (pTypeExt->AutoDeath_Behavior.isset())
2526
{
2627
auto& vec = ScenarioExt::Global()->AutoDeathObjects;
2728
vec.erase(std::remove(vec.begin(), vec.end(), this), vec.end());
2829
}
2930

30-
if (whatAmI != AbstractType::Aircraft && whatAmI != AbstractType::Building
31+
if (whatAmI != AbstractType::AircraftType && whatAmI != AbstractType::BuildingType
3132
&& pType->Ammo > 0 && pTypeExt->ReloadInTransport)
3233
{
3334
auto& vec = ScenarioExt::Global()->TransportReloaders;

src/Utilities/AresAddressInit.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ void AresFunctions::InitAres3_0p1()
6767

6868
#undef NOTE_ARES_FUN
6969

70+
void AresFunctions::InitNoAres()
71+
{
72+
Patch::Apply_RAW(0x6CDE40, { 0xC2, 0x08, 0x00, 0x90, 0x67 });
73+
}

src/Utilities/AresFunctions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class AresFunctions
2424
public:
2525
static void InitAres3_0();
2626
static void InitAres3_0p1();
27+
static void InitNoAres();
2728
// TechnoExt
2829
static bool(__stdcall* ConvertTypeTo)(TechnoClass* pFoot, TechnoTypeClass* pConvertTo);
2930

src/Utilities/AresHelper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void AresHelper::Init()
143143
break;
144144
default:
145145
Debug::LogDeferred("[Phobos] Detected a version of Ares that is not supported by Phobos. Disabling integration.\n");
146+
AresFunctions::InitNoAres();
146147
break;
147148
}
148149
}

0 commit comments

Comments
 (0)