4b825dc642cb6eb9a060e54bf8d69288fbee4904ebd360ec63ec976c05699f3180e866b3f69e5472
 
 
1
#include "system.h"
 
 
2
#include "stratdef.h"
 
 
3
#include "npc_predator.h"
 
 
4
#include "weapons.h"
 
 
5
#include "pldghost.h"
 
 
6
#include "kshape.h"
 
 
7
#include "paintball.h"
 
 
8
#include "userprofile.h"
 
 
9
#include "savegame.h"
 
 
10
#include "bh_types.h"
 
 
11
#include "userprofile.h"
 
 
12
#include <stdio.h>
 
 
13
#include <assert.h>
 
 
14
 
 
 
15
#define MAX_NO_OF_FIXED_DECALS 1024
 
 
16
#define DECAL_Z_OFFSET 0
 
 
17
 
 
 
18
int NumActiveDecals, current_decal_index, NumFixedDecalsBackup, NumFixedDecals, CurrentFixedDecalIndex;
 
 
19
 
 
 
20
static DECAL DecalStorage[MAX_NO_OF_DECALS];
 
 
21
FIXED_DECAL FixedDecalStorage[MAX_NO_OF_FIXED_DECALS];
 
 
22
THREE_LASER_DOT_DESC PredatorLaserSights[NET_MAXPLAYERS];
 
 
23
 
 
 
