-Remove superfluous variables from raise_t

-Cleanup signatures of P_AddRaiseThinker and P_AddAirbob
This commit is contained in:
MascaraSnake 2020-04-17 11:11:36 +02:00
parent a41dbe2bae
commit 63a901b714
4 changed files with 52 additions and 67 deletions

View File

@ -1856,8 +1856,9 @@ void T_RaiseSector(raise_t *raise)
boolean playeronme = false, active = false;
boolean moveUp;
fixed_t ceilingdestination, floordestination;
fixed_t origspeed;
fixed_t speed, origspeed;
fixed_t distToNearestEndpoint;
INT32 direction;
result_e res = 0;
if (raise->sector->crumblestate >= 3 || raise->sector->ceilingdata)
@ -1936,60 +1937,59 @@ void T_RaiseSector(raise_t *raise)
else // Air bobbing platform (not a Dynamically Sinking Platform^tm)
active = playeronme;
raise->speed = raise->basespeed;
if (!active)
raise->speed /= 2;
moveUp = active ^ (raise->flags & RF_REVERSE);
ceilingdestination = moveUp ? raise->ceilingtop : raise->ceilingbottom;
floordestination = moveUp ? raise->floortop : raise->floorbottom;
floordestination = ceilingdestination - (raise->sector->ceilingheight - raise->sector->floorheight);
if ((moveUp && raise->sector->ceilingheight >= ceilingdestination)
|| (!moveUp && raise->sector->ceilingheight <= ceilingdestination))
{
raise->sector->floorheight = ceilingdestination - (raise->sector->ceilingheight - raise->sector->floorheight);
raise->sector->floorheight = floordestination;
raise->sector->ceilingheight = ceilingdestination;
raise->sector->ceilspeed = 0;
raise->sector->floorspeed = 0;
return;
}
raise->direction = moveUp ? 1 : -1;
direction = moveUp ? 1 : -1;
origspeed = raise->basespeed;
if (!active)
origspeed /= 2;
origspeed = raise->speed;
// Speed up as you get closer to the middle, then slow down again
distToNearestEndpoint = min(raise->sector->ceilingheight - raise->ceilingbottom, raise->ceilingtop - raise->sector->ceilingheight);
raise->speed = FixedMul(raise->speed, FixedDiv(distToNearestEndpoint, (raise->ceilingtop - raise->ceilingbottom) >> 5));
speed = FixedMul(origspeed, FixedDiv(distToNearestEndpoint, (raise->ceilingtop - raise->ceilingbottom) >> 5));
if (raise->speed <= origspeed/16)
raise->speed = origspeed/16;
else if (raise->speed > origspeed)
raise->speed = origspeed;
if (speed <= origspeed/16)
speed = origspeed/16;
else if (speed > origspeed)
speed = origspeed;
raise->speed += raise->extraspeed;
speed += raise->extraspeed;
res = T_MovePlane
(
raise->sector, // sector
raise->speed, // speed
raise->sector, // sector
speed, // speed
ceilingdestination, // dest
0, // crush
1, // floor or ceiling (1 for ceiling)
raise->direction // direction
0, // crush
1, // floor or ceiling (1 for ceiling)
direction // direction
);
if (res == ok || res == pastdest)
T_MovePlane
(
raise->sector, // sector
raise->speed, // speed
raise->sector, // sector
speed, // speed
floordestination, // dest
0, // crush
0, // floor or ceiling (0 for floor)
raise->direction // direction
0, // crush
0, // floor or ceiling (0 for floor)
direction // direction
);
raise->sector->ceilspeed = 42;
raise->sector->floorspeed = raise->speed*raise->direction;
raise->sector->floorspeed = speed*direction;
for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;)
P_RecalcPrecipInSector(&sectors[i]);

View File

