Skip to content

Commit

Permalink
- wrapped player::pos z-assignments.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 9, 2022
1 parent bd531ac commit a0e84d8
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 60 deletions.
26 changes: 13 additions & 13 deletions source/games/duke/src/actors.cpp
Expand Up @@ -791,7 +791,7 @@ void movecrane(DDukeActor *actor, int crane)
ps[p].backupxyz();
ps[p].__int_pos.X = actor->int_pos().X - bcos(ang, -6);
ps[p].__int_pos.Y = actor->int_pos().Y - bsin(ang, -6);
ps[p].__int_pos.Z = actor->int_pos().Z + (2 << 8);
ps[p].player_set_int_z(actor->int_pos().Z + (2 << 8));
SetActor(ps[p].GetActor(), ps[p].player_int_pos());
ps[p].setCursector(ps[p].GetActor()->sector());
}
Expand Down Expand Up @@ -1095,7 +1095,7 @@ void movetouchplate(DDukeActor* actor, int plate)
{
sectp->add_int_floorz(sectp->extra);
p = checkcursectnums(actor->sector());
if (p >= 0) ps[p].__int_pos.Z += sectp->extra;
if (p >= 0) ps[p].player_add_int_z(sectp->extra);
}
}
else
Expand All @@ -1110,7 +1110,7 @@ void movetouchplate(DDukeActor* actor, int plate)
sectp->add_int_floorz(-sectp->extra);
p = checkcursectnums(actor->sector());
if (p >= 0)
ps[p].__int_pos.Z -= sectp->extra;
ps[p].player_add_int_z(-sectp->extra);
}
}
return;
Expand Down Expand Up @@ -2680,7 +2680,7 @@ void handle_se00(DDukeActor* actor)
{
ps[p].angle.addadjustment(buildang(l * q));

ps[p].__int_pos.Z += zchange;
ps[p].player_add_int_z(zchange);

vec2_t res;
rotatepoint(Owner->int_pos().vec2, ps[p].player_int_pos().vec2, (q * l), &res);
Expand Down Expand Up @@ -3827,7 +3827,7 @@ void handle_se17(DDukeActor* actor)
{
int p = act1->spr.yvel;
if (numplayers < 2) ps[p].backupz();
ps[p].__int_pos.Z += q * zworldtoint;
ps[p].player_add_int_z(q * zworldtoint);
ps[p].truefz += q;
ps[p].truecz += q;
if (numplayers > 1) ps[p].backupz();
Expand Down Expand Up @@ -3880,7 +3880,7 @@ void handle_se17(DDukeActor* actor)

ps[p].__int_pos.X += act2->int_pos().X - actor->int_pos().X;
ps[p].__int_pos.Y +=act2->int_pos().Y - actor->int_pos().Y;
ps[p].__int_pos.Z = act2->sector()->int_floorz() - (sc->int_floorz() - ps[p].player_int_pos().Z);
ps[p].player_set_int_z(act2->sector()->int_floorz() - (sc->int_floorz() - ps[p].player_int_pos().Z));

act3->floorz = act2->sector()->floorz;
act3->ceilingz = act2->sector()->ceilingz;
Expand Down Expand Up @@ -3946,7 +3946,7 @@ void handle_se18(DDukeActor *actor, bool morecheck)
while (auto a2 = it.Next())
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].__int_pos.Z += sc->extra;
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].player_add_int_z(sc->extra);
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
{
a2->add_int_z(sc->extra);
Expand Down Expand Up @@ -3983,7 +3983,7 @@ void handle_se18(DDukeActor *actor, bool morecheck)
while (auto a2 = it.Next())
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].__int_pos.Z -= sc->extra;
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].player_add_int_z(-sc->extra);
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
{
a2->add_int_z(-sc->extra);
Expand Down Expand Up @@ -4287,7 +4287,7 @@ void handle_se26(DDukeActor* actor)
{
ps[p].fric.X += l << 5;
ps[p].fric.Y += x << 5;
ps[p].__int_pos.Z += actor->spr.zvel;
ps[p].player_add_int_z(actor->spr.zvel);
}

ms(actor);
Expand Down Expand Up @@ -4678,7 +4678,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].__int_pos.Z += l;
ps[a2->PlayerIndex()].player_add_int_z(l);
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
a2->add_int_z(l);
Expand Down Expand Up @@ -4707,7 +4707,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].__int_pos.Z += l;
ps[a2->PlayerIndex()].player_add_int_z(l);
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
a2->add_int_z(l);
Expand Down Expand Up @@ -4738,7 +4738,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].__int_pos.Z += l;
ps[a2->PlayerIndex()].player_add_int_z(l);
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
a2->add_int_z(l);
Expand Down Expand Up @@ -4766,7 +4766,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
{
if (a2->isPlayer() && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].__int_pos.Z -= l;
ps[a2->PlayerIndex()].player_add_int_z(-l);
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && (!choosedir || a2->spr.statnum != STAT_PROJECTILE))
{
a2->add_int_z(-l);
Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/actors_d.cpp
Expand Up @@ -1833,8 +1833,8 @@ void movetransports_d(void)
ps[p].backupxy();

if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].__int_pos.Z = Owner->int_pos().Z - 6144;
else ps[p].__int_pos.Z = Owner->int_pos().Z + 6144;
ps[p].player_set_int_z(Owner->int_pos().Z - 6144);
else ps[p].player_set_int_z(Owner->int_pos().Z + 6144);
ps[p].backupz();

