Annotation of doom/p_ceilng.c, revision 1.1.1.6

1.1.1.4   root        1: // Emacs style mode select   -*- C++ -*- 
                      2: //-----------------------------------------------------------------------------
                      3: //
                      4: // $Id:$
                      5: //
                      6: // Copyright (C) 1993-1996 by id Software, Inc.
                      7: //
1.1.1.6 ! root        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.
1.1.1.4   root       11: //
1.1.1.6 ! root       12: // The source is distributed in the hope that it will be useful,
1.1.1.4   root       13: // but WITHOUT ANY WARRANTY; without even the implied warranty of
1.1.1.6 ! root       14: // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
        !            15: // for more details.
1.1.1.4   root       16: //
                     17: // $Log:$
                     18: //
                     19: // DESCRIPTION:  Ceiling aninmation (lowering, crushing, raising)
                     20: //
                     21: //-----------------------------------------------------------------------------
                     22: 
                     23: static const char
                     24: rcsid[] = "$Id: p_ceilng.c,v 1.4 1997/02/03 16:47:53 b1 Exp $";
1.1       root       25: 
1.1.1.3   root       26: 
1.1.1.4   root       27: #include "z_zone.h"
                     28: #include "doomdef.h"
1.1.1.3   root       29: #include "p_local.h"
1.1.1.2   root       30: 
1.1.1.4   root       31: #include "s_sound.h"
                     32: 
                     33: // State.
                     34: #include "doomstat.h"
                     35: #include "r_state.h"
                     36: 
                     37: // Data.
                     38: #include "sounds.h"
                     39: 
1.1.1.2   root       40: //
1.1.1.4   root       41: // CEILINGS
1.1.1.2   root       42: //
1.1       root       43: 
                     44: 
1.1.1.4   root       45: ceiling_t*     activeceilings[MAXCEILINGS];
                     46: 
                     47: 
1.1.1.2   root       48: //
1.1.1.4   root       49: // T_MoveCeiling
1.1.1.2   root       50: //
1.1.1.3   root       51: 
1.1.1.4   root       52: void T_MoveCeiling (ceiling_t* ceiling)
                     53: {
                     54:     result_e   res;
                     55:        
                     56:     switch(ceiling->direction)
                     57:     {
                     58:       case 0:
                     59:        // IN STASIS
                     60:        break;
                     61:       case 1:
                     62:        // UP
                     63:        res = T_MovePlane(ceiling->sector,
                     64:                          ceiling->speed,
                     65:                          ceiling->topheight,
                     66:                          false,1,ceiling->direction);
                     67:        
                     68:        if (!(leveltime&7))
1.1       root       69:        {
1.1.1.4   root       70:            switch(ceiling->type)
                     71:            {
                     72:              case silentCrushAndRaise:
                     73:                break;
                     74:              default:
                     75:                S_StartSound((mobj_t *)&ceiling->sector->soundorg,
                     76:                             sfx_stnmov);
                     77:                // ?
                     78:                break;
                     79:            }
1.1       root       80:        }
1.1.1.4   root       81:        
                     82:        if (res == pastdest)
                     83:        {
                     84:            switch(ceiling->type)
                     85:            {
                     86:              case raiseToHighest:
                     87:                P_RemoveActiveCeiling(ceiling);
                     88:                break;
                     89:                
                     90:              case silentCrushAndRaise:
                     91:                S_StartSound((mobj_t *)&ceiling->sector->soundorg,
                     92:                             sfx_pstop);
                     93:              case fastCrushAndRaise:
                     94:              case crushAndRaise:
                     95:                ceiling->direction = -1;
                     96:                break;
                     97:                
                     98:              default:
                     99:                break;
                    100:            }
                    101:            
                    102:        }
                    103:        break;
                    104:        
                    105:       case -1:
                    106:        // DOWN
                    107:        res = T_MovePlane(ceiling->sector,
                    108:                          ceiling->speed,
                    109:                          ceiling->bottomheight,
                    110:                          ceiling->crush,1,ceiling->direction);
                    111:        
                    112:        if (!(leveltime&7))
                    113:        {
                    114:            switch(ceiling->type)
                    115:            {
                    116:              case silentCrushAndRaise: break;
                    117:              default:
                    118:                S_StartSound((mobj_t *)&ceiling->sector->soundorg,
                    119:                             sfx_stnmov);
                    120:            }
                    121:        }
                    122:        
                    123:        if (res == pastdest)
                    124:        {
                    125:            switch(ceiling->type)
                    126:            {
                    127:              case silentCrushAndRaise:
                    128:                S_StartSound((mobj_t *)&ceiling->sector->soundorg,
                    129:                             sfx_pstop);
                    130:              case crushAndRaise:
                    131:                ceiling->speed = CEILSPEED;
                    132:              case fastCrushAndRaise:
                    133:                ceiling->direction = 1;
                    134:                break;
                    135: 
                    136:              case lowerAndCrush:
                    137:              case lowerToFloor:
                    138:                P_RemoveActiveCeiling(ceiling);
                    139:                break;
                    140: 
                    141:              default:
                    142:                break;
                    143:            }
                    144:        }
                    145:        else // ( res != pastdest )
                    146:        {
                    147:            if (res == crushed)
                    148:            {
                    149:                switch(ceiling->type)
                    150:                {
                    151:                  case silentCrushAndRaise:
                    152:                  case crushAndRaise:
                    153:                  case lowerAndCrush:
                    154:                    ceiling->speed = CEILSPEED / 8;
                    155:                    break;
                    156: 
                    157:                  default:
                    158:                    break;
                    159:                }
                    160:            }
                    161:        }
                    162:        break;
                    163:     }
1.1       root      164: }
                    165: 
