Skip to content

Commit

Permalink
- added a float version of gs.playerheight.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 9, 2022
1 parent 8b8e0d8 commit ebefa42
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 35 deletions.
6 changes: 3 additions & 3 deletions source/games/duke/src/actors.cpp
Expand Up @@ -397,7 +397,7 @@ void moveplayers(void)
{
if (p->newOwner != nullptr) //Looking thru the camera
{
act->set_int_pos({ p->__int_opos.X, p->__int_opos.Y, p->__int_opos.Z + gs.playerheight });
act->set_int_pos({ p->__int_opos.X, p->__int_opos.Y, p->__int_opos.Z + gs.int_playerheight });
act->backupz();
act->spr.ang = p->angle.oang.asbuild();
SetActor(act, act->int_pos());
Expand Down Expand Up @@ -4187,7 +4187,7 @@ void handle_se20(DDukeActor* actor)
ps[p].__int_opos.X = ps[p].__int_pos.X;
ps[p].__int_opos.Y = ps[p].__int_pos.Y;

SetActor(ps[p].GetActor(), { ps[p].__int_pos.X, ps[p].__int_pos.Y, ps[p].__int_pos.Z + gs.playerheight });
SetActor(ps[p].GetActor(), { ps[p].__int_pos.X, ps[p].__int_pos.Y, ps[p].__int_pos.Z + gs.int_playerheight });
}

sc->addfloorxpan(-x / 8.f);
Expand Down Expand Up @@ -4418,7 +4418,7 @@ void handle_se24(DDukeActor *actor, bool scroll, int shift)
{
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
{
if (abs(ps[p].__int_pos.Z - ps[p].truefz * zworldtoint) < gs.playerheight + (9 << 8))
if (abs(ps[p].__int_pos.Z - ps[p].truefz * zworldtoint) < gs.int_playerheight + (9 << 8))
{
ps[p].fric.X += x << 3;
ps[p].fric.Y += y << 3;
Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/actors_d.cpp
Expand Up @@ -343,9 +343,9 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
continue;
}

if (act2->spr.picnum == APLAYER) act2->add_int_z(-gs.playerheight);
if (act2->spr.picnum == APLAYER) act2->spr.pos.Z -= gs.playerheight;
int d = dist(actor, act2);
if (act2->spr.picnum == APLAYER) act2->add_int_z(gs.playerheight);
if (act2->spr.picnum == APLAYER) act2->spr.pos.Z += gs.playerheight;

if (d < r && cansee(act2->int_pos().X, act2->int_pos().Y, act2->int_pos().Z - (8 << 8), act2->sector(), actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (12 << 8), actor->sector()))
{
Expand Down Expand Up @@ -1808,7 +1808,7 @@ void movetransports_d(void)

ps[p].bobpos.X = ps[p].__int_opos.X = ps[p].__int_pos.X = Owner->int_pos().X;
ps[p].bobpos.Y = ps[p].__int_opos.Y = ps[p].__int_pos.Y = Owner->int_pos().Y;
ps[p].__int_opos.Z = ps[p].__int_pos.Z = Owner->int_pos().Z - gs.playerheight;
ps[p].__int_opos.Z = ps[p].__int_pos.Z = Owner->int_pos().Z - gs.int_playerheight;

ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
Expand Down Expand Up @@ -1892,7 +1892,7 @@ void movetransports_d(void)
ps[p].setCursector(Owner->sector());

ChangeActorSect(act2, Owner->sector());
SetActor(ps[p].GetActor(), { ps[p].__int_pos.X, ps[p].__int_pos.Y, ps[p].__int_pos.Z + gs.playerheight });
SetActor(ps[p].GetActor(), { ps[p].__int_pos.X, ps[p].__int_pos.Y, ps[p].__int_pos.Z + gs.int_playerheight });

if ((krand() & 255) < 32)
spawn(act2, WATERSPLASH2);
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/actors_r.cpp
Expand Up @@ -290,9 +290,9 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
continue;
}

if (act2->spr.picnum == APLAYER) act2->add_int_z(-gs.playerheight);
if (act2->spr.picnum == APLAYER) act2->spr.pos.Z -= gs.playerheight;
int d = dist(actor, act2);
if (act2->spr.picnum == APLAYER) act2->add_int_z(gs.playerheight);
if (act2->spr.picnum == APLAYER) act2->spr.pos.Z += gs.playerheight;

if (d < r && cansee(act2->int_pos().X, act2->int_pos().Y, act2->int_pos().Z - (8 << 8), act2->sector(), actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (12 << 8), actor->sector()))
{
Expand Down Expand Up @@ -1458,7 +1458,7 @@ void movetransports_r(void)

ps[p].bobpos.X = ps[p].__int_opos.X = ps[p].__int_pos.X = Owner->int_pos().X;
ps[p].bobpos.Y = ps[p].__int_opos.Y = ps[p].__int_pos.Y = Owner->int_pos().Y;
ps[p].__int_opos.Z = ps[p].__int_pos.Z = Owner->int_pos().Z - (gs.playerheight - (4 << 8));
ps[p].__int_opos.Z = ps[p].__int_pos.Z = Owner->int_pos().Z - (gs.int_playerheight - (4 << 8));

ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector());
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/animatesprites_d.cpp
Expand Up @@ -168,7 +168,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
t->add_int_x(-MulScale(MaxSmoothRatio - smoothratio, ps[h->spr.yvel].__int_pos.X - ps[h->spr.yvel].__int_opos.X, 16));
t->add_int_y(-MulScale(MaxSmoothRatio - smoothratio, ps[h->spr.yvel].__int_pos.Y - ps[h->spr.yvel].__int_opos.Y, 16));
t->set_int_z(interpolatedvalue(ps[h->spr.yvel].__int_opos.Z, ps[h->spr.yvel].__int_pos.Z, smoothratio));
t->add_int_z(gs.playerheight);
t->pos.Z += gs.playerheight;
}
else if (!actorflag(h, SFLAG_NOINTERPOLATE))
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/animatesprites_r.cpp
Expand Up @@ -148,7 +148,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
t->add_int_x(-MulScale(MaxSmoothRatio - smoothratio, ps[h->spr.yvel].__int_pos.X - ps[h->spr.yvel].__int_opos.X, 16));
t->add_int_y(-MulScale(MaxSmoothRatio - smoothratio, ps[h->spr.yvel].__int_pos.Y - ps[h->spr.yvel].__int_opos.Y, 16));
t->set_int_z(interpolatedvalue(ps[h->spr.yvel].__int_opos.Z, ps[h->spr.yvel].__int_pos.Z, smoothratio));
t->add_int_z(gs.playerheight);
t->pos.Z += gs.playerheight;
h->spr.xrepeat = 24;
h->spr.yrepeat = 17;
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/constants.h
Expand Up @@ -419,8 +419,8 @@ enum miscConstants

MOVEFIFOSIZ =256,
AUTO_AIM_ANGLE =48,
PHEIGHT_DUKE =(38<<8),
PHEIGHT_RR =(40<<8),
PHEIGHT_DUKE =38,
PHEIGHT_RR =40,

MAXMINECARTS = 16,
MAXJAILDOORS = 32,
Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/flags_r.cpp
Expand Up @@ -323,6 +323,7 @@ void initactorflags_r()
TILE_BIGORBIT1 = BIGORBIT1;
TILE_EGG = EGG;

gs.int_playerheight = PHEIGHT_RR << 8;
gs.playerheight = PHEIGHT_RR;
}

Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/gamedef.cpp
Expand Up @@ -3187,6 +3187,7 @@ void loadcons()
gs.shrinkerblastradius = 650;
gs.gravity = 176;
gs.tripbombblastradius = 3880;
gs.int_playerheight = PHEIGHT_DUKE << 8;
gs.playerheight = PHEIGHT_DUKE;
gs.displayflags = DUKE3D_NO_WIDESCREEN_PINNING;

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -2229,7 +2229,7 @@ int ParseState::parse(void)
g_ac->set_int_pos({ ps[g_p].bobpos.X = ps[g_p].__int_opos.X = ps[g_p].__int_pos.X, ps[g_p].bobpos.Y = ps[g_p].__int_opos.Y = ps[g_p].__int_pos.Y, ps[g_p].__int_opos.Z = ps[g_p].__int_pos.Z });
g_ac->backuppos();
updatesector(ps[g_p].__int_pos.X, ps[g_p].__int_pos.Y, &ps[g_p].cursector);
SetActor(ps[g_p].GetActor(), { ps[g_p].__int_pos.X, ps[g_p].__int_pos.Y, ps[g_p].__int_pos.Z + gs.playerheight });
SetActor(ps[g_p].GetActor(), { ps[g_p].__int_pos.X, ps[g_p].__int_pos.Y, ps[g_p].__int_pos.Z + gs.int_playerheight });
g_ac->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;

g_ac->spr.shade = -12;
Expand Down
3 changes: 2 additions & 1 deletion source/games/duke/src/global.h
Expand Up @@ -39,7 +39,8 @@ struct DukeGameInfo
ActorInfo actorinfo[MAXTILES];
int16_t max_ammo_amount[MAX_WEAPONS];
int16_t weaponsandammosprites[15];
int playerheight;
int int_playerheight;
double playerheight;
int displayflags;
};

Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/player.cpp
Expand Up @@ -171,7 +171,7 @@ int hits(DDukeActor* actor)
int zoff;
HitInfo hit{};

