Add an enum for crumblestate

This commit is contained in:
MascaraSnake 2020-04-17 23:54:37 +02:00
parent 7e617fa938
commit 93eb0ee1c8
6 changed files with 25 additions and 24 deletions

View file

@ -690,10 +690,10 @@ void T_BounceCheese(levelspecthink_t *bouncer)
INT32 i; INT32 i;
boolean remove; boolean remove;
if (bouncer->sector->crumblestate == 4 || bouncer->sector->crumblestate == 1 if (bouncer->sector->crumblestate == CRUMBLE_RESTORE || bouncer->sector->crumblestate == CRUMBLE_WAIT
|| bouncer->sector->crumblestate == 2) // Oops! Crumbler says to remove yourself! || bouncer->sector->crumblestate == CRUMBLE_ACTIVATED) // Oops! Crumbler says to remove yourself!
{ {
bouncer->sector->crumblestate = 1; bouncer->sector->crumblestate = CRUMBLE_WAIT;
bouncer->sector->ceilingdata = NULL; bouncer->sector->ceilingdata = NULL;
bouncer->sector->ceilspeed = 0; bouncer->sector->ceilspeed = 0;
bouncer->sector->floordata = NULL; bouncer->sector->floordata = NULL;
@ -817,15 +817,6 @@ void T_BounceCheese(levelspecthink_t *bouncer)
// T_StartCrumble //////////////////////////////// // T_StartCrumble ////////////////////////////////
////////////////////////////////////////////////// //////////////////////////////////////////////////
// Crumbling platform Tails 03-11-2002 // Crumbling platform Tails 03-11-2002
//
// DEFINITION OF THE 'CRUMBLESTATE'S:
//
// 0 - No crumble thinker
// 1 - Don't float on water because this is supposed to wait for a crumble
// 2 - Crumble thinker activated, but hasn't fallen yet
// 3 - Crumble thinker is falling
// 4 - Crumble thinker is about to restore to original position
//
void T_StartCrumble(elevator_t *elevator) void T_StartCrumble(elevator_t *elevator)
{ {
ffloor_t *rover; ffloor_t *rover;
@ -921,13 +912,13 @@ void T_StartCrumble(elevator_t *elevator)
// so set this to let other thinkers know what is // so set this to let other thinkers know what is
// about to happen. // about to happen.
if (elevator->distance < 0 && elevator->distance > -3) if (elevator->distance < 0 && elevator->distance > -3)
elevator->sector->crumblestate = 4; // makes T_BounceCheese remove itself elevator->sector->crumblestate = CRUMBLE_RESTORE; // makes T_BounceCheese remove itself
} }
if ((elevator->floordestheight == 0 && elevator->direction == -1) if ((elevator->floordestheight == 0 && elevator->direction == -1)
|| (elevator->floordestheight == 1 && elevator->direction == 1)) // Down || (elevator->floordestheight == 1 && elevator->direction == 1)) // Down
{ {
elevator->sector->crumblestate = 3; // Allow floating now. elevator->sector->crumblestate = CRUMBLE_FALL; // Allow floating now.
// Only fall like this if it isn't meant to float on water // Only fall like this if it isn't meant to float on water
if (elevator->high != 42) if (elevator->high != 42)
@ -976,7 +967,7 @@ void T_StartCrumble(elevator_t *elevator)
} }
else // Up (restore to original position) else // Up (restore to original position)
{ {
elevator->sector->crumblestate = 1; elevator->sector->crumblestate = CRUMBLE_WAIT;
elevator->sector->ceilingheight = elevator->ceilingwasheight; elevator->sector->ceilingheight = elevator->ceilingwasheight;
elevator->sector->floorheight = elevator->floorwasheight; elevator->sector->floorheight = elevator->floorwasheight;
elevator->sector->floordata = NULL; elevator->sector->floordata = NULL;
@ -1085,7 +1076,7 @@ void T_FloatSector(levelspecthink_t *floater)
else if (floater->sector->ceilingheight == actionsector->ceilingheight && waterheight > cheeseheight) // too high else if (floater->sector->ceilingheight == actionsector->ceilingheight && waterheight > cheeseheight) // too high
; ;
// we have something to float in! Or we're for some reason above the ground, let's fall anyway // we have something to float in! Or we're for some reason above the ground, let's fall anyway
else if (floater->sector->crumblestate == 0 || floater->sector->crumblestate >= 3/* || floatanyway*/) else if (floater->sector->crumblestate == CRUMBLE_NONE || floater->sector->crumblestate >= CRUMBLE_FALL/* || floatanyway*/)
EV_BounceSector(floater->sector, FRACUNIT, floater->sourceline); EV_BounceSector(floater->sector, FRACUNIT, floater->sourceline);
P_RecalcPrecipInSector(actionsector); P_RecalcPrecipInSector(actionsector);
@ -1687,7 +1678,7 @@ void T_RaiseSector(raise_t *raise)
INT32 direction; INT32 direction;
result_e res = 0; result_e res = 0;
if (raise->sector->crumblestate >= 3 || raise->sector->ceilingdata) if (raise->sector->crumblestate >= CRUMBLE_FALL || raise->sector->ceilingdata)
return; return;
for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;)
@ -2489,7 +2480,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
if (sec->floordata) if (sec->floordata)
return 0; return 0;
if (sec->crumblestate > 1) if (sec->crumblestate >= CRUMBLE_ACTIVATED)
return 0; return 0;
// create and initialize new elevator thinker // create and initialize new elevator thinker
@ -2534,7 +2525,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
else else
elevator->high = 0; elevator->high = 0;
elevator->sector->crumblestate = 2; elevator->sector->crumblestate = CRUMBLE_ACTIVATED;
for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;) for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;)
{ {

View file

@ -1691,7 +1691,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
// Needs ML_EFFECT4 flag for pushables to break it // Needs ML_EFFECT4 flag for pushables to break it
if (!(rover->master->flags & ML_EFFECT4)) continue; if (!(rover->master->flags & ML_EFFECT4)) continue;
if (!rover->master->frontsector->crumblestate) if (rover->master->frontsector->crumblestate == CRUMBLE_NONE)
{ {
topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);

View file

@ -866,7 +866,7 @@ static void P_InitializeSector(sector_t *ss)
ss->camsec = -1; ss->camsec = -1;
ss->floorlightsec = ss->ceilinglightsec = -1; ss->floorlightsec = ss->ceilinglightsec = -1;
ss->crumblestate = 0; ss->crumblestate = CRUMBLE_NONE;
ss->touching_thinglist = NULL; ss->touching_thinglist = NULL;

View file

@ -5902,7 +5902,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
} }
if ((flags & FF_CRUMBLE)) if ((flags & FF_CRUMBLE))
sec2->crumblestate = 1; sec2->crumblestate = CRUMBLE_WAIT;
if ((flags & FF_FLOATBOB)) if ((flags & FF_FLOATBOB))
{ {

View file

@ -2566,7 +2566,7 @@ static void P_CheckBustableBlocks(player_t *player)
{ {
if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_EXISTS)) continue;
if ((rover->flags & FF_BUSTUP)/* && !rover->master->frontsector->crumblestate*/) if ((rover->flags & FF_BUSTUP)/* && rover->master->frontsector->crumblestate == CRUMBLE_NONE*/)
{ {
// If it's an FF_SHATTER, you can break it just by touching it. // If it's an FF_SHATTER, you can break it just by touching it.
if (rover->flags & FF_SHATTER) if (rover->flags & FF_SHATTER)
@ -12213,7 +12213,7 @@ void P_PlayerThink(player_t *player)
player->powers[pw_nocontrol]--; player->powers[pw_nocontrol]--;
else else
player->powers[pw_nocontrol] = 0; player->powers[pw_nocontrol] = 0;
//pw_super acts as a timer now //pw_super acts as a timer now
if (player->powers[pw_super] if (player->powers[pw_super]
&& (player->mo->state < &states[S_PLAY_SUPER_TRANS1] && (player->mo->state < &states[S_PLAY_SUPER_TRANS1]

View file

@ -277,6 +277,16 @@ typedef enum
SF_INVERTPRECIP = 1<<4, SF_INVERTPRECIP = 1<<4,
} sectorflags_t; } sectorflags_t;
typedef enum
{
CRUMBLE_NONE, // No crumble thinker
CRUMBLE_WAIT, // Don't float on water because this is supposed to wait for a crumble
CRUMBLE_ACTIVATED, // Crumble thinker activated, but hasn't fallen yet
CRUMBLE_FALL, // Crumble thinker is falling
CRUMBLE_RESTORE, // Crumble thinker is about to restore to original position
} crumblestate_t;
// //
// The SECTORS record, at runtime. // The SECTORS record, at runtime.
// Stores things/mobjs. // Stores things/mobjs.