Annotation of doom/p_change.c, revision 1.1.1.1

1.1       root        1: /* p_change.c */
                      2: 
                      3: #include "doomdef.h"
                      4: #include "p_local.h"
                      5: 
                      6: /* 
                      7: ============================================================================== 
                      8: 
                      9:                                                SECTOR HEIGHT CHANGING
                     10: 
                     11: = After modifying a sectors floor or ceiling height, call this
                     12: = routine to adjust the positions of all things that touch the
                     13: = sector.
                     14: =
                     15: = If anything doesn't fit anymore, true will be returned.
                     16: = If crunch is true, they will take damage as they are being crushed
                     17: = If Crunch is false, you should set the sector height back the way it
                     18: = was and call P_ChangeSector again to undo the changes
                     19: ============================================================================== 
                     20: */ 
                     21:  
                     22: boolean                crushchange;
                     23: boolean                nofit;
                     24: 
                     25: /*
                     26: ==================
                     27: =
                     28: = P_ThingHeightClip
                     29: =
                     30: = Takes a valid thing and adjusts the thing->floorz, thing->ceilingz,
                     31: = anf possibly thing->z
                     32: =
                     33: = This is called for all nearby monsters whenever a sector changes height
                     34: =
                     35: = If the thing doesn't fit, the z will be set to the lowest value and
                     36: = false will be returned
                     37: ==================
                     38: */
                     39: 
                     40: boolean P_ThingHeightClip (mobj_t *thing)
                     41: {
                     42:        boolean         onfloor;
                     43:        
                     44:        onfloor = (thing->z == thing->floorz);
                     45:        
                     46:        P_CheckPosition (thing, thing->x, thing->y);    
                     47:        /* what about stranding a monster partially off an edge? */
                     48:        
                     49:        thing->floorz = tmfloorz;
                     50:        thing->ceilingz = tmceilingz;
                     51:        
                     52:        if (onfloor)
                     53:        /* walking monsters rise and fall with the floor */
                     54:                thing->z = thing->floorz;
                     55:        else
                     56:        {       /* don't adjust a floating monster unless forced to */
                     57:                if (thing->z+thing->height > thing->ceilingz)
                     58:                        thing->z = thing->ceilingz - thing->height;
                     59:        }
                     60:        
                     61:        if (thing->ceilingz - thing->floorz < thing->height)
                     62:                return false;
                     63:                
                     64:        return true;
                     65: }
                     66: 
                     67: 
                     68: /*
                     69: ===============
                     70: =
                     71: = PIT_ChangeSector
                     72: =
                     73: ===============
                     74: */
                     75: 
                     76: boolean PIT_ChangeSector (mobj_t *thing)
                     77: {
                     78:        mobj_t          *mo;
                     79:        
                     80:        if (P_ThingHeightClip (thing))
                     81:                return true;            /* keep checking */
                     82: 
                     83:        /* crunch bodies to giblets */
                     84:        if (thing->health <= 0)
                     85:        {
                     86:                P_SetMobjState (thing, S_GIBS);
                     87:                thing->height = 0;
                     88:                thing->radius = 0;
                     89:                return true;            /* keep checking */
                     90:        }
                     91: 
                     92:        /* crunch dropped items */
                     93:        if (thing->flags & MF_DROPPED)
                     94:        {
                     95:                P_RemoveMobj (thing);
                     96:                return true;            /* keep checking */
                     97:        }
                     98: 
                     99:        if (! (thing->flags & MF_SHOOTABLE) )
                    100:                return true;                            /* assume it is bloody gibs or something */
                    101:                
                    102:        nofit = true;
                    103:        if (crushchange && !(gametic&3) )
                    104:        {
                    105:                P_DamageMobj(thing,NULL,NULL,10);
                    106:                /* spray blood in a random direction */
                    107:                mo = P_SpawnMobj (thing->x, thing->y, thing->z + thing->height/2, MT_BLOOD);
                    108:                mo->momx = (P_Random() - P_Random ())<<12;
                    109:                mo->momy = (P_Random() - P_Random ())<<12;
                    110:        }
                    111:                
                    112:        return true;            /* keep checking (crush other things)    */
                    113: }
                    114: 
                    115: /*
                    116: ===============
                    117: =
                    118: = P_ChangeSector
                    119: =
                    120: ===============
                    121: */
                    122: 
                    123: boolean P_ChangeSector (sector_t *sector, boolean crunch)
                    124: {
                    125:        int                     x,y;
                    126:        int                     i;
                    127:        
                    128: /* force next sound to reflood */
                    129:        for (i=0 ; i<MAXPLAYERS ; i++)
                    130:                players[i].lastsoundsector = NULL;
                    131:                
                    132:        nofit = false;
                    133:        crushchange = crunch;
                    134:        
                    135: /* recheck heights for all things near the moving sector */
                    136: 
                    137:        for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++)
                    138:                for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++)
                    139:                        P_BlockThingsIterator (x, y, PIT_ChangeSector);
                    140:        
                    141:        
                    142:        return nofit;
                    143: }
                    144: 
                    145: 

unix.superglobalmegacorp.com

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