if (actor->isPlayer()) zoff = gs.playerheight;
if (actor->isPlayer()) zoff = gs.int_playerheight;
else zoff = 0;

auto pos = actor->int_pos();
Expand All @@ -192,7 +192,7 @@ int hitasprite(DDukeActor* actor, DDukeActor** hitsp)

if (badguy(actor))
zoff = (42 << 8);
else if (actor->spr.picnum == TILE_APLAYER) zoff = gs.playerheight;
else if (actor->spr.picnum == TILE_APLAYER) zoff = gs.int_playerheight;
else zoff = 0;

auto pos = actor->int_pos();
Expand Down Expand Up @@ -608,7 +608,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
{
if (p->on_warping_sector == 0)
{
if (abs(p->__int_pos.Z - fz) > (gs.playerheight >> 1))
if (abs(p->__int_pos.Z - fz) > (gs.int_playerheight >> 1))
p->__int_pos.Z += 348;
}
else
Expand Down
12 changes: 6 additions & 6 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -1763,7 +1763,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
}
else i = 12;

if (shrunk == 0 && truefdist <= gs.playerheight)
if (shrunk == 0 && truefdist <= gs.int_playerheight)
{
if (p->on_ground == 1)
{
Expand Down Expand Up @@ -2744,7 +2744,7 @@ void processinput_d(int snum)
p->truecz = getceilzofslopeptr(psectp, p->__int_pos.X, p->__int_pos.Y) * zinttoworld;

truefdist = abs(p->__int_pos.Z - j);
if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8))
if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.int_playerheight + (16 << 8))
psectlotag = 0;