24
DECAL_DESC DecalDescription[MAX_NO_OF_DECAL_IDS] =
 
 
25
{
 
 
26
    /* DECAL_FMV */
 
 
27
    {
 
 
28
        //int StartU;
 
 
29
        0,
 
 
30
        //int StartV;
 
 
31
        0,     
 
 
32
        //int EndU;
 
 
33
        (127)<<16,
 
 
34
        //int EndV;
 
 
35
        (95)<<16,
 
 
36
 
 
 
37
        //int MinSize;
 
 
38
        3000,
 
 
39
        //int MaxSize;
 
 
40
        3000,
 
 
41
        //int GrowthRate;
 
 
42
        0,
 
 
43
 
 
 
44
        //int MaxSubclassNumber;
 
 
45
        0,
 
 
46
        //int UOffsetForSubclass;
 
 
47
        0,
 
 
48
 
 
 
49
        TRANSLUCENCY_NORMAL,
 
 
50
 
 
 
51
        //unsigned char Alpha;
 
 
52
        96,
 
 
53
        //unsigned char RedScale;
 
 
54
        {255,        255,    0,        255,    255},
 
 
55
        //unsigned char GreenScale;
 
 
56
        {255,        255,    255,    0,        0},
 
 
57
        //unsigned char BlueScale;
 
 
58
        {255,        255,    0,        255,    0},
 
 
59
 
 
 
60
        //unsigned char IsLit:1;
 
 
61
        0,
 
 
62
        //unsigned char CanCombine:1;
 
 
63
        0, 
 
 
64
    },
 
 
65
    /* DECAL_SCORCHED */
 
 
66
    {
 
 
67
        //int StartU;
 
 
68
        0,
 
 
69
        //int StartV;
 
 
70
        64<<16,
 
 
71
        //int EndU;
 
 
72
        63<<16,
 
 
73
        //int EndV;
 
 
74
        127<<16,
 
 
75
 
 
 
76
        //int MinSize;
 
 
77
        20,
 
 
78
        //int MaxSize;
 
 
79
        200,
 
 
80
        //int GrowthRate;
 
 
81
        300,
 
 
82
 
 
 
83
        //int MaxSubclassNumber;
 
 
84
        0,
 
 
85
        //int UOffsetForSubclass;
 
 
86
        0,
 
 
87
 
 
 
88
        TRANSLUCENCY_INVCOLOUR,
 
 
89
 
 
 
90
        //unsigned char Alpha;
 
 
91
        255,
 
 
92
        //unsigned char RedScale;
 
 
93
        {128,128,128,128,128},
 
 
94
        //unsigned char GreenScale;
 
 
95
        {128,128,128,128,128},
 
 
96
        //unsigned char BlueScale;
 
 
97
        {128,128,128,128,128},
 
 
98
 
 
 
99
        //unsigned char IsLit:1;
 
 
100
        0,
 
 
101
        //unsigned char CanCombine:1;
 
 
102
        0, 
 
 
103
 
 
 
104
    },
 
 
105
    /* DECAL_BULLETHOLE */
 
 
106
    {
 
 
107
        //int StartU;
 
 
108
        224<<16,
 
 
109
        //int StartV;
 
 
110
        224<<16,
 
 
111
        //int EndU;
 
 
112
        255<<16,
 
 
113
        //int EndV;
 
 
114
        255<<16,
 
 
115
 
 
 
116
        //int MinSize;
 
 
117
        32,
 
 
118
        //int MaxSize;
 
 
119
        32,
 
 
120
        //int GrowthRate;
 
 
121
        0,
 
 
122
 
 
 
123
        //int MaxSubclassNumber;
 
 
124
        0,
 
 
125
        //int UOffsetForSubclass;
 
 
126
        0,
 
 
127
 
 
 
128
        TRANSLUCENCY_INVCOLOUR,
 
 
129
 
 
 
130
        //unsigned char Alpha;
 
 
131
        255,
 
 
132
        //unsigned char RedScale;
 
 
133
        {255,255,255,255,255},
 
 
134
        //unsigned char GreenScale;
 
 
135
        {255,255,255,255,255},
 
 
136
        //unsigned char BlueScale;
 
 
137
        {255,255,255,255,255},
 
 
138
 
 
 
139
        //unsigned char IsLit:1;
 
 
140
        0,
 
 
141
        //unsigned char CanCombine:1;
 
 
142
        0, 
 
 
143
    },
 
 
144
 
 
 
145
    /* DECAL_PREDATOR_BLOOD */
 
 
146
    {
 
 
147
        //int StartU;
 
 
148
        0,
 
 
149
        //int StartV;
 
 
150
        224<<16,
 
 
151
        //int EndU;
 
 
152
        (31)<<16,
 
 
153
        //int EndV;
 
 
154
        255<<16,
 
 
155
 
 
 
156
        //int MinSize;
 
 
157
        20,
 
 
158
        //int MaxSize;
 
 
159
        400,
 
 
160
        //int GrowthRate;
 
 
161
        100,
 
 
162
 
 
 
163
        //int MaxSubclassNumber;
 
 
164
        3,
 
 
165
        //int UOffsetForSubclass;
 
 
166
        32<<16,
 
 
167
 
 
 
168
        TRANSLUCENCY_GLOWING,
 
 
169
 
 
 
170
        //unsigned char Alpha;
 
 
171
        128,
 
 
172
        //unsigned char RedScale;
 
 
173
        {0,        0,        192,    0,        255},
 
 
174
        //unsigned char GreenScale;
 
 
175
        {255,    255,    255,    255,    0},
 
 
176
        //unsigned char BlueScale;
 
 
177
        {0,        0,        192,    255,    0},
 
 
178
 
 
 
179
        //unsigned char IsLit:1;
 
 
180
        0,
 
 
181
        //unsigned char CanCombine:1;
 
 
182
        1, 
 
 
183
    },
 
 
184
    /* DECAL_ALIEN_BLOOD */
 
 
185
    {
 
 
186
        //int StartU;
 
 
187
        0,
 
 
188
        //int StartV;
 
 
189
        64<<16,
 
 
190
        //int EndU;
 
 
191
        63<<16,
 
 
192
        //int EndV;
 
 
193
        127<<16,
 
 
194
 
 
 
195
        //int MinSize;
 
 
196
        20,
 
 
197
        //int MaxSize;
 
 
198
        400,
 
 
199
        //int GrowthRate;
 
 
200
        100,
 
 
201
 
 
 
202
        //int MaxSubclassNumber;
 
 
203
        0,
 
 
204
        //int UOffsetForSubclass;
 
 
205
        0,
 
 
206
 
 
 
207
        TRANSLUCENCY_GLOWING,
 
 
208
 
 
 
209
        //unsigned char Alpha;
 
 
210
        128,
 
 
211
        //unsigned char RedScale;
 
 
212
        {255,    255,    0,        128,    128},
 
 
213
        //unsigned char GreenScale;
 
 
214
        {255,    255,    255,    128,    128},
 
 
215
        //unsigned char BlueScale;
 
 
216
        {0,        0,        0,        128,    128},
 
 
217
 
 
 
218
        //unsigned char IsLit:1;
 
 
219
        1,
 
 
220
        //unsigned char CanCombine:1;
 
 
221
        1, 
 
 
222
 
 
 
223
    },
 
 
224
    /* DECAL_HUMAN_BLOOD */
 
 
225
    {
 
 
226
        //int StartU;
 
 
227
        0,
 
 
228
        //int StartV;
 
 
229
        224<<16,
 
 
230
        //int EndU;
 
 
231
        (31)<<16,
 
 
232
        //int EndV;
 
 
233
        255<<16,
 
 
234
 
 
 
235
        //int MinSize;
 
 
236
        20,
 
 
237
        //int MaxSize;
 
 
238
        400,
 
 
239
        //int GrowthRate;
 
 
240
        100,
 
 
241
 
 
 
242
        //int MaxSubclassNumber;
 
 
243
        4,
 
 
244
        //int UOffsetForSubclass;
 
 
245
        32<<16,
 
 
246
 
 
 
247
        TRANSLUCENCY_INVCOLOUR,//GLOWING,
 
 
248
 
 
 
249
        //unsigned char Alpha;
 
 
250
        255,
 
 
251
        //unsigned char RedScale;
 
 
252
        {64,        64,        255,        0,          0}, 
 
 
253
        //unsigned char GreenScale;
 
 
254
        {192,        192,    192,        112,    112},
 
 
255
        //unsigned char BlueScale;
 
 
256
        {192,        192,    255,        112,    112},
 
 
257
 
 
 
258
        //unsigned char IsLit:1;
 
 
259
        0,
 
 
260
        //unsigned char CanCombine:1;
 
 
261
        1, 
 
 
262
 
 
 
263
    },
 
 
264
    /* DECAL_ANDROID_BLOOD */
 
 
265
    {
 
 
266
        //int StartU;
 
 
267
        0,
 
 
268
        //int StartV;
 
 
269
        224<<16,
 
 
270
        //int EndU;
 
 
271
        (31)<<16,
 
 
272
        //int EndV;
 
 
273
        255<<16,
 
 
274
 
 
 
275
        //int MinSize;
 
 
276
        20,
 
 
277
        //int MaxSize;
 
 
278
        400,
 
 
279
        //int GrowthRate;
 
 
280
        100,
 
 
281
 
 
 
282
        //int MaxSubclassNumber;
 
 
283
        3,
 
 
284
        //int UOffsetForSubclass;
 
 
285
        32<<16,
 
 
286
 
 
 
287
        TRANSLUCENCY_GLOWING,
 
 
288
 
 
 
289
        //unsigned char Alpha;
 
 
290
        128,
 
 
291
        //unsigned char RedScale;
 
 
292
        {255,    255,    255,    255,    255},
 
 
293
        //unsigned char GreenScale;
 
 
294
        {255,    255,    255,    255,    255},
 
 
295
        //unsigned char BlueScale;
 
 
296
        {255,    255,    255,    255,    255},
 
 
297
 
 
 
298
        //unsigned char IsLit:1;
 
 
299
        1,
 
 
300
        //unsigned char CanCombine:1;
 
 
301
        1, 
 
 
302
    },
 
 
303
 
 
 
304
    // DECAL_PREDATOR_BLOOD_SPLASH
 
 
305
    {
 
 
306
        //int StartU;
 
 
307
        0<<16,
 
 
308
        //int StartV;
 
 
309
        224<<16,
 
 
310
        //int EndU;
 
 
311
        (31)<<16,
 
 
312
        //int EndV;
 
 
313
        255<<16,
 
 
314
 
 
 
315
        //int MinSize;
 
 
316
        20,
 
 
317
        //int MaxSize;
 
 
318
        400,
 
 
319
        //int GrowthRate;
 
 
320
        0,
 
 
321
 
 
 
322
        //int MaxSubclassNumber;
 
 
323
        3,
 
 
324
        //int UOffsetForSubclass;
 
 
325
        32<<16,
 
 
326
 
 
 
327
        TRANSLUCENCY_GLOWING,
 
 
328
 
 
 
329
        //unsigned char Alpha;
 
 
330
        128,
 
 
331
        //unsigned char RedScale;
 
 
332
        {0,        0,        192,    0,        255},
 
 
333
        //unsigned char GreenScale;
 
 
334
        {255,    255,    255,    255,    0},
 
 
335
        //unsigned char BlueScale;
 
 
336
        {0,        0,        192,    255,    0},
 
 
337
 
 
 
338
        //unsigned char IsLit:1;
 
 
339
        0,
 
 
340
        //unsigned char CanCombine:1;
 
 
341
        1, 
 
 
342
    },
 
 
343
    // DECAL_ALIEN_BLOOD_SPLASH
 
 
344
    {
 
 
345
        //int StartU;
 
 
346
        0<<16,
 
 
347
        //int StartV;
 
 
348
        64<<16,
 
 
349
        //int EndU;
 
 
350
        63<<16,
 
 
351
        //int EndV;
 
 
352
        127<<16,
 
 
353
 
 
 
354
        //int MinSize;
 
 
355
        20,
 
 
356
        //int MaxSize;
 
 
357
        400,
 
 
358
        //int GrowthRate;
 
 
359
        0,
 
 
360
 
 
 
361
        //int MaxSubclassNumber;
 
 
362
        0,
 
 
363
        //int UOffsetForSubclass;
 
 
364
        0,
 
 
365
 
 
 
366
        TRANSLUCENCY_GLOWING,
 
 
367
 
 
 
368
        //unsigned char Alpha;
 
 
369
        128,
 
 
370
        //unsigned char RedScale;
 
 
371
        {255,    255,    0,        128,    128},
 
 
372
        //unsigned char GreenScale;
 
 
373
        {255,    255,    255,    128,    128},
 
 
374
        //unsigned char BlueScale;
 
 
375
        {0,        0,        0,        128,    128},
 
 
376
 
 
 
377
        //unsigned char IsLit:1;
 
 
378
        1,
 
 
379
        //unsigned char CanCombine:1;
 
 
380
        1, 
 
 
381
 
 
 
382
    },
 
 
383
    // DECAL_HUMAN_BLOOD_SPLASH
 
 
384
    {
 
 
385
        //int StartU;
 
 
386
        0<<16,
 
 
387
        //int StartV;
 
 
388
        224<<16,
 
 
389
        //int EndU;
 
 
390
        (31)<<16,
 
 
391
        //int EndV;
 
 
392
        255<<16,
 
 
393
 
 
 
394
        //int MinSize;
 
 
395
        //20,
 
 
396
        400,
 
 
397
        //int MaxSize;
 
 
398
        400,
 
 
399
        //int GrowthRate;
 
 
400
        0,
 
 
401
 
 
 
402
        //int MaxSubclassNumber;
 
 
403
        4,
 
 
404
        //int UOffsetForSubclass;
 
 
405
        32<<16,
 
 
406
 
 
 
407
        TRANSLUCENCY_INVCOLOUR,//GLOWING,
 
 
408
 
 
 
409
        //unsigned char Alpha;
 
 
410
        255,
 
 
411
        //unsigned char RedScale;
 
 
412
        {64,        64,        255,        0,          0}, 
 
 
413
        //unsigned char GreenScale;
 
 
414
        {192,        192,    192,        112,    112},
 
 
415
        //unsigned char BlueScale;
 
 
416
        {192,        192,    255,        112,    112},
 
 
417
 
 
 
418
        //unsigned char IsLit:1;
 
 
419
        0,
 
 
420
        //unsigned char CanCombine:1;
 
 
421
        1, 
 
 
422
 
 
 
423
    },
 
 
424
    // DECAL_ANDROID_BLOOD_SPLASH
 
 
425
    {
 
 
426
        //int StartU;
 
 
427
        0<<16,
 
 
428
        //int StartV;
 
 
429
        224<<16,
 
 
430
        //int EndU;
 
 
431
        (31)<<16,
 
 
432
        //int EndV;
 
 
433
        255<<16,
 
 
434
 
 
 
435
        //int MinSize;
 
 
436
        20,
 
 
437
        //int MaxSize;
 
 
438
        400,
 
 
439
        //int GrowthRate;
 
 
440
        0,
 
 
441
 
 
 
442
        //int MaxSubclassNumber;
 
 
443
        3,
 
 
444
        //int UOffsetForSubclass;
 
 
445
        32<<16,
 
 
446
 
 
 
447
        TRANSLUCENCY_GLOWING,
 
 
448
 
 
 
449
        //unsigned char Alpha;
 
 
450
        128,
 
 
451
        //unsigned char RedScale;
 
 
452
        {255,    255,    255,    255,    255},
 
 
453
        //unsigned char GreenScale;
 
 
454
        {255,    255,    255,    255,    255},
 
 
455
        //unsigned char BlueScale;
 
 
456
        {255,    255,    255,    255,    255},
 
 
457
 
 
 
458
        //unsigned char IsLit:1;
 
 
459
        1,
 
 
460
        //unsigned char CanCombine:1;
 
 
461
        1, 
 
 
462
    },
 
 
463
    /* DECAL_LASERTARGET */
 
 
464
    {
 
 
465
        //int StartU;
 
 
466
        0<<16,
 
 
467
        //int StartV;
 
 
468
        0<<16,
 
 
469
        //int EndU;
 
 
470
        63<<16,
 
 
471
        //int EndV;
 
 
472
        63<<16,
 
 
473
 
 
 
474
        //int MinSize;
 
 
475
        20,
 
 
476
        //int MaxSize;
 
 
477
        20,
 
 
478
        //int GrowthRate;
 
 
479
        0,
 
 
480
 
 
 
481
        //int MaxSubclassNumber;
 
 
482
        0,
 
 
483
        //int UOffsetForSubclass;
 
 
484
        0,
 
 
485
 
 
 
486
        TRANSLUCENCY_GLOWING,
 
 
487
 
 
 
488
        //unsigned char Alpha;
 
 
489
        255,
 
 
490
        //unsigned char RedScale;
 
 
491
        {255,    255,    255,    255,    255},
 
 
492
        //unsigned char GreenScale;
 
 
493
        {0,        0,        255,    255,    255},
 
 
494
        //unsigned char BlueScale;
 
 
495
        {0,        0,        255,    255,    255},
 
 
496
 
 
 
497
        //unsigned char IsLit:1;
 
 
498
        0,
 
 
499
        //unsigned char CanCombine:1;
 
 
500
        0, 
 
 
501
 
 
 
502
    },
 
 
503
    /* DECAL_SHAFTOFLIGHT */
 
 
504
    {
 
 
505
        //int StartU;
 
 
506
        0,
 
 
507
        //int StartV;
 
 
508
        0,
 
 
509
        //int EndU;
 
 
510
        0,
 
 
511
        //int EndV;
 
 
512
        0,
 
 
513
 
 
 
514
        //int MinSize;
 
 
515
        0,
 
 
516
        //int MaxSize;
 
 
517
        0,
 
 
518
        //int GrowthRate;
 
 
519
        0,
 
 
520
 
 
 
521
        //int MaxSubclassNumber;
 
 
522
        0,
 
 
523
        //int UOffsetForSubclass;
 
 
524
        0,
 
 
525
 
 
 
526
        TRANSLUCENCY_GLOWING,
 
 
527
 
 
 
528
        //unsigned char Alpha;
 
 
529
        64,
 
 
530
        //unsigned char RedScale;
 
 
531
        {255,255,255,255},
 
 
532
        //unsigned char GreenScale;
 
 
533
        {255,255,255,255},
 
 
534
        //unsigned char BlueScale;
 
 
535
        {192,192,192,192},
 
 
536
 
 
 
537
        //unsigned char IsLit:1;
 
 
538
        0,
 
 
539
        //unsigned char CanCombine:1;
 
 
540
        0, 
 
 
541
 
 
 
542
    },
 
 
543
    /* DECAL_SHAFTOFLIGHT_OUTER */
 
 
544
    {
 
 
545
        //int StartU;
 
 
546
        0,
 
 
547
        //int StartV;
 
 
548
        0,
 
 
549
        //int EndU;
 
 
550
        0,
 
 
551
        //int EndV;
 
 
552
        0,
 
 
553
 
 
 
554
        //int MinSize;
 
 
555
        0,
 
 
556
        //int MaxSize;
 
 
557
        0,
 
 
558
        //int GrowthRate;
 
 
559
        0,
 
 
560
 
 
 
561
        //int MaxSubclassNumber;
 
 
562
        0,
 
 
563
        //int UOffsetForSubclass;
 
 
564
        0,
 
 
565
 
 
 
566
        TRANSLUCENCY_GLOWING,
 
 
567
 
 
 
568
        //unsigned char Alpha;
 
 
569
        32,
 
 
570
        //unsigned char RedScale;
 
 
571
        {255,255,255,255},
 
 
572
        //unsigned char GreenScale;
 
 
573
        {255,255,255,255},
 
 
574
        //unsigned char BlueScale;
 
 
575
        {192,192,192,192},
 
 
576
 
 
 
577
        //unsigned char IsLit:1;
 
 
578
        0,
 
 
579
        //unsigned char CanCombine:1;
 
 
580
        0, 
 
 
581
    }
 
 
582
};
 
 
583
 
 
 
