| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* Generalized linedef type handlers |
| 31 |
* Floors, Ceilings, Doors, Locked Doors, Lifts, Stairs, Crushers |
| 32 |
* |
| 33 |
*-----------------------------------------------------------------------------*/ |
| 34 |
|
| 35 |
#include "doomstat.h" //jff 6/19/98 for demo_compatibility |
| 36 |
#include "r_main.h" |
| 37 |
#include "p_spec.h" |
| 38 |
#include "p_tick.h" |
| 39 |
#include "m_random.h" |
| 40 |
#include "s_sound.h" |
| 41 |
#include "sounds.h" |
| 42 |
#include "e6y.h" |
| 43 |
|
| 44 |
#include "dsda/id_list.h" |
| 45 |
|
| 46 |
// check if a manual trigger, if so do just the sector on the backside |
| 47 |
#define FIND_GENLIN_SECTORS if (Trig == PushOnce || Trig == PushMany) \ |
| 48 |
{ \ |
| 49 |
if (!(sec = line->backsector)) \ |
| 50 |
return rtn; \ |
| 51 |
manual_list[0] = sec->iSectorID; \ |
| 52 |
id_p = manual_list; \ |
| 53 |
} \ |
| 54 |
else \ |
| 55 |
{ \ |
| 56 |
id_p = dsda_FindSectorsFromID(line->tag); \ |
| 57 |
} |
| 58 |
|
| 59 |
////////////////////////////////////////////////////////// |
| 60 |
// |
| 61 |
// Generalized Linedef Type handlers |
| 62 |
// |
| 63 |
////////////////////////////////////////////////////////// |
| 64 |
|
| 65 |
// |
| 66 |
// EV_DoGenFloor() |
| 67 |
// |
| 68 |
// Handle generalized floor types |
| 69 |
// |
| 70 |
// Passed the line activating the generalized floor function |
| 71 |
// Returns true if a thinker is created |
| 72 |
// |
| 73 |
// jff 02/04/98 Added this routine (and file) to handle generalized |
| 74 |
// floor movers using bit fields in the line special type. |
| 75 |
// |
| 76 |
int EV_DoGenFloor |
| 77 |
( line_t* line ) |
| 78 |
{ |
| 79 |
const int *id_p; |
| 80 |
int manual_list[2] = { -1, -1 }; |
| 81 |
int rtn; |
| 82 |
sector_t* sec; |
| 83 |
floormove_t* floor; |
| 84 |
unsigned value = (unsigned)line->special - GenFloorBase; |
| 85 |
|
| 86 |
// parse the bit fields in the line's special type |
| 87 |
|
| 88 |
int Crsh = (value & FloorCrush) >> FloorCrushShift; |
| 89 |
int ChgT = (value & FloorChange) >> FloorChangeShift; |
| 90 |
int Targ = (value & FloorTarget) >> FloorTargetShift; |
| 91 |
int Dirn = (value & FloorDirection) >> FloorDirectionShift; |
| 92 |
int ChgM = (value & FloorModel) >> FloorModelShift; |
| 93 |
int Sped = (value & FloorSpeed) >> FloorSpeedShift; |
| 94 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 95 |
|
| 96 |
rtn = 0; |
| 97 |
|
| 98 |
FIND_GENLIN_SECTORS; |
| 99 |
|
| 100 |
for (; *id_p >= 0; id_p++) |
| 101 |
{ |
| 102 |
sec = §ors[*id_p]; |
| 103 |
|
| 104 |
// Do not start another function if floor already moving |
| 105 |
if (P_FloorActive(sec)) |
| 106 |
continue; |
| 107 |
|
| 108 |
// new floor thinker |
| 109 |
rtn = 1; |
| 110 |
floor = Z_MallocLevel (sizeof(*floor)); |
| 111 |
memset(floor, 0, sizeof(*floor)); |
| 112 |
P_AddThinker (&floor->thinker); |
| 113 |
sec->floordata = floor; |
| 114 |
floor->thinker.function = T_MoveFloor; |
| 115 |
floor->crush = (Crsh ? DOOM_CRUSH : NO_CRUSH); |
| 116 |
floor->direction = Dirn? 1 : -1; |
| 117 |
floor->sector = sec; |
| 118 |
floor->texture = sec->floorpic; |
| 119 |
P_CopyTransferSpecial(&floor->newspecial, sec); |
| 120 |
floor->type = genFloor; |
| 121 |
|
| 122 |
// set the speed of motion |
| 123 |
switch (Sped) |
| 124 |
{ |
| 125 |
case SpeedSlow: |
| 126 |
floor->speed = FLOORSPEED; |
| 127 |
break; |
| 128 |
case SpeedNormal: |
| 129 |
floor->speed = FLOORSPEED*2; |
| 130 |
break; |
| 131 |
case SpeedFast: |
| 132 |
floor->speed = FLOORSPEED*4; |
| 133 |
break; |
| 134 |
case SpeedTurbo: |
| 135 |
floor->speed = FLOORSPEED*8; |
| 136 |
break; |
| 137 |
default: |
| 138 |
break; |
| 139 |
} |
| 140 |
|
| 141 |
// set the destination height |
| 142 |
switch(Targ) |
| 143 |
{ |
| 144 |
case FtoHnF: |
| 145 |
floor->floordestheight = P_FindHighestFloorSurrounding(sec); |
| 146 |
break; |
| 147 |
case FtoLnF: |
| 148 |
floor->floordestheight = P_FindLowestFloorSurrounding(sec); |
| 149 |
break; |
| 150 |
case FtoNnF: |
| 151 |
floor->floordestheight = Dirn? |
| 152 |
P_FindNextHighestFloor(sec,sec->floorheight) : |
| 153 |
P_FindNextLowestFloor(sec,sec->floorheight); |
| 154 |
break; |
| 155 |
case FtoLnC: |
| 156 |
floor->floordestheight = P_FindLowestCeilingSurrounding(sec); |
| 157 |
break; |
| 158 |
case FtoC: |
| 159 |
floor->floordestheight = sec->ceilingheight; |
| 160 |
break; |
| 161 |
case FbyST: |
| 162 |
floor->floordestheight = (floor->sector->floorheight>>FRACBITS) + |
| 163 |
floor->direction * (P_FindShortestTextureAround(*id_p)>>FRACBITS); |
| 164 |
if (floor->floordestheight>32000) //jff 3/13/98 prevent overflow |
| 165 |
floor->floordestheight=32000; // wraparound in floor height |
| 166 |
if (floor->floordestheight<-32000) |
| 167 |
floor->floordestheight=-32000; |
| 168 |
floor->floordestheight<<=FRACBITS; |
| 169 |
break; |
| 170 |
case Fby24: |
| 171 |
floor->floordestheight = floor->sector->floorheight + |
| 172 |
floor->direction * 24*FRACUNIT; |
| 173 |
break; |
| 174 |
case Fby32: |
| 175 |
floor->floordestheight = floor->sector->floorheight + |
| 176 |
floor->direction * 32*FRACUNIT; |
| 177 |
break; |
| 178 |
default: |
| 179 |
break; |
| 180 |
} |
| 181 |
|
| 182 |
// set texture/type change properties |
| 183 |
if (ChgT) // if a texture change is indicated |
| 184 |
{ |
| 185 |
if (ChgM) // if a numeric model change |
| 186 |
{ |
| 187 |
sector_t *sec; |
| 188 |
|
| 189 |
//jff 5/23/98 find model with ceiling at target height if target |
| 190 |
//is a ceiling type |
| 191 |
sec = (Targ==FtoLnC || Targ==FtoC)? |
| 192 |
P_FindModelCeilingSector(floor->floordestheight,*id_p) : |
| 193 |
P_FindModelFloorSector(floor->floordestheight,*id_p); |
| 194 |
if (sec) |
| 195 |
{ |
| 196 |
floor->texture = sec->floorpic; |
| 197 |
switch(ChgT) |
| 198 |
{ |
| 199 |
case FChgZero: // zero type |
| 200 |
P_ResetTransferSpecial(&floor->newspecial); |
| 201 |
floor->type = genFloorChg0; |
| 202 |
break; |
| 203 |
case FChgTyp: // copy type |
| 204 |
P_CopyTransferSpecial(&floor->newspecial, sec); |
| 205 |
floor->type = genFloorChgT; |
| 206 |
break; |
| 207 |
case FChgTxt: // leave type be |
| 208 |
floor->type = genFloorChg; |
| 209 |
break; |
| 210 |
default: |
| 211 |
break; |
| 212 |
} |
| 213 |
} |
| 214 |
} |
| 215 |
else // else if a trigger model change |
| 216 |
{ |
| 217 |
floor->texture = line->frontsector->floorpic; |
| 218 |
switch (ChgT) |
| 219 |
{ |
| 220 |
case FChgZero: // zero type |
| 221 |
P_ResetTransferSpecial(&floor->newspecial); |
| 222 |
floor->type = genFloorChg0; |
| 223 |
break; |
| 224 |
case FChgTyp: // copy type |
| 225 |
P_CopyTransferSpecial(&floor->newspecial, line->frontsector); |
| 226 |
floor->type = genFloorChgT; |
| 227 |
break; |
| 228 |
case FChgTxt: // leave type be |
| 229 |
floor->type = genFloorChg; |
| 230 |
default: |
| 231 |
break; |
| 232 |
} |
| 233 |
} |
| 234 |
} |
| 235 |
} |
| 236 |
return rtn; |
| 237 |
} |
| 238 |
|
| 239 |
|
| 240 |
// |
| 241 |
// EV_DoGenCeiling() |
| 242 |
// |
| 243 |
// Handle generalized ceiling types |
| 244 |
// |
| 245 |
// Passed the linedef activating the ceiling function |
| 246 |
// Returns true if a thinker created |
| 247 |
// |
| 248 |
// jff 02/04/98 Added this routine (and file) to handle generalized |
| 249 |
// floor movers using bit fields in the line special type. |
| 250 |
// |
| 251 |
int EV_DoGenCeiling |
| 252 |
( line_t* line ) |
| 253 |
{ |
| 254 |
const int *id_p; |
| 255 |
int manual_list[2] = { -1, -1 }; |
| 256 |
int rtn; |
| 257 |
fixed_t targheight; |
| 258 |
sector_t* sec; |
| 259 |
ceiling_t* ceiling; |
| 260 |
unsigned value = (unsigned)line->special - GenCeilingBase; |
| 261 |
|
| 262 |
// parse the bit fields in the line's special type |
| 263 |
|
| 264 |
int Crsh = (value & CeilingCrush) >> CeilingCrushShift; |
| 265 |
int ChgT = (value & CeilingChange) >> CeilingChangeShift; |
| 266 |
int Targ = (value & CeilingTarget) >> CeilingTargetShift; |
| 267 |
int Dirn = (value & CeilingDirection) >> CeilingDirectionShift; |
| 268 |
int ChgM = (value & CeilingModel) >> CeilingModelShift; |
| 269 |
int Sped = (value & CeilingSpeed) >> CeilingSpeedShift; |
| 270 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 271 |
|
| 272 |
rtn = 0; |
| 273 |
|
| 274 |
FIND_GENLIN_SECTORS; |
| 275 |
|
| 276 |
for (; *id_p >= 0; id_p++) |
| 277 |
{ |
| 278 |
sec = §ors[*id_p]; |
| 279 |
|
| 280 |
// Do not start another function if ceiling already moving |
| 281 |
if (P_CeilingActive(sec)) //jff 2/22/98 |
| 282 |
continue; |
| 283 |
|
| 284 |
// new ceiling thinker |
| 285 |
rtn = 1; |
| 286 |
ceiling = Z_MallocLevel (sizeof(*ceiling)); |
| 287 |
memset(ceiling, 0, sizeof(*ceiling)); |
| 288 |
P_AddThinker (&ceiling->thinker); |
| 289 |
sec->ceilingdata = ceiling; //jff 2/22/98 |
| 290 |
ceiling->thinker.function = T_MoveCeiling; |
| 291 |
ceiling->crush = (Crsh ? DOOM_CRUSH : NO_CRUSH); |
| 292 |
ceiling->direction = Dirn? 1 : -1; |
| 293 |
ceiling->sector = sec; |
| 294 |
ceiling->texture = sec->ceilingpic; |
| 295 |
P_CopyTransferSpecial(&ceiling->newspecial, sec); |
| 296 |
ceiling->tag = sec->tag; |
| 297 |
ceiling->type = genCeiling; |
| 298 |
|
| 299 |
// set speed of motion |
| 300 |
switch (Sped) |
| 301 |
{ |
| 302 |
case SpeedSlow: |
| 303 |
ceiling->speed = CEILSPEED; |
| 304 |
break; |
| 305 |
case SpeedNormal: |
| 306 |
ceiling->speed = CEILSPEED*2; |
| 307 |
break; |
| 308 |
case SpeedFast: |
| 309 |
ceiling->speed = CEILSPEED*4; |
| 310 |
break; |
| 311 |
case SpeedTurbo: |
| 312 |
ceiling->speed = CEILSPEED*8; |
| 313 |
break; |
| 314 |
default: |
| 315 |
break; |
| 316 |
} |
| 317 |
|
| 318 |
// set destination target height |
| 319 |
targheight = sec->ceilingheight; |
| 320 |
switch(Targ) |
| 321 |
{ |
| 322 |
case CtoHnC: |
| 323 |
targheight = P_FindHighestCeilingSurrounding(sec); |
| 324 |
break; |
| 325 |
case CtoLnC: |
| 326 |
targheight = P_FindLowestCeilingSurrounding(sec); |
| 327 |
break; |
| 328 |
case CtoNnC: |
| 329 |
targheight = Dirn? |
| 330 |
P_FindNextHighestCeiling(sec,sec->ceilingheight) : |
| 331 |
P_FindNextLowestCeiling(sec,sec->ceilingheight); |
| 332 |
break; |
| 333 |
case CtoHnF: |
| 334 |
targheight = P_FindHighestFloorSurrounding(sec); |
| 335 |
break; |
| 336 |
case CtoF: |
| 337 |
targheight = sec->floorheight; |
| 338 |
break; |
| 339 |
case CbyST: |
| 340 |
targheight = (ceiling->sector->ceilingheight>>FRACBITS) + |
| 341 |
ceiling->direction * (P_FindShortestUpperAround(*id_p)>>FRACBITS); |
| 342 |
if (targheight>32000) //jff 3/13/98 prevent overflow |
| 343 |
targheight=32000; // wraparound in ceiling height |
| 344 |
if (targheight<-32000) |
| 345 |
targheight=-32000; |
| 346 |
targheight<<=FRACBITS; |
| 347 |
break; |
| 348 |
case Cby24: |
| 349 |
targheight = ceiling->sector->ceilingheight + |
| 350 |
ceiling->direction * 24*FRACUNIT; |
| 351 |
break; |
| 352 |
case Cby32: |
| 353 |
targheight = ceiling->sector->ceilingheight + |
| 354 |
ceiling->direction * 32*FRACUNIT; |
| 355 |
break; |
| 356 |
default: |
| 357 |
break; |
| 358 |
} |
| 359 |
if (Dirn) ceiling->topheight = targheight; |
| 360 |
else ceiling->bottomheight = targheight; |
| 361 |
|
| 362 |
// set texture/type change properties |
| 363 |
if (ChgT) // if a texture change is indicated |
| 364 |
{ |
| 365 |
if (ChgM) // if a numeric model change |
| 366 |
{ |
| 367 |
sector_t *sec; |
| 368 |
|
| 369 |
//jff 5/23/98 find model with floor at target height if target |
| 370 |
//is a floor type |
| 371 |
sec = (Targ==CtoHnF || Targ==CtoF)? |
| 372 |
P_FindModelFloorSector(targheight,*id_p) : |
| 373 |
P_FindModelCeilingSector(targheight,*id_p); |
| 374 |
if (sec) |
| 375 |
{ |
| 376 |
ceiling->texture = sec->ceilingpic; |
| 377 |
switch (ChgT) |
| 378 |
{ |
| 379 |
case CChgZero: // type is zeroed |
| 380 |
P_ResetTransferSpecial(&ceiling->newspecial); |
| 381 |
ceiling->type = genCeilingChg0; |
| 382 |
break; |
| 383 |
case CChgTyp: // type is copied |
| 384 |
P_CopyTransferSpecial(&ceiling->newspecial, sec); |
| 385 |
ceiling->type = genCeilingChgT; |
| 386 |
break; |
| 387 |
case CChgTxt: // type is left alone |
| 388 |
ceiling->type = genCeilingChg; |
| 389 |
break; |
| 390 |
default: |
| 391 |
break; |
| 392 |
} |
| 393 |
} |
| 394 |
} |
| 395 |
else // else if a trigger model change |
| 396 |
{ |
| 397 |
ceiling->texture = line->frontsector->ceilingpic; |
| 398 |
switch (ChgT) |
| 399 |
{ |
| 400 |
case CChgZero: // type is zeroed |
| 401 |
P_ResetTransferSpecial(&ceiling->newspecial); |
| 402 |
ceiling->type = genCeilingChg0; |
| 403 |
break; |
| 404 |
case CChgTyp: // type is copied |
| 405 |
P_CopyTransferSpecial(&ceiling->newspecial, line->frontsector); |
| 406 |
ceiling->type = genCeilingChgT; |
| 407 |
break; |
| 408 |
case CChgTxt: // type is left alone |
| 409 |
ceiling->type = genCeilingChg; |
| 410 |
break; |
| 411 |
default: |
| 412 |
break; |
| 413 |
} |
| 414 |
} |
| 415 |
} |
| 416 |
P_AddActiveCeiling(ceiling); // add this ceiling to the active list |
| 417 |
} |
| 418 |
return rtn; |
| 419 |
} |
| 420 |
|
| 421 |
// |
| 422 |
// EV_DoGenLift() |
| 423 |
// |
| 424 |
// Handle generalized lift types |
| 425 |
// |
| 426 |
// Passed the linedef activating the lift |
| 427 |
// Returns true if a thinker is created |
| 428 |
// |
| 429 |
int EV_DoGenLift |
| 430 |
( line_t* line ) |
| 431 |
{ |
| 432 |
const int *id_p; |
| 433 |
int manual_list[2] = { -1, -1 }; |
| 434 |
plat_t* plat; |
| 435 |
int rtn; |
| 436 |
sector_t* sec; |
| 437 |
unsigned value = (unsigned)line->special - GenLiftBase; |
| 438 |
|
| 439 |
// parse the bit fields in the line's special type |
| 440 |
|
| 441 |
int Targ = (value & LiftTarget) >> LiftTargetShift; |
| 442 |
int Dely = (value & LiftDelay) >> LiftDelayShift; |
| 443 |
int Sped = (value & LiftSpeed) >> LiftSpeedShift; |
| 444 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 445 |
|
| 446 |
rtn = 0; |
| 447 |
|
| 448 |
// Activate all <type> plats that are in_stasis |
| 449 |
|
| 450 |
if (Targ==LnF2HnF) |
| 451 |
P_ActivateInStasis(line->tag); |
| 452 |
|
| 453 |
FIND_GENLIN_SECTORS; |
| 454 |
|
| 455 |
for (; *id_p >= 0; id_p++) |
| 456 |
{ |
| 457 |
sec = §ors[*id_p]; |
| 458 |
|
| 459 |
// Do not start another function if floor already moving |
| 460 |
if (P_FloorActive(sec)) |
| 461 |
continue; |
| 462 |
|
| 463 |
// Setup the plat thinker |
| 464 |
rtn = 1; |
| 465 |
plat = Z_MallocLevel( sizeof(*plat)); |
| 466 |
memset(plat, 0, sizeof(*plat)); |
| 467 |
P_AddThinker(&plat->thinker); |
| 468 |
|
| 469 |
plat->sector = sec; |
| 470 |
plat->sector->floordata = plat; |
| 471 |
plat->thinker.function = T_PlatRaise; |
| 472 |
plat->crush = NO_CRUSH; |
| 473 |
plat->tag = line->tag; |
| 474 |
|
| 475 |
plat->type = genLift; |
| 476 |
plat->high = sec->floorheight; |
| 477 |
plat->status = down; |
| 478 |
|
| 479 |
// setup the target destination height |
| 480 |
switch(Targ) |
| 481 |
{ |
| 482 |
case F2LnF: |
| 483 |
plat->low = P_FindLowestFloorSurrounding(sec); |
| 484 |
if (plat->low > sec->floorheight) |
| 485 |
plat->low = sec->floorheight; |
| 486 |
break; |
| 487 |
case F2NnF: |
| 488 |
plat->low = P_FindNextLowestFloor(sec,sec->floorheight); |
| 489 |
break; |
| 490 |
case F2LnC: |
| 491 |
plat->low = P_FindLowestCeilingSurrounding(sec); |
| 492 |
if (plat->low > sec->floorheight) |
| 493 |
plat->low = sec->floorheight; |
| 494 |
break; |
| 495 |
case LnF2HnF: |
| 496 |
plat->type = genPerpetual; |
| 497 |
plat->low = P_FindLowestFloorSurrounding(sec); |
| 498 |
if (plat->low > sec->floorheight) |
| 499 |
plat->low = sec->floorheight; |
| 500 |
plat->high = P_FindHighestFloorSurrounding(sec); |
| 501 |
if (plat->high < sec->floorheight) |
| 502 |
plat->high = sec->floorheight; |
| 503 |
plat->status = P_Random(pr_genlift)&1; |
| 504 |
break; |
| 505 |
default: |
| 506 |
break; |
| 507 |
} |
| 508 |
|
| 509 |
// setup the speed of motion |
| 510 |
switch(Sped) |
| 511 |
{ |
| 512 |
case SpeedSlow: |
| 513 |
plat->speed = PLATSPEED * 2; |
| 514 |
break; |
| 515 |
case SpeedNormal: |
| 516 |
plat->speed = PLATSPEED * 4; |
| 517 |
break; |
| 518 |
case SpeedFast: |
| 519 |
plat->speed = PLATSPEED * 8; |
| 520 |
break; |
| 521 |
case SpeedTurbo: |
| 522 |
plat->speed = PLATSPEED * 16; |
| 523 |
break; |
| 524 |
default: |
| 525 |
break; |
| 526 |
} |
| 527 |
|
| 528 |
// setup the delay time before the floor returns |
| 529 |
switch(Dely) |
| 530 |
{ |
| 531 |
case 0: |
| 532 |
plat->wait = 1*35; |
| 533 |
break; |
| 534 |
case 1: |
| 535 |
plat->wait = PLATWAIT*35; |
| 536 |
break; |
| 537 |
case 2: |
| 538 |
plat->wait = 5*35; |
| 539 |
break; |
| 540 |
case 3: |
| 541 |
plat->wait = 10*35; |
| 542 |
break; |
| 543 |
} |
| 544 |
|
| 545 |
S_StartSectorSound(sec, sfx_pstart); |
| 546 |
P_AddActivePlat(plat); // add this plat to the list of active plats |
| 547 |
} |
| 548 |
return rtn; |
| 549 |
} |
| 550 |
|
| 551 |
// |
| 552 |
// EV_DoGenStairs() |
| 553 |
// |
| 554 |
// Handle generalized stair building |
| 555 |
// |
| 556 |
// Passed the linedef activating the stairs |
| 557 |
// Returns true if a thinker is created |
| 558 |
// |
| 559 |
int EV_DoGenStairs |
| 560 |
( line_t* line ) |
| 561 |
{ |
| 562 |
const int *id_p; |
| 563 |
int manual_list[2] = { -1, -1 }; |
| 564 |
int height; |
| 565 |
int i; |
| 566 |
int oldsecnum; |
| 567 |
int newsecnum; |
| 568 |
int texture; |
| 569 |
int ok; |
| 570 |
int rtn; |
| 571 |
|
| 572 |
sector_t* sec; |
| 573 |
sector_t* tsec; |
| 574 |
|
| 575 |
floormove_t* floor; |
| 576 |
|
| 577 |
fixed_t stairsize; |
| 578 |
fixed_t speed; |
| 579 |
|
| 580 |
unsigned value = (unsigned)line->special - GenStairsBase; |
| 581 |
|
| 582 |
// parse the bit fields in the line's special type |
| 583 |
|
| 584 |
int Igno = (value & StairIgnore) >> StairIgnoreShift; |
| 585 |
int Dirn = (value & StairDirection) >> StairDirectionShift; |
| 586 |
int Step = (value & StairStep) >> StairStepShift; |
| 587 |
int Sped = (value & StairSpeed) >> StairSpeedShift; |
| 588 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 589 |
|
| 590 |
rtn = 0; |
| 591 |
|
| 592 |
FIND_GENLIN_SECTORS; |
| 593 |
|
| 594 |
for (; *id_p >= 0; id_p++) |
| 595 |
{ |
| 596 |
sec = §ors[*id_p]; |
| 597 |
|
| 598 |
//Do not start another function if floor already moving |
| 599 |
//jff 2/26/98 add special lockout condition to wait for entire |
| 600 |
//staircase to build before retriggering |
| 601 |
if (P_FloorActive(sec) || sec->stairlock) |
| 602 |
continue; |
| 603 |
|
| 604 |
// new floor thinker |
| 605 |
rtn = 1; |
| 606 |
floor = Z_MallocLevel (sizeof(*floor)); |
| 607 |
memset(floor, 0, sizeof(*floor)); |
| 608 |
P_AddThinker (&floor->thinker); |
| 609 |
sec->floordata = floor; |
| 610 |
floor->thinker.function = T_MoveFloor; |
| 611 |
floor->direction = Dirn? 1 : -1; |
| 612 |
floor->sector = sec; |
| 613 |
|
| 614 |
// setup speed of stair building |
| 615 |
switch(Sped) |
| 616 |
{ |
| 617 |
default: |
| 618 |
case SpeedSlow: |
| 619 |
floor->speed = FLOORSPEED/4; |
| 620 |
break; |
| 621 |
case SpeedNormal: |
| 622 |
floor->speed = FLOORSPEED/2; |
| 623 |
break; |
| 624 |
case SpeedFast: |
| 625 |
floor->speed = FLOORSPEED*2; |
| 626 |
break; |
| 627 |
case SpeedTurbo: |
| 628 |
floor->speed = FLOORSPEED*4; |
| 629 |
break; |
| 630 |
} |
| 631 |
|
| 632 |
// setup stepsize for stairs |
| 633 |
switch(Step) |
| 634 |
{ |
| 635 |
default: |
| 636 |
case 0: |
| 637 |
stairsize = 4*FRACUNIT; |
| 638 |
break; |
| 639 |
case 1: |
| 640 |
stairsize = 8*FRACUNIT; |
| 641 |
break; |
| 642 |
case 2: |
| 643 |
stairsize = 16*FRACUNIT; |
| 644 |
break; |
| 645 |
case 3: |
| 646 |
stairsize = 24*FRACUNIT; |
| 647 |
break; |
| 648 |
} |
| 649 |
|
| 650 |
speed = floor->speed; |
| 651 |
height = sec->floorheight + floor->direction * stairsize; |
| 652 |
floor->floordestheight = height; |
| 653 |
texture = sec->floorpic; |
| 654 |
floor->crush = NO_CRUSH; |
| 655 |
floor->type = genBuildStair; // jff 3/31/98 do not leave uninited |
| 656 |
|
| 657 |
sec->stairlock = -2; // jff 2/26/98 set up lock on current sector |
| 658 |
sec->nextsec = -1; |
| 659 |
sec->prevsec = -1; |
| 660 |
|
| 661 |
oldsecnum = *id_p; |
| 662 |
// Find next sector to raise |
| 663 |
// 1. Find 2-sided line with same sector side[0] |
| 664 |
// 2. Other side is the next sector to raise |
| 665 |
do |
| 666 |
{ |
| 667 |
ok = 0; |
| 668 |
for (i = 0;i < sec->linecount;i++) |
| 669 |
{ |
| 670 |
if ( !((sec->lines[i])->backsector) ) |
| 671 |
continue; |
| 672 |
|
| 673 |
tsec = (sec->lines[i])->frontsector; |
| 674 |
newsecnum = tsec->iSectorID; |
| 675 |
|
| 676 |
if (oldsecnum != newsecnum) |
| 677 |
continue; |
| 678 |
|
| 679 |
tsec = (sec->lines[i])->backsector; |
| 680 |
newsecnum = tsec->iSectorID; |
| 681 |
|
| 682 |
if (!Igno && tsec->floorpic != texture) |
| 683 |
continue; |
| 684 |
|
| 685 |
/* jff 6/19/98 prevent double stepsize */ |
| 686 |
if (compatibility_level < boom_202_compatibility) |
| 687 |
height += floor->direction * stairsize; |
| 688 |
|
| 689 |
//jff 2/26/98 special lockout condition for retriggering |
| 690 |
if (P_FloorActive(tsec) || tsec->stairlock) |
| 691 |
continue; |
| 692 |
|
| 693 |
/* jff 6/19/98 increase height AFTER continue */ |
| 694 |
if (compatibility_level >= boom_202_compatibility) |
| 695 |
height += floor->direction * stairsize; |
| 696 |
|
| 697 |
// jff 2/26/98 |
| 698 |
// link the stair chain in both directions |
| 699 |
// lock the stair sector until building complete |
| 700 |
sec->nextsec = newsecnum; // link step to next |
| 701 |
tsec->prevsec = oldsecnum; // link next back |
| 702 |
tsec->nextsec = -1; // set next forward link as end |
| 703 |
tsec->stairlock = -2; // lock the step |
| 704 |
|
| 705 |
sec = tsec; |
| 706 |
oldsecnum = newsecnum; |
| 707 |
floor = Z_MallocLevel (sizeof(*floor)); |
| 708 |
|
| 709 |
memset(floor, 0, sizeof(*floor)); |
| 710 |
P_AddThinker (&floor->thinker); |
| 711 |
|
| 712 |
sec->floordata = floor; |
| 713 |
floor->thinker.function = T_MoveFloor; |
| 714 |
floor->direction = Dirn? 1 : -1; |
| 715 |
floor->sector = sec; |
| 716 |
floor->speed = speed; |
| 717 |
floor->floordestheight = height; |
| 718 |
floor->crush = NO_CRUSH; |
| 719 |
floor->type = genBuildStair; // jff 3/31/98 do not leave uninited |
| 720 |
|
| 721 |
ok = 1; |
| 722 |
break; |
| 723 |
} |
| 724 |
} while(ok); |
| 725 |
} |
| 726 |
// retriggerable generalized stairs build up or down alternately |
| 727 |
if (rtn) |
| 728 |
line->special ^= StairDirection; // alternate dir on succ activations |
| 729 |
return rtn; |
| 730 |
} |
| 731 |
|
| 732 |
// |
| 733 |
// EV_DoGenCrusher() |
| 734 |
// |
| 735 |
// Handle generalized crusher types |
| 736 |
// |
| 737 |
// Passed the linedef activating the crusher |
| 738 |
// Returns true if a thinker created |
| 739 |
// |
| 740 |
int EV_DoGenCrusher |
| 741 |
( line_t* line ) |
| 742 |
{ |
| 743 |
const int *id_p; |
| 744 |
int manual_list[2] = { -1, -1 }; |
| 745 |
int rtn; |
| 746 |
sector_t* sec; |
| 747 |
ceiling_t* ceiling; |
| 748 |
unsigned value = (unsigned)line->special - GenCrusherBase; |
| 749 |
|
| 750 |
// parse the bit fields in the line's special type |
| 751 |
|
| 752 |
int Slnt = (value & CrusherSilent) >> CrusherSilentShift; |
| 753 |
int Sped = (value & CrusherSpeed) >> CrusherSpeedShift; |
| 754 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 755 |
|
| 756 |
//jff 2/22/98 Reactivate in-stasis ceilings...for certain types. |
| 757 |
//jff 4/5/98 return if activated |
| 758 |
rtn = P_ActivateInStasisCeiling(line->tag); |
| 759 |
|
| 760 |
FIND_GENLIN_SECTORS; |
| 761 |
|
| 762 |
for (; *id_p >= 0; id_p++) |
| 763 |
{ |
| 764 |
sec = §ors[*id_p]; |
| 765 |
|
| 766 |
// Do not start another function if ceiling already moving |
| 767 |
if (P_CeilingActive(sec)) //jff 2/22/98 |
| 768 |
continue; |
| 769 |
|
| 770 |
// new ceiling thinker |
| 771 |
rtn = 1; |
| 772 |
ceiling = Z_MallocLevel (sizeof(*ceiling)); |
| 773 |
memset(ceiling, 0, sizeof(*ceiling)); |
| 774 |
P_AddThinker (&ceiling->thinker); |
| 775 |
sec->ceilingdata = ceiling; //jff 2/22/98 |
| 776 |
ceiling->thinker.function = T_MoveCeiling; |
| 777 |
ceiling->crush = DOOM_CRUSH; |
| 778 |
ceiling->direction = -1; |
| 779 |
ceiling->sector = sec; |
| 780 |
ceiling->texture = sec->ceilingpic; |
| 781 |
P_CopyTransferSpecial(&ceiling->newspecial, sec); |
| 782 |
ceiling->tag = sec->tag; |
| 783 |
ceiling->type = Slnt? genSilentCrusher : genCrusher; |
| 784 |
ceiling->silent = (ceiling->type == genSilentCrusher); |
| 785 |
ceiling->topheight = sec->ceilingheight; |
| 786 |
ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); |
| 787 |
|
| 788 |
// setup ceiling motion speed |
| 789 |
switch (Sped) |
| 790 |
{ |
| 791 |
case SpeedSlow: |
| 792 |
ceiling->speed = CEILSPEED; |
| 793 |
break; |
| 794 |
case SpeedNormal: |
| 795 |
ceiling->speed = CEILSPEED*2; |
| 796 |
break; |
| 797 |
case SpeedFast: |
| 798 |
ceiling->speed = CEILSPEED*4; |
| 799 |
break; |
| 800 |
case SpeedTurbo: |
| 801 |
ceiling->speed = CEILSPEED*8; |
| 802 |
break; |
| 803 |
default: |
| 804 |
break; |
| 805 |
} |
| 806 |
ceiling->oldspeed=ceiling->speed; |
| 807 |
|
| 808 |
P_AddActiveCeiling(ceiling); // add to list of active ceilings |
| 809 |
} |
| 810 |
return rtn; |
| 811 |
} |
| 812 |
|
| 813 |
// |
| 814 |
// EV_DoGenLockedDoor() |
| 815 |
// |
| 816 |
// Handle generalized locked door types |
| 817 |
// |
| 818 |
// Passed the linedef activating the generalized locked door |
| 819 |
// Returns true if a thinker created |
| 820 |
// |
| 821 |
int EV_DoGenLockedDoor |
| 822 |
( line_t* line ) |
| 823 |
{ |
| 824 |
const int *id_p; |
| 825 |
int manual_list[2] = { -1, -1 }; |
| 826 |
int rtn; |
| 827 |
sector_t* sec; |
| 828 |
vldoor_t* door; |
| 829 |
unsigned value = (unsigned)line->special - GenLockedBase; |
| 830 |
|
| 831 |
// parse the bit fields in the line's special type |
| 832 |
|
| 833 |
int Kind = (value & LockedKind) >> LockedKindShift; |
| 834 |
int Sped = (value & LockedSpeed) >> LockedSpeedShift; |
| 835 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 836 |
|
| 837 |
rtn = 0; |
| 838 |
|
| 839 |
FIND_GENLIN_SECTORS; |
| 840 |
|
| 841 |
rtn = 0; |
| 842 |
|
| 843 |
for (; *id_p >= 0; id_p++) |
| 844 |
{ |
| 845 |
sec = §ors[*id_p]; |
| 846 |
|
| 847 |
// Do not start another function if ceiling already moving |
| 848 |
if (P_CeilingActive(sec)) //jff 2/22/98 |
| 849 |
continue; |
| 850 |
|
| 851 |
// new door thinker |
| 852 |
rtn = 1; |
| 853 |
door = Z_MallocLevel (sizeof(*door)); |
| 854 |
memset(door, 0, sizeof(*door)); |
| 855 |
P_AddThinker (&door->thinker); |
| 856 |
sec->ceilingdata = door; //jff 2/22/98 |
| 857 |
|
| 858 |
door->thinker.function = T_VerticalDoor; |
| 859 |
door->sector = sec; |
| 860 |
door->topwait = VDOORWAIT; |
| 861 |
door->line = line; |
| 862 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 863 |
door->topheight -= 4*FRACUNIT; |
| 864 |
door->direction = 1; |
| 865 |
|
| 866 |
/* killough 10/98: implement gradual lighting */ |
| 867 |
door->lighttag = !comp[comp_doorlight] && |
| 868 |
(line->special&6) == 6 && |
| 869 |
line->special > GenLockedBase ? line->tag : 0; |
| 870 |
|
| 871 |
// setup speed of door motion |
| 872 |
switch(Sped) |
| 873 |
{ |
| 874 |
default: |
| 875 |
case SpeedSlow: |
| 876 |
door->type = Kind? genOpen : genRaise; |
| 877 |
door->speed = VDOORSPEED; |
| 878 |
break; |
| 879 |
case SpeedNormal: |
| 880 |
door->type = Kind? genOpen : genRaise; |
| 881 |
door->speed = VDOORSPEED*2; |
| 882 |
break; |
| 883 |
case SpeedFast: |
| 884 |
door->type = Kind? genBlazeOpen : genBlazeRaise; |
| 885 |
door->speed = VDOORSPEED*4; |
| 886 |
break; |
| 887 |
case SpeedTurbo: |
| 888 |
door->type = Kind? genBlazeOpen : genBlazeRaise; |
| 889 |
door->speed = VDOORSPEED*8; |
| 890 |
|
| 891 |
break; |
| 892 |
} |
| 893 |
|
| 894 |
// killough 4/15/98: fix generalized door opening sounds |
| 895 |
// (previously they always had the blazing door close sound) |
| 896 |
S_StartSectorSound(door->sector, door->speed >= VDOORSPEED * 4 ? sfx_bdopn : sfx_doropn); |
| 897 |
} |
| 898 |
return rtn; |
| 899 |
} |
| 900 |
|
| 901 |
// |
| 902 |
// EV_DoGenDoor() |
| 903 |
// |
| 904 |
// Handle generalized door types |
| 905 |
// |
| 906 |
// Passed the linedef activating the generalized door |
| 907 |
// Returns true if a thinker created |
| 908 |
// |
| 909 |
int EV_DoGenDoor |
| 910 |
( line_t* line ) |
| 911 |
{ |
| 912 |
const int *id_p; |
| 913 |
int manual_list[2] = { -1, -1 }; |
| 914 |
int rtn; |
| 915 |
sector_t* sec; |
| 916 |
vldoor_t* door; |
| 917 |
unsigned value = (unsigned)line->special - GenDoorBase; |
| 918 |
|
| 919 |
// parse the bit fields in the line's special type |
| 920 |
|
| 921 |
int Dely = (value & DoorDelay) >> DoorDelayShift; |
| 922 |
int Kind = (value & DoorKind) >> DoorKindShift; |
| 923 |
int Sped = (value & DoorSpeed) >> DoorSpeedShift; |
| 924 |
int Trig = (value & TriggerType) >> TriggerTypeShift; |
| 925 |
|
| 926 |
rtn = 0; |
| 927 |
|
| 928 |
FIND_GENLIN_SECTORS; |
| 929 |
|
| 930 |
rtn = 0; |
| 931 |
|
| 932 |
for (; *id_p >= 0; id_p++) |
| 933 |
{ |
| 934 |
sec = §ors[*id_p]; |
| 935 |
|
| 936 |
// Do not start another function if ceiling already moving |
| 937 |
if (P_CeilingActive(sec)) //jff 2/22/98 |
| 938 |
continue; |
| 939 |
|
| 940 |
// new door thinker |
| 941 |
rtn = 1; |
| 942 |
door = Z_MallocLevel (sizeof(*door)); |
| 943 |
memset(door, 0, sizeof(*door)); |
| 944 |
P_AddThinker (&door->thinker); |
| 945 |
sec->ceilingdata = door; //jff 2/22/98 |
| 946 |
|
| 947 |
door->thinker.function = T_VerticalDoor; |
| 948 |
door->sector = sec; |
| 949 |
// setup delay for door remaining open/closed |
| 950 |
switch(Dely) |
| 951 |
{ |
| 952 |
default: |
| 953 |
case 0: |
| 954 |
door->topwait = 35; |
| 955 |
break; |
| 956 |
case 1: |
| 957 |
door->topwait = VDOORWAIT; |
| 958 |
break; |
| 959 |
case 2: |
| 960 |
door->topwait = 2*VDOORWAIT; |
| 961 |
break; |
| 962 |
case 3: |
| 963 |
door->topwait = 7*VDOORWAIT; |
| 964 |
break; |
| 965 |
} |
| 966 |
|
| 967 |
// setup speed of door motion |
| 968 |
switch(Sped) |
| 969 |
{ |
| 970 |
default: |
| 971 |
case SpeedSlow: |
| 972 |
door->speed = VDOORSPEED; |
| 973 |
break; |
| 974 |
case SpeedNormal: |
| 975 |
door->speed = VDOORSPEED*2; |
| 976 |
break; |
| 977 |
case SpeedFast: |
| 978 |
door->speed = VDOORSPEED*4; |
| 979 |
break; |
| 980 |
case SpeedTurbo: |
| 981 |
door->speed = VDOORSPEED*8; |
| 982 |
break; |
| 983 |
} |
| 984 |
door->line = line; // jff 1/31/98 remember line that triggered us |
| 985 |
|
| 986 |
/* killough 10/98: implement gradual lighting */ |
| 987 |
door->lighttag = !comp[comp_doorlight] && |
| 988 |
(line->special&6) == 6 && |
| 989 |
line->special > GenLockedBase ? line->tag : 0; |
| 990 |
|
| 991 |
// set kind of door, whether it opens then close, opens, closes etc. |
| 992 |
// assign target heights accordingly |
| 993 |
switch(Kind) |
| 994 |
{ |
| 995 |
case OdCDoor: |
| 996 |
door->direction = 1; |
| 997 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 998 |
door->topheight -= 4*FRACUNIT; |
| 999 |
if (door->topheight != sec->ceilingheight) |
| 1000 |
S_StartSectorSound(door->sector, |
| 1001 |
Sped >= SpeedFast || comp[comp_sound] ? sfx_bdopn : sfx_doropn); |
| 1002 |
door->type = Sped>=SpeedFast? genBlazeRaise : genRaise; |
| 1003 |
break; |
| 1004 |
case ODoor: |
| 1005 |
door->direction = 1; |
| 1006 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1007 |
door->topheight -= 4*FRACUNIT; |
| 1008 |
if (door->topheight != sec->ceilingheight) |
| 1009 |
S_StartSectorSound(door->sector, |
| 1010 |
Sped >= SpeedFast || comp[comp_sound] ? sfx_bdopn : sfx_doropn); |
| 1011 |
door->type = Sped>=SpeedFast? genBlazeOpen : genOpen; |
| 1012 |
break; |
| 1013 |
case CdODoor: |
| 1014 |
door->topheight = sec->ceilingheight; |
| 1015 |
door->direction = -1; |
| 1016 |
S_StartSectorSound(door->sector, |
| 1017 |
Sped >= SpeedFast && !comp[comp_sound] ? sfx_bdcls : sfx_dorcls); |
| 1018 |
door->type = Sped>=SpeedFast? genBlazeCdO : genCdO; |
| 1019 |
break; |
| 1020 |
case CDoor: |
| 1021 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1022 |
door->topheight -= 4*FRACUNIT; |
| 1023 |
door->direction = -1; |
| 1024 |
S_StartSectorSound(door->sector, |
| 1025 |
Sped >= SpeedFast && !comp[comp_sound] ? sfx_bdcls : sfx_dorcls); |
| 1026 |
door->type = Sped>=SpeedFast? genBlazeClose : genClose; |
| 1027 |
break; |
| 1028 |
default: |
| 1029 |
break; |
| 1030 |
} |
| 1031 |
} |
| 1032 |
return rtn; |
| 1033 |
} |