pact->floorz = fz * zinttoworld;
Expand Down Expand Up @@ -2920,7 +2920,7 @@ void processinput_d(int snum)

k = 0;

if (p->on_ground && truefdist <= gs.playerheight + (16 << 8))
if (p->on_ground && truefdist <= gs.int_playerheight + (16 << 8))
{
int whichsound = (gs.tileinfo[j].flags & TFLAG_ELECTRIC) ? 0 : j == FLOORSLIME ? 1 : j == FLOORPLASMA ? 2 : -1;
if (j >= 0) k = makepainsounds(snum, whichsound);
Expand All @@ -2941,7 +2941,7 @@ void processinput_d(int snum)

k = bsin(p->bobcounter, -12);

if (truefdist < gs.playerheight + (8 << 8) && (k == 1 || k == 3))
if (truefdist < gs.int_playerheight + (8 << 8) && (k == 1 || k == 3))
{
if (p->spritebridge == 0 && p->walking_snd_toggle == 0 && p->on_ground)
{
Expand Down Expand Up @@ -3056,7 +3056,7 @@ void processinput_d(int snum)
}

// RBG***
SetActor(pact, { p->__int_pos.X, p->__int_pos.Y, p->__int_pos.Z + gs.playerheight });
SetActor(pact, { p->__int_pos.X, p->__int_pos.Y, p->__int_pos.Z + gs.int_playerheight });

if (psectlotag < 3)
{
Expand All @@ -3072,7 +3072,7 @@ void processinput_d(int snum)
}
}

if (truefdist < gs.playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector->lotag == 1)
if (truefdist < gs.int_playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector->lotag == 1)
if (!S_CheckActorSoundPlaying(pact, DUKE_ONWATER))
S_PlayActorSound(DUKE_ONWATER, pact);

Expand Down
12 changes: 6 additions & 6 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -2084,7 +2084,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int
}
else i = 12;