584
FIXED_DECAL* AllocateFixedDecal()
 
 
585
{
 
 
586
    if (CurrentFixedDecalIndex >= MAX_NO_OF_FIXED_DECALS)
 
 
587
        CurrentFixedDecalIndex = 0;
 
 
588
    else
 
 
589
        NumFixedDecals++;
 
 
590
 
 
 
591
    return &FixedDecalStorage[CurrentFixedDecalIndex++];
 
 
592
}
 
 
593
 
 
 
594
void RemoveFixedDecal()
 
 
595
{
 
 
596
    if (CurrentFixedDecalIndex > 0)
 
 
597
    {
 
 
598
        CurrentFixedDecalIndex--;
 
 
599
        NumFixedDecals--;
 
 
600
    }
 
 
601
}
 
 
602
 
 
 
603
void check_preplaced_decal_modules()
 
 
604
{
 
 
605
    extern SCENEMODULE MainScene;
 
 
606
    int i;
 
 
607
 
 
 
608
    NumFixedDecals = NumFixedDecalsBackup;
 
 
609
 
 
 
610
    for(i=0; i < NumFixedDecals; i++)
 
 
611
    {
 
 
612
        FIXED_DECAL* fd = &FixedDecalStorage[i];
 
 
613
 
 
 
614
        MODULE* mod = MainScene.sm_marray[fd->ModuleIndex];
 
 
615
        mod = ModuleFromPosition(&fd->Vertices[0], mod);
 
 
616
 
 
 
617
        if(mod)
 
 
618
            fd->ModuleIndex = mod->m_index;
 
 
619
    }
 
 
620
}
 
 
621
 
 
 