auto pa = ps[p].GetActor();
Expand All @@ -1858,7 +1858,7 @@ void movetransports_d(void)
}
if (ps[p].GetActor()->spr.extra > 0)
S_PlayActorSound(DUKE_UNDERWATER, act2);
ps[p].__int_pos.Z = Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].player_set_int_z(Owner->sector()->int_ceilingz() + (7 << 8));
ps[p].backupz();

ps[p].vel.X = 4096 - (krand() & 8192);
Expand All @@ -1876,7 +1876,7 @@ void movetransports_d(void)
}
S_PlayActorSound(DUKE_GASP, act2);

ps[p].__int_pos.Z = Owner->sector()->int_floorz() - (7 << 8);
ps[p].player_set_int_z(Owner->sector()->int_floorz() - (7 << 8));
ps[p].backupz();

ps[p].jumping_toggle = 1;
Expand Down
12 changes: 6 additions & 6 deletions source/games/duke/src/actors_r.cpp
Expand Up @@ -1480,8 +1480,8 @@ void movetransports_r(void)
ps[p].backupxy();

if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11))
ps[p].__int_pos.Z = Owner->int_pos().Z - 6144;
else ps[p].__int_pos.Z = Owner->int_pos().Z + 6144;
ps[p].player_set_int_z(Owner->int_pos().Z - 6144);
else ps[p].player_set_int_z(Owner->int_pos().Z + 6144);
ps[p].backupz();

ChangeActorSect(act2, Owner->sector());
Expand All @@ -1497,15 +1497,15 @@ void movetransports_r(void)
if (onfloorz && sectlotag == 160 && ps[p].player_int_pos().Z > (sectp->int_floorz() - (48 << 8)))
{
k = 2;
ps[p].__int_pos.Z = Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].player_set_int_z(Owner->sector()->int_ceilingz() + (7 << 8));
ps[p].backupz();
}

if (onfloorz && sectlotag == 161 && ps[p].player_int_pos().Z < (sectp->int_ceilingz() + (6 << 8)))
{
k = 2;
if (ps[p].GetActor()->spr.extra <= 0) break;
ps[p].__int_pos.Z = Owner->sector()->int_floorz() - (49 << 8);
ps[p].player_set_int_z(Owner->sector()->int_floorz() - (49 << 8));
ps[p].backupz();
}
}
Expand All @@ -1520,7 +1520,7 @@ void movetransports_r(void)
FX_StopAllSounds();
}
S_PlayActorSound(DUKE_UNDERWATER, ps[p].GetActor());
ps[p].__int_pos.Z = Owner->sector()->int_ceilingz() + (7 << 8);
ps[p].player_set_int_z(Owner->sector()->int_ceilingz() + (7 << 8));
ps[p].backupz();
if (ps[p].OnMotorcycle)
ps[p].moto_underwater = 1;
Expand All @@ -1536,7 +1536,7 @@ void movetransports_r(void)
}
S_PlayActorSound(DUKE_GASP, ps[p].GetActor());

