Floor/ceiling movers: Stop abusing the texture variable to store the sourceline

This commit is contained in:
MascaraSnake 2021-06-26 16:25:14 +02:00
parent 202c56054e
commit 588c56b224
4 changed files with 20 additions and 22 deletions

View file

@ -46,8 +46,8 @@ void T_MoveCeiling(ceiling_t *ceiling)
if (ceiling->type == bounceCeiling)
{
const fixed_t origspeed = FixedDiv(ceiling->origspeed, (ELEVATORSPEED/2));
const fixed_t fs = abs(ceiling->sector->ceilingheight - lines[ceiling->texture].frontsector->ceilingheight);
const fixed_t bs = abs(ceiling->sector->ceilingheight - lines[ceiling->texture].backsector->ceilingheight);
const fixed_t fs = abs(ceiling->sector->ceilingheight - lines[ceiling->sourceline].frontsector->ceilingheight);
const fixed_t bs = abs(ceiling->sector->ceilingheight - lines[ceiling->sourceline].backsector->ceilingheight);
if (fs < bs)
ceiling->speed = FixedDiv(fs, 25*FRACUNIT) + FRACUNIT/4;
else
@ -83,15 +83,15 @@ void T_MoveCeiling(ceiling_t *ceiling)
{
fixed_t dest = (ceiling->direction == 1) ? ceiling->topheight : ceiling->bottomheight;
if (dest == lines[ceiling->texture].frontsector->ceilingheight)
if (dest == lines[ceiling->sourceline].frontsector->ceilingheight)
{
dest = lines[ceiling->texture].backsector->ceilingheight;
ceiling->speed = ceiling->origspeed = lines[ceiling->texture].args[3] << (FRACBITS - 2); // return trip, use args[3]
dest = lines[ceiling->sourceline].backsector->ceilingheight;
ceiling->speed = ceiling->origspeed = lines[ceiling->sourceline].args[3] << (FRACBITS - 2); // return trip, use args[3]
}
else
{
dest = lines[ceiling->texture].frontsector->ceilingheight;
ceiling->speed = ceiling->origspeed = lines[ceiling->texture].args[2] << (FRACBITS - 2); // going frontways, use args[2]
dest = lines[ceiling->sourceline].frontsector->ceilingheight;
ceiling->speed = ceiling->origspeed = lines[ceiling->sourceline].args[2] << (FRACBITS - 2); // going frontways, use args[2]
}
if (dest < ceiling->sector->ceilingheight) // must move down
@ -330,8 +330,6 @@ INT32 EV_DoCeiling(mtag_t tag, line_t *line, ceiling_e type)
// Any delay?
ceiling->delay = line->args[5];
ceiling->delaytimer = line->args[4]; // Initial delay
ceiling->texture = (fixed_t)(line - lines); // hack: use texture to store sourceline number
break;
default:

View file

@ -178,8 +178,8 @@ void T_MoveFloor(floormove_t *movefloor)
if (movefloor->type == bounceFloor)
{
const fixed_t origspeed = FixedDiv(movefloor->origspeed,(ELEVATORSPEED/2));
const fixed_t fs = abs(movefloor->sector->floorheight - lines[movefloor->texture].frontsector->floorheight);
const fixed_t bs = abs(movefloor->sector->floorheight - lines[movefloor->texture].backsector->floorheight);
const fixed_t fs = abs(movefloor->sector->floorheight - lines[movefloor->sourceline].frontsector->floorheight);
const fixed_t bs = abs(movefloor->sector->floorheight - lines[movefloor->sourceline].backsector->floorheight);
if (fs < bs)
movefloor->speed = FixedDiv(fs,25*FRACUNIT) + FRACUNIT/4;
else
@ -203,15 +203,15 @@ void T_MoveFloor(floormove_t *movefloor)
break;
case bounceFloor: // Graue 03-12-2004
case bounceFloorCrush: // Graue 03-27-2004
if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight)
if (movefloor->floordestheight == lines[movefloor->sourceline].frontsector->floorheight)
{
movefloor->floordestheight = lines[movefloor->texture].backsector->floorheight;
movefloor->speed = movefloor->origspeed = lines[movefloor->texture].args[3] << (FRACBITS - 2); // return trip, use args[3]
movefloor->floordestheight = lines[movefloor->sourceline].backsector->floorheight;
movefloor->speed = movefloor->origspeed = lines[movefloor->sourceline].args[3] << (FRACBITS - 2); // return trip, use args[3]
}
else
{
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
movefloor->speed = movefloor->origspeed = lines[movefloor->texture].args[2] << (FRACBITS - 2); // forward again, use args[2]
movefloor->floordestheight = lines[movefloor->sourceline].frontsector->floorheight;
movefloor->speed = movefloor->origspeed = lines[movefloor->sourceline].args[2] << (FRACBITS - 2); // forward again, use args[2]
}
movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1;
movefloor->delaytimer = movefloor->delay;
@ -220,9 +220,9 @@ void T_MoveFloor(floormove_t *movefloor)
case crushFloorOnce:
if (movefloor->direction == 1)
{
movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight;
movefloor->floordestheight = lines[movefloor->sourceline].frontsector->floorheight;
movefloor->direction = -1;
movefloor->speed = lines[movefloor->texture].args[3] << (FRACBITS - 2);
movefloor->speed = lines[movefloor->sourceline].args[3] << (FRACBITS - 2);
movefloor->sector->soundorg.z = movefloor->sector->floorheight;
S_StartSound(&movefloor->sector->soundorg, sfx_pstop);
remove = false;
@ -1777,6 +1777,7 @@ void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype)
dofloor->type = floortype;
dofloor->crush = false; // default: types that crush will change this
dofloor->sector = sec;
dofloor->sourceline = (INT32)(line - lines);
switch (floortype)
{
@ -1856,8 +1857,6 @@ void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype)
// Any delay?
dofloor->delay = line->args[5];
dofloor->delaytimer = line->args[4]; // Initial delay
dofloor->texture = (fixed_t)(line - lines); // hack: store source line number
break;
case crushFloorOnce:
@ -1868,8 +1867,6 @@ void EV_DoFloor(mtag_t tag, line_t *line, floor_e floortype)
dofloor->direction = 1; // up
else
dofloor->direction = -1; // down
dofloor->texture = (fixed_t)(line - lines); // hack: store source line number
break;
default:

View file

@ -2010,6 +2010,7 @@ static void SaveFloormoveThinker(const thinker_t *th, const UINT8 type)
WRITEFIXED(save_p, ht->delay);
WRITEFIXED(save_p, ht->delaytimer);
WRITEINT16(save_p, ht->tag);
WRITEFIXED(save_p, ht->sourceline);
}
static void SaveLightflashThinker(const thinker_t *th, const UINT8 type)
@ -3118,6 +3119,7 @@ static thinker_t* LoadFloormoveThinker(actionf_p1 thinker)
ht->delay = READFIXED(save_p);
ht->delaytimer = READFIXED(save_p);
ht->tag = READINT16(save_p);
ht->sourceline = READFIXED(save_p);
if (ht->sector)
ht->sector->floordata = ht;
return &ht->thinker;

View file

@ -355,6 +355,7 @@ typedef struct
fixed_t delay;
fixed_t delaytimer;
INT16 tag;
INT32 sourceline;
} floormove_t;
typedef struct