2
#include "../TechnoType/Body.h"
4
#include <TacticalClass.h>
6
hash_AlphaExt TechnoExt::AlphaExt;
7
// conventions for hashmaps like this:
8
// the value's CTOR is the only thing allowed to .insert() or [] stuff
9
// the value's (SD)DTOR is the only thing allowed to .erase() stuff
11
DEFINE_HOOK(420960, AlphaShapeClass_CTOR, 5)
13
GET_STACK(ObjectClass *, O, 0x4);
14
GET(AlphaShapeClass *, AS, ECX);
15
hash_AlphaExt::iterator i = TechnoExt::AlphaExt.find(O);
16
if(i != TechnoExt::AlphaExt.end()) {
19
TechnoExt::AlphaExt[O] = AS;
23
DEFINE_HOOK(421730, AlphaShapeClass_SDDTOR, 8)
25
GET(AlphaShapeClass *, AS, ECX);
26
ObjectClass *O = AS->AttachedTo;
27
hash_AlphaExt::iterator i = TechnoExt::AlphaExt.find(O);
28
if(i != TechnoExt::AlphaExt.end()) {
29
TechnoExt::AlphaExt.erase(i);
34
DEFINE_HOOK(5F3D5B, ObjectClass_DTOR, A)
36
GET(ObjectClass *, O, ESI);
37
hash_AlphaExt::iterator i = TechnoExt::AlphaExt.find(O);
38
if(i != TechnoExt::AlphaExt.end()) {
44
DEFINE_HOOK(5F3E70, ObjectClass_Update, 5)
46
GET(ObjectClass *, Source, ECX);
47
ObjectTypeClass *SourceType = Source->GetType();
52
SHPStruct *Alpha = SourceType->AlphaImage;
59
RectangleStruct *ScreenArea = &TacticalClass::Instance->VisibleArea;
60
Point2D off = { ScreenArea->X - (Alpha->Width / 2), ScreenArea->Y - (Alpha->Height / 2) };
63
if(FootClass *Foot = generic_cast<FootClass *>(Source)) {
64
if(Foot->LastMapCoords != Foot->CurrentMapCoords) {
65
// we moved - need to redraw the area we were in
66
// alas, we don't have the precise XYZ we were in, only the cell we were last seen in
67
// so we need to add the cell's dimensions to the dirty area just in case
68
CellClass::Cell2Coord(&Foot->LastMapCoords, &XYZ);
70
TacticalClass::Instance->CoordsToClient(&XYZ, &xyTL);
71
// because the coord systems are different - xyz is x/, y\, xy is x-, y|
73
TacticalClass::Instance->CoordsToClient(&XYZ, &xyBR);
74
Point2D cellDimensions = xyBR - xyTL;
76
xy.X += cellDimensions.X / 2;
77
xy.Y += cellDimensions.Y / 2;
79
RectangleStruct Dirty =
80
{ xy.X - ScreenArea->X - cellDimensions.X, xy.Y - ScreenArea->Y - cellDimensions.Y,
81
Alpha->Width + cellDimensions.X * 2, Alpha->Height + cellDimensions.Y * 2 };
82
TacticalClass::Instance->RegisterDirtyArea(Dirty, 1);
86
bool Inactive = Source->InLimbo;
88
if(Source->AbstractFlags & ABSFLAGS_ISTECHNO) {
89
Inactive |= reinterpret_cast<TechnoClass *>(Source)->Deactivated;
92
if(Source->WhatAmI() == abs_Building && Source->GetCurrentMission() != mission_Construction) {
93
Inactive |= !reinterpret_cast<BuildingClass *>(Source)->IsPowerOnline();
97
hash_AlphaExt::iterator i = TechnoExt::AlphaExt.find(Source);
98
if(i != TechnoExt::AlphaExt.end()) {
104
if(Unsorted::CurrentFrame % 2) { // lag reduction - don't draw a new alpha every frame
105
Source->GetCoords(&XYZ);
106
TacticalClass::Instance->CoordsToClient(&XYZ, &xy);
108
++Unsorted::IKnowWhatImDoing;
109
AlphaShapeClass *placeholder;
110
GAME_ALLOC(AlphaShapeClass, placeholder, Source, xy.X, xy.Y);
111
--Unsorted::IKnowWhatImDoing;
113
RectangleStruct Dirty =
114
{ xy.X - ScreenArea->X, xy.Y - ScreenArea->Y,
115
Alpha->Width, Alpha->Height };
116
TacticalClass::Instance->RegisterDirtyArea(Dirty, 1);
123
DEFINE_HOOK(420F75, AlphaLightClass_UpdateScreen_ShouldDraw, 5)
125
GET(AlphaShapeClass *, A, ECX);
126
unsigned int idx = 0;
127
if(ObjectClass *O = A->AttachedTo) {
128
if(TechnoClass * T = generic_cast<TechnoClass *>(O)) {
129
TechnoExt::ExtData * pData = TechnoExt::ExtMap.Find(T);
130
if(!pData->DrawVisualFX()) {
138
DEFINE_HOOK(4210AC, AlphaLightClass_UpdateScreen_Header, 5)
140
GET(AlphaShapeClass *, A, EDX);
141
GET(SHPStruct *, Image, ECX);
142
if(ObjectClass *O = A->AttachedTo) {
143
if(TechnoClass * T = generic_cast<TechnoClass *>(O)) {
144
TechnoExt::ExtData * pData = TechnoExt::ExtMap.Find(T);
145
unsigned int idx = pData->AlphaFrame(Image);
152
DEFINE_HOOK(4211AC, AlphaLightClass_UpdateScreen_Body, 8)
154
GET_STACK(int, AlphaLightIndex, STACK_OFFS(0xDC, 0xB4));
155
GET_STACK(SHPStruct *, Image, STACK_OFFS(0xDC, 0x6C));
156
AlphaShapeClass *A = AlphaShapeClass::Array->Items[AlphaLightIndex];
157
if(ObjectClass *O = A->AttachedTo) {
158
if(TechnoClass * T = generic_cast<TechnoClass *>(O)) {
159
TechnoExt::ExtData * pData = TechnoExt::ExtMap.Find(T);
160
unsigned int idx = pData->AlphaFrame(Image);
168
DEFINE_HOOK(421371, TacticalClass_UpdateAlphasInRectangle_ShouldDraw, 5)
170
GET(int, AlphaLightIndex, EBX);
171
AlphaShapeClass *A = AlphaShapeClass::Array->Items[AlphaLightIndex];
172
unsigned int idx = 0;
173
if(ObjectClass *O = A->AttachedTo) {
174
if(TechnoClass * T = generic_cast<TechnoClass *>(O)) {
175
TechnoExt::ExtData * pData = TechnoExt::ExtMap.Find(T);
176
if(!pData->DrawVisualFX()) {
184
DEFINE_HOOK(42146E, TacticalClass_UpdateAlphasInRectangle_Header, 5)
186
GET(int, AlphaLightIndex, EBX);
187
GET(RectangleStruct *, buffer, EDX);
188
GET(SHPStruct *, Image, EDI);
190
AlphaShapeClass *A = AlphaShapeClass::Array->Items[AlphaLightIndex];
191
unsigned int idx = 0;
192
if(ObjectClass *O = A->AttachedTo) {
193
if(TechnoClass * T = generic_cast<TechnoClass *>(O)) {
194
TechnoExt::ExtData * pData = TechnoExt::ExtMap.Find(T);
195
idx = pData->AlphaFrame(Image);
198
R->EAX(Image->GetFrameHeader(buffer, idx));
202
DEFINE_HOOK(42152C, TacticalClass_UpdateAlphasInRectangle_Body, 8)
204
GET_STACK(int, AlphaLightIndex, STACK_OFFS(0xA4, 0x78));
205
GET(SHPStruct *, Image, ECX);
206
AlphaShapeClass *A = AlphaShapeClass::Array->Items[AlphaLightIndex];
207
if(ObjectClass *O = A->AttachedTo) {
208
if(TechnoClass * T = generic_cast<TechnoClass *>(O)) {
209
TechnoExt::ExtData * pData = TechnoExt::ExtMap.Find(T);
210
unsigned int idx = pData->AlphaFrame(Image);
217
DEFINE_HOOK(71944E, TeleportLocomotionClass_ILocomotion_Process, 6)
219
GET(FootClass *, Object, ECX);
220
GET(CoordStruct *, XYZ, EDX);
221
Object->GetCoords(XYZ);
222
R->EAX<CoordStruct *>(XYZ);
224
if(TechnoTypeClass *Type = Object->GetTechnoType()) {
225
if(SHPStruct *Alpha = Type->AlphaImage) {
227
TacticalClass::Instance->CoordsToClient(XYZ, &xy);
228
RectangleStruct *ScreenArea = &TacticalClass::Instance->VisibleArea;
229
Point2D off = { ScreenArea->X - (Alpha->Width / 2), ScreenArea->Y - (Alpha->Height / 2) };
231
RectangleStruct Dirty =
232
{ xy.X - ScreenArea->X, xy.Y - ScreenArea->Y,
233
Alpha->Width, Alpha->Height };
234
TacticalClass::Instance->RegisterDirtyArea(Dirty, 1);