📄 p_floor.c
字号:
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: p_floor.c,v 1.12 2001/03/30 17:12:50 bpereira Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// 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.////// $Log: p_floor.c,v $// Revision 1.12 2001/03/30 17:12:50 bpereira// no message//// Revision 1.11 2001/01/25 22:15:43 bpereira// added heretic support//// Revision 1.10 2000/11/02 17:50:07 stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.9 2000/10/21 08:43:30 bpereira// no message//// Revision 1.8 2000/09/28 20:57:16 bpereira// no message//// Revision 1.7 2000/07/01 09:23:49 bpereira// no message//// Revision 1.6 2000/05/23 15:22:34 stroggonmeth// Not much. A graphic bug fixed.//// Revision 1.5 2000/04/16 18:38:07 bpereira// no message//// Revision 1.4 2000/04/08 17:29:24 stroggonmeth// no message//// Revision 1.3 2000/04/04 00:32:46 stroggonmeth// Initial Boom compatability plus few misc changes all around.//// Revision 1.2 2000/02/27 00:42:10 hurdler// fix CR+LF problem//// Revision 1.1.1.1 2000/02/22 20:32:32 hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION:// Floor animation: raising stairs.////-----------------------------------------------------------------------------#include "doomdef.h"#include "doomstat.h"#include "p_local.h"#include "r_state.h"#include "s_sound.h"#include "z_zone.h"// ==========================================================================// FLOORS// ==========================================================================//// Move a plane (floor or ceiling) and check for crushing////SoM: I had to copy the entire function from Boom because it was causing errors.result_e T_MovePlane( sector_t* sector, fixed_t speed, fixed_t dest, boolean crush, int floorOrCeiling, int direction ){ boolean flag; fixed_t lastpos; fixed_t destheight; //jff 02/04/98 used to keep floors/ceilings // from moving thru each other switch(floorOrCeiling) { case 0: // Moving a floor switch(direction) { case -1: //SoM: 3/20/2000: Make splash when platform floor hits water if(boomsupport && sector->heightsec != -1 && sector->altheightsec == 1) { if((sector->floorheight - speed) < sectors[sector->heightsec].floorheight && sector->floorheight > sectors[sector->heightsec].floorheight) S_StartSound((mobj_t *)§or->soundorg, sfx_gloop); } // Moving a floor down if (sector->floorheight - speed < dest) { lastpos = sector->floorheight; sector->floorheight = dest; flag = P_CheckSector(sector,crush); if (flag == true && sector->numattached) { sector->floorheight =lastpos; P_CheckSector(sector,crush); } return pastdest; } else { lastpos = sector->floorheight; sector->floorheight -= speed; flag = P_CheckSector(sector,crush); if(flag == true && sector->numattached) { sector->floorheight = lastpos; P_CheckSector(sector, crush); return crushed; } } break; case 1: // Moving a floor up // keep floor from moving thru ceilings //SoM: 3/20/2000: Make splash when platform floor hits water if(boomsupport && sector->heightsec != -1 && sector->altheightsec == 1) { if((sector->floorheight + speed) > sectors[sector->heightsec].floorheight && sector->floorheight < sectors[sector->heightsec].floorheight) S_StartSound((mobj_t *)§or->soundorg, sfx_gloop); } destheight = (!boomsupport || dest<sector->ceilingheight)? dest : sector->ceilingheight; if (sector->floorheight + speed > destheight) { lastpos = sector->floorheight; sector->floorheight = destheight; flag = P_CheckSector(sector,crush); if (flag == true) { sector->floorheight = lastpos; P_CheckSector(sector,crush); } return pastdest; } else { // crushing is possible lastpos = sector->floorheight; sector->floorheight += speed; flag = P_CheckSector(sector,crush); if (flag == true) { if (!boomsupport) { if (crush == true) return crushed; } sector->floorheight = lastpos; P_CheckSector(sector,crush); return crushed; } } break; } break; case 1: // moving a ceiling switch(direction) { case -1: if(boomsupport && sector->heightsec != -1 && sector->altheightsec == 1) { if((sector->ceilingheight - speed) < sectors[sector->heightsec].floorheight && sector->ceilingheight > sectors[sector->heightsec].floorheight) S_StartSound((mobj_t *)§or->soundorg, sfx_gloop); } // moving a ceiling down // keep ceiling from moving thru floors destheight = (!boomsupport || dest>sector->floorheight)? dest : sector->floorheight; if (sector->ceilingheight - speed < destheight) { lastpos = sector->ceilingheight; sector->ceilingheight = destheight; flag = P_CheckSector(sector,crush); if (flag == true) { sector->ceilingheight = lastpos; P_CheckSector(sector,crush); } return pastdest; } else { // crushing is possible lastpos = sector->ceilingheight; sector->ceilingheight -= speed; flag = P_CheckSector(sector,crush); if (flag == true) { if (crush == true) return crushed; sector->ceilingheight = lastpos; P_CheckSector(sector,crush); return crushed; } } break; case 1: if(boomsupport && sector->heightsec != -1 && sector->altheightsec == 1) { if((sector->ceilingheight + speed) > sectors[sector->heightsec].floorheight && sector->ceilingheight < sectors[sector->heightsec].floorheight) S_StartSound((mobj_t *)§or->soundorg, sfx_gloop); } // moving a ceiling up if (sector->ceilingheight + speed > dest) { lastpos = sector->ceilingheight; sector->ceilingheight = dest; flag = P_CheckSector(sector,crush); if (flag == true && sector->numattached) { sector->ceilingheight = lastpos; P_CheckSector(sector,crush); } return pastdest; } else { lastpos = sector->ceilingheight; sector->ceilingheight += speed; flag = P_CheckSector(sector,crush); if (flag == true && sector->numattached) { sector->ceilingheight = lastpos; P_CheckSector(sector,crush); return crushed; } } break; } break; } return ok;}//// MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)//void T_MoveFloor(floormove_t* floor){ result_e res = 0; res = T_MovePlane(floor->sector, floor->speed, floor->floordestheight, floor->crush,0,floor->direction); if (!(leveltime % (8*NEWTICRATERATIO))) S_StartSound((mobj_t *)&floor->sector->soundorg, ceilmovesound); 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; break; case genFloorChgT: //SoM: 3/6/2000: Add support for General types case genFloorChg0: floor->sector->special = floor->newspecial; //SoM: 3/6/2000: this records the old special of the sector floor->sector->oldspecial = floor->oldspecial; // Don't break. case genFloorChg: floor->sector->floorpic = floor->texture; break; default: break; } } else if (floor->direction == -1) { switch(floor->type) { case lowerAndChange: floor->sector->special = floor->newspecial; // SoM: 3/6/2000: Store old special type floor->sector->oldspecial = floor->oldspecial; floor->sector->floorpic = floor->texture; break; case genFloorChgT: case genFloorChg0: floor->sector->special = floor->newspecial; floor->sector->oldspecial = floor->oldspecial; // Don't break case genFloorChg: floor->sector->floorpic = floor->texture; break; default: break; } } floor->sector->floordata = NULL; // Clear up the thinker so others can use it P_RemoveThinker(&floor->thinker); // SoM: This code locks out stair steps while generic, retriggerable generic stairs // are building. if (floor->sector->stairlock==-2) // if this sector is stairlocked { sector_t *sec = floor->sector; sec->stairlock=-1; // thinker done, promote lock to -1 while (sec->prevsec!=-1 && sectors[sec->prevsec].stairlock!=-2) sec = §ors[sec->prevsec]; // search for a non-done thinker if (sec->prevsec==-1) // if all thinkers previous are done {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -