Skip to content

Commit

Permalink
- floatified player_struct::truecz/truefz.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 9, 2022
1 parent 5c45535 commit f0788fa
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
20 changes: 10 additions & 10 deletions source/games/duke/src/actors.cpp
Expand Up @@ -3826,10 +3826,10 @@ void handle_se17(DDukeActor* actor)
auto sc = actor->sector();
int sh = actor->spr.hitag;

int q = actor->temp_data[0] * (actor->spr.yvel << 2);
double q = actor->temp_data[0] * actor->spr.yvel * (2 * zinttoworld);

sc->add_int_ceilingz(q);
sc->add_int_floorz(q);
sc->ceilingz += q;
sc->floorz += q;

DukeSectIterator it(actor->sector());
while (auto act1 = it.Next())
Expand All @@ -3838,15 +3838,15 @@ void handle_se17(DDukeActor* actor)
{
int p = act1->spr.yvel;
if (numplayers < 2) ps[p].opos.Z = ps[p].pos.Z;
ps[p].pos.Z += q;
ps[p].__int_truefz += q;
ps[p].__int_truecz += q;
ps[p].pos.Z += q * zworldtoint;
ps[p].truefz += q;
ps[p].truecz += q;
if (numplayers > 1) ps[p].opos.Z = ps[p].pos.Z;
}
if (act1->spr.statnum != STAT_EFFECTOR)
{
act1->backupz();
act1->add_int_z(q);
act1->spr.pos.Z += q;
}

act1->floorz = sc->floorz;
Expand Down Expand Up @@ -3900,8 +3900,8 @@ void handle_se17(DDukeActor* actor)
ps[p].bobpos.Y = ps[p].opos.Y = ps[p].pos.Y;
ps[p].opos.Z = ps[p].pos.Z;

ps[p].__int_truefz = act3->actor_int_floorz();
ps[p].__int_truecz = act3->actor_int_ceilingz();
ps[p].truefz = act3->floorz;
ps[p].truecz = act3->ceilingz;
ps[p].bobcounter = 0;

ChangeActorSect(act3, act2->sector());
Expand Down Expand Up @@ -4420,7 +4420,7 @@ void handle_se24(DDukeActor *actor, bool scroll, int shift)
{
if (ps[p].cursector == actor->sector() && ps[p].on_ground)
{
if (abs(ps[p].pos.Z - ps[p].__int_truefz) < gs.playerheight + (9 << 8))
if (abs(ps[p].pos.Z - ps[p].truefz * zworldtoint) < gs.playerheight + (9 << 8))
{
ps[p].fric.X += x << 3;
ps[p].fric.Y += y << 3;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/game_misc.cpp
Expand Up @@ -577,7 +577,7 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, int
else
i = TILE_APLAYERTOP;

j = abs(pp.__int_truefz - pp.pos.Z) >> 8;
j = abs(int(pp.truefz * zworldtoint) - pp.pos.Z) >> 8;
j = czoom * (act->spr.yrepeat + j);

if (j < 22000) j = 22000;
Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/gameexec.cpp
Expand Up @@ -423,13 +423,13 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;

case PLAYER_TRUEFZ:
if (bSet) ps[iPlayer].__int_truefz = lValue;
else SetGameVarID(lVar2, ps[iPlayer].__int_truefz, sActor, sPlayer);
if (bSet) ps[iPlayer].truefz = lValue * zmaptoworld;
else SetGameVarID(lVar2, ps[iPlayer].truefz * (1/zmaptoworld), sActor, sPlayer);
break;

case PLAYER_TRUECZ:
if (bSet) ps[iPlayer].__int_truecz = lValue;
else SetGameVarID(lVar2, ps[iPlayer].__int_truecz, sActor, sPlayer);
if (bSet) ps[iPlayer].truecz = lValue * zmaptoworld;
else SetGameVarID(lVar2, ps[iPlayer].truecz * (1 / zmaptoworld), sActor, sPlayer);
break;

case PLAYER_PLAYER_PAR:
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -2740,8 +2740,8 @@ void processinput_d(int snum)

j = getflorzofslopeptr(psectp, p->pos.X, p->pos.Y);

p->__int_truefz = j;
p->__int_truecz = getceilzofslopeptr(psectp, p->pos.X, p->pos.Y);
p->truefz = j * zinttoworld;
p->truecz = getceilzofslopeptr(psectp, p->pos.X, p->pos.Y) * zinttoworld;

truefdist = abs(p->pos.Z - j);
if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8))
Expand All @@ -2761,7 +2761,7 @@ void processinput_d(int snum)
if (chz.actor()->spr.statnum == 1 && chz.actor()->spr.extra >= 0)
{
chz.setNone();
cz = p->__int_truecz;
cz = p->truecz * zworldtoint;
}
}

Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -3410,8 +3410,8 @@ void processinput_r(int snum)
tempfz = getflorzofslopeptr(psectp, p->pos.X, p->pos.Y);
}