ps[p].__int_pos.Z = Owner->sector()->int_floorz() - (7 << 8);
ps[p].player_set_int_z(Owner->sector()->int_floorz() - (7 << 8));
ps[p].backupz();
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -1981,7 +1981,7 @@ int ParseState::parse(void)
break;
case concmd_larrybird:
insptr++;
ps[g_p].__int_pos.Z = ps[g_p].GetActor()->sector()->int_ceilingz();
ps[g_p].player_set_int_z(ps[g_p].GetActor()->sector()->int_ceilingz());
ps[g_p].GetActor()->set_int_z(ps[g_p].player_int_pos().Z);
break;
case concmd_destroyit:
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/player.cpp
Expand Up @@ -560,7 +560,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
if (actor->spr.pal != 1)
{
SetPlayerPal(p, PalEntry(63, 63, 0, 0));
p->__int_pos.Z -= (16 << 8);
p->player_add_int_z(-(16 << 8));
actor->add_int_z(-(16 << 8));
}
#if 0
Expand Down Expand Up @@ -609,7 +609,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
if (p->on_warping_sector == 0)
{
if (abs(p->player_int_pos().Z - fz) > (gs.int_playerheight >> 1))
p->__int_pos.Z += 348;
p->player_add_int_z(348);
}
else
{
Expand Down Expand Up @@ -706,7 +706,7 @@ void playerCrouch(int snum)
OnEvent(EVENT_CROUCH, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
{
p->__int_pos.Z += (2048 + 768);
p->player_add_int_z((2048 + 768));
p->crack_time = CRACK_TIME;
}
}
Expand Down
34 changes: 17 additions & 17 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -1687,7 +1687,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
if (p->jetpack_on < 11)
{
p->jetpack_on++;
p->__int_pos.Z -= (p->jetpack_on << 7); //Goin up
p->player_add_int_z(-(p->jetpack_on << 7)); //Goin up
}
else if (p->jetpack_on == 11 && !S_CheckActorSoundPlaying(pact, DUKE_JETPACK_IDLE))
S_PlayActorSound(DUKE_JETPACK_IDLE, pact);
Expand All @@ -1702,7 +1702,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
OnEvent(EVENT_SOARUP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
{
p->__int_pos.Z -= j;
p->player_add_int_z(-j);
p->crack_time = CRACK_TIME;
}
}
Expand All @@ -1714,7 +1714,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
OnEvent(EVENT_SOARDOWN, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
{
p->__int_pos.Z += j;
p->player_add_int_z(j);
p->crack_time = CRACK_TIME;
}
}
Expand All @@ -1727,9 +1727,9 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
p->scuba_on = 0;

if (p->player_int_pos().Z > (fz - (k << 8)))
p->__int_pos.Z += ((fz - (k << 8)) - p->player_int_pos().Z) >> 1;
p->player_add_int_z(((fz - (k << 8)) - p->player_int_pos().Z) >> 1);
if (p->player_int_pos().Z < (pact->actor_int_ceilingz() + (18 << 8)))
p->__int_pos.Z = pact->actor_int_ceilingz() + (18 << 8);
p->player_set_int_z(pact->actor_int_ceilingz() + (18 << 8));

}

Expand Down Expand Up @@ -1788,7 +1788,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int