622
void RemoveAllDecals()
 
 
623
{
 
 
624
    /* pretty drastic */
 
 
625
    NumFixedDecalsBackup = NumFixedDecals;
 
 
626
    CurrentFixedDecalIndex = NumFixedDecals =  NumActiveDecals = 0;
 
 
627
}
 
 
628
 
 
 
629
#define MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE 4
 
 
630
#define INCREMENT_IN_DECAL_SIZE (25*4)
 
 
631
 
 
 
632
static int TooManyDecalsOfThisType(enum DECAL_ID decalID, VECTORCH *positionPtr)
 
 
633
{
 
 
634
    int i = NumActiveDecals;
 
 
635
    DECAL *decalPtr = DecalStorage;
 
 
636
    DECAL *similarDecalsPtr[MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE];
 
 
637
 
 
 
638
    int decalsOfThisType = 0;
 
 
639
    int decalSize = DecalDescription[decalID].MaxSize;
 
 
640
    int minX = positionPtr->vx - decalSize;
 
 
641
    int maxX = positionPtr->vx + decalSize;
 
 
642
    int minY = positionPtr->vy - decalSize;
 
 
643
    int maxY = positionPtr->vy + decalSize;
 
 
644
    int minZ = positionPtr->vz - decalSize;
 
 
645
    int maxZ = positionPtr->vz + decalSize;
 
 
646
 
 
 
647
    while(i--)
 
 
648
    {
 
 
649
        if (decalPtr->DecalID == decalID)
 
 
650
        {
 
 
651
            if (
 
 
652
                (decalPtr->Centre.vx > minX && decalPtr->Centre.vx < maxX)
 
 
653
                &&
 
 
654
                (decalPtr->Centre.vy > minY && decalPtr->Centre.vy < maxY)
 
 
655
                &&
 
 
656
                (decalPtr->Centre.vz > minZ && decalPtr->Centre.vz < maxZ)
 
 
657
            )
 
 
658
            {
 
 
659
                similarDecalsPtr[decalsOfThisType++] = decalPtr;
 
 
660
 
 
 
661
                if (decalsOfThisType >= MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE)
 
 
662
                {
 
 
663
                    if (DecalDescription[decalID].CanCombine) 
 
 
664
                    {
 
 
665
                        int j;
 
 
666
                        for (j=0; j < MAX_NO_OF_SIMILAR_DECALS_IN_ONE_PLACE; j++)
 
 
667
                        {
 
 
668
                            if (similarDecalsPtr[j]->TargetSize >= DecalDescription[decalID].MaxSize)
 
 
669
                            {
 
 
670
                                similarDecalsPtr[j]->TargetSize = DecalDescription[decalID].MaxSize;
 
 
671
                                break;
 
 
672
                            }
 
 
673
                            else
 
 
674
                            {
 
 
675
                                similarDecalsPtr[j]->TargetSize += INCREMENT_IN_DECAL_SIZE;
 
 
676
                            }
 
 
677
                        }
 
 
678
                    }
 
 
679
                    return 1;
 
 
680
                }
 
 
681
            }
 
 
682
        }
 
 
683
 
 
 
684
        decalPtr++;
 
 
685
    }
 
 
686
 
 
 
687
return 0;
 
 
688
}
 
 
689
 
 
 
690
 
 
 