if (shrunk == 0 && truefdist <= gs.playerheight)
if (shrunk == 0 && truefdist <= gs.int_playerheight)
{
if (p->on_ground == 1)
{
Expand Down Expand Up @@ -3414,7 +3414,7 @@ void processinput_r(int snum)
p->truecz = getceilzofslopeptr(psectp, p->__int_pos.X, p->__int_pos.Y) * zinttoworld;

truefdist = abs(p->__int_pos.Z - tempfz);
if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8))
if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.int_playerheight + (16 << 8))
psectlotag = 0;

pact->floorz = fz * zinttoworld;
Expand Down Expand Up @@ -3642,7 +3642,7 @@ void processinput_r(int snum)
int j = pact->sector()->floorpicnum;
k = 0;

if (p->on_ground && truefdist <= gs.playerheight + (16 << 8))
if (p->on_ground && truefdist <= gs.int_playerheight + (16 << 8))
{
int whichsound = (gs.tileinfo[j].flags & TFLAG_ELECTRIC) ? 0 : j == FLOORSLIME ? 1 : j == FLOORPLASMA ? 2 :
(isRRRA() && (j == RRTILE7768 || j == RRTILE7820) ? 3 : -1);
Expand Down Expand Up @@ -3679,7 +3679,7 @@ void processinput_r(int snum)
p->NotOnWater = 1;
}

if (truefdist < gs.playerheight + (8 << 8) && (k == 1 || k == 3))
if (truefdist < gs.int_playerheight + (8 << 8) && (k == 1 || k == 3))
{
if (p->spritebridge == 0 && p->walking_snd_toggle == 0 && p->on_ground)
{
Expand Down Expand Up @@ -3898,7 +3898,7 @@ void processinput_r(int snum)
}

// RBG***
SetActor(pact, { p->__int_pos.X, p->__int_pos.Y, p->__int_pos.Z + gs.playerheight });
SetActor(pact, { p->__int_pos.X, p->__int_pos.Y, p->__int_pos.Z + gs.int_playerheight });

if (psectlotag == 800 && (!isRRRA() || !p->lotag800kill))
{
Expand All @@ -3921,7 +3921,7 @@ void processinput_r(int snum)
}
}

if (truefdist < gs.playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector->lotag == 1)
if (truefdist < gs.int_playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector->lotag == 1)
if (!S_CheckActorSoundPlaying(pact, DUKE_ONWATER))
if (!isRRRA() || (!p->OnBoat && !p->OnMotorcycle && p->cursector->hitag != 321))
S_PlayActorSound(DUKE_ONWATER, pact);
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/spawn.cpp
Expand Up @@ -301,7 +301,7 @@ void spawntransporter(DDukeActor *actj, DDukeActor* act, bool beam)
{
act->spr.xrepeat = 31;
act->spr.yrepeat = 1;
act->set_int_z(actj->sector()->int_floorz() - gs.playerheight);
act->set_int_z(actj->sector()->int_floorz() - gs.int_playerheight);
}
else
{
Expand Down Expand Up @@ -439,7 +439,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell)
else
{
a = act->spr.ang;
act->set_int_z(actj->int_pos().Z - gs.playerheight + (3 << 8));
act->set_int_z(actj->int_pos().Z - gs.int_playerheight + (3 << 8));
}

act->set_int_xy(actj->int_pos().X + bcos(a, -7), actj->int_pos().Y + bsin(a, -7));
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/spawn_d.cpp
Expand Up @@ -202,7 +202,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case TONGUE:
if (actj)
act->spr.ang = actj->spr.ang;
act->add_int_z(-gs.playerheight);
act->add_int_z(-gs.int_playerheight);
act->spr.zvel = 256 - (krand() & 511);
act->spr.xvel = 64 - (krand() & 127);
ChangeActorStat(act, 4);
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/spawn_r.cpp
Expand Up @@ -284,7 +284,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
case TONGUE:
if (actj)
act->spr.ang = actj->spr.ang;
act->add_int_z(-gs.playerheight);
act->add_int_z(-gs.int_playerheight);
act->spr.zvel = 256 - (krand() & 511);
act->spr.xvel = 64 - (krand() & 127);
ChangeActorStat(act, 4);
Expand Down

0 comments on commit ebefa42

Please sign in to comment.