From 6ad3237b62c5405937e11cce567475c0890e311f Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 3 Aug 2020 13:28:16 +1000 Subject: [PATCH] - backup `p->kickback_pic` in prep for interpolation and tidy up other weapon interpolation variables. --- source/games/duke/src/funct.h | 1 + source/games/duke/src/input.cpp | 4 ++-- source/games/duke/src/player.cpp | 13 +++++++++++++ source/games/duke/src/player_d.cpp | 1 - source/games/duke/src/player_r.cpp | 1 - source/games/duke/src/types.h | 13 ++++++++++--- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 736406e40..debe316ca 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -247,5 +247,6 @@ void updateviewport(void); void backuppos(player_struct* p, bool noclipping = false); void backuplook(player_struct* p); void backupview(player_struct* p); +void backupweapon(player_struct* p); END_DUKE_NS diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 83165ff3f..44fccdb13 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -253,8 +253,8 @@ void hud_input(int snum) if (p->aim_mode < i) p->return_to_center = 9; - // Backup weapon_pos here as this is the earliest occurence where weapon_pos can change. - p->oweapon_pos = p->weapon_pos; + // Backup weapon here as hud_input() is the first function where any one of the weapon variables can change. + backupweapon(p); if (isRR()) { diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 7c868c25e..2fe10ca94 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -900,6 +900,19 @@ void backupview(player_struct* p) // //--------------------------------------------------------------------------- +void backupweapon(player_struct* p) +{ + p->oweapon_sway = p->weapon_sway; + p->oweapon_pos = p->weapon_pos; + p->okickback_pic = p->kickback_pic; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void checklook(int snum, int sb_snum) { auto p = &ps[snum]; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 7116ad459..49ea6d8fc 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2732,7 +2732,6 @@ void processinput_d(int snum) if (p->on_crane >= 0) goto HORIZONLY; - p->oweapon_sway = p->weapon_sway; if (s->xvel < 32 || p->on_ground == 0 || p->bobcounter == 1024) { if ((p->weapon_sway & 2047) > (1024 + 96)) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 136625602..e013ecee0 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3627,7 +3627,6 @@ void processinput_r(int snum) if (p->on_crane >= 0) goto HORIZONLY; - p->oweapon_sway = p->weapon_sway; if (s->xvel < 32 || p->on_ground == 0 || p->bobcounter == 1024) { if ((p->weapon_sway & 2047) > (1024 + 96)) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 40c44858a..c5c67ec44 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -116,13 +116,20 @@ struct player_struct // this was a global variable originally. vec2_t fric; + // weapon drawer variables and their interpolation counterparts. + int weapon_sway; + int oweapon_sway; + short weapon_pos, kickback_pic; + short oweapon_pos, okickback_pic; + + // From here on it is unaltered from JFDuke with the exception of a few fields that are no longer needed and were removed. int zoom, exitx, exity, loogiex[64], loogiey[64], numloogs, loogcnt; int invdisptime; int bobposx, bobposy, oposx, oposy, oposz, pyoff, opyoff; int posxv, posyv, poszv, last_pissed_time, truefz, truecz; int player_par, visibility; - int bobcounter, weapon_sway, oweapon_sway; + int bobcounter; int pals_time, randomflamex, crack_time; int aim_mode, auto_aim, ftt; @@ -134,7 +141,7 @@ struct player_struct short holoduke_amount, newowner, hurt_delay, hbomb_hold_delay; short jumping_counter, airleft, knee_incs, access_incs; short ftq, access_wallnum, access_spritenum; - short kickback_pic, got_access, weapon_ang, firstaid_amount; + short got_access, weapon_ang, firstaid_amount; short somethingonplayer, on_crane, i, one_parallax_sectnum; short over_shoulder_on, random_club_frame, fist_incs; short cheat_phase; @@ -146,7 +153,7 @@ struct player_struct short dead_flag, show_empty_weapon; // JBF 20031220: added orotscrnang short scuba_amount, jetpack_amount, steroids_amount, shield_amount; - short holoduke_on, pycount, weapon_pos, frag_ps, oweapon_pos; + short holoduke_on, pycount, frag_ps; short transporter_hold, last_full_weapon, footprintshade, boot_amount; int scream_voice;