Skip to content

Commit

Permalink
- more floatification cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 9, 2022
1 parent 8899ed3 commit d04117d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
24 changes: 10 additions & 14 deletions source/games/duke/src/actors.cpp
Expand Up @@ -398,7 +398,7 @@ void moveplayers(void)
{
if (p->newOwner != nullptr) //Looking thru the camera
{
act->set_int_pos({ p->player_int_opos().X, p->player_int_opos().Y, p->player_int_opos().Z + gs.int_playerheight });
act->spr.pos = p->opos.plusZ(gs.playerheight);
act->backupz();
act->spr.ang = p->angle.oang.asbuild();
SetActor(act, act->int_pos());
Expand Down Expand Up @@ -5202,7 +5202,7 @@ void recordoldspritepos()

void movefta(void)
{
int x, px, py, sx, sy;
int x;
int canseeme, p;
sectortype* psect, * ssect;

Expand All @@ -5229,20 +5229,16 @@ void movefta(void)
{
if (badguy(act))
{
px = ps[p].player_int_opos().X + 64 - (krand() & 127);
py = ps[p].player_int_opos().Y + 64 - (krand() & 127);
updatesector(px, py, &psect);
double px = ps[p].opos.X + (64 - (krand() & 127)) * maptoworld;
double py = ps[p].opos.Y + (64 - (krand() & 127)) * maptoworld;
updatesector(DVector3(px, py, 0), &psect);
if (psect == nullptr)
{
continue;
}
sx = act->int_pos().X + 64 - (krand() & 127);
sy = act->int_pos().Y + 64 - (krand() & 127);
updatesector(px, py, &ssect);
if (ssect == nullptr)
{
continue;
}
double sx = act->spr.pos.X + (64 - (krand() & 127)) * maptoworld;
double sy = act->spr.pos.Y + (64 - (krand() & 127)) * maptoworld;
// The second updatesector call here used px and py again and was redundant as coded.

// SFLAG_MOVEFTA_CHECKSEE is set for all actors in Duke.
if (act->spr.pal == 33 || actorflag(act, SFLAG_MOVEFTA_CHECKSEE) ||
Expand All @@ -5251,14 +5247,14 @@ void movefta(void)
{
int r1 = krand();
int r2 = krand();
canseeme = cansee(sx, sy, act->int_pos().Z - (r2 % (52 << 8)), act->sector(), px, py, ps[p].player_int_opos().Z - (r1 % (32 << 8)), ps[p].cursector);
canseeme = cansee({ sx, sy, act->spr.pos.Z - (r2 % (52 << 8)) * maptoworld }, act->sector(), { px, py, ps[p].opos.Z - (r1 % (32 << 8)) * maptoworld }, ps[p].cursector);
}
}
else
{
int r1 = krand();
int r2 = krand();
canseeme = cansee(act->int_pos().X, act->int_pos().Y, act->int_pos().Z - ((r2 & 31) << 8), act->sector(), ps[p].player_int_opos().X, ps[p].player_int_opos().Y, ps[p].player_int_opos().Z - ((r1 & 31) << 8), ps[p].cursector);
canseeme = cansee(act->spr.pos.plusZ(-(r2 & 31)), act->sector(), ps[p].opos.plusZ(-(r1 & 31)), ps[p].cursector);
}


Expand Down
34 changes: 16 additions & 18 deletions source/games/duke/src/actors_r.cpp
Expand Up @@ -1471,7 +1471,7 @@ void movetransports_r(void)
}
else break;

if (onfloorz == 0 && abs(act->int_pos().Z - ps[p].player_int_pos().Z) < 6144)
if (onfloorz == 0 && fabs(act->spr.pos.Z - ps[p].pos.Z) < 24)
if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) ||
(ps[p].jetpack_on && PlayerInput(p, SB_CROUCH)))
{
Expand All @@ -1494,14 +1494,14 @@ void movetransports_r(void)

if (isRRRA())
{
if (onfloorz && sectlotag == 160 && ps[p].player_int_pos().Z > (sectp->int_floorz() - (48 << 8)))
if (onfloorz && sectlotag == 160 && ps[p].pos.Z > sectp->floorz - 48)
{
k = 2;
ps[p].pos.Z = Owner->sector()->ceilingz + 7;
ps[p].backupz();
}

if (onfloorz && sectlotag == 161 && ps[p].player_int_pos().Z < (sectp->int_ceilingz() + (6 << 8)))
if (onfloorz && sectlotag == 161 && ps[p].pos.Z < sectp->ceilingz + 6)
{
k = 2;
if (ps[p].GetActor()->spr.extra <= 0) break;
Expand All @@ -1510,7 +1510,7 @@ void movetransports_r(void)
}
}

if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].player_int_pos().Z > (sectp->int_floorz() - (6 << 8))) ||
if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].pos.Z > sectp->floorz - 6) ||
(onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].OnMotorcycle))
{
if (ps[p].OnBoat) break;
Expand All @@ -1526,7 +1526,7 @@ void movetransports_r(void)
ps[p].moto_underwater = 1;
}

if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].player_int_pos().Z < (sectp->int_ceilingz() + (6 << 8)))
if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].pos.Z > sectp->floorz + 6)
{
k = 1;
if (ps[p].GetActor()->spr.extra <= 0) break;
Expand Down Expand Up @@ -2498,7 +2498,7 @@ static void heavyhbomb(DDukeActor *actor)
}
}
else if (actor->spr.picnum == HEAVYHBOMB && x < 788 && actor->temp_data[0] > 7 && actor->spr.xvel == 0)
if (cansee(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (8 << 8), actor->sector(), ps[p].player_int_pos().X, ps[p].player_int_pos().Y, ps[p].player_int_pos().Z, ps[p].cursector))
if (cansee(actor->spr.pos.plusZ(-8), actor->sector(), ps[p].pos, ps[p].cursector))
if (ps[p].ammo_amount[DYNAMITE_WEAPON] < gs.max_ammo_amount[DYNAMITE_WEAPON])
if (actor->spr.pal == 0)
{
Expand Down Expand Up @@ -3492,8 +3492,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & face_player)
{
if (ps[pnum].newOwner != nullptr)
goalang = getangle(ps[pnum].player_int_opos().X - actor->int_pos().X, ps[pnum].player_int_opos().Y - actor->int_pos().Y);
else goalang = getangle(ps[pnum].player_int_pos().X - actor->int_pos().X, ps[pnum].player_int_pos().Y - actor->int_pos().Y);
goalang = getangle(ps[pnum].opos.XY() - actor->spr.pos.XY());
else goalang = getangle(ps[pnum].pos.XY() - actor->spr.pos.XY());
angdif = getincangle(actor->spr.ang, goalang) >> 2;
if (angdif > -8 && angdif < 0) angdif = 0;
actor->spr.ang += angdif;
Expand All @@ -3505,8 +3505,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & face_player_slow)
{
if (ps[pnum].newOwner != nullptr)
goalang = getangle(ps[pnum].player_int_opos().X - actor->int_pos().X, ps[pnum].player_int_opos().Y - actor->int_pos().Y);
else goalang = getangle(ps[pnum].player_int_pos().X - actor->int_pos().X, ps[pnum].player_int_pos().Y - actor->int_pos().Y);
goalang = getangle(ps[pnum].opos.XY() - actor->spr.pos.XY());
else goalang = getangle(ps[pnum].pos.XY() - actor->spr.pos.XY());
angdif = Sgn(getincangle(actor->spr.ang, goalang)) << 5;
if (angdif > -32 && angdif < 0)
{
Expand All @@ -3521,8 +3521,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & antifaceplayerslow)
{
if (ps[pnum].newOwner != nullptr)
goalang = (getangle(ps[pnum].player_int_opos().X - actor->int_pos().X, ps[pnum].player_int_opos().Y - actor->int_pos().Y) + 1024) & 2047;
else goalang = (getangle(ps[pnum].player_int_pos().X - actor->int_pos().X, ps[pnum].player_int_pos().Y - actor->int_pos().Y) + 1024) & 2047;
goalang = (getangle(ps[pnum].opos.XY() - actor->spr.pos.XY()) + 1024) & 2047;
else goalang = (getangle(ps[pnum].pos.XY() - actor->spr.pos.XY()) + 1024) & 2047;
angdif = Sgn(getincangle(actor->spr.ang, goalang)) << 5;
if (angdif > -32 && angdif < 0)
{
Expand Down Expand Up @@ -3586,11 +3586,9 @@ void move_r(DDukeActor *actor, int pnum, int xvel)

if (a & face_player_smart)
{
int newx, newy;

newx = ps[pnum].player_int_pos().X + (ps[pnum].vel.X / 768);
newy = ps[pnum].player_int_pos().Y + (ps[pnum].vel.Y / 768);
goalang = getangle(newx - actor->int_pos().X, newy - actor->int_pos().Y);
double newx = ps[pnum].pos.X + (ps[pnum].vel.X / 768) * inttoworld;
double newy = ps[pnum].pos.Y + (ps[pnum].vel.Y / 768) * inttoworld;
goalang = getangle(newx - actor->spr.pos.X, newy - actor->spr.pos.Y);
angdif = getincangle(actor->spr.ang, goalang) >> 2;
if (angdif > -8 && angdif < 0) angdif = 0;
actor->spr.ang += angdif;
Expand Down Expand Up @@ -3689,7 +3687,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{

daxvel = -(1024 - xvel);
angdif = getangle(ps[pnum].player_int_pos().X - actor->int_pos().X, ps[pnum].player_int_pos().Y - actor->int_pos().Y);
angdif = getangle(ps[pnum].pos.XY() - actor->spr.pos.XY());

if (xvel < 512)
{
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/game_misc.cpp
Expand Up @@ -60,8 +60,8 @@ FString GameInterface::GetCoordString()
int snum = screenpeek;
FString out;

out.Format("pos= %d, %d, %d - angle = %2.3f - sector = %d, lotag = %d, hitag = %d",
ps[snum].player_int_pos().X, ps[snum].player_int_pos().Y, ps[snum].player_int_pos().Z, ps[snum].angle.ang.asdeg(), sectnum(ps[snum].cursector),
out.Format("pos= %2.3f, %2.3f, %2.3f - angle = %2.3f - sector = %d, lotag = %d, hitag = %d",
ps[snum].pos.X, ps[snum].pos.Y, ps[snum].pos.Z, ps[snum].angle.ang.asdeg(), sectnum(ps[snum].cursector),
ps[snum].cursector->lotag, ps[snum].cursector->hitag);

return out;
Expand Down Expand Up @@ -577,7 +577,7 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, int
else
i = TILE_APLAYERTOP;

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

if (j < 22000) j = 22000;
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/prediction.cpp
Expand Up @@ -50,9 +50,9 @@ short myangbak[MOVEFIFOSIZ];

void resetmys()
{
myx = omyx = ps[myconnectindex].player_int_pos().X;
myy = omyy = ps[myconnectindex].player_int_pos().Y;
myz = omyz = ps[myconnectindex].player_int_pos().Z;
myx = omyx = ps[myconnectindex].pos.X;
myy = omyy = ps[myconnectindex].pos.Y;
myz = omyz = ps[myconnectindex].pos.Z;
myxvel = myyvel = myzvel = 0;
myang = ps[myconnectindex].angle.ang;
myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz;
Expand Down

0 comments on commit d04117d

Please sign in to comment.