@ -1669,13 +1669,9 @@ static void SaveRaiseThinker(const thinker_t *th, const UINT8 type)
WRITEUINT8(save_p, type);
WRITEUINT32(save_p, SaveLine(ht->sourceline));
WRITEUINT32(save_p, SaveSector(ht->sector));
WRITEFIXED(save_p, ht->floorbottom);
WRITEFIXED(save_p, ht->ceilingbottom);
WRITEFIXED(save_p, ht->floortop);
WRITEFIXED(save_p, ht->ceilingtop);
WRITEFIXED(save_p, ht->basespeed);
WRITEFIXED(save_p, ht->speed);
WRITEINT32(save_p, ht->direction);
WRITEFIXED(save_p, ht->extraspeed);
WRITEUINT8(save_p, ht->shaketimer);
WRITEUINT8(save_p, ht->flags);
@ -2802,13 +2798,9 @@ static thinker_t* LoadRaiseThinker(actionf_p1 thinker)
ht->thinker.function.acp1 = thinker;
ht->sourceline = LoadLine(READUINT32(save_p));
ht->sector = LoadSector(READUINT32(save_p));
ht->floorbottom = READFIXED(save_p);
ht->ceilingbottom = READFIXED(save_p);
ht->floortop = READFIXED(save_p);
ht->ceilingtop = READFIXED(save_p);
ht->basespeed = READFIXED(save_p);
ht->speed = READFIXED(save_p);
ht->direction = READINT32(save_p);
ht->extraspeed = READFIXED(save_p);
ht->shaketimer = READUINT8(save_p);
ht->flags = READUINT8(save_p);

View File