691
void AddDecal(enum DECAL_ID decalID, VECTORCH *normalPtr, VECTORCH *positionPtr, int moduleIndex)
 
 
692
{
 
 
693
    DECAL *decalPtr;
 
 
694
 
 
 
695
    if (NumActiveDecals < UserProfile.GameOptions.NumberOfDecals)
 
 
696
    {
 
 
697
        decalPtr = &DecalStorage[NumActiveDecals++];
 
 
698
    }
 
 
699
    else
 
 
700
    {
 
 
701
        if(current_decal_index >= NumActiveDecals)
 
 
702
            current_decal_index = 0;
 
 
703
 
 
 
704
        decalPtr = &DecalStorage[current_decal_index++];
 
 
705
    }
 
 
706
 
 
 
707
    {
 
 
708
        MATRIXCH orientation;
 
 
709
        int decalSize; 
 
 
710
        int theta = FastRandom() & 4095;
 
 
711
        int sin = GetSin(theta);
 
 
712
        int cos = GetCos(theta);
 
 
713
 
 
 
714
        MakeMatrixFromDirection(normalPtr, &orientation);
 
 
715
 
 
 
716
        decalPtr->DecalID = decalID;
 
 
717
        decalPtr->Centre = *positionPtr;
 
 
718
 
 
 
719
        if(DecalDescription[decalID].GrowthRate)
 
 
720
        {
 
 
721
            decalSize = ONE_FIXED;
 
 
722
            decalPtr->Direction[0].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(-decalSize,sin);
 
 
723
            decalPtr->Direction[0].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(-decalSize,cos);
 
 
724
            decalPtr->Direction[0].vz = DECAL_Z_OFFSET;
 
 
725
            RotateVector(&decalPtr->Direction[0], &orientation);
 
 
726
            Normalise(&decalPtr->Direction[0]);
 
 
727
 
 
 
728
            decalPtr->Direction[1].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(-decalSize,sin);
 
 
729
            decalPtr->Direction[1].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(-decalSize,cos);
 
 
730
            decalPtr->Direction[1].vz = DECAL_Z_OFFSET;
 
 
731
            RotateVector(&decalPtr->Direction[1], &orientation);
 
 
732
            Normalise(&decalPtr->Direction[1]);
 
 
733
 
 
 
734
            decalPtr->Direction[2].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(decalSize,sin);
 
 
735
            decalPtr->Direction[2].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(decalSize,cos);
 
 
736
            decalPtr->Direction[2].vz = DECAL_Z_OFFSET;
 
 
737
            RotateVector(&decalPtr->Direction[2], &orientation);
 
 
738
            Normalise(&decalPtr->Direction[2]);
 
 
739
 
 
 
740
            decalPtr->Direction[3].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(decalSize,sin);
 
 
741
            decalPtr->Direction[3].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(decalSize,cos);
 
 
742
            decalPtr->Direction[3].vz = DECAL_Z_OFFSET;
 
 
743
            RotateVector(&decalPtr->Direction[3], &orientation);
 
 
744
            Normalise(&decalPtr->Direction[3]);
 
 
745
            decalPtr->CurrentSize = DecalDescription[decalID].MinSize;
 
 
746
            decalPtr->TargetSize = DecalDescription[decalID].MaxSize;
 
 
747
 
 
 
748
            if (DecalDescription[decalID].CanCombine)
 
 
749
                decalPtr->TargetSize /= 4;
 
 
750
        }
 
 
751
        else
 
 
752
        {
 
 
753
            decalSize = DecalDescription[decalID].MinSize;
 
 
754
            decalPtr->Vertices[0].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(-decalSize,sin);
 
 
755
            decalPtr->Vertices[0].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(-decalSize,cos);
 
 
756
            decalPtr->Vertices[0].vz = DECAL_Z_OFFSET;
 
 
757
            RotateVector(&decalPtr->Vertices[0], &orientation);
 
 
758
            decalPtr->Vertices[0].vx += positionPtr->vx;
 
 
759
            decalPtr->Vertices[0].vy += positionPtr->vy;
 
 
760
            decalPtr->Vertices[0].vz += positionPtr->vz;
 
 
761
 
 
 
762
            decalPtr->Vertices[1].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(-decalSize,sin);
 
 
763
            decalPtr->Vertices[1].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(-decalSize,cos);
 
 
764
            decalPtr->Vertices[1].vz = DECAL_Z_OFFSET;
 
 
765
            RotateVector(&decalPtr->Vertices[1], &orientation);
 
 
766
            decalPtr->Vertices[1].vx += positionPtr->vx;
 
 
767
            decalPtr->Vertices[1].vy += positionPtr->vy;
 
 
768
            decalPtr->Vertices[1].vz += positionPtr->vz;
 
 
769
 
 
 
770
            decalPtr->Vertices[2].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(decalSize,sin);
 
 
771
            decalPtr->Vertices[2].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(decalSize,cos);
 
 
772
            decalPtr->Vertices[2].vz = DECAL_Z_OFFSET;
 
 
773
            RotateVector(&decalPtr->Vertices[2], &orientation);
 
 
774
            decalPtr->Vertices[2].vx += positionPtr->vx;
 
 
775
            decalPtr->Vertices[2].vy += positionPtr->vy;
 
 
776
            decalPtr->Vertices[2].vz += positionPtr->vz;
 
 
777
 
 
 
778
            decalPtr->Vertices[3].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(decalSize,sin);
 
 
779
            decalPtr->Vertices[3].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(decalSize,cos);
 
 
780
            decalPtr->Vertices[3].vz = DECAL_Z_OFFSET;
 
 
781
            RotateVector(&decalPtr->Vertices[3], &orientation);
 
 
782
            decalPtr->Vertices[3].vx += positionPtr->vx;
 
 
783
            decalPtr->Vertices[3].vy += positionPtr->vy;
 
 
784
            decalPtr->Vertices[3].vz += positionPtr->vz;
 
 
785
        }
 
 
786
 
 
 
787
        decalPtr->ModuleIndex = moduleIndex;
 
 
788
 
 
 
789
        switch (decalID)
 
 
790
        {
 
 
791
            case DECAL_HUMAN_BLOOD:
 
 
792
            case DECAL_PREDATOR_BLOOD:
 
 
793
            case DECAL_ANDROID_BLOOD:
 
 
794
            {    
 
 
795
                //decalPtr->UOffset = (FastRandom() & 1) * (32 << 16);
 
 
796
                decalPtr->UOffset = 0;
 
 
797
                //decalPtr->UOffset = 64 << 16;
 
 
798
                //decalPtr->UOffset = 32 << 16;
 
 
799
                //decalPtr->UOffset = 96 << 16;
 
 
800
                //decalPtr->UOffset =  64 << 16; // fill blood
 
 
801
                //decalPtr->UOffset =  96 << 16; // fill blood
 
 
802
 
 
 
803
                //if(0)
 
 
804
                if (normalPtr->vy < -32768)
 
 
805
                {
 
 
806
                    decalPtr->UOffset += 64 << 16;
 
 
807
                }
 
 
808
                else
 
 
809
                {
 
 
810
                    decalPtr->TargetSize = DecalDescription[decalID].MaxSize;
 
 
811
                    decalPtr->CurrentSize = decalPtr->TargetSize - 1;
 
 
812
                }
 
 
813
            }
 
 
814
            break;
 
 
815
            case DECAL_HUMAN_BLOOD_SPLASH:
 
 
816
            case DECAL_PREDATOR_BLOOD_SPLASH:
 
 
817
            case DECAL_ANDROID_BLOOD_SPLASH:
 
 
818
                decalPtr->UOffset = (FastRandom() & 1) ? (32 << 16) : 0;
 
 
819
            break;
 
 
820
            case DECAL_BULLETHOLE:
 
 
821
                MakeImpactSmoke(&orientation, positionPtr);
 
 
822
            default:
 
 
823
                decalPtr->UOffset = 0;
 
 
824
        }
 
 
825
    }
 
 
826
}
 
 
827
 
 
 
828
void MakeDecal(enum DECAL_ID decalID, VECTORCH *normalPtr, VECTORCH *positionPtr, int moduleIndex)
 
 
829
{
 
 
830
    if (!TooManyDecalsOfThisType(decalID, positionPtr))
 
 
831
    {
 
 
832
        AddDecal(decalID, normalPtr, positionPtr, moduleIndex);
 
 
833
 
 
 
834
        /* no blood across network? */
 
 
835
        if(SinglePlayer != AvP.PlayMode)
 
 
836
        {
 
 
837
            if(netGameData.sendDecals)
 
 
838
            {
 
 
839
                switch (decalID)
 
 
840
                {
 
 
841
                    case DECAL_BULLETHOLE:
 
 
842
                    case DECAL_SCORCHED:
 
 
843
                        AddNetMsg_MakeDecal(decalID, normalPtr, positionPtr, moduleIndex);
 
 
844
                    default:
 
 
845
                    break;
 
 
846
                }
 
 
847
            }
 
 
848
        }
 
 
849
    }
 
 
850
}
 
 
851
 
 
 
