From 588c56b22425e4ebc8a148771269617cdd60d921 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 26 Jun 2021 16:25:14 +0200 Subject: [PATCH] Floor/ceiling movers: Stop abusing the texture variable to store the sourceline --- src/p_ceilng.c | 16 +++++++--------- src/p_floor.c | 23 ++++++++++------------- src/p_saveg.c | 2 ++ src/p_spec.h | 1 + 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 83c342712..b64d496fb 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -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: diff --git a/src/p_floor.c b/src/p_floor.c index 4ad78d86c..e388657cf 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -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: diff --git a/src/p_saveg.c b/src/p_saveg.c index 600561c8d..bf28b11a5 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -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; diff --git a/src/p_spec.h b/src/p_spec.h index 4ad817ab2..921af714e 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -355,6 +355,7 @@ typedef struct fixed_t delay; fixed_t delaytimer; INT16 tag; + INT32 sourceline; } floormove_t; typedef struct