- floatified player_struct::pos.

This commit is contained in:
Christoph Oelckers 2022-02-05 13:29:21 +01:00
parent 86076b2871
commit e878ecb511
10 changed files with 47 additions and 61 deletions

View file

@ -2850,8 +2850,8 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
{ {
if (po[p].os == actor->sector()) if (po[p].os == actor->sector())
{ {
po[p].opos.X += m; po[p].opos.X += m * inttoworld;
po[p].opos.Y += x; po[p].opos.Y += x * inttoworld;
} }
if (actor->sector() == psp->sector()) if (actor->sector() == psp->sector())
@ -3042,8 +3042,8 @@ void handle_se30(DDukeActor *actor, int JIBS6)
if (po[p].os == actor->sector()) if (po[p].os == actor->sector())
{ {
po[p].opos.X += l; po[p].opos.X += l * inttoworld;
po[p].opos.Y += x; po[p].opos.Y += x * inttoworld;
} }
} }

View file

@ -1837,7 +1837,7 @@ void movetransports_d(void)
ps[p].backupz(); ps[p].backupz();
auto pa = ps[p].GetActor(); auto pa = ps[p].GetActor();
pa->opos = DVector3(ps[p].__int_pos.X * inttoworld, ps[p].__int_pos.Y * inttoworld, ps[p].__int_pos.Z * zinttoworld); pa->opos = ps[p].pos;
ChangeActorSect(act2, Owner->sector()); ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(Owner->sector()); ps[p].setCursector(Owner->sector());

View file

@ -1522,12 +1522,12 @@ int ParseState::parse(void)
parseifelse(ifcanshoottarget(g_ac, g_p, g_x)); parseifelse(ifcanshoottarget(g_ac, g_p, g_x));
break; break;
case concmd_ifcanseetarget: case concmd_ifcanseetarget:
j = cansee(g_ac->int_pos().X, g_ac->int_pos().Y, g_ac->int_pos().Z - ((krand() & 41) << 8), g_ac->sector(), ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, ps[g_p].__int_pos.Z/*-((krand()&41)<<8)*/, ps[g_p].GetActor()->sector()); j = cansee(g_ac->spr.pos.plusZ(krand() & 41), g_ac->sector(), ps[g_p].pos, ps[g_p].GetActor()->sector());
parseifelse(j); parseifelse(j);
if (j) g_ac->timetosleep = SLEEPTIME; if (j) g_ac->timetosleep = SLEEPTIME;
break; break;
case concmd_ifnocover: case concmd_ifnocover:
j = cansee(g_ac->int_pos().X, g_ac->int_pos().Y, g_ac->int_pos().Z, g_ac->sector(), ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, ps[g_p].player_int_pos().Z, ps[g_p].GetActor()->sector()); j = cansee(g_ac->spr.pos, g_ac->sector(), ps[g_p].pos, ps[g_p].GetActor()->sector());
parseifelse(j); parseifelse(j);
if (j) g_ac->timetosleep = SLEEPTIME; if (j) g_ac->timetosleep = SLEEPTIME;
break; break;
@ -2792,7 +2792,7 @@ int ParseState::parse(void)
case concmd_pstomp: case concmd_pstomp:
insptr++; insptr++;
if( ps[g_p].knee_incs == 0 && ps[g_p].GetActor()->spr.xrepeat >= (isRR()? 9: 40) ) if( ps[g_p].knee_incs == 0 && ps[g_p].GetActor()->spr.xrepeat >= (isRR()? 9: 40) )
if( cansee(g_ac->int_pos().X,g_ac->int_pos().Y,g_ac->int_pos().Z-(4<<8),g_ac->sector(),ps[g_p].player_int_pos().X,ps[g_p].player_int_pos().Y,ps[g_p].__int_pos.Z+(16<<8),ps[g_p].GetActor()->sector()) ) if (cansee(g_ac->spr.pos.plusZ(-4), g_ac->sector(), ps[g_p].pos.plusZ(16), ps[g_p].GetActor()->sector()))
{ {
ps[g_p].knee_incs = 1; ps[g_p].knee_incs = 1;
if(ps[g_p].weapon_pos == 0) if(ps[g_p].weapon_pos == 0)

View file

@ -247,10 +247,4 @@ inline ESpriteFlags randomXFlip()
return CSTAT_SPRITE_XFLIP; return CSTAT_SPRITE_XFLIP;
} }
inline int pushmove_p(player_struct* actor, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
uint32_t const cliptype, bool clear = true)
{
return ::pushmove(&actor->__int_pos, sect, walldist, ceildist, flordist, cliptype, clear);
}
END_DUKE_NS END_DUKE_NS

View file