852
void RenderLaserTarget(THREE_LASER_DOT_DESC *laserTargetPtr)
 
 
853
{
 
 
854
    int i = 2;
 
 
855
 
 
 
856
    do
 
 
857
    {
 
 
858
        DECAL decal;
 
 
859
        MATRIXCH orientation;
 
 
860
        VECTORCH *positionPtr = &laserTargetPtr->Position[i];
 
 
861
 
 
 
862
        MakeMatrixFromDirection(&laserTargetPtr->Normal[i], &orientation);
 
 
863
 
 
 
864
        decal.DecalID = DECAL_LASERTARGET;
 
 
865
        int decalSize = DecalDescription[DECAL_LASERTARGET].MaxSize;
 
 
866
 
 
 
867
        decal.Vertices[0].vx = -decalSize;
 
 
868
        decal.Vertices[0].vy = -decalSize;
 
 
869
        decal.Vertices[0].vz = DECAL_Z_OFFSET;
 
 
870
        RotateVector(&decal.Vertices[0], &orientation);
 
 
871
        decal.Vertices[0].vx += positionPtr->vx;
 
 
872
        decal.Vertices[0].vy += positionPtr->vy;
 
 
873
        decal.Vertices[0].vz += positionPtr->vz;
 
 
874
 
 
 
875
        decal.Vertices[1].vx = decalSize;
 
 
876
        decal.Vertices[1].vy = -decalSize;
 
 
877
        decal.Vertices[1].vz = DECAL_Z_OFFSET;
 
 
878
        RotateVector(&decal.Vertices[1], &orientation);
 
 
879
        decal.Vertices[1].vx += positionPtr->vx;
 
 
880
        decal.Vertices[1].vy += positionPtr->vy;
 
 
881
        decal.Vertices[1].vz += positionPtr->vz;
 
 
882
 
 
 
883
        decal.Vertices[2].vx = decalSize;
 
 
884
        decal.Vertices[2].vy = decalSize;
 
 
885
        decal.Vertices[2].vz = DECAL_Z_OFFSET;
 
 
886
        RotateVector(&decal.Vertices[2], &orientation);
 
 
887
        decal.Vertices[2].vx += positionPtr->vx;
 
 
888
        decal.Vertices[2].vy += positionPtr->vy;
 
 
889
        decal.Vertices[2].vz += positionPtr->vz;
 
 
890
 
 
 
891
        decal.Vertices[3].vx = -decalSize;
 
 
892
        decal.Vertices[3].vy = decalSize;
 
 
893
        decal.Vertices[3].vz = DECAL_Z_OFFSET;
 
 
894
        RotateVector(&decal.Vertices[3], &orientation);
 
 
895
        decal.Vertices[3].vx += positionPtr->vx;
 
 
896
        decal.Vertices[3].vy += positionPtr->vy;
 
 
897
        decal.Vertices[3].vz += positionPtr->vz;
 
 
898
 
 
 
899
        decal.ModuleIndex = PlayerStatus.sbptr->containingModule->m_index;
 
 
900
        decal.UOffset = 0;
 
 
901
if(ModuleCurrVisArray[decal.ModuleIndex] > 1)
 
 
902
        RenderDecal(&decal);
 
 
903
 
 
 
904
    } while(i--);
 
 
905
}
 
 
906
 
 
 
907
void HandleDecalSystem()
 
 
908
{
 
 
909
    int i;
 
 
910
 
 
 
911
    {
 
 
912
        i = NumActiveDecals;
 
 
913
        DECAL *decalPtr = DecalStorage;
 
 
914
    //    printf("Decals Active: %d\n",i);
 
 
915
 
 
 
916
        while(i--)
 
 
917
        {
 
 
918
            DECAL_DESC *decalDescPtr = &DecalDescription[decalPtr->DecalID];
 
 
919
 
 
 
920
            if (decalDescPtr->GrowthRate && (decalPtr->CurrentSize < decalPtr->TargetSize))
 
 
921
            {
 
 
922
                int i=0;
 
 
923
                decalPtr->CurrentSize += MUL_FIXED(decalDescPtr->GrowthRate, NormalFrameTime);
 
 
924
 
 
 
925
                if (decalPtr->CurrentSize > decalPtr->TargetSize)
 
 
926
                    decalPtr->CurrentSize = decalPtr->TargetSize;
 
 
927
 
 
 
928
                for (; i < 4; i++)
 
 
929
                {
 
 
930
                    decalPtr->Vertices[i].vx = MUL_FIXED(decalPtr->Direction[i].vx, decalPtr->CurrentSize);
 
 
931
                    decalPtr->Vertices[i].vy = MUL_FIXED(decalPtr->Direction[i].vy, decalPtr->CurrentSize);
 
 
932
                    decalPtr->Vertices[i].vz = MUL_FIXED(decalPtr->Direction[i].vz, decalPtr->CurrentSize);
 
 
933
                    decalPtr->Vertices[i].vx += decalPtr->Centre.vx;
 
 
934
                    decalPtr->Vertices[i].vy += decalPtr->Centre.vy;
 
 
935
                    decalPtr->Vertices[i].vz += decalPtr->Centre.vz;
 
 
936
                }
 
 
937
            }
 
 
938
 
 
 
939
            if(ModuleCurrVisArray[decalPtr->ModuleIndex] > 1)
 
 
940
                RenderDecal(decalPtr);
 
 
941
 
 
 
942
            decalPtr++;
 
 
943
        }
 
 
944
    }
 
 
945
 
 
 
946
    i = NumFixedDecals;
 
 
947
    //printf("Fixed Decals Active: %d\n",i);
 
 
948
 
 
 
949
    while(i--)
 
 
950
    {
 
 
951
        if(ModuleCurrVisArray[FixedDecalStorage[i].ModuleIndex] > 1)
 
 
952
            RenderDecal(&FixedDecalStorage[i]);
 
 
953
    }
 
 
954
 
 
 
955
    {
 
 
956
        extern struct KObject VisibleObjects[];
 
 
957
        extern int numVisObjs;
 
 
958
        int numOfObjects = numVisObjs;
 
 
959
 
 
 
960
        while(numOfObjects--)
 
 
961
        {
 
 
962
            DISPLAYBLOCK *objectPtr = VisibleObjects[numOfObjects].DispPtr;
 
 
963
            STRATEGYBLOCK *sbPtr = objectPtr->ObStrategyBlock;
 
 
964
 
 
 
965
            if (sbPtr)
 
 
966
            {
 
 
967
                switch(sbPtr->type)
 
 
968
                {
 
 
969
                    case I_BehaviourNetGhost:
 
 
970
                       {
 
 
971
                         NETGHOSTDATABLOCK *ghostData = (NETGHOSTDATABLOCK *)sbPtr->dataptr;
 
 
972
 
 
 
973
                        if (ghostData->type == I_BehaviourPredatorPlayer)
 
 
974
                        {
 
 
975
                            extern int AVPDPNetID;
 
 
976
                            int playerIndex = PlayerIdInPlayerList(ghostData->playerId);
 
 
977
 
 
 
978
                            if(playerIndex == NET_IDNOTINPLAYERLIST)
 
 
979
                                continue;
 
 
980
 
 
 
981
                            switch(ghostData->CurrentWeapon)
 
 
982
                            {
 
 
983
                                case WEAPON_PRED_RIFLE:
 
 
984
                                case WEAPON_PRED_SHOULDERCANNON:
 
 
985
                                    break;
 
 
986
                                default:
 
 
987
                                continue;
 
 
988
                            }
 
 
989
 
 
 
990
                            if (AVPDPNetID == PredatorLaserSights[playerIndex].TargetID)
 
 
991
                            {
 
 
992
                                SECTION_DATA *plasma_muzzle = GetThisSectionData(ghostData->HModelController.section_data, "dum flash");
 
 
993
 
 
 
994
                                if (plasma_muzzle != NULL)
 
 
995
                                    RenderLightFlare(&plasma_muzzle->World_Offset, 0xffff0000);
 
 
996
                            }
 
 
997
                            else
 
 
998
                            {
 
 
999
                                RenderLaserTarget(&PredatorLaserSights[playerIndex]);
 
 
1000
                            }
 
 
1001
                        }
 
 
1002
                    }
 
 
1003
                    break;
 
 
1004
                    case I_BehaviourPredator:
 
 
1005
                    {
 
 
1006
                        PREDATOR_STATUS_BLOCK *statusPtr = (PREDATOR_STATUS_BLOCK *)sbPtr->dataptr;
 
 
1007
                        //RenderLightFlare(&sbPtr->DynPtr->Position, 0x7fffffff);
 
 
1008
 
 
 
1009
                        if(statusPtr->Pred_Laser_On)
 
 
1010
                        {
 
 
1011
                            if (statusPtr->Pred_Laser_Sight.DotIsOnPlayer)
 
 
1012
                                RenderLightFlare(&statusPtr->Pred_Laser_Sight.LightSource, 0xffff0000);
 
 
1013
                            else
 
 
1014
                                RenderLaserTarget(&statusPtr->Pred_Laser_Sight);
 
 
1015
                        }
 
 
1016
                    }
 
 
1017
                    default:
 
 
1018
                    break;
 
 
1019
                }
 
 
1020
            }
 
 
1021
        }
 
 
1022
    }
 
 
1023
}
 
 
1024
 
 
 
