forked from Phobos-developers/Phobos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
for future use
- Loading branch information
Showing
8 changed files
with
46 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,6 @@ | |
|
||
#include <string> | ||
|
||
#define CAN_USE_ARES 1 | ||
|
||
class CCINIClass; | ||
class AbstractClass; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,35 @@ | ||
#pragma once | ||
#include "AresFunctions.h" | ||
#include "AresHelper.h" | ||
#include "Patch.h" | ||
#define NOTE_ARES_FUN(name,reladdr) AresFunctions::name = reinterpret_cast<decltype(AresFunctions::name)>(AresHelper::AresBaseAddress + reladdr) | ||
|
||
const AresHelper::AresVersionFunctionMap AresHelper::AresFunctionOffsets = | ||
decltype(AresFunctions::ConvertTypeTo) AresFunctions::ConvertTypeTo = nullptr; | ||
decltype(AresFunctions::SpawnSurvivors) AresFunctions::SpawnSurvivors = nullptr; | ||
|
||
void AresFunctions::InitAres3_0() | ||
{ | ||
NOTE_ARES_FUN(ConvertTypeTo, 0x043650); | ||
if constexpr (AresFunctions::AresWasWrongAboutSpawnSurvivors) | ||
{ | ||
AresHelper::Version::Ares30, | ||
{ | ||
{ ARES_FUN(ConvertTypeTo), 0x043650 }, | ||
{ ARES_FUN(SpawnSurvivors), 0x0464C0 }, | ||
{ ARES_FUN(HasFactory), 0x0217C0 }, | ||
{ ARES_FUN(CanBeBuiltAt), 0x03E3B0 }, | ||
} | ||
}, | ||
Patch::Apply_RAW(AresHelper::AresBaseAddress + 0x4C0EB, { 0x5C }); | ||
Patch::Apply_RAW(AresHelper::AresBaseAddress + 0x48C69, { 0x30 }); | ||
} | ||
else | ||
NOTE_ARES_FUN(SpawnSurvivors, 0x0464C0); | ||
} | ||
|
||
void AresFunctions::InitAres3_0p1() | ||
{ | ||
NOTE_ARES_FUN(ConvertTypeTo, 0x044130); | ||
if constexpr (AresFunctions::AresWasWrongAboutSpawnSurvivors) | ||
{ | ||
AresHelper::Version::Ares30p, | ||
{ | ||
{ ARES_FUN(ConvertTypeTo), 0x044130 }, | ||
{ ARES_FUN(SpawnSurvivors), 0x047030 }, | ||
{ ARES_FUN(HasFactory), 0x0217C0 }, | ||
{ ARES_FUN(CanBeBuiltAt), 0x03E3B0 }, | ||
} | ||
}, | ||
}; | ||
Patch::Apply_RAW(AresHelper::AresBaseAddress + 0x4CD4B, { 0x5C }); | ||
Patch::Apply_RAW(AresHelper::AresBaseAddress + 0x498B9, { 0x30 }); | ||
} | ||
else | ||
NOTE_ARES_FUN(SpawnSurvivors, 0x047030); | ||
} | ||
|
||
#undef NOTE_ARES_FUN | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,22 @@ | ||
#pragma once | ||
#include "AresHelper.h" | ||
|
||
#include <nameof/nameof.h> | ||
#include <ASMMacros.h> | ||
#include <functional> | ||
|
||
class TechnoClass; | ||
class TechnoTypeClass; | ||
class FootClass; | ||
class HouseClass; | ||
class BuildingTypeClass; | ||
|
||
class AresTechnoTypeExt | ||
{ | ||
public: | ||
__declspec(noinline) bool __thiscall CanBeBuiltAt(BuildingTypeClass* pBuildingType) { return 0; } | ||
}; | ||
|
||
|
||
class AresFunctions | ||
{ | ||
public: | ||
#define CALL_ARES(name, ...) std::invoke(reinterpret_cast<decltype(name)*>(AresHelper::AresFunctionOffsetsFinal[ARES_FUN(name)]), __VA_ARGS__) | ||
#define THIS_CALL_ARES(name, ...) std::invoke(*reinterpret_cast<decltype(name)*>(AresHelper::AresFunctionOffsetsFinal[ARES_FUN_M(name)]), __VA_ARGS__) | ||
|
||
// ??? | ||
static bool ConvertTypeTo(TechnoClass* pFoot, TechnoTypeClass* pConvertTo) | ||
{ | ||
return CALL_ARES(ConvertTypeTo, pFoot, pConvertTo); | ||
} | ||
|
||
static void InitAres3_0(); | ||
static void InitAres3_0p1(); | ||
// TechnoExt | ||
static void SpawnSurvivors(FootClass* const pThis, TechnoClass* const pKiller, const bool Select, const bool IgnoreDefenses) | ||
{ | ||
CALL_ARES(SpawnSurvivors, pThis, pKiller, Select, IgnoreDefenses); | ||
} | ||
|
||
// HouseExt | ||
static int HasFactory(int buffer, HouseClass* pOwner, TechnoTypeClass* pType, bool skipAircraft, bool requirePower, bool checkCanBuild, bool unknown) | ||
{ | ||
return CALL_ARES(HasFactory, buffer, pOwner, pType, skipAircraft, requirePower, checkCanBuild, unknown); | ||
} | ||
static bool(__stdcall* ConvertTypeTo)(TechnoClass* pFoot, TechnoTypeClass* pConvertTo); | ||
|
||
// TechnoTypeExt | ||
static bool CanBeBuiltAt(AresTechnoTypeExt* pExt, BuildingTypeClass* pBuildingType) | ||
{ | ||
return THIS_CALL_ARES(&AresTechnoTypeExt::CanBeBuiltAt, pExt, pBuildingType); | ||
} | ||
static void(__stdcall* SpawnSurvivors)(FootClass* pThis, TechnoClass* pKiller, bool Select, bool IgnoreDefenses); | ||
private: | ||
static constexpr bool _maybe = false; | ||
|
||
#undef CALL_ARES | ||
#undef THIS_CALL_ARES | ||
static constexpr bool AresWasWrongAboutSpawnSurvivors = _maybe; | ||
static constexpr bool AresWasWrongAboutAduction = true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters