-
-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathHooks.BuildLastTab.cpp
More file actions
42 lines (32 loc) · 1.23 KB
/
Copy pathHooks.BuildLastTab.cpp
File metadata and controls
42 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Body.h"
#include <SidebarClass.h>
#include <BuildingTypeClass.h>
#include <TechnoClass.h>
// Hook into HouseClass::RegisterObjectGain_FromFactory (0x4FB6B0).
// Fires when a unit or building is delivered from a factory.
// At this point: EDI = HouseClass*, EBP = TechnoClass* (the object being delivered).
// We track the delivered type per sidebar tab so the "Build Last" commands can re-queue it.
DEFINE_HOOK(0x4FB6C2, HouseClass_RegisterObjectGain_TrackLastBuiltTab, 0x7)
{
GET(HouseClass* const, pThis, EDI);
GET(TechnoClass* const, pTechno, EBP);
if (pThis != HouseClass::CurrentPlayer)
return 0;
auto const pType = pTechno->GetTechnoType();
if (!pType)
return 0;
auto const absType = pType->WhatAmI();
auto const isNaval = pType->Naval;
auto buildCat = BuildCat::DontCare;
if (absType == AbstractType::BuildingType)
buildCat = static_cast<BuildingTypeClass const*>(pType)->BuildCat;
int const tabIdx = SidebarClass::GetObjectTabIdx(absType, buildCat, isNaval);
if (tabIdx >= 0 && tabIdx < 4)
{
auto const pExt = HouseExt::ExtMap.Find(pThis);
pExt->LastBuiltPerTab[tabIdx] = pType->GetArrayIndex();
pExt->LastBuiltRTTIPerTab[tabIdx] = absType;
pExt->LastBuiltIsNavalPerTab[tabIdx] = isNaval;
}
return 0;
}