1025
void AddDecalToHModel(VECTORCH *normalPtr, VECTORCH *positionPtr, SECTION_DATA *sectionDataPtr)
 
 
1026
{
 
 
1027
    if (UserProfile.GameOptions.DecalsOnCharacters)
 
 
1028
    {
 
 
1029
        enum DECAL_ID decalID;
 
 
1030
        MATRIXCH orientation;
 
 
1031
        VECTORCH v;
 
 
1032
        int theta = FastRandom() & 4095;
 
 
1033
        int sin = GetSin(theta);
 
 
1034
        int cos = GetCos(theta);
 
 
1035
 
 
 
1036
        assert(sectionDataPtr->NumberOfDecals <= MAX_NO_OF_DECALS_PER_HIERARCHICAL_SECTION);
 
 
1037
 
 
 
1038
        {
 
 
1039
            MATRIXCH mat = sectionDataPtr->SecMat;
 
 
1040
            VECTORCH n = *normalPtr;
 
 
1041
 
 
 
1042
            TransposeMatrixCH(&mat);
 
 
1043
 
 
 
1044
            RotateVector(&n,&mat);
 
 
1045
            MakeMatrixFromDirection(&n,&orientation);
 
 
1046
 
 
 
1047
            v = *positionPtr;
 
 
1048
            v.vx -= sectionDataPtr->World_Offset.vx;
 
 
1049
            v.vy -= sectionDataPtr->World_Offset.vy;
 
 
1050
            v.vz -= sectionDataPtr->World_Offset.vz;
 
 
1051
            RotateVector(&v,&mat);
 
 
1052
        }
 
 
1053
 
 
 
1054
        {
 
 
1055
            SECTION    *sectionPtr = sectionDataPtr->sempai;
 
 
1056
 
 
 
1057
            if(sectionPtr->flags & section_sprays_blood)
 
 
1058
            {
 
 
1059
                decalID = DECAL_HUMAN_BLOOD;
 
 
1060
            }
 
 
1061
            else if(sectionPtr->flags & section_sprays_predoblood)
 
 
1062
            {
 
 
1063
                decalID = DECAL_PREDATOR_BLOOD;
 
 
1064
            }
 
 
1065
            else if(sectionPtr->flags & section_sprays_acid)
 
 
1066
            {
 
 
1067
                decalID = DECAL_ALIEN_BLOOD;
 
 
1068
            }
 
 
1069
            else
 
 
1070
            {
 
 
1071
                decalID = DECAL_BULLETHOLE;
 
 
1072
            }
 
 
1073
        }
 
 
1074
 
 
 
1075
        OBJECT_DECAL *decalPtr = &sectionDataPtr->Decals[sectionDataPtr->NextDecalToUse];
 
 
1076
 
 
 
1077
        if (sectionDataPtr->NextDecalToUse >= MAX_NO_OF_DECALS_PER_HIERARCHICAL_SECTION-1)
 
 
1078
            sectionDataPtr->NextDecalToUse = 0;
 
 
1079
        else
 
 
1080
            sectionDataPtr->NextDecalToUse++;
 
 
1081
 
 
 
1082
        if (sectionDataPtr->NumberOfDecals < MAX_NO_OF_DECALS_PER_HIERARCHICAL_SECTION)
 
 
1083
            sectionDataPtr->NumberOfDecals++;
 
 
1084
 
 
 
1085
        decalPtr->DecalID = decalID;
 
 
1086
        int decalSize = 40;//DecalDescription[decalID].MaxSize;
 
 
1087
 
 
 
1088
        decalPtr->Centre = v;
 
 
1089
 
 
 
1090
        decalPtr->Vertices[0].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(-decalSize,sin);
 
 
1091
        decalPtr->Vertices[0].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(-decalSize,cos);
 
 
1092
        decalPtr->Vertices[0].vz = DECAL_Z_OFFSET;
 
 
1093
        RotateVector(&decalPtr->Vertices[0], &orientation);
 
 
1094
        decalPtr->Vertices[0].vx += v.vx;
 
 
1095
        decalPtr->Vertices[0].vy += v.vy;
 
 
1096
        decalPtr->Vertices[0].vz += v.vz;
 
 
1097
 
 
 
1098
        decalPtr->Vertices[1].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(-decalSize,sin);
 
 
1099
        decalPtr->Vertices[1].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(-decalSize,cos);
 
 
1100
        decalPtr->Vertices[1].vz = DECAL_Z_OFFSET;
 
 
1101
        RotateVector(&decalPtr->Vertices[1], &orientation);
 
 
1102
        decalPtr->Vertices[1].vx += v.vx;
 
 
1103
        decalPtr->Vertices[1].vy += v.vy;
 
 
1104
        decalPtr->Vertices[1].vz += v.vz;
 
 
1105
 
 
 
1106
        decalPtr->Vertices[2].vx = MUL_FIXED(decalSize,cos) - MUL_FIXED(decalSize,sin);
 
 
1107
        decalPtr->Vertices[2].vy = MUL_FIXED(decalSize,sin) + MUL_FIXED(decalSize,cos);
 
 
1108
        decalPtr->Vertices[2].vz = DECAL_Z_OFFSET;
 
 
1109
        RotateVector(&decalPtr->Vertices[2], &orientation);
 
 
1110
        decalPtr->Vertices[2].vx += v.vx;
 
 
1111
        decalPtr->Vertices[2].vy += v.vy;
 
 
1112
        decalPtr->Vertices[2].vz += v.vz;
 
 
1113
 
 
 
1114
        decalPtr->Vertices[3].vx = MUL_FIXED(-decalSize,cos) - MUL_FIXED(decalSize,sin);
 
 
1115
        decalPtr->Vertices[3].vy = MUL_FIXED(-decalSize,sin) + MUL_FIXED(decalSize,cos);
 
 
1116
        decalPtr->Vertices[3].vz = DECAL_Z_OFFSET;
 
 
1117
        RotateVector(&decalPtr->Vertices[3], &orientation);
 
 
1118
        decalPtr->Vertices[3].vx += v.vx;
 
 
1119
        decalPtr->Vertices[3].vy += v.vy;
 
 
1120
        decalPtr->Vertices[3].vz += v.vz;
 
 
1121
    }
 
 
1122
}
 
 
1123
 
 
 
