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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005-2014 Simon Howard
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// DESCRIPTION:
// Floor animation: raising stairs.
//
#include "z_zone.h"
#include "doomdef.h"
#include "p_local.h"
#include "s_sound.h"
// State.
#include "doomstat.h"
#include "r_state.h"
// Data.
#include "sounds.h"
//
// FLOORS
//
//
// Move a plane (floor or ceiling) and check for crushing
//
// [STRIFE] Various changes were made to remove calls to P_ChangeSector when
// P_ChangeSector returns true.
//
result_e
T_MovePlane
( sector_t* sector,
fixed_t speed,
fixed_t dest,
boolean crush,
int floorOrCeiling,
int direction )
{
boolean flag;
fixed_t lastpos;
switch(floorOrCeiling)
{
case 0:
// FLOOR
switch(direction)
{
case -1:
// DOWN
if (sector->floorheight - speed < dest)
{
// villsa [STRIFE] unused
//lastpos = sector->floorheight;
sector->floorheight = dest;
flag = P_ChangeSector(sector,crush);
// villsa [STRIFE] unused
/*if (flag == true)
{
sector->floorheight =lastpos;
P_ChangeSector(sector,crush);
//return crushed;
}*/
return pastdest;
}
else
{
// villsa [STRIFE] unused
//lastpos = sector->floorheight;
sector->floorheight -= speed;
flag = P_ChangeSector(sector,crush);
// villsa [STRIFE] unused
/*if (flag == true)
{
sector->floorheight = lastpos;
P_ChangeSector(sector,crush);
return crushed;
}*/
return ok;
}
break;
case 1:
// UP
if (sector->floorheight + speed > dest)
{
lastpos = sector->floorheight;
sector->floorheight = dest;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
sector->floorheight = lastpos;
P_ChangeSector(sector,crush);
//return crushed;
}
return pastdest;
}
else
{
// COULD GET CRUSHED
lastpos = sector->floorheight;
sector->floorheight += speed;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
// haleyjd 20130210: Bug fix - Strife DOES do this.
if (crush == true)
return crushed;
sector->floorheight = lastpos;
P_ChangeSector(sector,crush);
return crushed;
}
else
return ok;
}
break;
}
break;
case 1:
// CEILING
switch(direction)
{
case -1:
// DOWN
if (sector->ceilingheight - speed < dest)
{
lastpos = sector->ceilingheight;
sector->ceilingheight = dest;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
sector->ceilingheight = lastpos;
P_ChangeSector(sector,crush);
//return crushed;
}
return pastdest;
}
else
{
// COULD GET CRUSHED
lastpos = sector->ceilingheight;
sector->ceilingheight -= speed;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
if (crush == true)
return crushed;
sector->ceilingheight = lastpos;
P_ChangeSector(sector,crush);
return crushed;
}
}
break;
case 1:
// UP
if (sector->ceilingheight + speed > dest)
{
// villsa [STRIFE] unused
//lastpos = sector->ceilingheight;
sector->ceilingheight = dest;
// villsa [STRIFE] unused
//flag = P_ChangeSector(sector,crush);
/*if (flag == true)
{
sector->ceilingheight = lastpos;
P_ChangeSector(sector,crush);
//return crushed;
}*/
return pastdest;
}
else
{
// villsa [STRIFE] unused
//lastpos = sector->ceilingheight;
sector->ceilingheight += speed;
// villsa [STRIFE] unused
//flag = P_ChangeSector(sector,crush);
return ok;
}
break;
}
break;
}
return ok;
}
//
// MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)
//
void T_MoveFloor(floormove_t* floor)
{
result_e res;
res = T_MovePlane(floor->sector,
floor->speed,
floor->floordestheight,
floor->crush,0,floor->direction);
if (!(leveltime&7))
S_StartSound(&floor->sector->soundorg, sfx_stnmov);
if (res == pastdest)
{
floor->sector->specialdata = NULL;
if (floor->direction == 1)
{
switch(floor->type)
{
case donutRaise:
floor->sector->special = floor->newspecial;
floor->sector->floorpic = floor->texture;
default:
break;
}
}
else if (floor->direction == -1)
{
switch(floor->type)
{
case lowerAndChange:
floor->sector->special = floor->newspecial;
floor->sector->floorpic = floor->texture;
default:
break;
}
}
P_RemoveThinker(&floor->thinker);
S_StartSound(&floor->sector->soundorg, sfx_pstop);
}
}
//
// HANDLE FLOOR TYPES
//
// haleyjd 09/16/2010: [STRIFE] Modifications to floortypes:
// * raiseFloor24 was changed into raiseFloor64
// * turboLower does not appear to adjust the floor height (STRIFE-TODO: verify)
// * raiseFloor512AndChange type was added.
//
int
EV_DoFloor
( line_t* line,
floor_e floortype )
{
int secnum;
int rtn;
int i;
sector_t* sec;
floormove_t* floor;
secnum = -1;
rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
sec = §ors[secnum];
// ALREADY MOVING? IF SO, KEEP GOING...
if (sec->specialdata)
continue;
// new floor thinker
rtn = 1;
floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
P_AddThinker (&floor->thinker);
sec->specialdata = floor;
floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
floor->type = floortype;
floor->crush = false;
switch(floortype)
{
case lowerFloor: // [STRIFE] verified unmodified
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindHighestFloorSurrounding(sec);
break;
case lowerFloorToLowest: // [STRIFE] verified unmodified
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestFloorSurrounding(sec);
break;
case turboLower: // [STRIFE] Modified: does not += 8
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED * 4;
floor->floordestheight =
P_FindHighestFloorSurrounding(sec);
//if (floor->floordestheight != sec->floorheight)
// floor->floordestheight += 8*FRACUNIT;
break;
case raiseFloorCrush: // [STRIFE] verified unmodified
floor->crush = true;
case raiseFloor:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestCeilingSurrounding(sec);
if (floor->floordestheight > sec->ceilingheight)
floor->floordestheight = sec->ceilingheight;
floor->floordestheight -= (8*FRACUNIT)*
(floortype == raiseFloorCrush);
break;
case raiseFloorTurbo: // [STRIFE] verified unmodified
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED*4;
floor->floordestheight =
P_FindNextHighestFloor(sec,sec->floorheight);
break;
case raiseFloorToNearest: // [STRIFE] verified unmodified
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindNextHighestFloor(sec,sec->floorheight);
break;
case raiseFloor64: // [STRIFE] modified from raiseFloor24!
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
64 * FRACUNIT; // [STRIFE]
break;
case raiseFloor512: // [STRIFE] verified unmodified
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
512 * FRACUNIT;
break;
case raiseFloor24AndChange: // [STRIFE] verified unmodified
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
24 * FRACUNIT;
sec->floorpic = line->frontsector->floorpic;
sec->special = line->frontsector->special;
break;
case raiseFloor512AndChange: // [STRIFE] New floor type
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
512 * FRACUNIT;
sec->floorpic = line->frontsector->floorpic;
sec->special = line->frontsector->special;
break;
case raiseToTexture: // [STRIFE] verified unmodified
{
int minsize = INT_MAX;
side_t* side;
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
for (i = 0; i < sec->linecount; i++)
{
if (twoSided (secnum, i) )
{
side = getSide(secnum,i,0);
if (side->bottomtexture >= 0)
if (textureheight[side->bottomtexture] <
minsize)
minsize =
textureheight[side->bottomtexture];
side = getSide(secnum,i,1);
if (side->bottomtexture >= 0)
if (textureheight[side->bottomtexture] <
minsize)
minsize =
textureheight[side->bottomtexture];
}
}
floor->floordestheight =
floor->sector->floorheight + minsize;
}
break;
case lowerAndChange: // [STRIFE] verified unmodified
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestFloorSurrounding(sec);
floor->texture = sec->floorpic;
for (i = 0; i < sec->linecount; i++)
{
if ( twoSided(secnum, i) )
{
if (getSide(secnum,i,0)->sector-sectors == secnum)
{
sec = getSector(secnum,i,1);
if (sec->floorheight == floor->floordestheight)
{
floor->texture = sec->floorpic;
floor->newspecial = sec->special;
break;
}
}
else
{
sec = getSector(secnum,i,0);
if (sec->floorheight == floor->floordestheight)
{
floor->texture = sec->floorpic;
floor->newspecial = sec->special;
break;
}
}
}
}
default:
break;
}
}
return rtn;
}
//
// BUILD A STAIRCASE!
//
int
EV_BuildStairs
( line_t* line,
stair_e type )
{
int secnum;
int height;
int i;
int newsecnum;
int texture;
int ok;
int rtn;
sector_t* sec;
sector_t* tsec;
floormove_t* floor;
// Either Watcom or Rogue moved the switch out of the loop below, probably
// because it was a loop invariant, and put the default values in the
// initializers here. I cannot be bothered to figure it out without doing
// this myself :P
fixed_t stairsize = 8*FRACUNIT;
fixed_t speed = FLOORSPEED;
int direction = 1;
switch(type)
{
case build8: // [STRIFE] Verified unmodified.
speed = FLOORSPEED/4;
break;
case turbo16: // [STRIFE] Verified unmodified.
speed = FLOORSPEED*4;
stairsize = 16*FRACUNIT;
break;
case buildDown16: // [STRIFE] New stair type
stairsize = -16*FRACUNIT;
direction = -1;
break;
}
secnum = -1;
rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
sec = §ors[secnum];
// ALREADY MOVING? IF SO, KEEP GOING...
if (sec->specialdata)
continue;
// new floor thinker
rtn = 1;
floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
P_AddThinker (&floor->thinker);
sec->specialdata = floor;
floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
floor->direction = 1;
floor->sector = sec;
floor->speed = speed;
height = sec->floorheight + stairsize;
floor->floordestheight = height;
texture = sec->floorpic;
// Find next sector to raise
// 1. Find 2-sided line with same sector side[0]
// 2. Other side is the next sector to raise
do
{
ok = 0;
for (i = 0;i < sec->linecount;i++)
{
if ( !((sec->lines[i])->flags & ML_TWOSIDED) )
continue;
tsec = (sec->lines[i])->frontsector;
newsecnum = tsec-sectors;
if (secnum != newsecnum)
continue;
tsec = (sec->lines[i])->backsector;
newsecnum = tsec - sectors;
if (tsec->floorpic != texture)
continue;
height += stairsize;
if (tsec->specialdata)
continue;
sec = tsec;
secnum = newsecnum;
floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
P_AddThinker (&floor->thinker);
sec->specialdata = floor;
floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
floor->direction = direction; // [STRIFE]: for buildDown16
floor->sector = sec;
floor->speed = speed;
floor->floordestheight = height;
ok = 1;
break;
}
} while(ok);
}
return rtn;
}
|