|
|
1.1 ! root 1: #include "doomdef.h" ! 2: #include "p_local.h" ! 3: ! 4: /*================================================================== */ ! 5: /*================================================================== */ ! 6: /* */ ! 7: /* CEILINGS */ ! 8: /* */ ! 9: /*================================================================== */ ! 10: /*================================================================== */ ! 11: ! 12: ceiling_t *activeceilings[MAXCEILINGS]; ! 13: ! 14: /*================================================================== */ ! 15: /* */ ! 16: /* T_MoveCeiling */ ! 17: /* */ ! 18: /*================================================================== */ ! 19: void T_MoveCeiling (ceiling_t *ceiling) ! 20: { ! 21: result_e res; ! 22: ! 23: switch(ceiling->direction) ! 24: { ! 25: case 0: /* IN STASIS */ ! 26: break; ! 27: case 1: /* UP */ ! 28: res = T_MovePlane(ceiling->sector,ceiling->speed, ! 29: ceiling->topheight,false,1,ceiling->direction); ! 30: if (!(gametic&7)) ! 31: S_StartSound((mobj_t *)&ceiling->sector->soundorg,sfx_stnmov); ! 32: if (res == pastdest) ! 33: switch(ceiling->type) ! 34: { ! 35: case raiseToHighest: ! 36: P_RemoveActiveCeiling(ceiling); ! 37: break; ! 38: case fastCrushAndRaise: ! 39: case crushAndRaise: ! 40: ceiling->direction = -1; ! 41: break; ! 42: default: ! 43: break; ! 44: } ! 45: break; ! 46: case -1: /* DOWN */ ! 47: res = T_MovePlane(ceiling->sector,ceiling->speed, ! 48: ceiling->bottomheight,ceiling->crush,1,ceiling->direction); ! 49: if (!(gametic&7)) ! 50: S_StartSound((mobj_t *)&ceiling->sector->soundorg,sfx_stnmov); ! 51: if (res == pastdest) ! 52: switch(ceiling->type) ! 53: { ! 54: case crushAndRaise: ! 55: ceiling->speed = CEILSPEED; ! 56: case fastCrushAndRaise: ! 57: ceiling->direction = 1; ! 58: break; ! 59: case lowerAndCrush: ! 60: case lowerToFloor: ! 61: P_RemoveActiveCeiling(ceiling); ! 62: break; ! 63: default: ! 64: break; ! 65: } ! 66: else ! 67: if (res == crushed) ! 68: switch(ceiling->type) ! 69: { ! 70: case crushAndRaise: ! 71: case lowerAndCrush: ! 72: ceiling->speed = CEILSPEED / 8; ! 73: break; ! 74: default: ! 75: break; ! 76: } ! 77: break; ! 78: } ! 79: } ! 80: ! 81: /*================================================================== */ ! 82: /* */ ! 83: /* EV_DoCeiling */ ! 84: /* Move a ceiling up/down and all around! */ ! 85: /* */ ! 86: /*================================================================== */ ! 87: int EV_DoCeiling (line_t *line, ceiling_e type) ! 88: { ! 89: int secnum,rtn; ! 90: sector_t *sec; ! 91: ceiling_t *ceiling; ! 92: ! 93: secnum = -1; ! 94: rtn = 0; ! 95: ! 96: /* */ ! 97: /* Reactivate in-stasis ceilings...for certain types. */ ! 98: /* */ ! 99: switch(type) ! 100: { ! 101: case fastCrushAndRaise: ! 102: case crushAndRaise: ! 103: P_ActivateInStasisCeiling(line); ! 104: default: ! 105: break; ! 106: } ! 107: ! 108: while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) ! 109: { ! 110: sec = §ors[secnum]; ! 111: if (sec->specialdata) ! 112: continue; ! 113: ! 114: /* */ ! 115: /* new door thinker */ ! 116: /* */ ! 117: rtn = 1; ! 118: ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); ! 119: P_AddThinker (&ceiling->thinker); ! 120: sec->specialdata = ceiling; ! 121: ceiling->thinker.function = T_MoveCeiling; ! 122: ceiling->sector = sec; ! 123: ceiling->crush = false; ! 124: switch(type) ! 125: { ! 126: case fastCrushAndRaise: ! 127: ceiling->crush = true; ! 128: ceiling->topheight = sec->ceilingheight; ! 129: ceiling->bottomheight = sec->floorheight; ! 130: ceiling->direction = -1; ! 131: ceiling->speed = CEILSPEED * 2; ! 132: break; ! 133: case crushAndRaise: ! 134: ceiling->crush = true; ! 135: ceiling->topheight = sec->ceilingheight; ! 136: case lowerAndCrush: ! 137: case lowerToFloor: ! 138: ceiling->bottomheight = sec->floorheight; ! 139: ceiling->direction = -1; ! 140: ceiling->speed = CEILSPEED; ! 141: break; ! 142: case raiseToHighest: ! 143: ceiling->topheight = P_FindHighestCeilingSurrounding(sec); ! 144: ceiling->direction = 1; ! 145: ceiling->speed = CEILSPEED; ! 146: break; ! 147: } ! 148: ! 149: ceiling->tag = sec->tag; ! 150: ceiling->type = type; ! 151: P_AddActiveCeiling(ceiling); ! 152: } ! 153: return rtn; ! 154: } ! 155: ! 156: /*================================================================== */ ! 157: /* */ ! 158: /* Add an active ceiling */ ! 159: /* */ ! 160: /*================================================================== */ ! 161: void P_AddActiveCeiling(ceiling_t *c) ! 162: { ! 163: int i; ! 164: for (i = 0; i < MAXCEILINGS;i++) ! 165: if (activeceilings[i] == NULL) ! 166: { ! 167: activeceilings[i] = c; ! 168: return; ! 169: } ! 170: } ! 171: ! 172: /*================================================================== */ ! 173: /* */ ! 174: /* Remove a ceiling's thinker */ ! 175: /* */ ! 176: /*================================================================== */ ! 177: void P_RemoveActiveCeiling(ceiling_t *c) ! 178: { ! 179: int i; ! 180: ! 181: for (i = 0;i < MAXCEILINGS;i++) ! 182: if (activeceilings[i] == c) ! 183: { ! 184: activeceilings[i]->sector->specialdata = NULL; ! 185: P_RemoveThinker (&activeceilings[i]->thinker); ! 186: activeceilings[i] = NULL; ! 187: break; ! 188: } ! 189: } ! 190: ! 191: /*================================================================== */ ! 192: /* */ ! 193: /* Restart a ceiling that's in-stasis */ ! 194: /* */ ! 195: /*================================================================== */ ! 196: void P_ActivateInStasisCeiling(line_t *line) ! 197: { ! 198: int i; ! 199: ! 200: for (i = 0;i < MAXCEILINGS;i++) ! 201: if (activeceilings[i] && (activeceilings[i]->tag == line->tag) && ! 202: (activeceilings[i]->direction == 0)) ! 203: { ! 204: activeceilings[i]->direction = activeceilings[i]->olddirection; ! 205: activeceilings[i]->thinker.function = T_MoveCeiling; ! 206: } ! 207: } ! 208: ! 209: /*================================================================== */ ! 210: /* */ ! 211: /* EV_CeilingCrushStop */ ! 212: /* Stop a ceiling from crushing! */ ! 213: /* */ ! 214: /*================================================================== */ ! 215: int EV_CeilingCrushStop(line_t *line) ! 216: { ! 217: int i; ! 218: int rtn; ! 219: ! 220: rtn = 0; ! 221: for (i = 0;i < MAXCEILINGS;i++) ! 222: if (activeceilings[i] && (activeceilings[i]->tag == line->tag) && ! 223: (activeceilings[i]->direction != 0)) ! 224: { ! 225: activeceilings[i]->olddirection = activeceilings[i]->direction; ! 226: activeceilings[i]->thinker.function = NULL; ! 227: activeceilings[i]->direction = 0; /* in-stasis */ ! 228: rtn = 1; ! 229: } ! 230: ! 231: return rtn; ! 232: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.