1124
void ScanHModelForDecals(DISPLAYBLOCK *objectPtr, SECTION_DATA *sectionDataPtr)
 
 
1125
{
 
 
1126
    SECTION *sectionPtr = sectionDataPtr->sempai;
 
 
1127
 
 
 
1128
    /* Unreal things aren't drawn... */
 
 
1129
    if (!(sectionDataPtr->flags & section_data_notreal) && (sectionPtr->Shape != NULL) && sectionDataPtr->NumberOfDecals)
 
 
1130
    {
 
 
1131
        int d;
 
 
1132
        for(d = 0; d < sectionDataPtr->NumberOfDecals; d++)
 
 
1133
        {
 
 
1134
            int i;
 
 
1135
            DECAL decal;
 
 
1136
            decal.DecalID = sectionDataPtr->Decals[d].DecalID;
 
 
1137
            decal.ModuleIndex = PlayerStatus.sbptr->containingModule->m_index;
 
 
1138
            decal.UOffset = 0;
 
 
1139
 
 
 
1140
            for(i = 0; i < 5; i++)
 
 
1141
            {
 
 
1142
                decal.Vertices[i] = sectionDataPtr->Decals[d].Vertices[i];
 
 
1143
                RotateVector(&decal.Vertices[i], &sectionDataPtr->SecMat);
 
 
1144
                decal.Vertices[i].vx += sectionDataPtr->World_Offset.vx;
 
 
1145
                decal.Vertices[i].vy += sectionDataPtr->World_Offset.vy;
 
 
1146
                decal.Vertices[i].vz += sectionDataPtr->World_Offset.vz;
 
 
1147
            }
 
 
1148
 
 
 
1149
            RenderDecal(&decal);
 
 
1150
        }
 
 
1151
    }
 
 
1152
 
 
 
1153
    /* Now call recursion... */
 
 
1154
    if (sectionDataPtr->First_Child != NULL)
 
 
1155
    {
 
 
1156
        SECTION_DATA *childrenListPtr = sectionDataPtr->First_Child;
 
 
1157
 
 
 
1158
        while (childrenListPtr != NULL)
 
 
1159
        {
 
 
1160
            ScanHModelForDecals(objectPtr, childrenListPtr);
 
 
1161
            childrenListPtr = childrenListPtr->Next_Sibling;
 
 
1162
        }
 
 
1163
    }
 
 
1164
}
 
 
1165
 
 
 
1166
/*------------------**
 
 
1167
** Load/Save Decals **
 
 
1168
**------------------*/
 
 
1169
 
 
 
1170
typedef struct decal_save_block_header
 
 
1171
{
 
 
1172
    SAVE_BLOCK_HEADER header;
 
 
1173
 
 
 
1174
    int NumActiveDecals;
 
 
1175
 
 
 
1176
    //followed by array of decals
 
 
1177
 
 
 
1178
} DECAL_SAVE_BLOCK_HEADER;
 
 
1179
 
 
 
1180
void Load_Decals(SAVE_BLOCK_HEADER* header)
 
 
1181
{
 
 
1182
    int i = 0;
 
 
1183
    DECAL_SAVE_BLOCK_HEADER* block = (DECAL_SAVE_BLOCK_HEADER*) header;
 
 
1184
    DECAL* saved_decal = (DECAL*) (block+1);
 
 
1185
    //make sure the block is the correct size
 
 
1186
    int expected_size = sizeof(*block);
 
 
1187
    expected_size += sizeof(DECAL) * block->NumActiveDecals;
 
 
1188
 
 
 
1189
    if(header->size != expected_size)
 
 
1190
        return;
 
 
1191
 
 
 
1192
    for(; i < block->NumActiveDecals; i++)
 
 
1193
    {
 
 
1194
        if (NumActiveDecals < UserProfile.GameOptions.NumberOfDecals)
 
 
1195
        {
 
 
1196
            DecalStorage[NumActiveDecals++] = *saved_decal++;
 
 
1197
        }
 
 
1198
        else
 
 
1199
        {
 
 
1200
            break; // this will most likely not happen
 
 
1201
        }
 
 
1202
    }
 
 
1203
}
 
 
1204
 
 
 
1205
void Save_Decals()
 
 
1206
{
 
 
1207
    if(NumActiveDecals > 0)
 
 
1208
    {
 
 
1209
        DECAL_SAVE_BLOCK_HEADER* block;
 
 
1210
        int i = 0;
 
 
1211
        GET_SAVE_BLOCK_POINTER(block);
 
 
1212
 
 
 
1213
        //fill in header
 
 
1214
        block->header.type = SaveBlock_Decals;
 
 
1215
        block->header.size = sizeof(*block) + NumActiveDecals * sizeof(DECAL);
 
 
1216
 
 
 
1217
        block->NumActiveDecals = NumActiveDecals;
 
 
1218
 
 
 
1219
        for(; i < NumActiveDecals; i++)
 
 
1220
        {
 
 
1221
            DECAL* decal = GET_SAVE_BLOCK_POINTER(decal);
 
 
1222
            *decal = DecalStorage[i];
 
 
1223
        }
 
 
1224
    }
 
 
1225
}