- Duke: Replace player_struct poszv with vel.Z calls.

This commit is contained in:
Mitchell Richters 2021-12-30 22:14:04 +11:00
parent b2023efb44
commit fd8c7bfa52
12 changed files with 85 additions and 85 deletions

View file

@ -1972,7 +1972,7 @@ void movetransports_d(void)
int k = 0;
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].pos.Z > (sectp->floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].poszv > 2048))
if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].pos.Z > (sectp->floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].vel.Z > 2048))
// if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) )
{
k = 1;

View file

@ -413,8 +413,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case PLAYER_POSZV:
if (bSet) ps[iPlayer].poszv = lValue;
else SetGameVarID(lVar2, ps[iPlayer].poszv, sActor, sPlayer);
if (bSet) ps[iPlayer].vel.Z = lValue;
else SetGameVarID(lVar2, ps[iPlayer].vel.Z, sActor, sPlayer);
break;
case PLAYER_LAST_PISSED_TIME:
@ -2414,7 +2414,7 @@ int ParseState::parse(void)
// sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable.
if( (l& pducking) && ps[g_p].on_ground && PlayerInput(g_p, SB_CROUCH))
j = 1;
else if( (l& pfalling) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && ps[g_p].poszv > 2048 )
else if( (l& pfalling) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && ps[g_p].vel.Z > 2048 )
j = 1;
else if( (l& pjumping) && ps[g_p].jumping_counter > 348 )
j = 1;

View file

@ -433,7 +433,7 @@ void hud_input(int plnum)
else
{
p->hard_landing = 0;
p->poszv = 0;
p->vel.Z = 0;
S_PlayActorSound(DUKE_JETPACK_OFF, pact);
S_StopSound(DUKE_JETPACK_IDLE, pact);
S_StopSound(DUKE_JETPACK_ON, pact);

View file

@ -1088,7 +1088,7 @@ DEFINE_FIELD_X(DukePlayer, player_struct, pyoff)
DEFINE_FIELD_X(DukePlayer, player_struct, opyoff)
//DEFINE_FIELD_X(DukePlayer, player_struct, posxv)
//DEFINE_FIELD_X(DukePlayer, player_struct, posyv)
DEFINE_FIELD_X(DukePlayer, player_struct, poszv)
//DEFINE_FIELD_X(DukePlayer, player_struct, poszv)
DEFINE_FIELD_X(DukePlayer, player_struct, last_pissed_time)
DEFINE_FIELD_X(DukePlayer, player_struct, truefz)
DEFINE_FIELD_X(DukePlayer, player_struct, truecz)

View file

@ -1796,16 +1796,16 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
else
{
p->on_ground = 0;
p->poszv += (gs.gravity + 80); // (TICSPERFRAME<<6);
if (p->poszv >= (4096 + 2048)) p->poszv = (4096 + 2048);
if (p->poszv > 2400 && p->falling_counter < 255)
p->vel.Z += (gs.gravity + 80); // (TICSPERFRAME<<6);
if (p->vel.Z >= (4096 + 2048)) p->vel.Z = (4096 + 2048);
if (p->vel.Z > 2400 && p->falling_counter < 255)
{
p->falling_counter++;
if (p->falling_counter == 38 && !S_CheckActorSoundPlaying(pact, DUKE_SCREAM))
S_PlayActorSound(DUKE_SCREAM, pact);
}
if ((p->pos.Z + p->poszv) >= (fz - (i << 8))) // hit the ground
if ((p->pos.Z + p->vel.Z) >= (fz - (i << 8))) // hit the ground
{
S_StopSound(DUKE_SCREAM, pact);
if (!p->insector() || p->cursector->lotag != 1)
@ -1829,7 +1829,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
SetPlayerPal(p, PalEntry(32, 16, 0, 0));
}
else if (p->poszv > 2048) S_PlayActorSound(DUKE_LAND, pact);
else if (p->vel.Z > 2048) S_PlayActorSound(DUKE_LAND, pact);
}
}
}
@ -1840,8 +1840,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
p->falling_counter = 0;
S_StopSound(-1, pact, CHAN_VOICE);
if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->poszv > (6144 >> 1))
p->hard_landing = p->poszv >> 10;
if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->vel.Z > (6144 >> 1))
p->hard_landing = p->vel.Z >> 10;
p->on_ground = 1;
@ -1852,8 +1852,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
int k = ((fz - (i << 8)) - p->pos.Z) >> 1;
if (abs(k) < 256) k = 0;
p->pos.Z += k;
p->poszv -= 768;
if (p->poszv < 0) p->poszv = 0;
p->vel.Z -= 768;
if (p->vel.Z < 0) p->vel.Z = 0;
}
else if (p->jumping_counter == 0)
{
@ -1861,7 +1861,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
if (p->on_warping_sector == 0 && p->pos.Z > fz - (16 << 8))
{
p->pos.Z = fz - (16 << 8);
p->poszv >>= 1;
p->vel.Z >>= 1;
}
}
@ -1895,11 +1895,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
if (psectlotag == 1 && p->jumping_counter > 768)
{
p->jumping_counter = 0;
p->poszv = -512;
p->vel.Z = -512;
}
else
{
p->poszv -= bsin(2048 - 128 + p->jumping_counter) / 12;
p->vel.Z -= bsin(2048 - 128 + p->jumping_counter) / 12;
p->jumping_counter += 180;
p->on_ground = 0;
}
@ -1907,18 +1907,18 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
else
{
p->jumping_counter = 0;
p->poszv = 0;
p->vel.Z = 0;
}
}
p->pos.Z += p->poszv;
p->pos.Z += p->vel.Z;
if (p->pos.Z < (cz + (4 << 8)))
{
p->jumping_counter = 0;
if (p->poszv < 0)
if (p->vel.Z < 0)
p->vel.X = p->vel.Y = 0;
p->poszv = 128;
p->vel.Z = 128;
p->pos.Z = cz + (4 << 8);
}
}
@ -1947,38 +1947,38 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz)
if (actions & SB_JUMP)
{
// jump
if (p->poszv > 0) p->poszv = 0;
p->poszv -= 348;
if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6);
if (p->vel.Z > 0) p->vel.Z = 0;
p->vel.Z -= 348;
if (p->vel.Z < -(256 * 6)) p->vel.Z = -(256 * 6);
}
else if (actions & SB_CROUCH)
{
// crouch
if (p->poszv < 0) p->poszv = 0;
p->poszv += 348;
if (p->poszv > (256 * 6)) p->poszv = (256 * 6);
if (p->vel.Z < 0) p->vel.Z = 0;
p->vel.Z += 348;
if (p->vel.Z > (256 * 6)) p->vel.Z = (256 * 6);
}
else
{
// normal view
if (p->poszv < 0)
if (p->vel.Z < 0)
{
p->poszv += 256;
if (p->poszv > 0)
p->poszv = 0;
p->vel.Z += 256;
if (p->vel.Z > 0)
p->vel.Z = 0;
}
if (p->poszv > 0)
if (p->vel.Z > 0)
{
p->poszv -= 256;
if (p->poszv < 0)
p->poszv = 0;
p->vel.Z -= 256;
if (p->vel.Z < 0)
p->vel.Z = 0;
}
}
if (p->poszv > 2048)
p->poszv >>= 1;
if (p->vel.Z > 2048)
p->vel.Z >>= 1;
p->pos.Z += p->poszv;
p->pos.Z += p->vel.Z;
if (p->pos.Z > (fz - (15 << 8)))
p->pos.Z += ((fz - (15 << 8)) - p->pos.Z) >> 1;
@ -1986,7 +1986,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz)
if (p->pos.Z < (cz + (4 << 8)))
{
p->pos.Z = cz + (4 << 8);
p->poszv = 0;
p->vel.Z = 0;
}
if (p->scuba_on && (krand() & 255) < 8)
@ -2040,7 +2040,7 @@ int operateTripbomb(int snum)
if (((hit.hitpos.X - p->pos.X) * (hit.hitpos.X - p->pos.X) + (hit.hitpos.Y - p->pos.Y) * (hit.hitpos.Y - p->pos.Y)) < (290 * 290))
{
p->pos.Z = p->opos.Z;
p->poszv = 0;
p->vel.Z = 0;
return 1;
}
@ -2580,7 +2580,7 @@ static void operateweapon(int snum, ESyncBits actions)
if (p->kickback_pic < 4)
{
p->pos.Z = p->opos.Z;
p->poszv = 0;
p->vel.Z = 0;
if (p->kickback_pic == 3)
fi.shoot(pact, HANDHOLDINGLASER);
}