@ -622,7 +622,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
} }
Collision coll; Collision coll;
clipmove(p->__int_pos, &p->cursector, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll); clipmove(p->pos, &p->cursector, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll);
} }
backupplayer(p); backupplayer(p);
@ -631,7 +631,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
updatesector(p->player_int_pos().X, p->player_int_pos().Y, &p->cursector); updatesector(p->player_int_pos().X, p->player_int_pos().Y, &p->cursector);
pushmove_p(p, &p->cursector, 128L, (4 << 8), (20 << 8), CLIPMASK0); pushmove(p->pos, &p->cursector, 128L, (4 << 8), (20 << 8), CLIPMASK0);
if (fz > cz + (16 << 8) && actor->spr.pal != 1) if (fz > cz + (16 << 8) && actor->spr.pal != 1)
p->angle.rotscrnang = buildang(p->dead_flag + ((fz + p->player_int_pos().Z) >> 7)); p->angle.rotscrnang = buildang(p->dead_flag + ((fz + p->player_int_pos().Z) >> 7));

View file

@ -3031,7 +3031,7 @@ HORIZONLY:
ChangeActorSect(pact, p->cursector); ChangeActorSect(pact, p->cursector);
} }
else else
clipmove(p->__int_pos, &p->cursector, p->vel.X, p->vel.Y, 164, (4 << 8), ii, CLIPMASK0, clip); 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) if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk)
p->player_add_int_z(32 << 8); p->player_add_int_z(32 << 8);
@ -3082,7 +3082,7 @@ HORIZONLY:
while (ud.clipping == 0) while (ud.clipping == 0)
{ {
int blocked; int blocked;
blocked = (pushmove_p(p, &p->cursector, 164, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); blocked = (pushmove(p->pos, &p->cursector, 164, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked) if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked)
{ {
@ -3093,8 +3093,7 @@ HORIZONLY:
{ {
if (!retry++) if (!retry++)
{ {
p->opos = oldpos; p->pos = p->opos = oldpos;
p->restorexyz();
continue; continue;
} }
quickkill(p); quickkill(p);

View file

@ -3800,7 +3800,7 @@ HORIZONLY:
ChangeActorSect(pact, p->cursector); ChangeActorSect(pact, p->cursector);
} }
else else
clipmove(p->__int_pos, &p->cursector, p->vel.X, p->vel.Y, 164, (4 << 8), i, CLIPMASK0, clip); 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) if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk)
p->player_add_int_z(32 << 8); p->player_add_int_z(32 << 8);
@ -3829,10 +3829,10 @@ HORIZONLY:
if (wal->lotag < 44) if (wal->lotag < 44)
{ {
dofurniture(clip.hitWall, p->cursector, snum); dofurniture(clip.hitWall, p->cursector, snum);
pushmove_p(p, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0); pushmove(p->pos, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0);
} }
else else
pushmove_p(p, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0); pushmove(p->pos, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0);
} }
} }
} }
@ -3933,9 +3933,9 @@ HORIZONLY:
{ {
int blocked; int blocked;
if (pact->spr.clipdist == 64) if (pact->spr.clipdist == 64)
blocked = (pushmove_p(p, &p->cursector, 128, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); blocked = (pushmove(p->pos, &p->cursector, 128, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
else else
blocked = (pushmove_p(p, &p->cursector, 16, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); blocked = (pushmove(p->pos, &p->cursector, 16, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked) if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked)
{ {
@ -3946,8 +3946,7 @@ HORIZONLY:
{ {
if (!retry++) if (!retry++)
{ {
p->opos = oldpos; p->pos = p->opos = oldpos;
p->restorexyz();
continue; continue;
} }
quickkill(p); quickkill(p);

View file

@ -95,7 +95,7 @@ void pickrandomspot(int snum)
i = krand()%numplayersprites; i = krand()%numplayersprites;
else i = snum; else i = snum;
p->__int_pos = po[i].opos; p->pos = po[i].opos;
p->backupxyz(); p->backupxyz();
p->setbobpos(); p->setbobpos();
p->angle.oang = p->angle.ang = buildang(po[i].oa); p->angle.oang = p->angle.ang = buildang(po[i].oa);
@ -615,7 +615,7 @@ void resetpspritevars(int g)
firsty = ps[0].player_int_pos().Y; firsty = ps[0].player_int_pos().Y;
} }
po[numplayersprites].opos = act->int_pos(); po[numplayersprites].opos = act->spr.pos;
po[numplayersprites].oa = act->spr.ang; po[numplayersprites].oa = act->spr.ang;
po[numplayersprites].os = act->sector(); po[numplayersprites].os = act->sector();
@ -1005,7 +1005,7 @@ static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode)
SpawnSpriteDef sprites; SpawnSpriteDef sprites;
vec3_t pos; vec3_t pos;
loadMap(mi->fileName, isShareware(), &pos, &lbang, &sect, sprites); loadMap(mi->fileName, isShareware(), &pos, &lbang, &sect, sprites);
p->__int_pos = pos; p->pos = { pos.X * inttoworld, pos.Y * inttoworld, pos.Z * zinttoworld };
p->cursector = &sector[sect]; p->cursector = &sector[sect];
SECRET_SetMapName(mi->DisplayName(), mi->name); SECRET_SetMapName(mi->DisplayName(), mi->name);

View file

@ -107,9 +107,9 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
{ {
if (arc.BeginObject(keyname)) if (arc.BeginObject(keyname))
{ {
arc("posx", w.__int_pos.X) arc("posx", w.pos.X)
("posy", w.__int_pos.Y) ("posy", w.pos.Y)
("posz", w.__int_pos.Z) ("posz", w.pos.Z)
("angle", w.angle) ("angle", w.angle)
("horizon", w.horizon) ("horizon", w.horizon)
.Array("gotweapon", w.gotweapon, MAX_WEAPONS) .Array("gotweapon", w.gotweapon, MAX_WEAPONS)

View file

@ -189,7 +189,7 @@ struct user_defs
struct player_orig struct player_orig
{ {
vec3_t opos; DVector3 opos;
short oa; short oa;
sectortype* os; sectortype* os;
}; };
@ -203,12 +203,8 @@ struct CraneDef
struct player_struct struct player_struct
{ {
// This is basically the version from JFDuke but this first block contains a few changes to make it work with other parts of Raze. vec3_t vel;
DVector3 pos, opos;
// The sound code wants to read a vector out of this so we need to define one for the main coordinate.
vec3_t __int_pos, vel;
DVector3 opos;
// player's horizon and angle structs. // player's horizon and angle structs.
PlayerHorizon horizon; PlayerHorizon horizon;
@ -362,55 +358,51 @@ struct player_struct
void backupxyz() void backupxyz()
{ {
opos.X = __int_pos.X * inttoworld; opos = pos;
opos.Y = __int_pos.Y * inttoworld;
opos.Z = __int_pos.Z * zinttoworld;
} }
void restorexyz() void restorexyz()
{ {
__int_pos.X = opos.X * worldtoint; pos = opos;
__int_pos.Y = opos.Y * worldtoint;
__int_pos.Z = opos.Z * zworldtoint;
} }
void backupxy() void backupxy()
{ {
opos.X = __int_pos.X * inttoworld; opos.X = pos.X;
opos.Y = __int_pos.Y * inttoworld; opos.Y = pos.Y;
} }
void restorexy() void restorexy()
{ {
__int_pos.X = opos.X * worldtoint; pos.X = opos.X;
__int_pos.Y = opos.Y * worldtoint; pos.Y = opos.Y;
} }
void backupz() void backupz()
{ {
opos.Z = __int_pos.Z * zinttoworld; opos.Z = pos.Z;
} }
void setbobpos() void setbobpos()
{ {
bobpos = __int_pos.vec2; bobpos = player_int_pos().vec2;
} }
void getposfromactor(DCoreActor* actor, double addz = 0) void getposfromactor(DCoreActor* actor, double addz = 0)
{ {
__int_pos = actor->int_pos(); pos = actor->spr.pos;
if (addz) __int_pos.Z += int(addz * worldtoint); if (addz) pos.Z += addz;
} }
void getxyfromactor(DCoreActor* actor) void getxyfromactor(DCoreActor* actor)
{ {
__int_pos.X = actor->int_pos().X; pos.X = actor->spr.pos.X;
__int_pos.Y = actor->int_pos().Y; pos.Y = actor->spr.pos.Y;
} }
vec3_t player_int_pos() const vec3_t player_int_pos() const
{ {
return __int_pos; return { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
} }
vec3_t player_int_opos() const vec3_t player_int_opos() const
@ -420,20 +412,22 @@ struct player_struct
void player_add_int_z(int z) void player_add_int_z(int z)
{ {
__int_pos.Z += z; pos.Z += z * zinttoworld;
} }
void player_set_int_z(int z) void player_set_int_z(int z)
{ {
__int_pos.Z = z; pos.Z = z * zinttoworld;
} }
void player_add_int_xy(const vec2_t& v) void player_add_int_xy(const vec2_t& v)
{ {
__int_pos.vec2 += v; pos.X += v.X * inttoworld;
pos.Y += v.Y * inttoworld;
} }
void player_set_int_xy(const vec2_t& v) void player_set_int_xy(const vec2_t& v)
{ {
__int_pos.vec2 = v; pos.X = v.X * inttoworld;
pos.Y = v.Y * inttoworld;
} }