|
| 1 | +#include "Body.h" |
| 2 | + |
| 3 | +#include <Ext/Side/Body.h> |
| 4 | +#include <Utilities/GeneralUtils.h> |
| 5 | + |
| 6 | +HouseTypeExt::ExtContainer HouseTypeExt::ExtMap; |
| 7 | + |
| 8 | +void HouseTypeExt::ExtData::Initialize() { } |
| 9 | + |
| 10 | +void HouseTypeExt::ExtData::LoadFromINIFile(CCINIClass* pINI) |
| 11 | +{ |
| 12 | + auto pThis = this->OwnerObject(); |
| 13 | + const char* pSection = pThis->ID; |
| 14 | + |
| 15 | + if (!pINI->GetSection(pSection)) |
| 16 | + return; |
| 17 | + |
| 18 | + INI_EX exINI(pINI); |
| 19 | + |
| 20 | + this->EVATag.Read(pINI, pSection, "EVA.Tag"); |
| 21 | +} |
| 22 | + |
| 23 | +template <typename T> |
| 24 | +void HouseTypeExt::ExtData::Serialize(T& Stm) |
| 25 | +{ |
| 26 | + Stm |
| 27 | + .Process(this->EVATag) |
| 28 | + ; |
| 29 | +} |
| 30 | + |
| 31 | +void HouseTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm) |
| 32 | +{ |
| 33 | + Extension<HouseTypeClass>::LoadFromStream(Stm); |
| 34 | + this->Serialize(Stm); |
| 35 | +} |
| 36 | + |
| 37 | +void HouseTypeExt::ExtData::SaveToStream(PhobosStreamWriter& Stm) |
| 38 | +{ |
| 39 | + Extension<HouseTypeClass>::SaveToStream(Stm); |
| 40 | + this->Serialize(Stm); |
| 41 | +} |
| 42 | + |
| 43 | +bool HouseTypeExt::LoadGlobals(PhobosStreamReader& Stm) |
| 44 | +{ |
| 45 | + return Stm |
| 46 | + .Success(); |
| 47 | +} |
| 48 | + |
| 49 | +bool HouseTypeExt::SaveGlobals(PhobosStreamWriter& Stm) |
| 50 | +{ |
| 51 | + return Stm |
| 52 | + .Success(); |
| 53 | +} |
| 54 | + |
| 55 | +// ============================= |
| 56 | +// container |
| 57 | + |
| 58 | +HouseTypeExt::ExtContainer::ExtContainer() : Container("HouseTypeClass") { } |
| 59 | +HouseTypeExt::ExtContainer::~ExtContainer() = default; |
| 60 | + |
| 61 | +// ============================= |
| 62 | +// container hooks |
| 63 | + |
| 64 | +DEFINE_HOOK(0x511635, HouseTypeClass_CTOR_1, 0x5) |
| 65 | +{ |
| 66 | + GET(HouseTypeClass*, pItem, EAX); |
| 67 | + |
| 68 | + HouseTypeExt::ExtMap.TryAllocate(pItem); |
| 69 | + return 0; |
| 70 | +} |
| 71 | + |
| 72 | +DEFINE_HOOK(0x511643, HouseTypeClass_CTOR_2, 0x5) |
| 73 | +{ |
| 74 | + GET(HouseTypeClass*, pItem, EAX); |
| 75 | + |
| 76 | + HouseTypeExt::ExtMap.TryAllocate(pItem); |
| 77 | + return 0; |
| 78 | +} |
| 79 | + |
| 80 | +DEFINE_HOOK(0x5127CF, HouseTypeClass_DTOR, 0x6) |
| 81 | +{ |
| 82 | + GET(HouseTypeClass*, pItem, ESI); |
| 83 | + |
| 84 | + HouseTypeExt::ExtMap.Remove(pItem); |
| 85 | + return 0; |
| 86 | +} |
| 87 | + |
| 88 | +DEFINE_HOOK_AGAIN(0x512480, HouseTypeClass_SaveLoad_Prefix, 0x5) |
| 89 | +DEFINE_HOOK(0x512290, HouseTypeClass_SaveLoad_Prefix, 0x5) |
| 90 | +{ |
| 91 | + GET_STACK(HouseTypeClass*, pItem, 0x4); |
| 92 | + GET_STACK(IStream*, pStm, 0x8); |
| 93 | + |
| 94 | + HouseTypeExt::ExtMap.PrepareStream(pItem, pStm); |
| 95 | + |
| 96 | + return 0; |
| 97 | +} |
| 98 | + |
| 99 | +DEFINE_HOOK(0x51246D, HouseTypeClass_Load_Suffix, 0x5) |
| 100 | +{ |
| 101 | + |
| 102 | + HouseTypeExt::ExtMap.LoadStatic(); |
| 103 | + return 0; |
| 104 | +} |
| 105 | + |
| 106 | +DEFINE_HOOK(0x51255C, HouseTypeClass_Save_Suffix, 0x5) |
| 107 | +{ |
| 108 | + HouseTypeExt::ExtMap.SaveStatic(); |
| 109 | + return 0; |
| 110 | +} |
| 111 | + |
| 112 | +DEFINE_HOOK_AGAIN(0x51215A, HouseTypeClass_LoadFromINI, 0x5) |
| 113 | +DEFINE_HOOK(0x51214F, HouseTypeClass_LoadFromINI, 0x5) |
| 114 | +{ |
| 115 | + GET(HouseTypeClass*, pItem, EBX); |
| 116 | + GET_BASE(CCINIClass*, pINI, 0x8); |
| 117 | + |
| 118 | + HouseTypeExt::ExtMap.LoadFromINI(pItem, pINI); |
| 119 | + return 0; |
| 120 | +} |
0 commit comments