~ares-developers/ares/gd03

« back to all changes in this revision

Viewing changes to src/Ext/Building/Hooks.Firewall.cpp

  • Committer: Renegade
  • Date: 2010-05-29 08:12:17 UTC
  • Revision ID: git-v1:0a1bb6321f04d723afe64d1b843dc87b4da783ec
Creating /trunk/src.

git-svn-id: svn://svn.renegadeprojects.com/ares/trunk@622 859b54a9-7a54-0410-aeb3-f8d2f1fa40fd

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <AnimClass.h>
 
2
#include <WeaponTypeClass.h>
 
3
 
 
4
#include "../../Misc/Applicators.h"
 
5
 
 
6
#include "Body.h"
 
7
#include "../BuildingType/Body.h"
 
8
#include "../House/Body.h"
 
9
#include "../Techno/Body.h"
 
10
 
 
11
DEFINE_HOOK(4FB257, HouseClass_UnitFromFactory_Firewall, 6)
 
12
{
 
13
        GET(BuildingClass *, B, ESI);
 
14
        GET(HouseClass *, H, EBP);
 
15
        GET_STACK(CellStruct, CenterPos, 0x4C);
 
16
 
 
17
        //BuildingExt::ExtendFirewall(B, CenterPos, H);
 
18
        BuildingExt::buildLines(B, CenterPos, H);
 
19
 
 
20
        return 0;
 
21
}
 
22
 
 
23
 
 
24
DEFINE_HOOK(445355, BuildingClass_KickOutUnit_Firewall, 6)
 
25
{
 
26
        GET(BuildingClass *, Factory, ESI);
 
27
 
 
28
        GET(BuildingClass *, B, EDI);
 
29
        GET_STACK(CellStruct, CenterPos, 0x20);
 
30
 
 
31
        //BuildingExt::ExtendFirewall(B, CenterPos, Factory->Owner);
 
32
        BuildingExt::buildLines(B, CenterPos, Factory->Owner);
 
33
 
 
34
        return 0;
 
35
}
 
36
 
 
37
// placement linking
 
38
DEFINE_HOOK(6D5455, sub_6D5030, 6)
 
39
{
 
40
        GET(BuildingTypeClass *, BT, EAX);
 
41
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(BT);
 
42
 
 
43
        return pTypeData->IsLinkable()
 
44
         ? 0x6D545F
 
45
         : 0x6D54A9;
 
46
}
 
47
 
 
48
// placement linking
 
49
DEFINE_HOOK(6D5A5C, sub_6D59D0, 6)
 
50
{
 
51
        GET(BuildingTypeClass *, BT, EDX);
 
52
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(BT);
 
53
 
 
54
        return pTypeData->IsLinkable()
 
55
         ? 0x6D5A66
 
56
         : 0x6D5A75;
 
57
}
 
58
 
 
59
// frame to draw
 
60
DEFINE_HOOK(43EFB3, BuildingClass_GetStaticImageFrame, 6)
 
61
{
 
62
        GET(BuildingClass *, B, ESI);
 
63
 
 
64
        if(B->GetCurrentMission() != mission_Construction) {
 
65
                signed int FrameIdx = BuildingExt::GetImageFrameIndex(B);
 
66
 
 
67
                if(FrameIdx != -1) {
 
68
                        R->EAX<signed int>(FrameIdx);
 
69
                        return 0x43EFC3;
 
70
                }
 
71
        }
 
72
        return 0x43EFC6;
 
73
}
 
74
 
 
75
// ignore damage
 
76
DEFINE_HOOK(442230, BuildingClass_ReceiveDamage_FSW, 6)
 
77
{
 
78
        GET(BuildingClass *, pThis, ECX);
 
79
        GET_STACK(int *, Damage, 0x4);
 
80
 
 
81
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(pThis->Type);
 
82
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(pThis->Owner);
 
83
        if(pTypeData->Firewall_Is && pHouseData->FirewallActive) {
 
84
                *Damage = 0;
 
85
                return 0x442C14;
 
86
        }
 
87
 
 
88
        return 0;
 
89
}
 
90
 
 
91
// main update
 
92
DEFINE_HOOK(43FC39, BuildingClass_Update_FSW, 6)
 
93
{
 
94
        GET(BuildingClass*, B, ESI);
 
95
 
 
96
        BuildingExt::ExtData * pData = BuildingExt::ExtMap.Find(B);
 
97
        pData->UpdateFirewall();
 
98
 
 
99
        return 0;
 
100
}
 
