From 08909f414a7aa40c2809664d9d33880fc524dc12 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jul 2020 19:52:16 +0200 Subject: [PATCH] - merged playerdata_t into player_struct --- source/games/duke/src/player.cpp | 20 ++++++++++---------- source/games/duke/src/player.h | 11 ----------- source/games/duke/src/player_d.cpp | 6 +++--- source/games/duke/src/player_r.cpp | 6 +++--- source/games/duke/src/types.h | 7 +++++++ source/games/duke/src/zz_game.cpp | 3 --- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index b25385d92..bb9f40318 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -387,7 +387,7 @@ void dokneeattack(int snum, int pi, const std::initializer_list & respawnli p->addhoriz(-48); else { - g_player[snum].horizSkew = -48; + p->horizSkew = -48; } p->return_to_center = 9; @@ -786,13 +786,13 @@ void applylook(int snum, double factor) p->addlookang(factor * -0.25 * fix16_to_dbl(p->q16look_ang)); if (abs(p->q16look_ang) < FRACUNIT) p->q16look_ang = 0; - if (g_player[snum].lookLeft) + if (p->lookLeft) { p->addlookang(factor * -152); p->addrotscrnang(factor * 24); } - if (g_player[snum].lookRight) + if (p->lookRight) { p->addlookang(factor * 152); p->addrotscrnang(factor * 24); @@ -823,14 +823,14 @@ void checklook(int snum, int sb_snum) { auto p = &ps[snum]; - g_player[snum].lookLeft = false; + p->lookLeft = false; if ((sb_snum & SKB_LOOK_LEFT) && !p->OnMotorcycle) { SetGameVarID(g_iReturnVarID, 0, p->i, snum); OnEvent(EVENT_LOOKLEFT, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { - g_player[snum].lookLeft = true; + p->lookLeft = true; } } @@ -840,7 +840,7 @@ void checklook(int snum, int sb_snum) OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { - g_player[snum].lookRight = true; + p->lookRight = true; } } p->oq16ang = p->q16ang; @@ -860,9 +860,9 @@ void sethorizon(int snum, int sb_snum, double factor, bool frominput) auto p = &ps[snum]; // Calculate adjustment as true pitch (Fixed point nath really sucks...) - if (g_player[snum].horizAngleAdjust) + if (p->horizAngleAdjust) { - double horizAngle = atan2(p->q16horiz - F16(100), F16(128)) * (512. / pi::pi()) +factor * g_player[snum].horizAngleAdjust; + double horizAngle = atan2(p->q16horiz - F16(100), F16(128)) * (512. / pi::pi()) +factor * p->horizAngleAdjust; p->q16horiz = F16(100) + int(F16(128) * tan(horizAngle * (pi::pi() / 512.))); } else if (p->return_to_center > 0 && (sb_snum & (SKB_LOOK_UP | SKB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed. @@ -871,7 +871,7 @@ void sethorizon(int snum, int sb_snum, double factor, bool frominput) p->q16horiz += factor * (frominput? 2.016 : 1.) * (F16(33) - (p->q16horiz / 3)); // in P_GetInput this used different factors than in the original code. Hm... } - p->q16horiz += int(factor * g_player[snum].horizSkew); + p->q16horiz += int(factor * p->horizSkew); if (p->aim_mode == 0) { @@ -901,7 +901,7 @@ void playerCenterView(int snum) void horizAngleAdjust(int snum, int delta) { - g_player[snum].horizAngleAdjust = delta; + ps[snum].horizAngleAdjust = delta; } void playerLookUp(int snum, ESyncBits sb_snum) diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 94df79e1f..fa52e3b96 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -46,20 +46,9 @@ enum gamemode_t { }; -typedef struct -{ - float horizAngleAdjust; - fix16_t horizSkew; - bool lookLeft; - bool lookRight; - -} playerdata_t; - extern uint16_t frags[MAXPLAYERS][MAXPLAYERS]; extern input_t sync[MAXPLAYERS]; -extern playerdata_t g_player[MAXPLAYERS]; - extern int16_t max_ammo_amount[MAX_WEAPONS]; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 515fb5b19..f06771cb9 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2598,8 +2598,8 @@ void processinput_d(int snum) if (!synchronized_input) { - g_player[snum].horizAngleAdjust = 0; - g_player[snum].horizSkew = 0; + p->horizAngleAdjust = 0; + p->horizSkew = 0; } sb_snum = PlayerInputBits(snum, SKB_ALL); @@ -3047,7 +3047,7 @@ HORIZONLY: if (p->hard_landing > 0) { - g_player[snum].horizSkew = (-(p->hard_landing << 4)) * FRACUNIT; + p->horizSkew = (-(p->hard_landing << 4)) * FRACUNIT; p->hard_landing--; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index fec692c59..b9b7a2e76 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3395,8 +3395,8 @@ void processinput_r(int snum) pi = p->i; s = &sprite[pi]; - g_player[snum].horizAngleAdjust = 0; - g_player[snum].horizSkew = 0; + p->horizAngleAdjust = 0; + p->horizSkew = 0; sb_snum = PlayerInputBits(snum, SKB_ALL); @@ -4076,7 +4076,7 @@ HORIZONLY: } if (p->hard_landing > 0) { - g_player[snum].horizSkew = (-(p->hard_landing << 4)) * FRACUNIT; + p->horizSkew = (-(p->hard_landing << 4)) * FRACUNIT; p->hard_landing--; } diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 056e15fab..8bc40a226 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -192,6 +192,13 @@ struct player_struct int8_t crouch_toggle; + // input stuff. + float horizAngleAdjust; + fix16_t horizSkew; + bool lookLeft; + bool lookRight; + + // Access helpers for the widened angle and horizon fields. int getlookang() { return q16look_ang >> FRACBITS; } void setlookang(int b) { q16look_ang = b << FRACBITS; } diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index b213ef0f0..c342b9346 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -71,7 +71,4 @@ int32_t PHEIGHT = PHEIGHT_DUKE; int32_t lastvisinc; -playerdata_t g_player[MAXPLAYERS]; - - END_DUKE_NS