mirror of
https://github.com/DrBeef/Raze.git
synced 2025-04-01 05:30:58 +00:00
- Remove multiple addadjustment()
/settarget()
overloads in favour of native binangle
/fixedhoriz
versions only.
* Simplifies these classes a bit. * Better shows intent in actual game code. * Removes unnecessary int to double conversions.
This commit is contained in:
parent
5c65a9bab4
commit
7282e0d8bf
12 changed files with 93 additions and 103 deletions
|
@ -596,8 +596,6 @@ DEFINE_MAP_OPTION(ex_ramses_text, false)
|
|||
info->ex_ramses_text = parse.sc.String;
|
||||
}
|
||||
|
||||
int ex_ramses_horiz = 11;
|
||||
int ex_ramses_cdtrack = -1; // this is not music, it is the actual dialogue!
|
||||
FString ex_ramses_pup;
|
||||
FString ex_ramses_text;
|
||||
|
||||
|
|
|
@ -55,10 +55,6 @@ struct PlayerHorizon
|
|||
fixedhoriz interpolatedsum(double const smoothratio) { return interpolatedhorizon(osum(), sum(), smoothratio); }
|
||||
|
||||
// Ticrate playsim adjustment helpers.
|
||||
void addadjustment(double value) { __addadjustment(buildfhoriz(value)); }
|
||||
void addadjustment(fixedhoriz value) { __addadjustment(value); }
|
||||
void settarget(double value, bool backup = false) { __settarget(buildfhoriz(value), backup); }
|
||||
void settarget(fixedhoriz value, bool backup = false) { __settarget(value, backup); }
|
||||
void resetadjustment() { adjustment = 0; }
|
||||
bool targetset() { return target.asq16(); }
|
||||
|
||||
|
@ -85,7 +81,35 @@ struct PlayerHorizon
|
|||
}
|
||||
}
|
||||
|
||||
// Ticrate playsim adjustment processor.
|
||||
// Ticrate playsim adjustment setters and processor.
|
||||
void addadjustment(fixedhoriz const value)
|
||||
{
|
||||
if (!SyncInput())
|
||||
{
|
||||
adjustment += value.asbuildf();
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz += value;
|
||||
}
|
||||
}
|
||||
|
||||
void settarget(fixedhoriz value, bool const backup = false)
|
||||
{
|
||||
value = q16horiz(clamp(value.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
|
||||
|
||||
if (!SyncInput() && !backup)
|
||||
{
|
||||
target = value;
|
||||
if (!targetset()) target = q16horiz(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz = value;
|
||||
if (backup) ohoriz = horiz;
|
||||
}
|
||||
}
|
||||
|
||||
void processhelpers(double const scaleAdjust)
|
||||
{
|
||||
if (targetset())
|
||||
|
@ -112,34 +136,6 @@ private:
|
|||
fixedhoriz target;
|
||||
double adjustment;
|
||||
bool inputdisabled;
|
||||
|
||||
void __addadjustment(fixedhoriz value)
|
||||
{
|
||||
if (!SyncInput())
|
||||
{
|
||||
adjustment += value.asbuildf();
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz += value;
|
||||
}
|
||||
}
|
||||
|
||||
void __settarget(fixedhoriz value, bool backup)
|
||||
{
|
||||
value = q16horiz(clamp(value.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
|
||||
|
||||
if (!SyncInput() && !backup)
|
||||
{
|
||||
target = value;
|
||||
if (!targetset()) target = q16horiz(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz = value;
|
||||
if (backup) ohoriz = horiz;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct PlayerAngle
|
||||
|
@ -174,10 +170,6 @@ struct PlayerAngle
|
|||
binangle interpolatedrotscrn(double const smoothratio) { return interpolatedangle(orotscrnang, rotscrnang, smoothratio); }
|
||||
|
||||
// Ticrate playsim adjustment helpers.
|
||||
void addadjustment(double value) { __addadjustment(buildfang(value)); }
|
||||
void addadjustment(binangle value) { __addadjustment(value); }
|
||||
void settarget(double value, bool backup = false) { __settarget(buildfang(value), backup); }
|
||||
void settarget(binangle value, bool backup = false) { __settarget(value, backup); }
|
||||
void resetadjustment() { adjustment = 0; }
|
||||
bool targetset() { return target.asbam(); }
|
||||
|
||||
|
@ -205,7 +197,33 @@ struct PlayerAngle
|
|||
}
|
||||
}
|
||||
|
||||
// Ticrate playsim adjustment processor.
|
||||
// Ticrate playsim adjustment setters and processor.
|
||||
void addadjustment(binangle const value)
|
||||
{
|
||||
if (!SyncInput())
|
||||
{
|
||||
adjustment += value.signedbuildf();
|
||||
}
|
||||
else
|
||||
{
|
||||
ang += value;
|
||||
}
|
||||
}
|
||||
|
||||
void settarget(binangle const value, bool const backup = false)
|
||||
{
|
||||
if (!SyncInput() && !backup)
|
||||
{
|
||||
target = value;
|
||||
if (!targetset()) target = bamang(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ang = value;
|
||||
if (backup) oang = ang;
|
||||
}
|
||||
}
|
||||
|
||||
void processhelpers(double const scaleAdjust)
|
||||
{
|
||||
if (targetset())
|
||||
|
@ -232,32 +250,6 @@ private:
|
|||
binangle target;
|
||||
double adjustment;
|
||||
bool inputdisabled;
|
||||
|
||||
void __addadjustment(binangle value)
|
||||
{
|
||||
if (!SyncInput())
|
||||
{
|
||||
adjustment += value.signedbuildf();
|
||||
}
|
||||
else
|
||||
{
|
||||
ang += value;
|
||||
}
|
||||
}
|
||||
|
||||
void __settarget(binangle value, bool backup)
|
||||
{
|
||||
if (!SyncInput() && !backup)
|
||||
{
|
||||
target = value;
|
||||
if (!targetset()) target = bamang(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ang = value;
|
||||
if (backup) oang = ang;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct PlayerPosition
|
||||
|
|
|
@ -2234,7 +2234,7 @@ void trPlayerCtrlSetLookAngle(int value, PLAYER* pPlayer)
|
|||
adjustment = 0;
|
||||
}
|
||||
|
||||
pPlayer->horizon.settarget(100. * tan(adjustment * pi::pi() / 1024.));
|
||||
pPlayer->horizon.settarget(buildfhoriz(100. * tan(adjustment * pi::pi() / 1024.)));
|
||||
pPlayer->horizon.lockinput();
|
||||
}
|
||||
|
||||
|
@ -3120,7 +3120,7 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
|
|||
{
|
||||
if (pPlayer)
|
||||
{
|
||||
pPlayer->angle.settarget(sourceactor->spr.ang);
|
||||
pPlayer->angle.settarget(buildang(sourceactor->spr.ang));
|
||||
pPlayer->angle.lockinput();
|
||||
}
|
||||
else if (isDude) sourceactor->xspr.goalAng = actor->spr.ang = sourceactor->spr.ang;
|
||||
|
@ -5842,12 +5842,12 @@ bool modernTypeOperateSprite(DBloodActor* actor, EVENT& event)
|
|||
if (actor->xspr.data4 != 0) break;
|
||||
else if (actor->spr.flags & kModernTypeFlag1)
|
||||
{
|
||||
pPlayer->angle.settarget(actor->spr.ang);
|
||||
pPlayer->angle.settarget(buildang(actor->spr.ang));
|
||||
pPlayer->angle.lockinput();
|
||||
}
|
||||
else if (valueIsBetween(actor->xspr.data2, -kAng360, kAng360))
|
||||
{
|
||||
pPlayer->angle.settarget(actor->xspr.data2);
|
||||
pPlayer->angle.settarget(buildang(actor->xspr.data2));
|
||||
pPlayer->angle.lockinput();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1543,7 +1543,7 @@ void OperateTeleport(sectortype* pSector)
|
|||
{
|
||||
playerResetInertia(pPlayer);
|
||||
pPlayer->zViewVel = pPlayer->zWeaponVel = 0;
|
||||
pPlayer->angle.settarget(actor->spr.ang, true);
|
||||
pPlayer->angle.settarget(buildang(actor->spr.ang), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -711,7 +711,7 @@ void movecrane(DDukeActor *actor, int crane)
|
|||
actor->SetActiveCrane(true);
|
||||
ps[p].on_crane = actor;
|
||||
S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].GetActor());
|
||||
ps[p].angle.settarget(actor->spr.ang + 1024);
|
||||
ps[p].angle.settarget(buildang(actor->spr.ang + 1024));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2691,7 +2691,7 @@ void handle_se00(DDukeActor* actor)
|
|||
{
|
||||
if (ps[p].cursector == actor->sector() && ps[p].on_ground == 1)
|
||||
{
|
||||
ps[p].angle.addadjustment(l * q);
|
||||
ps[p].angle.addadjustment(buildang(l * q));
|
||||
|
||||
ps[p].pos.Z += zchange;
|
||||
|
||||
|
@ -2877,7 +2877,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
|
|||
ps[p].bobpos.X += m;
|
||||
ps[p].bobpos.Y += x;
|
||||
|
||||
ps[p].angle.addadjustment(q);
|
||||
ps[p].angle.addadjustment(buildang(q));
|
||||
|
||||
if (numplayers > 1)
|
||||
{
|
||||
|
|
|
@ -1389,7 +1389,7 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball)
|
|||
|
||||
if (proj->spr.picnum == SPIT)
|
||||
{
|
||||
ps[p].horizon.addadjustment(32);
|
||||
ps[p].horizon.addadjustment(buildhoriz(32));
|
||||
ps[p].sync.actions |= SB_CENTERVIEW;
|
||||
|
||||
if (ps[p].loogcnt == 0)
|
||||
|
|
|
@ -1014,7 +1014,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const vec3_t &ol
|
|||
guts_r(proj, RABBITJIBC, 2, myconnectindex);
|
||||
}
|
||||
|
||||
ps[p].horizon.addadjustment(32);
|
||||
ps[p].horizon.addadjustment(buildhoriz(32));
|
||||
ps[p].sync.actions |= SB_CENTERVIEW;
|
||||
|
||||
if (ps[p].loogcnt == 0)
|
||||
|
|
|
@ -344,7 +344,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
|
|||
{
|
||||
ps[iPlayer].sync.actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
ps[iPlayer].horizon.settarget(lValue);
|
||||
ps[iPlayer].horizon.settarget(buildhoriz(lValue));
|
||||
}
|
||||
else SetGameVarID(lVar2, ps[iPlayer].horizon.horiz.asbuild(), sActor, sPlayer);
|
||||
break;
|
||||
|
@ -472,7 +472,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
|
|||
break;
|
||||
|
||||
case PLAYER_ANG:
|
||||
if (bSet) ps[iPlayer].angle.settarget(lValue);
|
||||
if (bSet) ps[iPlayer].angle.settarget(buildang(lValue));
|
||||
else SetGameVarID(lVar2, ps[iPlayer].angle.ang.asbuild(), sActor, sPlayer);
|
||||
break;
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ void forceplayerangle(int snum)
|
|||
|
||||
n = 128 - (krand() & 255);
|
||||
|
||||
p->horizon.addadjustment(64);
|
||||
p->horizon.addadjustment(buildhoriz(64));
|
||||
p->sync.actions |= SB_CENTERVIEW;
|
||||
p->angle.rotscrnang = p->angle.look_ang = buildang(n >> 1);
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ void dokneeattack(int snum, const std::initializer_list<int> & respawnlist)
|
|||
if (p->knee_incs > 0)
|
||||
{
|
||||
p->knee_incs++;
|
||||
p->horizon.addadjustment(-48);
|
||||
p->horizon.addadjustment(buildhoriz(-48));
|
||||
p->sync.actions |= SB_CENTERVIEW;
|
||||
if (p->knee_incs > 15)
|
||||
{
|
||||
|
@ -802,7 +802,7 @@ void player_struct::checkhardlanding()
|
|||
{
|
||||
if (hard_landing > 0)
|
||||
{
|
||||
horizon.addadjustment(-(hard_landing << 4));
|
||||
horizon.addadjustment(buildhoriz(-(hard_landing << 4)));
|
||||
hard_landing--;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1755,7 +1755,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
|
|||
}
|
||||
if (horiz != FRACUNIT)
|
||||
{
|
||||
p->horizon.addadjustment(horiz - p->horizon.horiz.asbuildf());
|
||||
p->horizon.addadjustment(buildfhoriz(horiz) - p->horizon.horiz);
|
||||
}
|
||||
|
||||
int currSpeed = int(p->MotoSpeed);
|
||||
|
@ -2023,7 +2023,7 @@ static void onBoat(int snum, ESyncBits &actions)
|
|||
}
|
||||
if (horiz != FRACUNIT)
|
||||
{
|
||||
p->horizon.addadjustment(horiz - p->horizon.horiz.asbuildf());
|
||||
p->horizon.addadjustment(buildfhoriz(horiz) - p->horizon.horiz);
|
||||
}
|
||||
|
||||
if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
|
||||
|
@ -2371,7 +2371,7 @@ void onMotorcycleMove(int snum, walltype* wal)
|
|||
int angleDelta = abs(p->angle.ang.asbuild() - getangle(wal->delta()));
|
||||
int damageAmount;
|
||||
|
||||
p->angle.addadjustment(p->MotoSpeed / (krand() & 1 ? -2 : 2));
|
||||
p->angle.addadjustment(buildfang(p->MotoSpeed / (krand() & 1 ? -2 : 2)));
|
||||
|
||||
if (angleDelta >= 441 && angleDelta <= 581)
|
||||
{
|
||||
|
@ -2425,7 +2425,7 @@ void onBoatMove(int snum, int psectlotag, walltype* wal)
|
|||
auto delta = wal->delta();
|
||||
int angleDelta = abs(p->angle.ang.asbuild() - getangle(wal->delta()));
|
||||
|
||||
p->angle.addadjustment(p->MotoSpeed / (krand() & 1 ? -4 : 4));
|
||||
p->angle.addadjustment(buildfang(p->MotoSpeed / (krand() & 1 ? -4 : 4)));
|
||||
|
||||
if (angleDelta >= 441 && angleDelta <= 581)
|
||||
{
|
||||
|
@ -2961,7 +2961,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
|
|||
case RIFLEGUN_WEAPON:
|
||||
|
||||
p->kickback_pic++;
|
||||
p->horizon.addadjustment(1);
|
||||
p->horizon.addadjustment(buildhoriz(1));
|
||||
p->recoil++;
|
||||
|
||||
if (p->kickback_pic <= 12)
|
||||
|
@ -3054,11 +3054,11 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
|
|||
}
|
||||
if (p->kickback_pic == 2)
|
||||
{
|
||||
p->angle.addadjustment(16);
|
||||
p->angle.addadjustment(buildang(16));
|
||||
}
|
||||
else if (p->kickback_pic == 4)
|
||||
{
|
||||
p->angle.addadjustment(-16);
|
||||
p->angle.addadjustment(buildang(-16));
|
||||
}
|
||||
if (p->kickback_pic > 4)
|
||||
p->kickback_pic = 1;
|
||||
|
@ -3084,11 +3084,11 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
|
|||
}
|
||||
if (p->kickback_pic == 2)
|
||||
{
|
||||
p->angle.addadjustment(4);
|
||||
p->angle.addadjustment(buildang(4));
|
||||
}
|
||||
else if (p->kickback_pic == 4)
|
||||
{
|
||||
p->angle.addadjustment(-4);
|
||||
p->angle.addadjustment(buildang(-4));
|
||||
}
|
||||
if (p->kickback_pic > 4)
|
||||
p->kickback_pic = 1;
|
||||
|
@ -3136,7 +3136,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
|
|||
{
|
||||
p->vel.X -= p->angle.ang.bcos(4);
|
||||
p->vel.Y -= p->angle.ang.bsin(4);
|
||||
p->horizon.addadjustment(20);
|
||||
p->horizon.addadjustment(buildhoriz(20));
|
||||
p->recoil += 20;
|
||||
}
|
||||
if (p->kickback_pic > 20)
|
||||
|
@ -3977,7 +3977,7 @@ HORIZONLY:
|
|||
if (!d)
|
||||
d = 1;
|
||||
p->recoil -= d;
|
||||
p->horizon.addadjustment(-d);
|
||||
p->horizon.addadjustment(buildhoriz(-d));
|
||||
}
|
||||
|
||||
if (SyncInput())
|
||||
|
|
|
@ -935,10 +935,10 @@ void AIPlayer::Tick(RunListEvent* ev)
|
|||
if (nTotalPlayers <= 1)
|
||||
{
|
||||
auto ang = GetAngleToSprite(pPlayerActor, pSpiritSprite) & kAngleMask;
|
||||
PlayerList[nPlayer].angle.settarget(ang, true);
|
||||
PlayerList[nPlayer].angle.settarget(buildang(ang), true);
|
||||
pPlayerActor->spr.ang = ang;
|
||||
|
||||
PlayerList[nPlayer].horizon.settarget(0, true);
|
||||
PlayerList[nPlayer].horizon.settarget(buildhoriz(0), true);
|
||||
|
||||
lPlayerXVel = 0;
|
||||
lPlayerYVel = 0;
|
||||
|
@ -955,7 +955,7 @@ void AIPlayer::Tick(RunListEvent* ev)
|
|||
InitSpiritHead();
|
||||
|
||||
PlayerList[nPlayer].nDestVertPan = q16horiz(0);
|
||||
PlayerList[nPlayer].horizon.settarget(currentLevel->ex_ramses_horiz);
|
||||
PlayerList[nPlayer].horizon.settarget(buildhoriz(currentLevel->ex_ramses_horiz));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2445,7 +2445,7 @@ sectdone:
|
|||
double nVertPan = (pPlayer->nDestVertPan - pPlayer->horizon.horiz).asbuildf() * 0.25;
|
||||
if (nVertPan != 0)
|
||||
{
|
||||
pPlayer->horizon.addadjustment(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.);
|
||||
pPlayer->horizon.addadjustment(buildfhoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2568,16 +2568,16 @@ sectdone:
|
|||
{
|
||||
if (PlayerList[nPlayer].horizon.horiz.asq16() < 0)
|
||||
{
|
||||
PlayerList[nPlayer].horizon.settarget(0);
|
||||
PlayerList[nPlayer].horizon.settarget(buildhoriz(0));
|
||||
PlayerList[nPlayer].eyelevel -= (dVertPan[nPlayer] << 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerList[nPlayer].horizon.addadjustment(dVertPan[nPlayer]);
|
||||
PlayerList[nPlayer].horizon.addadjustment(buildhoriz(dVertPan[nPlayer]));
|
||||
|
||||
if (PlayerList[nPlayer].horizon.horiz.asq16() > gi->playerHorizMax())
|
||||
{
|
||||
PlayerList[nPlayer].horizon.settarget(gi->playerHorizMax());
|
||||
PlayerList[nPlayer].horizon.settarget(q16horiz(gi->playerHorizMax()));
|
||||
}
|
||||
else if (PlayerList[nPlayer].horizon.horiz.asq16() <= 0)
|
||||
{
|
||||
|
|
|
@ -3348,7 +3348,7 @@ void DoPlayerClimb(PLAYER* pp)
|
|||
pp->LadderPosition.X = lActor->spr.pos.X + nx * 5;
|
||||
pp->LadderPosition.Y = lActor->spr.pos.Y + ny * 5;
|
||||
|
||||
pp->angle.settarget(lActor->spr.ang + 1024);
|
||||
pp->angle.settarget(buildang(lActor->spr.ang + 1024));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3730,7 +3730,7 @@ bool PlayerOnLadder(PLAYER* pp)
|
|||
pp->LadderPosition.X = lActor->spr.pos.X + nx * 5;
|
||||
pp->LadderPosition.Y = lActor->spr.pos.Y + ny * 5;
|
||||
|
||||
pp->angle.settarget(lActor->spr.ang + 1024);
|
||||
pp->angle.settarget(buildang(lActor->spr.ang + 1024));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5619,12 +5619,12 @@ void DoPlayerDeathHoriz(PLAYER* pp, short target, short speed)
|
|||
{
|
||||
if ((pp->horizon.horiz.asbuild() - target) > 1)
|
||||
{
|
||||
pp->horizon.addadjustment(-speed);
|
||||
pp->horizon.addadjustment(buildhoriz(-speed));
|
||||
}
|
||||
|
||||
if ((target - pp->horizon.horiz.asbuild()) > 1)
|
||||
{
|
||||
pp->horizon.addadjustment(speed);
|
||||
pp->horizon.addadjustment(buildhoriz(speed));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue