2
#include "../TechnoType/Body.h"
4
#include <StringTable.h>
5
#include <GameModeOptionsClass.h>
6
#include <BuildingClass.h>
7
#include <AircraftClass.h>
8
#include <InfantryClass.h>
10
#include <ArrayClasses.h>
11
#include <Helpers/Template.h>
14
// =============================
17
DEFINE_HOOK(4F7870, HouseClass_PrereqValidator, 7)
19
// int (TechnoTypeClass *item, bool BuildLimitOnly, bool includeQueued)
26
GET(HouseClass *, pHouse, ECX);
27
GET_STACK(TechnoTypeClass *, pItem, 0x4);
28
GET_STACK(bool, BuildLimitOnly, 0x8);
29
GET_STACK(bool, IncludeQueued, 0xC);
31
R->EAX(HouseExt::PrereqValidate(pHouse, pItem, BuildLimitOnly, IncludeQueued));
35
// upgrades as prereqs, facepalm of epic proportions
36
// not needed anymore since the whole function's been replaced
38
A_FINE_HOOK(4F7E49, HouseClass_CanBuildHowMany_Upgrades, 5)
40
return R->get_EAX() < 3 ? 0x4F7E41 : 0x4F7E34;
45
* Attention: This is a rewrite of the "is this house defeated yet?" check that should clear up the
46
* "On rare occasions, a player may lose every single unit they have but will not be 'defeated'." issues
47
* But! It does so by detecting if you have any objects that are not in limbo, and defeating you if you don't.
48
* An exception was added for parasites - they will count as eligible even when in limbo...
51
DEFINE_HOOK(4F8EBD, HouseClass_Update_HasBeenDefeated, 0)
53
GET(HouseClass *, H, ESI);
55
if(H->OwnedBuildings) {
59
struct EligibleObject {
61
EligibleObject(HouseClass *pHouse) : H(pHouse) {};
62
bool operator()(TechnoClass *T) {
69
if(FootClass *F = generic_cast<FootClass *>(T)) {
70
return F->ParasiteImUsing != NULL;
76
if(GameModeOptionsClass::Instance->ShortGame) {
77
for(int i = 0; i < RulesClass::Instance->BaseUnit.Count; ++i) {
78
UnitTypeClass *U = RulesClass::Instance->BaseUnit[i];
79
if(H->OwnedUnitTypes.GetItemCount(U->ArrayIndex)) {
84
if(H->OwnedUnitTypes1.Count) {
85
for(int i = 0; i < UnitClass::Array->Count; ++i) {
86
TechnoClass *T = UnitClass::Array->Items[i];
93
if(H->OwnedInfantryTypes1.Count) {
94
for(int i = 0; i < InfantryClass::Array->Count; ++i) {
95
TechnoClass *T = InfantryClass::Array->Items[i];
102
if(H->OwnedAircraftTypes1.Count) {
103
for(int i = 0; i < AircraftClass::Array->Count; ++i) {
104
TechnoClass *T = AircraftClass::Array->Items[i];
119
DEFINE_HOOK(4F645F, HouseClass_CTOR_FixSideIndices, 5)
121
GET(HouseClass *, pHouse, EBP);
122
if(HouseTypeClass * pCountry = pHouse->Type) {
123
if(strcmp(pCountry->ID, "Neutral") && strcmp(pCountry->ID, "Special")) {
124
pHouse->SideIndex = pCountry->SideIndex;
130
DEFINE_HOOK(500CC5, HouseClass_InitFromINI_FixBufferLimits, 6)
132
GET(HouseClass *, H, EBX);
134
if(H->UINameString[0]) {
135
const wchar_t *str = StringTable::LoadString(H->UINameString);
136
CRT::wcsncpy(H->UIName, str, 20);
138
CRT::wcsncpy(H->UIName, H->Type->UIName, 20);
145
DEFINE_HOOK(4F62FF, HouseClass_CTOR_FixNameOverflow, 6)
147
GET(HouseClass *, H, EBP);
148
GET_STACK(HouseTypeClass *, Country, 0x48);
150
CRT::wcsncpy(H->UIName, Country->UIName, 20);