View file

@ -2126,7 +2126,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
{
p->VBumpTarget = 80;
p->moto_bump_fast = 1;
p->poszv -= xs_CRoundToInt(gs.gravity * (p->MotoSpeed / 16.));
p->vel.Z -= xs_CRoundToInt(gs.gravity * (p->MotoSpeed / 16.));
p->MotoOnGround = 0;
if (S_CheckActorSoundPlaying(pact, 188))
S_StopSound(188, pact);
@ -2134,23 +2134,23 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
}
else
{
p->poszv += gs.gravity - 80 + int(120 - p->MotoSpeed);
p->vel.Z += gs.gravity - 80 + int(120 - p->MotoSpeed);
if (!S_CheckActorSoundPlaying(pact, 189) && !S_CheckActorSoundPlaying(pact, 190))
S_PlayActorSound(190, pact);
}
}
else
p->poszv += (gs.gravity + 80); // (TICSPERFRAME<<6);
p->vel.Z += (gs.gravity + 80); // (TICSPERFRAME<<6);
if (p->poszv >= (4096 + 2048)) p->poszv = (4096 + 2048);
if (p->poszv > 2400 && p->falling_counter < 255)
if (p->vel.Z >= (4096 + 2048)) p->vel.Z = (4096 + 2048);
if (p->vel.Z > 2400 && p->falling_counter < 255)
{
p->falling_counter++;
if (p->falling_counter == 38 && !S_CheckActorSoundPlaying(pact, DUKE_SCREAM))
S_PlayActorSound(DUKE_SCREAM, pact);
}
if ((p->pos.Z + p->poszv) >= (fz - (i << 8))) // hit the ground
if ((p->pos.Z + p->vel.Z) >= (fz - (i << 8))) // hit the ground
{
S_StopSound(DUKE_SCREAM, pact);
if (!p->insector() || p->cursector->lotag != 1)
@ -2175,7 +2175,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
SetPlayerPal(p, PalEntry(32, 16, 0, 0));
}
else if (p->poszv > 2048)
else if (p->vel.Z > 2048)
{
if (p->OnMotorcycle)
{
@ -2186,7 +2186,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
}
else S_PlayActorSound(DUKE_LAND, pact);
}
else if (p->poszv > 1024 && p->OnMotorcycle)
else if (p->vel.Z > 1024 && p->OnMotorcycle)
{
S_PlayActorSound(DUKE_LAND, pact);
p->TurbCount = 12;
@ -2201,8 +2201,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
p->falling_counter = 0;
S_StopSound(-1, pact, CHAN_VOICE);
if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->poszv > (6144 >> 1))
p->hard_landing = p->poszv >> 10;
if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->vel.Z > (6144 >> 1))
p->hard_landing = p->vel.Z >> 10;
p->on_ground = 1;
@ -2213,8 +2213,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
int k = ((fz - (i << 8)) - p->pos.Z) >> 1;
if (abs(k) < 256) k = 0;
p->pos.Z += k;
p->poszv -= 768;
if (p->poszv < 0) p->poszv = 0;
p->vel.Z -= 768;
if (p->vel.Z < 0) p->vel.Z = 0;
}
else if (p->jumping_counter == 0)
{
@ -2222,7 +2222,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
if (p->on_warping_sector == 0 && p->pos.Z > fz - (16 << 8))
{
p->pos.Z = fz - (16 << 8);
p->poszv >>= 1;
p->vel.Z >>= 1;
}
}
@ -2252,11 +2252,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
if (psectlotag == ST_1_ABOVE_WATER && p->jumping_counter > 768)
{
p->jumping_counter = 0;
p->poszv = -512;
p->vel.Z = -512;
}
else
{
p->poszv -= bsin(2048 - 128 + p->jumping_counter) / 12;
p->vel.Z -= bsin(2048 - 128 + p->jumping_counter) / 12;
p->jumping_counter += 180;
p->on_ground = 0;
}
@ -2264,18 +2264,18 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
else
{
p->jumping_counter = 0;
p->poszv = 0;
p->vel.Z = 0;
}
}
p->pos.Z += p->poszv;
p->pos.Z += p->vel.Z;
if (p->pos.Z < (cz + (4 << 8)))
{
p->jumping_counter = 0;
if (p->poszv < 0)
if (p->vel.Z < 0)
p->vel.X = p->vel.Y = 0;
p->poszv = 128;
p->vel.Z = 128;
p->pos.Z = cz + (4 << 8);
}
}
@ -2302,36 +2302,36 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz)
if ((actions & SB_JUMP) && !p->OnMotorcycle)
{
if (p->poszv > 0) p->poszv = 0;
p->poszv -= 348;
if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6);
if (p->vel.Z > 0) p->vel.Z = 0;
p->vel.Z -= 348;
if (p->vel.Z < -(256 * 6)) p->vel.Z = -(256 * 6);
}
else if ((actions & SB_CROUCH) || p->OnMotorcycle)
{
if (p->poszv < 0) p->poszv = 0;
p->poszv += 348;
if (p->poszv > (256 * 6)) p->poszv = (256 * 6);
if (p->vel.Z < 0) p->vel.Z = 0;
p->vel.Z += 348;
if (p->vel.Z > (256 * 6)) p->vel.Z = (256 * 6);
}
else
{
if (p->poszv < 0)
if (p->vel.Z < 0)
{
p->poszv += 256;
if (p->poszv > 0)
p->poszv = 0;
p->vel.Z += 256;
if (p->vel.Z > 0)
p->vel.Z = 0;
}
if (p->poszv > 0)
if (p->vel.Z > 0)
{
p->poszv -= 256;
if (p->poszv < 0)
p->poszv = 0;
p->vel.Z -= 256;
if (p->vel.Z < 0)
p->vel.Z = 0;
}
}
if (p->poszv > 2048)
p->poszv >>= 1;
if (p->vel.Z > 2048)
p->vel.Z >>= 1;
p->pos.Z += p->poszv;
p->pos.Z += p->vel.Z;
if (p->pos.Z > (fz - (15 << 8)))
p->pos.Z += ((fz - (15 << 8)) - p->pos.Z) >> 1;
@ -2339,7 +2339,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz)
if (p->pos.Z < (cz + (4 << 8)))
{
p->pos.Z = cz + (4 << 8);
p->poszv = 0;
p->vel.Z = 0;
}
if (p->scuba_on && (krand() & 255) < 8)

