Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- cleanup, part 3.
  • Loading branch information
coelckers committed Aug 9, 2022
1 parent 27fe199 commit c09b9f7
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 36 deletions.
3 changes: 1 addition & 2 deletions source/games/duke/src/ccmds.cpp
Expand Up @@ -115,8 +115,7 @@ void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz)
{
player_struct* p = &ps[myconnectindex];

p->player_set_int_xy({ x, y});
p->player_set_int_z(z);
p->pos = DVector3(x, y, z);
p->backupxyz();

if (ang != INT_MIN)
Expand Down
9 changes: 4 additions & 5 deletions source/games/duke/src/gameexec.cpp
Expand Up @@ -1981,8 +1981,7 @@ int ParseState::parse(void)
break;
case concmd_larrybird:
insptr++;
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);
ps[g_p].GetActor()->spr.pos.Z = ps[g_p].pos.Z = ps[g_p].GetActor()->sector()->ceilingz;
break;
case concmd_destroyit:
insptr++;
Expand Down Expand Up @@ -2224,12 +2223,12 @@ int ParseState::parse(void)
{
// I am not convinced this is even remotely smart to be executed from here..
pickrandomspot(g_p);
g_ac->set_int_pos(ps[g_p].player_int_pos());
g_ac->spr.pos = ps[g_p].pos;
ps[g_p].backupxyz();
ps[g_p].setbobpos();
g_ac->backuppos();
updatesector(ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, &ps[g_p].cursector);
SetActor(ps[g_p].GetActor(), vec3_t( ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, ps[g_p].player_int_pos().Z + gs.int_playerheight ));
updatesector(ps[g_p].pos, &ps[g_p].cursector);
SetActor(ps[g_p].GetActor(), ps[g_p].pos.plusZ(gs.playerheight ));
g_ac->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;

g_ac->spr.shade = -12;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/inlines.h
Expand Up @@ -208,7 +208,7 @@ inline bool playrunning()
inline void doslopetilting(player_struct* p, double const scaleAdjust = 1)
{
bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE);
p->horizon.calcviewpitch(p->player_int_pos().vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust);
p->horizon.calcviewpitch(p->pos, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust);
}

//---------------------------------------------------------------------------
Expand Down
16 changes: 9 additions & 7 deletions source/games/duke/src/player.cpp
Expand Up @@ -560,8 +560,8 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
if (actor->spr.pal != 1)
{
SetPlayerPal(p, PalEntry(63, 63, 0, 0));
p->player_add_int_z(-(16 << 8));
actor->add_int_z(-(16 << 8));
p->pos.Z -= 16;
actor->spr.pos.Z -= 16;
}
#if 0
if (ud.recstat == 1 && ud.multimode < 2)
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->player_add_int_z(348);
p->pos.Z += 348/ 256.;
}
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->player_add_int_z((2048 + 768));
p->pos.Z += 8 + 3;
p->crack_time = CRACK_TIME;
}
}
Expand Down Expand Up @@ -765,14 +765,16 @@ void player_struct::backuppos(bool noclipping)
{
if (!noclipping)
{
backupxy();
opos.X = pos.X;
opos.Y = pos.Y;
}
else
{
restorexy();
pos.X = opos.X;
pos.Y = opos.Y;
}

backupz();
opos.Z = pos.Z;
bobpos.X = player_int_pos().X;
bobpos.Y = player_int_pos().Y;
opyoff = pyoff;
Expand Down
22 changes: 11 additions & 11 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -1667,7 +1667,6 @@ void checkweapons_d(struct player_struct* p)

static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, int cz, int shrunk)
{
int j;
auto p = &ps[snum];
auto pact = p->GetActor();
p->on_ground = 0;
Expand All @@ -1687,13 +1686,14 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
if (p->jetpack_on < 11)
{
p->jetpack_on++;
p->player_add_int_z(-(p->jetpack_on << 7)); //Goin up
p->pos.Z -= (p->jetpack_on * 0.5); //Goin up
}
else if (p->jetpack_on == 11 && !S_CheckActorSoundPlaying(pact, DUKE_JETPACK_IDLE))
S_PlayActorSound(DUKE_JETPACK_IDLE, pact);

if (shrunk) j = 512;
else j = 2048;
double dist;
if (shrunk) dist = 2;
else dist = 8;

if (actions & SB_JUMP) //A (soar high)
{
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->player_add_int_z(-j);
p->pos.Z -= dist;
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->player_add_int_z(j);
p->pos.Z += dist;
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->player_add_int_z(((fz - (k << 8)) - p->player_int_pos().Z) >> 1);
p->pos.Z += (((fz - (k << 8)) - p->player_int_pos().Z) >> 1) * zinttoworld;
if (p->player_int_pos().Z < (pact->actor_int_ceilingz() + (18 << 8)))
p->player_set_int_z(pact->actor_int_ceilingz() + (18 << 8));
p->pos.Z = pact->ceilingz + 18;

}

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->player_set_int_z(p->player_int_opos().Z);
p->pos.Z = p->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->player_set_int_z(p->player_int_opos().Z);
p->pos.Z = p->opos.Z;
p->vel.Z = 0;
if (p->kickback_pic == 3)
fi.shoot(pact, HANDHOLDINGLASER);
Expand Down Expand Up @@ -3034,7 +3034,7 @@ void processinput_d(int snum)
clipmove(p->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->player_add_int_z(32 << 8);
p->pos.Z += 32;

if (clip.type != kHitNone)
checkplayerhurt_d(p, clip);
Expand Down
8 changes: 5 additions & 3 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -3803,7 +3803,7 @@ void processinput_r(int snum)
clipmove(p->pos, &p->cursector, p->vel.X, p->vel.Y, 164, (4 << 8), i, CLIPMASK0, clip);

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

if (clip.type != kHitNone)
checkplayerhurt_r(p, clip);
Expand Down Expand Up @@ -4046,7 +4046,8 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite)
{
if (motosprite)
{
p->getxyfromactor(motosprite);
p->pos.X = motosprite->spr.pos.X;
p->pos.Y = motosprite->spr.pos.Y;
p->angle.ang = buildang(motosprite->spr.ang);
p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo;
deletesprite(motosprite);
Expand Down Expand Up @@ -4125,7 +4126,8 @@ void OnBoat(struct player_struct *p, DDukeActor* boat)
{
if (boat)
{
p->getxyfromactor(boat);
p->pos.X = boat->spr.pos.X;
p->pos.Y = boat->spr.pos.Y;
p->angle.ang = buildang(boat->spr.ang);
p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo;
deletesprite(boat);
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/player_w.cpp
Expand Up @@ -439,7 +439,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_STANDSTILL
&& p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1))
{
p->player_set_int_z(p->player_int_opos().Z);
p->pos.Z = p->opos.Z;
p->vel.Z = 0;
}
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum))
Expand Down
6 changes: 0 additions & 6 deletions source/games/duke/src/types.h
Expand Up @@ -372,12 +372,6 @@ struct player_struct
opos.Y = pos.Y;
}

void restorexy()
{
pos.X = opos.X;
pos.Y = opos.Y;
}

void backupz()
{
opos.Z = pos.Z;
Expand Down

0 comments on commit c09b9f7

Please sign in to comment.