1.1.1.4   root      166: 
1.1.1.2   root      167: //
1.1.1.4   root      168: // EV_DoCeiling
                    169: // Move a ceiling up/down and all around!
1.1.1.2   root      170: //
1.1.1.4   root      171: int
                    172: EV_DoCeiling
                    173: ( line_t*      line,
                    174:   ceiling_e    type )
1.1       root      175: {
1.1.1.4   root      176:     int                secnum;
                    177:     int                rtn;
                    178:     sector_t*  sec;
                    179:     ceiling_t* ceiling;
                    180:        
                    181:     secnum = -1;
                    182:     rtn = 0;
                    183:     
                    184:     // Reactivate in-stasis ceilings...for certain types.
                    185:     switch(type)
                    186:     {
                    187:       case fastCrushAndRaise:
                    188:       case silentCrushAndRaise:
                    189:       case crushAndRaise:
                    190:        P_ActivateInStasisCeiling(line);
                    191:       default:
                    192:        break;
                    193:     }
                    194:        
                    195:     while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
                    196:     {
                    197:        sec = &sectors[secnum];
                    198:        if (sec->specialdata)
                    199:            continue;
                    200:        
                    201:        // new door thinker
                    202:        rtn = 1;
                    203:        ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0);
                    204:        P_AddThinker (&ceiling->thinker);
                    205:        sec->specialdata = ceiling;
                    206:        ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling;
                    207:        ceiling->sector = sec;
                    208:        ceiling->crush = false;
                    209:        
1.1       root      210:        switch(type)
                    211:        {
1.1.1.4   root      212:          case fastCrushAndRaise:
                    213:            ceiling->crush = true;
                    214:            ceiling->topheight = sec->ceilingheight;
                    215:            ceiling->bottomheight = sec->floorheight + (8*FRACUNIT);
                    216:            ceiling->direction = -1;
                    217:            ceiling->speed = CEILSPEED * 2;
                    218:            break;
                    219: 
                    220:          case silentCrushAndRaise:
                    221:          case crushAndRaise:
                    222:            ceiling->crush = true;
                    223:            ceiling->topheight = sec->ceilingheight;
                    224:          case lowerAndCrush:
                    225:          case lowerToFloor:
                    226:            ceiling->bottomheight = sec->floorheight;
                    227:            if (type != lowerToFloor)
                    228:                ceiling->bottomheight += 8*FRACUNIT;
                    229:            ceiling->direction = -1;
                    230:            ceiling->speed = CEILSPEED;
                    231:            break;
                    232: 
                    233:          case raiseToHighest:
                    234:            ceiling->topheight = P_FindHighestCeilingSurrounding(sec);
                    235:            ceiling->direction = 1;
                    236:            ceiling->speed = CEILSPEED;
                    237:            break;
1.1       root      238:        }
1.1.1.4   root      239:                
                    240:        ceiling->tag = sec->tag;
                    241:        ceiling->type = type;
                    242:        P_AddActiveCeiling(ceiling);
                    243:     }
                    244:     return rtn;