View file

@ -440,7 +440,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
&& p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1))
{
p->pos.Z = p->opos.Z;
p->poszv = 0;
p->vel.Z = 0;
}
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum))
{

View file

@ -150,7 +150,7 @@ void resetplayerstats(int snum)
p->hard_landing = 0;
p->vel.X = 0; //!!
p->vel.Y = 0;
p->poszv = 0;
p->vel.Z = 0;
p->fric.X = 0;
p->fric.Y = 0;
p->somethingonplayer =nullptr;

View file

@ -127,7 +127,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
("pyoff", w.pyoff)
("posxv", w.vel.X)
("posyv", w.vel.Y)
("poszv", w.poszv)
("poszv", w.vel.Z)
("last_pissed_time", w.last_pissed_time)
("truefz", w.truefz)
("truecz", w.truecz)

View file

@ -351,7 +351,7 @@ void doanimations(void)
if (ps[p].GetActor()->GetOwner() != nullptr)
{
ps[p].pos.Z += v;
ps[p].poszv = 0;
ps[p].vel.Z = 0;
}
DukeSectIterator it(dasectp);

View file

@ -205,7 +205,7 @@ struct player_struct
int exitx, exity, loogiex[64], loogiey[64], numloogs, loogcnt;
int invdisptime;
int bobposx, bobposy, pyoff, opyoff;
int poszv, last_pissed_time, truefz, truecz;
int last_pissed_time, truefz, truecz;
int player_par, visibility;
int bobcounter;
int randomflamex, crack_time;

View file

@ -153,7 +153,7 @@ struct DukePlayer
native int exitx, exity, loogiex[64], loogiey[64], numloogs, loogcnt;
native int invdisptime;
native int bobposx, bobposy, pyoff, opyoff;
native int poszv, last_pissed_time, truefz, truecz;
native int last_pissed_time, truefz, truecz;
native int player_par, visibility;
native int bobcounter;
native int randomflamex, crack_time;