1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
18 // Revision 1.1 2000/02/29 18:21:04 stegerg
19 // Doom port based on ADoomPPC. Read README.AROS!
23 // Floor animation: raising stairs.
25 //-----------------------------------------------------------------------------
49 // Move a plane (floor or ceiling) and check for crushing
63 switch(floorOrCeiling
)
71 if (sector
->floorheight
- speed
< dest
)
73 lastpos
= sector
->floorheight
;
74 sector
->floorheight
= dest
;
75 flag
= P_ChangeSector(sector
,crush
);
78 sector
->floorheight
=lastpos
;
79 P_ChangeSector(sector
,crush
);
86 lastpos
= sector
->floorheight
;
87 sector
->floorheight
-= speed
;
88 flag
= P_ChangeSector(sector
,crush
);
91 sector
->floorheight
= lastpos
;
92 P_ChangeSector(sector
,crush
);
100 if (sector
->floorheight
+ speed
> dest
)
102 lastpos
= sector
->floorheight
;
103 sector
->floorheight
= dest
;
104 flag
= P_ChangeSector(sector
,crush
);
107 sector
->floorheight
= lastpos
;
108 P_ChangeSector(sector
,crush
);
116 lastpos
= sector
->floorheight
;
117 sector
->floorheight
+= speed
;
118 flag
= P_ChangeSector(sector
,crush
);
123 sector
->floorheight
= lastpos
;
124 P_ChangeSector(sector
,crush
);
138 if (sector
->ceilingheight
- speed
< dest
)
140 lastpos
= sector
->ceilingheight
;
141 sector
->ceilingheight
= dest
;
142 flag
= P_ChangeSector(sector
,crush
);
146 sector
->ceilingheight
= lastpos
;
147 P_ChangeSector(sector
,crush
);
155 lastpos
= sector
->ceilingheight
;
156 sector
->ceilingheight
-= speed
;
157 flag
= P_ChangeSector(sector
,crush
);
163 sector
->ceilingheight
= lastpos
;
164 P_ChangeSector(sector
,crush
);
172 if (sector
->ceilingheight
+ speed
> dest
)
174 lastpos
= sector
->ceilingheight
;
175 sector
->ceilingheight
= dest
;
176 flag
= P_ChangeSector(sector
,crush
);
179 sector
->ceilingheight
= lastpos
;
180 P_ChangeSector(sector
,crush
);
187 lastpos
= sector
->ceilingheight
;
188 sector
->ceilingheight
+= speed
;
189 flag
= P_ChangeSector(sector
,crush
);
194 sector
->ceilingheight
= lastpos
;
195 P_ChangeSector(sector
,crush
);
210 // MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)
212 void T_MoveFloor(floormove_t
* floor
)
216 res
= T_MovePlane(floor
->sector
,
218 floor
->floordestheight
,
219 floor
->crush
,0,floor
->direction
);
222 S_StartSound((mobj_t
*)&floor
->sector
->soundorg
,
227 floor
->sector
->specialdata
= NULL
;
229 if (floor
->direction
== 1)
234 floor
->sector
->special
= floor
->newspecial
;
235 floor
->sector
->floorpic
= floor
->texture
;
240 else if (floor
->direction
== -1)
245 floor
->sector
->special
= floor
->newspecial
;
246 floor
->sector
->floorpic
= floor
->texture
;
251 P_RemoveThinker(&floor
->thinker
);
253 S_StartSound((mobj_t
*)&floor
->sector
->soundorg
,
260 // HANDLE FLOOR TYPES
275 while ((secnum
= P_FindSectorFromLineTag(line
,secnum
)) >= 0)
277 sec
= §ors
[secnum
];
279 // ALREADY MOVING? IF SO, KEEP GOING...
280 if (sec
->specialdata
)
285 floor
= Z_Malloc (sizeof(*floor
), PU_LEVSPEC
, 0);
286 P_AddThinker (&floor
->thinker
);
287 sec
->specialdata
= floor
;
288 floor
->thinker
.function
.acp1
= (actionf_p1
) T_MoveFloor
;
289 floor
->type
= floortype
;
290 floor
->crush
= false;
295 floor
->direction
= -1;
297 floor
->speed
= FLOORSPEED
;
298 floor
->floordestheight
=
299 P_FindHighestFloorSurrounding(sec
);
302 case lowerFloorToLowest
:
303 floor
->direction
= -1;
305 floor
->speed
= FLOORSPEED
;
306 floor
->floordestheight
=
307 P_FindLowestFloorSurrounding(sec
);
311 floor
->direction
= -1;
313 floor
->speed
= FLOORSPEED
* 4;
314 floor
->floordestheight
=
315 P_FindHighestFloorSurrounding(sec
);
316 if (floor
->floordestheight
!= sec
->floorheight
)
317 floor
->floordestheight
+= 8*FRACUNIT
;
320 case raiseFloorCrush
:
323 floor
->direction
= 1;
325 floor
->speed
= FLOORSPEED
;
326 floor
->floordestheight
=
327 P_FindLowestCeilingSurrounding(sec
);
328 if (floor
->floordestheight
> sec
->ceilingheight
)
329 floor
->floordestheight
= sec
->ceilingheight
;
330 floor
->floordestheight
-= (8*FRACUNIT
)*
331 (floortype
== raiseFloorCrush
);
334 case raiseFloorTurbo
:
335 floor
->direction
= 1;
337 floor
->speed
= FLOORSPEED
*4;
338 floor
->floordestheight
=
339 P_FindNextHighestFloor(sec
,sec
->floorheight
);
342 case raiseFloorToNearest
:
343 floor
->direction
= 1;
345 floor
->speed
= FLOORSPEED
;
346 floor
->floordestheight
=
347 P_FindNextHighestFloor(sec
,sec
->floorheight
);
351 floor
->direction
= 1;
353 floor
->speed
= FLOORSPEED
;
354 floor
->floordestheight
= floor
->sector
->floorheight
+
358 floor
->direction
= 1;
360 floor
->speed
= FLOORSPEED
;
361 floor
->floordestheight
= floor
->sector
->floorheight
+
365 case raiseFloor24AndChange
:
366 floor
->direction
= 1;
368 floor
->speed
= FLOORSPEED
;
369 floor
->floordestheight
= floor
->sector
->floorheight
+
371 sec
->floorpic
= line
->frontsector
->floorpic
;
372 sec
->special
= line
->frontsector
->special
;
377 int minsize
= MAXINT
;
380 floor
->direction
= 1;
382 floor
->speed
= FLOORSPEED
;
383 for (i
= 0; i
< sec
->linecount
; i
++)
385 if (twoSided (secnum
, i
) )
387 side
= getSide(secnum
,i
,0);
388 if (side
->bottomtexture
>= 0)
389 if (textureheight
[side
->bottomtexture
] <
392 textureheight
[side
->bottomtexture
];
393 side
= getSide(secnum
,i
,1);
394 if (side
->bottomtexture
>= 0)
395 if (textureheight
[side
->bottomtexture
] <
398 textureheight
[side
->bottomtexture
];
401 floor
->floordestheight
=
402 floor
->sector
->floorheight
+ minsize
;
407 floor
->direction
= -1;
409 floor
->speed
= FLOORSPEED
;
410 floor
->floordestheight
=
411 P_FindLowestFloorSurrounding(sec
);
412 floor
->texture
= sec
->floorpic
;
414 for (i
= 0; i
< sec
->linecount
; i
++)
416 if ( twoSided(secnum
, i
) )
418 if (getSide(secnum
,i
,0)->sector
-sectors
== secnum
)
420 sec
= getSector(secnum
,i
,1);
422 if (sec
->floorheight
== floor
->floordestheight
)
424 floor
->texture
= sec
->floorpic
;
425 floor
->newspecial
= sec
->special
;
431 sec
= getSector(secnum
,i
,0);
433 if (sec
->floorheight
== floor
->floordestheight
)
435 floor
->texture
= sec
->floorpic
;
436 floor
->newspecial
= sec
->special
;
453 // BUILD A STAIRCASE!
473 fixed_t stairsize
= 0;
478 while ((secnum
= P_FindSectorFromLineTag(line
,secnum
)) >= 0)
480 sec
= §ors
[secnum
];
482 // ALREADY MOVING? IF SO, KEEP GOING...
483 if (sec
->specialdata
)
488 floor
= Z_Malloc (sizeof(*floor
), PU_LEVSPEC
, 0);
489 P_AddThinker (&floor
->thinker
);
490 sec
->specialdata
= floor
;
491 floor
->thinker
.function
.acp1
= (actionf_p1
) T_MoveFloor
;
492 floor
->direction
= 1;
497 speed
= FLOORSPEED
/4;
498 stairsize
= 8*FRACUNIT
;
501 speed
= FLOORSPEED
*4;
502 stairsize
= 16*FRACUNIT
;
505 floor
->speed
= speed
;
506 height
= sec
->floorheight
+ stairsize
;
507 floor
->floordestheight
= height
;
509 texture
= sec
->floorpic
;
511 // Find next sector to raise
512 // 1. Find 2-sided line with same sector side[0]
513 // 2. Other side is the next sector to raise
517 for (i
= 0;i
< sec
->linecount
;i
++)
519 if ( !((sec
->lines
[i
])->flags
& ML_TWOSIDED
) )
522 tsec
= (sec
->lines
[i
])->frontsector
;
523 newsecnum
= tsec
-sectors
;
525 if (secnum
!= newsecnum
)
528 tsec
= (sec
->lines
[i
])->backsector
;
529 newsecnum
= tsec
- sectors
;
531 if (tsec
->floorpic
!= texture
)
536 if (tsec
->specialdata
)
541 floor
= Z_Malloc (sizeof(*floor
), PU_LEVSPEC
, 0);
543 P_AddThinker (&floor
->thinker
);
545 sec
->specialdata
= floor
;
546 floor
->thinker
.function
.acp1
= (actionf_p1
) T_MoveFloor
;
547 floor
->direction
= 1;
549 floor
->speed
= speed
;
550 floor
->floordestheight
= height
;