@ -6040,7 +6040,7 @@ static void P_AddBlockThinker(sector_t *sec, line_t *sourceline)
* \sa P_SpawnSpecials, T_RaiseSector
* \author SSNTails <http://www.ssntails.org>
*/
static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline)
static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline, boolean lower, boolean spindash)
{
raise_t *raise;
@ -6053,20 +6053,17 @@ static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline)
raise->sector = sec;
raise->ceilingtop = P_FindHighestCeilingSurrounding(sec);
raise->floortop = raise->ceilingtop - (sec->ceilingheight - sec->floorheight);
raise->ceilingbottom = P_FindLowestCeilingSurrounding(sec);
raise->floorbottom = raise->ceilingbottom - (sec->ceilingheight - sec->floorheight);
raise->basespeed = FixedDiv(P_AproxDistance(sourceline->dx, sourceline->dy), 4*FRACUNIT);
raise->speed = raise->basespeed;
if (sourceline->flags & ML_BLOCKMONSTERS)
if (lower)
raise->flags |= RF_REVERSE;
if (sourceline->flags & ML_NOCLIMB)
if (spindash)
raise->flags |= RF_SPINDASH;
}
static void P_AddAirbob(sector_t *sec, line_t *sourceline, boolean noadjust, boolean dynamic)
static void P_AddAirbob(sector_t *sec, line_t *sourceline, fixed_t dist, boolean raise, boolean spindash, boolean dynamic)
{
raise_t *airbob;
@ -6079,16 +6076,15 @@ static void P_AddAirbob(sector_t *sec, line_t *sourceline, boolean noadjust, boo
airbob->sector = sec;
airbob->ceilingtop = sec->ceilingheight;
airbob->floortop = airbob->ceilingtop - (sec->ceilingheight - sec->floorheight);
airbob->ceilingbottom = sec->ceilingheight - (noadjust ? 16*FRACUNIT : P_AproxDistance(sourceline->dx, sourceline->dy));
airbob->floorbottom = airbob->ceilingbottom - (sec->ceilingheight - sec->floorheight);
airbob->ceilingbottom = sec->ceilingheight - speed;
airbob->basespeed = FRACUNIT;
airbob->speed = airbob->basespeed;
if (sourceline->flags & ML_BLOCKMONSTERS)
airbob->flags = flags;
if (!raise)
airbob->flags |= RF_REVERSE;
if (sourceline->flags & ML_NOCLIMB)
if (spindash)
airbob->flags |= RF_SPINDASH;
if (dynamic)
airbob->flags |= RF_DYNAMIC;
@ -6894,18 +6890,22 @@ void P_SpawnSpecials(boolean fromnetsave)
case 150: // Air bobbing platform
case 151: // Adjustable air bobbing platform
{
fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : P_AproxDistance(lines[i].dx, lines[i].dy);
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
lines[i].flags |= ML_BLOCKMONSTERS;
P_AddAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151), false);
P_AddAirbob(lines[i].frontsector, lines + i, dist, false, !!(lines[i].flags & ML_NOCLIMB), false);
break;
}
case 152: // Adjustable air bobbing platform in reverse
if (lines[i].flags & NOCLIMB)
raiseflags |= RF_SPINDASH;
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
P_AddAirbob(lines[i].frontsector, lines + i, true, false);
P_AddAirbob(lines[i].frontsector, lines + i, P_AproxDistance(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false);
break;
case 153: // Dynamic Sinking Platform
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
lines[i].flags |= ML_BLOCKMONSTERS;
P_AddAirbob(lines[i].frontsector, lines + i, false, true);
P_AddAirbob(lines[i].frontsector, lines + i, P_AproxDistance(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true);
break;
case 160: // Float/bob platform
@ -6955,15 +6955,13 @@ void P_SpawnSpecials(boolean fromnetsave)
case 176: // Air bobbing platform that will crumble and bob on the water when it falls and hits
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB|FF_CRUMBLE, secthinkers);
lines[i].flags |= ML_BLOCKMONSTERS;
P_AddAirbob(lines[i].frontsector, lines + i, true, false);
P_AddAirbob(lines[i].frontsector, lines + i, 16*FRACUNIT, false, !!(lines[i].flags & ML_NOCLIMB), false);
break;
case 177: // Air bobbing platform that will crumble and bob on
// the water when it falls and hits, then never return
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_FLOATBOB|FF_CRUMBLE|FF_NORETURN, secthinkers);
lines[i].flags |= ML_BLOCKMONSTERS;
P_AddAirbob(lines[i].frontsector, lines + i, true, false);
P_AddAirbob(lines[i].frontsector, lines + i, 16*FRACUNIT, false, !!(lines[i].flags & ML_NOCLIMB), false);
break;
case 178: // Crumbling platform that will float when it hits water
@ -6976,28 +6974,27 @@ void P_SpawnSpecials(boolean fromnetsave)
case 180: // Air bobbing platform that will crumble
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_CRUMBLE, secthinkers);
lines[i].flags |= ML_BLOCKMONSTERS;
P_AddAirbob(lines[i].frontsector, lines + i, true, false);
P_AddAirbob(lines[i].frontsector, lines + i, 16*FRACUNIT, false, !!(lines[i].flags & ML_NOCLIMB), false);
break;
case 190: // Rising Platform FOF (solid, opaque, shadows)
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
P_AddRaiseThinker(lines[i].frontsector, &lines[i]);
P_AddRaiseThinker(lines[i].frontsector, &lines[i], !!(lines[i].flags & ML_BLOCKMONSTERS), !!(lines[i].flags & ML_NOCLIMB));
break;
case 191: // Rising Platform FOF (solid, opaque, no shadows)
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_NOSHADE|FF_CUTLEVEL, secthinkers);
P_AddRaiseThinker(lines[i].frontsector, &lines[i]);
P_AddRaiseThinker(lines[i].frontsector, &lines[i], !!(lines[i].flags & ML_BLOCKMONSTERS), !!(lines[i].flags & ML_NOCLIMB));
break;
case 192: // Rising Platform TL block: FOF (solid, translucent)
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_NOSHADE|FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA, secthinkers);
P_AddRaiseThinker(lines[i].frontsector, &lines[i]);
P_AddRaiseThinker(lines[i].frontsector, &lines[i], !!(lines[i].flags & ML_BLOCKMONSTERS), !!(lines[i].flags & ML_NOCLIMB));
break;
case 193: // Rising Platform FOF (solid, invisible)
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_NOSHADE, secthinkers);
P_AddRaiseThinker(lines[i].frontsector, &lines[i]);
P_AddRaiseThinker(lines[i].frontsector, &lines[i], !!(lines[i].flags & ML_BLOCKMONSTERS), !!(lines[i].flags & ML_NOCLIMB));
break;
case 194: // Rising Platform 'Platform' - You can jump up through it
@ -7007,7 +7004,7 @@ void P_SpawnSpecials(boolean fromnetsave)
ffloorflags |= FF_NOSHADE;
P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
P_AddRaiseThinker(lines[i].frontsector, &lines[i]);
P_AddRaiseThinker(lines[i].frontsector, &lines[i], !!(lines[i].flags & ML_BLOCKMONSTERS), !!(lines[i].flags & ML_NOCLIMB));
break;
case 195: // Rising Platform Translucent "platform"
@ -7017,7 +7014,7 @@ void P_SpawnSpecials(boolean fromnetsave)
ffloorflags |= FF_NOSHADE;
P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
P_AddRaiseThinker(lines[i].frontsector, &lines[i]);
P_AddRaiseThinker(lines[i].frontsector, &lines[i], !!(lines[i].flags & ML_BLOCKMONSTERS), !!(lines[i].flags & ML_NOCLIMB));
break;
case 200: // Double light effect

View File

@ -332,13 +332,9 @@ typedef struct
thinker_t thinker;
line_t *sourceline;
sector_t *sector;
fixed_t floorbottom;
fixed_t ceilingbottom;
fixed_t floortop;
fixed_t ceilingtop;
fixed_t basespeed;
fixed_t speed;
INT32 direction; //1 = up, -1 = down
fixed_t extraspeed; //For dynamically sinking platform
UINT8 shaketimer; //For dynamically sinking platform
UINT8 flags;