- Duke: Remove player_struct::posoldZset() and player_struct::posoldZget().

This commit is contained in:
Mitchell Richters 2022-11-24 19:47:02 +11:00 committed by Christoph Oelckers
parent 66a08a26e8
commit f10f1b9154
7 changed files with 16 additions and 20 deletions

View file

@ -161,6 +161,11 @@ public:
return spr.pos.Z + viewzoffset;
}
double getPrevOffsetZ()
{
return opos.Z + oviewzoffset;
}
DVector3 getPosWithOffsetZ()
{
return spr.pos.plusZ(viewzoffset);

View file

@ -4410,7 +4410,7 @@ void movefta(void)
{
double r1 = zrand(32);
double r2 = zrand(52);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].posoldZget() - r1 }, ps[p].cursector);
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].GetActor()->getPrevOffsetZ() - r1 }, ps[p].cursector);
}
}
else

View file

@ -388,8 +388,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;
case PLAYER_OPOSZ:
if (bSet) ps[iPlayer].posoldZset(lValue * zmaptoworld);
else SetGameVarID(lVar2, int(ps[iPlayer].posoldZget() * (1 / zmaptoworld)), sActor, sPlayer);
if (bSet) ps[iPlayer].GetActor()->opos.Z = (lValue * zmaptoworld) + gs.playerheight;
else SetGameVarID(lVar2, int(ps[iPlayer].GetActor()->getPrevOffsetZ() * (1 / zmaptoworld)), sActor, sPlayer);
break;
case PLAYER_PYOFF:

View file

@ -771,7 +771,7 @@ void player_struct::backuppos(bool noclipping)
GetActor()->restorevec2();
}
posoldZset(GetActor()->getOffsetZ());
GetActor()->backupz();
bobpos = GetActor()->spr.pos.XY();
opyoff = pyoff;
}

View file

@ -109,7 +109,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang)
double scratch;
int j = findplayer(actor, &scratch);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].GetActor()->getPrevOffsetZ() - pos.Z + 3) * vel) / dist;
}
else
{
@ -165,7 +165,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
if (dist != 0)
zvel = (((ps[j].posoldZget() - spos.Z) * vel) / dist);
zvel = (((ps[j].GetActor()->getPrevOffsetZ() - spos.Z) * vel) / dist);
if (badguy(actor) && (actor->spr.hitag & face_player_smart) != 0)
sang = actor->spr.angle + mapangle((krand() & 31) - 16);
@ -605,7 +605,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
#if 1
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].GetActor()->getPrevOffsetZ() - pos.Z + 3) * vel) / dist;
#else
// this is for pitch corrected velocity
auto dist = (ps[j].GetActor()->spr.pos - actor->spr.pos).Resized(vel);
@ -712,7 +712,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].posoldZget() - pos.Z) * vel) / dist;
zvel = ((ps[j].GetActor()->getPrevOffsetZ() - pos.Z) * vel) / dist;
if (badguy(actor) && (actor->spr.hitag & face_player_smart))
ang = actor->spr.angle + randomAngle(DAngle22_5 / 4) - DAngle22_5 / 8;

View file

@ -526,7 +526,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang += DAngle22_5 / 8. - randomAngle(22.5 / 4);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].GetActor()->getPrevOffsetZ() - pos.Z + 3) * vel) / dist;
}
double oldzvel = zvel;
@ -623,7 +623,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw
}
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].posoldZget() - pos.Z) * vel) / dist;
zvel = ((ps[j].GetActor()->getPrevOffsetZ() - pos.Z) * vel) / dist;
if (badguy(actor) && (actor->spr.hitag & face_player_smart))
ang = actor->spr.angle + randomAngle(22.5 / 4) - DAngle22_5 / 8;
@ -758,7 +758,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at
ang += DAngle22_5/8 - randomAngle(22.5 / 4);
double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length();
zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist;
zvel = ((ps[j].GetActor()->getPrevOffsetZ() - pos.Z + 3) * vel) / dist;
}
double oldzvel = zvel;

View file

@ -336,15 +336,6 @@ struct player_struct
}
void posoldZset(const double val)
{
GetActor()->opos.Z = val - GetActor()->viewzoffset;
}
double posoldZget()
{
return GetActor()->opos.Z + GetActor()->viewzoffset;
}
void posoldAdd(const DVector3& val)
{
GetActor()->opos += val;