1.1       root      245: }
                    246: 
1.1.1.4   root      247: 
1.1.1.2   root      248: //
1.1.1.4   root      249: // Add an active ceiling
1.1.1.2   root      250: //
1.1.1.4   root      251: void P_AddActiveCeiling(ceiling_t* c)
1.1       root      252: {
1.1.1.4   root      253:     int                i;
                    254:     
                    255:     for (i = 0; i < MAXCEILINGS;i++)
                    256:     {
                    257:        if (activeceilings[i] == NULL)
                    258:        {
                    259:            activeceilings[i] = c;
                    260:            return;
                    261:        }
                    262:     }
1.1       root      263: }
                    264: 
1.1.1.4   root      265: 
                    266: 
1.1.1.2   root      267: //
1.1.1.4   root      268: // Remove a ceiling's thinker
1.1.1.2   root      269: //
1.1.1.4   root      270: void P_RemoveActiveCeiling(ceiling_t* c)
1.1       root      271: {
1.1.1.4   root      272:     int                i;
                    273:        
                    274:     for (i = 0;i < MAXCEILINGS;i++)
                    275:     {
                    276:        if (activeceilings[i] == c)
                    277:        {
                    278:            activeceilings[i]->sector->specialdata = NULL;
                    279:            P_RemoveThinker (&activeceilings[i]->thinker);
                    280:            activeceilings[i] = NULL;
                    281:            break;
                    282:        }
                    283:     }
1.1       root      284: }
                    285: 
1.1.1.4   root      286: 
                    287: 
1.1.1.2   root      288: //
1.1.1.4   root      289: // Restart a ceiling that's in-stasis
1.1.1.2   root      290: //
1.1.1.4   root      291: void P_ActivateInStasisCeiling(line_t* line)
1.1       root      292: {
1.1.1.4   root      293:     int                i;
                    294:        
                    295:     for (i = 0;i < MAXCEILINGS;i++)
                    296:     {
                    297:        if (activeceilings[i]
                    298:            && (activeceilings[i]->tag == line->tag)
                    299:            && (activeceilings[i]->direction == 0))
                    300:        {
                    301:            activeceilings[i]->direction = activeceilings[i]->olddirection;
                    302:            activeceilings[i]->thinker.function.acp1
                    303:              = (actionf_p1)T_MoveCeiling;
                    304:        }
                    305:     }
1.1       root      306: }
                    307: 
1.1.1.4   root      308: 
                    309: 
1.1.1.2   root      310: //
1.1.1.4   root      311: // EV_CeilingCrushStop
                    312: // Stop a ceiling from crushing!
1.1.1.2   root      313: //
1.1.1.4   root      314: int    EV_CeilingCrushStop(line_t      *line)
1.1       root      315: {
1.1.1.4   root      316:     int                i;
                    317:     int                rtn;
                    318:        
                    319:     rtn = 0;
                    320:     for (i = 0;i < MAXCEILINGS;i++)
                    321:     {
                    322:        if (activeceilings[i]
                    323:            && (activeceilings[i]->tag == line->tag)
                    324:            && (activeceilings[i]->direction != 0))
1.1.1.3   root      325:        {
1.1.1.4   root      326:            activeceilings[i]->olddirection = activeceilings[i]->direction;
                    327:            activeceilings[i]->thinker.function.acv = (actionf_v)NULL;
                    328:            activeceilings[i]->direction = 0;           // in-stasis
                    329:            rtn = 1;
1.1.1.3   root      330:        }
1.1.1.4   root      331:     }
                    332:     
                    333: 
                    334:     return rtn;
1.1       root      335: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.