101
 
 
102
// pathfinding 1
 
103
DEFINE_HOOK(483D8E, CellClass_Setup_Slave, 6)
 
104
{
 
105
        GET(BuildingClass *, B, ESI);
 
106
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
107
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
108
 
 
109
        R->EAX<BuildingTypeClass *>(B->Type);
 
110
 
 
111
        if(pTypeData->Firewall_Is) {
 
112
                R->EAX<HouseClass *>(B->Owner);
 
113
                return pHouseData->FirewallActive
 
114
                         ? 0x483D6B
 
115
                         : 0x483DCD
 
116
                ;
 
117
        } else {
 
118
                return 0x483DB0;
 
119
        }
 
120
}
 
121
 
 
122
// pathfinding 2
 
123
DEFINE_HOOK(51BD4C, InfantryClass_Update, 6)
 
124
{
 
125
        GET(BuildingClass *, B, EDI);
 
126
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
127
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
128
 
 
129
        if(pTypeData->Firewall_Is) {
 
130
                return pHouseData->FirewallActive
 
131
                        ? 0x51BD7F
 
132
                        : 0x51BD7D
 
133
                ;
 
134
        } else {
 
135
                return 0x51BD68;
 
136
        }
 
137
}
 
138
 
 
139
// pathfinding 3
 
140
DEFINE_HOOK(51C4C8, InfantryClass_IsCellOccupied, 6)
 
141
{
 
142
        GET(BuildingClass *, B, ESI);
 
143
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
144
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
145
 
 
146
        if(pTypeData->Firewall_Is) {
 
147
                return pHouseData->FirewallActive
 
148
                        ? 0x51C7D0
 
149
                        : 0x51C70F
 
150
                ;
 
151
        } else {
 
152
                return 0x51C4EB;
 
153
        }
 
154
}
 
155
 
 
156
// pathfinding 4
 
157
DEFINE_HOOK(73F7B0, UnitClass_IsCellOccupied, 6)
 
158
{
 
159
        GET(BuildingClass *, B, ESI);
 
160
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
161
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
162
 
 
163
        if(pTypeData->Firewall_Is) {
 
164
                R->EAX<HouseClass *>(B->Owner);
 
165
                return pHouseData->FirewallActive
 
166
                        ? 0x73FCD0
 
167
                        : 0x73FA87
 
168
                ;
 
169
        } else {
 
170
                return 0x73F7D3;
 
171
        }
 
172
}
 
173
 
 
174
// pathfinding 5
 
175
DEFINE_HOOK(58819F, MapClass_SomePathfinding_1, 6)
 
176
{
 
177
        GET(BuildingClass *, B, EAX);
 
178
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
179
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
180
 
 
181
        R->EAX<HouseClass *>(B->Owner);
 
182
        return (pTypeData->Firewall_Is && pHouseData->FirewallActive)
 
183
                ? 0x5881BF
 
184
                : 0x5881C4
 
185
        ;
 
186
}
 
187
 
 
188
// pathfinding 6
 
189
DEFINE_HOOK(58828C, MapClass_SomePathfinding_2, 6)
 
190
{
 
191
        GET(BuildingClass *, B, EAX);
 
192
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
193
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
194
 
 
195
        R->EAX<HouseClass *>(B->Owner);
 
196
        return (pTypeData->Firewall_Is && pHouseData->FirewallActive)
 
197
                ? 0x5882AC
 
198
                : 0x5882B1
 
199
        ;
 
200
}
 
201
 
 
202
// pathfinding 7
 
203
DEFINE_HOOK(5884A4, MapClass_SomePathfinding_3, 6)
 
204
{
 
205
        GET(BuildingClass *, B, EAX);
 
206
        BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
207
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
208
 
 
209
        R->EAX<HouseClass *>(B->Owner);
 
210
        return (pTypeData->Firewall_Is && pHouseData->FirewallActive)
 
211
                ? 0x5884C4
 
212
                : 0x5884C9
 
213
        ;
 
214
}
 
215
 
 
216
// targeting state
 
217
DEFINE_HOOK(6FC0C5, TechnoClass_GetObjectActivityState_Firewall, 6)
 
218
{
 
219
        GET(TechnoClass *, Tgt, EBX);
 
220
        if(BuildingClass *B = specific_cast<BuildingClass*>(Tgt)) {
 
221
                if(BuildingTypeExt::ExtMap.Find(B->Type)->Firewall_Is) {
 
222
                        if(HouseExt::ExtMap.Find(B->Owner)->FirewallActive) {
 
223
                                return 0x6FC86A;
 
224
                        }
 
225
                }
 
226
        }
 
227
 
 
228
        return 0;
 
229
}
 
230
 
 
231
DEFINE_HOOK(6FCD1D, TechnoClass_GetObjectActivityState_CanTargetFirewall, 5)
 
232
{
 
233
        GET(TechnoClass *, Src, ESI);
 
234
        GET_STACK(TechnoClass *, Tgt, 0x24);
 
235
        GET_STACK(int, idxWeapon, 0x28);
 
236
 
 
237
        WeaponTypeClass *Weapon = Src->GetWeapon(idxWeapon)->WeaponType;
 
238
        if(!Weapon || !Weapon->Projectile) {
 
239
                return 0;
 
240
        }
 
241
 
 
242
        BulletTypeExt::ExtData *pBulletData = BulletTypeExt::ExtMap.Find(Weapon->Projectile);
 
243
        if(!pBulletData->SubjectToFirewall) {
 
244
                return 0;
 
245
        }
 
246
 
 
247
        FirestormFinderApplicator FireFinder(Src->Owner);
 
248
 
 
249
        CellSequence Path(&Src->Location, &Tgt->Location);
 
250
 
 
251
        Path.Apply(FireFinder);
 
252
 
 
253
        if(FireFinder.found) {
 
254
                Src->ShouldLoseTargetNow = 1;
 
255
                TechnoExt::FiringStateCache = FireError::ILLEGAL;
 
256
        } else {
 
257
                TechnoExt::FiringStateCache = FireError::NotAValue;
 
258
        }
 
259
        return 0;
 
260
}
 
261
 
 
262
DEFINE_HOOK(6FCD23, TechnoClass_GetObjectActivityState_OverrideFirewall, 6)
 
263
{
 
264
        if(TechnoExt::FiringStateCache != FireError::NotAValue) {
 
265
                R->EAX(TechnoExt::FiringStateCache);
 
266
                TechnoExt::FiringStateCache = FireError::NotAValue;
 
267
        }
 
268
 
 
269
        return 0;
 
270
}
 
271
 
 
272
DEFINE_HOOK(6F64CB, TechnoClass_DrawHealthBar, 6)
 
273
{
 
274
        GET(BuildingClass *, B, ESI);
 
275
        BuildingTypeExt::ExtData * pData = BuildingTypeExt::ExtMap.Find(B->Type);
 
276
        return (pData->Firewall_Is)
 
277
                ? 0x6F6832
 
278
                : 0
 
279
        ;
 
280
}
 
281
 
 
282
DEFINE_HOOK(71B126, TemporalClass_Fire, 7)
 
283
{
 
284
        GET(BuildingClass *, B, EDI);
 
285
        BuildingTypeExt::ExtData * pData = BuildingTypeExt::ExtMap.Find(B->Type);
 
286
        HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
287
 
 
288
        if(pData->Firewall_Is && pHouseData->FirewallActive) {
 
289
                bool found = false;
 
290
                for(int i = 0; i < B->Owner->Buildings.Count; ++i) {
 
291
                        BuildingClass * pBuilding = B->Owner->Buildings[i];
 
292
                        if(pBuilding->Type == B->Type && pBuilding != B) {
 
293
                                if(!pBuilding->InLimbo && pBuilding->IsAlive && pBuilding->Health) {
 
294
                                        found = true;
 
295
                                        break;
 
296
                                }
 
297
                        }
 
298
                }
 
299
                if(!found) {
 
300
                        pHouseData->SetFirestormState(0);
 
301
                }
 
302
        }
 
303
 
 
304
        return 0;
 
305
}
 
306
 
 
307
DEFINE_HOOK(4DA53E, FootClass_Update, 6)
 
308
{
 
309
        GET(FootClass *, F, ESI);
 
310
 
 
311
        CellClass *C = F->GetCell();
 
312
        if(BuildingClass * B = C->GetBuilding()) {
 
313
                BuildingTypeExt::ExtData* pTypeData = BuildingTypeExt::ExtMap.Find(B->Type);
 
314
                HouseExt::ExtData *pHouseData = HouseExt::ExtMap.Find(B->Owner);
 
315
                if(pTypeData->Firewall_Is && pHouseData->FirewallActive) {
 
316
                        BuildingExt::ExtData * pData = BuildingExt::ExtMap.Find(B);
 
317
                        pData->ImmolateVictim(F);
 
318
                }
 
319
        }
 
320
 
 
321
        return 0;
 
322
}