// not jumping or crouching
if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (psect->floorstat & CSTAT_SECTOR_SLOPE) && p->player_int_pos().Z >= (fz - (i << 8) - (16 << 8)))
p->__int_pos.Z = fz - (i << 8);
p->player_set_int_z(fz - (i << 8));
else
{
p->on_ground = 0;
Expand Down Expand Up @@ -1847,16 +1847,16 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int

int k = ((fz - (i << 8)) - p->player_int_pos().Z) >> 1;
if (abs(k) < 256) k = 0;
p->__int_pos.Z += k;
p->player_add_int_z(k);
p->vel.Z -= 768;
if (p->vel.Z < 0) p->vel.Z = 0;
}
else if (p->jumping_counter == 0)
{
p->__int_pos.Z += ((fz - (i << 7)) - p->player_int_pos().Z) >> 1; //Smooth on the water
p->player_add_int_z(((fz - (i << 7)) - p->player_int_pos().Z) >> 1); //Smooth on the water
if (p->on_warping_sector == 0 && p->player_int_pos().Z > fz - (16 << 8))
{
p->__int_pos.Z = fz - (16 << 8);
p->player_set_int_z(fz - (16 << 8));
p->vel.Z >>= 1;
}
}
Expand Down Expand Up @@ -1907,15 +1907,15 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
}
}

p->__int_pos.Z += p->vel.Z;
p->player_add_int_z(p->vel.Z);

if (p->player_int_pos().Z < (cz + (4 << 8)))
{
p->jumping_counter = 0;
if (p->vel.Z < 0)
p->vel.X = p->vel.Y = 0;
p->vel.Z = 128;
p->__int_pos.Z = cz + (4 << 8);
p->player_set_int_z(cz + (4 << 8));
}
}

Expand Down Expand Up @@ -1974,14 +1974,14 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz)
if (p->vel.Z > 2048)
p->vel.Z >>= 1;

p->__int_pos.Z += p->vel.Z;
p->player_add_int_z(p->vel.Z);

if (p->player_int_pos().Z > (fz - (15 << 8)))
p->__int_pos.Z += ((fz - (15 << 8)) - p->player_int_pos().Z) >> 1;
p->player_add_int_z(((fz - (15 << 8)) - p->player_int_pos().Z) >> 1);

if (p->player_int_pos().Z < (cz + (4 << 8)))
{
p->__int_pos.Z = cz + (4 << 8);
p->player_set_int_z(cz + (4 << 8));
p->vel.Z = 0;
}

Expand Down Expand Up @@ -2034,7 +2034,7 @@ int operateTripbomb(int snum)
if ((hit.hitWall->twoSided() && hit.hitWall->nextSector()->lotag <= 2) || (!hit.hitWall->twoSided() && hit.hitSector->lotag <= 2))
if (((hit.hitpos.X - p->player_int_pos().X) * (hit.hitpos.X - p->player_int_pos().X) + (hit.hitpos.Y - p->player_int_pos().Y) * (hit.hitpos.Y - p->player_int_pos().Y)) < (290 * 290))
{
p->__int_pos.Z = p->player_int_opos().Z;
p->player_set_int_z(p->player_int_opos().Z);
p->vel.Z = 0;
return 1;
}
Expand Down Expand Up @@ -2572,7 +2572,7 @@ static void operateweapon(int snum, ESyncBits actions)
case TRIPBOMB_WEAPON: // Claymore in NAM
if (p->kickback_pic < 4)
{
p->__int_pos.Z = p->player_int_opos().Z;
p->player_set_int_z(p->player_int_opos().Z);
p->vel.Z = 0;
if (p->kickback_pic == 3)
fi.shoot(pact, HANDHOLDINGLASER);
Expand Down Expand Up @@ -3035,7 +3035,7 @@ void processinput_d(int snum)
clipmove(p->__int_pos, &p->cursector, p->vel.X, p->vel.Y, 164, (4 << 8), ii, CLIPMASK0, clip);

if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk)
p->__int_pos.Z += 32 << 8;
p->player_add_int_z(32 << 8);

if (clip.type != kHitNone)
checkplayerhurt_d(p, clip);
Expand Down

0 comments on commit a0e84d8

Please sign in to comment.