Annotation of doom/p_ceilng.c, revision 1.1.1.5

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

unix.superglobalmegacorp.com

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