p->__int_truefz = tempfz;
p->__int_truecz = getceilzofslopeptr(psectp, p->pos.X, p->pos.Y);
p->truefz = tempfz * zinttoworld;
p->truecz = getceilzofslopeptr(psectp, p->pos.X, p->pos.Y) * zinttoworld;

truefdist = abs(p->pos.Z - tempfz);
if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + (16 << 8))
Expand All @@ -3431,7 +3431,7 @@ void processinput_r(int snum)
if (chz.actor()->spr.statnum == 1 && chz.actor()->spr.extra >= 0)
{
chz.setNone();
cz = p->__int_truecz;
cz = p->truecz * zworldtoint;
}
else if (chz.actor()->spr.picnum == LADDER)
{
Expand All @@ -3441,7 +3441,7 @@ void processinput_r(int snum)
if ((actions & SB_JUMP) && !p->OnMotorcycle)
{
chz.setNone();
cz = p->__int_truecz;
cz = p->truecz * zworldtoint;
}
}
else
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/render.cpp
Expand Up @@ -368,8 +368,8 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)

else if (p->spritebridge == 0 && p->newOwner == nullptr)
{
if (cposz < (p->__int_truecz + (4 << 8))) cposz = cz + (4 << 8);
else if (cposz > (p->__int_truefz - (4 << 8))) cposz = fz - (4 << 8);
if (cposz < (p->truecz * zworldtoint + (4 << 8))) cposz = cz + (4 << 8);
else if (cposz > (p->truefz * zworldtoint - (4 << 8))) cposz = fz - (4 << 8);
}

if (sect)
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/savegame.cpp
Expand Up @@ -128,8 +128,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
("posyv", w.vel.Y)
("poszv", w.vel.Z)
("last_pissed_time", w.last_pissed_time)
("truefz", w.__int_truefz)
("truecz", w.__int_truecz)
("truefz", w.truefz)
("truecz", w.truecz)
("player_par", w.player_par)
("visibility", w.visibility)
("bobcounter", w.bobcounter)
Expand Down
3 changes: 2 additions & 1 deletion source/games/duke/src/types.h
Expand Up @@ -238,13 +238,14 @@ struct player_struct
int numloogs, oloogcnt, loogcnt;
int invdisptime;
int pyoff, opyoff;
int last_pissed_time, __int_truefz, __int_truecz;
int last_pissed_time;
int player_par, visibility;
int bobcounter;
int randomflamex, crack_time;

int aim_mode, ftt;

double truefz, truecz;
sectortype* cursector;
sectortype* one_parallax_sectnum; // wall + sector references. Make them pointers later?
walltype* access_wall;
Expand Down
3 changes: 2 additions & 1 deletion wadsrc/static/zscript/games/duke/dukegame.zs
Expand Up @@ -160,7 +160,8 @@ struct DukePlayer
native int numloogs, loogcnt;
native int invdisptime;
native int pyoff, opyoff;
native int last_pissed_time, truefz, truecz;
native int last_pissed_time;
native double truefz, truecz;
native int player_par, visibility;
native int bobcounter;
native int randomflamex, crack_time;
Expand Down

0 comments on commit f0788fa

Please sign in to comment.