6 //==================================================================
7 //==================================================================
11 //==================================================================
12 //==================================================================
14 ceiling_t *activeceilings[MAXCEILINGS];
16 //==================================================================
20 //==================================================================
21 void T_MoveCeiling (ceiling_t *ceiling)
25 switch(ceiling->direction)
30 res = T_MovePlane(ceiling->sector,ceiling->speed,
31 ceiling->topheight,false,1,ceiling->direction);
33 S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_dormov);
38 P_RemoveActiveCeiling(ceiling);
40 case fastCrushAndRaise:
42 ceiling->direction = -1;
49 res = T_MovePlane(ceiling->sector,ceiling->speed,
50 ceiling->bottomheight,ceiling->crush,1,ceiling->direction);
52 S_StartSound((mobj_t *)&ceiling->sector->soundorg,sfx_dormov);
57 ceiling->speed = CEILSPEED;
58 case fastCrushAndRaise:
59 ceiling->direction = 1;
63 P_RemoveActiveCeiling(ceiling);
74 ceiling->speed = CEILSPEED / 8;
83 //==================================================================
86 // Move a ceiling up/down and all around!
88 //==================================================================
89 int EV_DoCeiling (line_t *line, ceiling_e type)
99 // Reactivate in-stasis ceilings...for certain types.
103 case fastCrushAndRaise:
105 P_ActivateInStasisCeiling(line);
110 while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
112 sec = §ors[secnum];
113 if (sec->specialdata)
120 ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0);
121 P_AddThinker (&ceiling->thinker);
122 sec->specialdata = ceiling;
123 ceiling->thinker.function = T_MoveCeiling;
124 ceiling->sector = sec;
125 ceiling->crush = false;
128 case fastCrushAndRaise:
129 ceiling->crush = true;
130 ceiling->topheight = sec->ceilingheight;
131 ceiling->bottomheight = sec->floorheight + (8*FRACUNIT);
132 ceiling->direction = -1;
133 ceiling->speed = CEILSPEED * 2;
136 ceiling->crush = true;
137 ceiling->topheight = sec->ceilingheight;
140 ceiling->bottomheight = sec->floorheight;
141 if (type != lowerToFloor)
142 ceiling->bottomheight += 8*FRACUNIT;
143 ceiling->direction = -1;
144 ceiling->speed = CEILSPEED;
147 ceiling->topheight = P_FindHighestCeilingSurrounding(sec);
148 ceiling->direction = 1;
149 ceiling->speed = CEILSPEED;
153 ceiling->tag = sec->tag;
154 ceiling->type = type;
155 P_AddActiveCeiling(ceiling);
160 //==================================================================
162 // Add an active ceiling
164 //==================================================================
165 void P_AddActiveCeiling(ceiling_t *c)
168 for (i = 0; i < MAXCEILINGS;i++)
169 if (activeceilings[i] == NULL)
171 activeceilings[i] = c;
176 //==================================================================
178 // Remove a ceiling's thinker
180 //==================================================================
181 void P_RemoveActiveCeiling(ceiling_t *c)
185 for (i = 0;i < MAXCEILINGS;i++)
186 if (activeceilings[i] == c)
188 activeceilings[i]->sector->specialdata = NULL;
189 P_RemoveThinker (&activeceilings[i]->thinker);
190 activeceilings[i] = NULL;
195 //==================================================================
197 // Restart a ceiling that's in-stasis
199 //==================================================================
200 void P_ActivateInStasisCeiling(line_t *line)
204 for (i = 0;i < MAXCEILINGS;i++)
205 if (activeceilings[i] && (activeceilings[i]->tag == line->tag) &&
206 (activeceilings[i]->direction == 0))
208 activeceilings[i]->direction = activeceilings[i]->olddirection;
209 activeceilings[i]->thinker.function = T_MoveCeiling;
213 //==================================================================
215 // EV_CeilingCrushStop
216 // Stop a ceiling from crushing!
218 //==================================================================
219 int EV_CeilingCrushStop(line_t *line)
225 for (i = 0;i < MAXCEILINGS;i++)
226 if (activeceilings[i] && (activeceilings[i]->tag == line->tag) &&
227 (activeceilings[i]->direction != 0))
229 activeceilings[i]->olddirection = activeceilings[i]->direction;
230 activeceilings[i]->thinker.function = NULL;
231 activeceilings[i]->direction = 0; // in-stasis