mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Refactor T_MoveFloor
This commit is contained in:
parent
de462f1213
commit
5b1a42af4c
1 changed files with 50 additions and 97 deletions
147
src/p_floor.c
147
src/p_floor.c
|
@ -162,7 +162,7 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus
|
||||||
void T_MoveFloor(floormove_t *movefloor)
|
void T_MoveFloor(floormove_t *movefloor)
|
||||||
{
|
{
|
||||||
result_e res = 0;
|
result_e res = 0;
|
||||||
boolean dontupdate = false;
|
boolean remove = false;
|
||||||
|
|
||||||
if (movefloor->delaytimer)
|
if (movefloor->delaytimer)
|
||||||
{
|
{
|
||||||
|
@ -190,113 +190,66 @@ void T_MoveFloor(floormove_t *movefloor)
|
||||||
|
|
||||||
if (res == pastdest)
|
if (res == pastdest)
|
||||||
{
|
{
|
||||||
if (movefloor->direction == 1)
|
switch (movefloor->type)
|
||||||
{
|
{
|
||||||
switch (movefloor->type)
|
case moveFloorByFrontSector:
|
||||||
{
|
if (movefloor->texture < -1) // chained linedef executing
|
||||||
case moveFloorByFrontSector:
|
P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL);
|
||||||
if (movefloor->texture < -1) // chained linedef executing
|
/* FALLTHRU */
|
||||||
P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL);
|
case instantMoveFloorByFrontSector:
|
||||||
/* FALLTHRU */
|
if (movefloor->texture > -1) // flat changing
|
||||||
case instantMoveFloorByFrontSector:
|
movefloor->sector->floorpic = movefloor->texture;
|
||||||
if (movefloor->texture > -1) // flat changing
|
remove = true;
|
||||||
movefloor->sector->floorpic = movefloor->texture;
|
break;
|
||||||
break;
|
case bounceFloor: // Graue 03-12-2004
|
||||||
case bounceFloor: // Graue 03-12-2004
|
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
||||||
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
||||||
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
else
|
||||||
else
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
||||||
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
||||||
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
movefloor->delaytimer = movefloor->delay;
|
||||||
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
remove = false;
|
||||||
movefloor->delaytimer = movefloor->delay;
|
break;
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
case bounceFloorCrush: // Graue 03-27-2004
|
||||||
return; // not break, why did this work? Graue 04-03-2004
|
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
||||||
case bounceFloorCrush: // Graue 03-27-2004
|
{
|
||||||
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
||||||
{
|
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dy), 4*FRACUNIT); // return trip, use dy
|
||||||
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
}
|
||||||
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dy),4*FRACUNIT); // return trip, use dy
|
else
|
||||||
}
|
{
|
||||||
else
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
||||||
{
|
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx), 4*FRACUNIT); // forward again, use dx
|
||||||
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
}
|
||||||
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx
|
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
||||||
}
|
movefloor->delaytimer = movefloor->delay;
|
||||||
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
remove = false;
|
||||||
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
break;
|
||||||
movefloor->delaytimer = movefloor->delay;
|
case crushFloorOnce:
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
if (movefloor->direction == 1)
|
||||||
return; // not break, why did this work? Graue 04-03-2004
|
{
|
||||||
case crushFloorOnce:
|
|
||||||
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
||||||
movefloor->direction = -1;
|
movefloor->direction = -1;
|
||||||
movefloor->sector->soundorg.z = movefloor->sector->floorheight;
|
movefloor->sector->soundorg.z = movefloor->sector->floorheight;
|
||||||
S_StartSound(&movefloor->sector->soundorg,sfx_pstop);
|
S_StartSound(&movefloor->sector->soundorg, sfx_pstop);
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
remove = false;
|
||||||
return;
|
}
|
||||||
default:
|
else
|
||||||
break;
|
remove = true;
|
||||||
}
|
break;
|
||||||
}
|
default:
|
||||||
else if (movefloor->direction == -1)
|
break;
|
||||||
{
|
|
||||||
switch (movefloor->type)
|
|
||||||
{
|
|
||||||
case moveFloorByFrontSector:
|
|
||||||
if (movefloor->texture < -1) // chained linedef executing
|
|
||||||
P_LinedefExecute((INT16)(movefloor->texture + INT16_MAX + 2), NULL, NULL);
|
|
||||||
/* FALLTHRU */
|
|
||||||
case instantMoveFloorByFrontSector:
|
|
||||||
if (movefloor->texture > -1) // flat changing
|
|
||||||
movefloor->sector->floorpic = movefloor->texture;
|
|
||||||
break;
|
|
||||||
case bounceFloor: // Graue 03-12-2004
|
|
||||||
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
|
||||||
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
|
||||||
else
|
|
||||||
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
||||||
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
|
||||||
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
|
||||||
movefloor->delaytimer = movefloor->delay;
|
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
|
||||||
return; // not break, why did this work? Graue 04-03-2004
|
|
||||||
case bounceFloorCrush: // Graue 03-27-2004
|
|
||||||
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
|
|
||||||
{
|
|
||||||
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
|
|
||||||
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dy),4*FRACUNIT); // return trip, use dy
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
|
|
||||||
movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx
|
|
||||||
}
|
|
||||||
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
|
|
||||||
movefloor->sector->floorspeed = movefloor->speed * movefloor->direction;
|
|
||||||
movefloor->delaytimer = movefloor->delay;
|
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
|
||||||
return; // not break, why did this work? Graue 04-03-2004
|
|
||||||
case crushFloorOnce:
|
|
||||||
movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it
|
|
||||||
P_RemoveThinker(&movefloor->thinker);
|
|
||||||
movefloor->sector->floorspeed = 0;
|
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remove)
|
||||||
|
{
|
||||||
movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it
|
movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it
|
||||||
movefloor->sector->floorspeed = 0;
|
movefloor->sector->floorspeed = 0;
|
||||||
P_RemoveThinker(&movefloor->thinker);
|
P_RemoveThinker(&movefloor->thinker);
|
||||||
dontupdate = true;
|
|
||||||
}
|
}
|
||||||
if (!dontupdate)
|
|
||||||
movefloor->sector->floorspeed = movefloor->speed*movefloor->direction;
|
|
||||||
else
|
else
|
||||||
movefloor->sector->floorspeed = 0;
|
movefloor->sector->floorspeed = movefloor->speed*movefloor->direction;
|
||||||
|
|
||||||
P_RecalcPrecipInSector(movefloor->sector);
|
P_RecalcPrecipInSector(movefloor->sector);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue