diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index ce3eaaa5a..27322cc84 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -789,6 +789,7 @@ void apply_seasick(player_struct* p, double factor) void applylook(int snum, double factor, fixed_t adjustment) { auto p = &ps[snum]; + fixed_t q16avel; if (p->dead_flag == 0) { @@ -831,7 +832,17 @@ void applylook(int snum, double factor, fixed_t adjustment) p->q16ang += fix16_from_dbl(factor * p->angAdjust); } - p->q16ang = (p->q16ang + adjustment) & 0x7FFFFFF; + // Taken from processinput() for use with applying look while cl_syncinput is 0. + if (p->psectlotag == ST_2_UNDERWATER) + { + q16avel = (adjustment - (adjustment >> 3)) * sgn(TICSPERFRAME); + } + else + { + q16avel = adjustment * sgn(TICSPERFRAME); + } + + p->q16ang = (p->q16ang + q16avel) & 0x7FFFFFF; } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index ca87a2dde..de46f819d 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2757,6 +2757,8 @@ void processinput_d(int snum) movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist); } + p->psectlotag = psectlotag; + //Do the quick lefts and rights if (movementBlocked(snum)) @@ -2771,16 +2773,7 @@ void processinput_d(int snum) //ENGINE calculates angvel for you // may still be needed later for demo recording - if (psectlotag == ST_2_UNDERWATER) - { - p->q16angvel = (sb_avel - (sb_avel >> 3)) * sgn(doubvel); - } - else - { - p->q16angvel = sb_avel * sgn(doubvel); - } - - applylook(snum, 1, p->q16angvel); + applylook(snum, 1, sb_avel); p->crack_time = 777; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index b542147ae..e68777761 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3680,6 +3680,8 @@ void processinput_r(int snum) movement(snum, sb_snum, psect, fz, cz, shrunk, truefdist); } + p->psectlotag = psectlotag; + //Do the quick lefts and rights if (movementBlocked(snum)) @@ -3694,16 +3696,7 @@ void processinput_r(int snum) //ENGINE calculates angvel for you // may still be needed later for demo recording - if (psectlotag == ST_2_UNDERWATER) - { - p->q16angvel = (sb_avel - (sb_avel >> 3)) * sgn(doubvel); - } - else - { - p->q16angvel = sb_avel * sgn(doubvel); - } - - applylook(snum, 1, p->q16angvel); + applylook(snum, 1, sb_avel); p->crack_time = 777; } diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 99044ca90..f5a12090a 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -95,7 +95,7 @@ void resetplayerstats(int snum) p->pyoff = 0; p->opyoff = 0; p->loogcnt = 0; - p->q16angvel = 0; + p->psectlotag = 0; p->weapon_sway = 0; // p->select_dir = 0; p->extra_extra8 = 0; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 67cd209a0..e150af7e9 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -149,7 +149,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("crack_time", w.crack_time) ("aim.mode", w.aim_mode) ("auto_aim", w.auto_aim) - ("q16angvel", w.q16angvel) + ("psectlotag", w.psectlotag) ("cursectnum", w.cursectnum) ("last_extra", w.last_extra) ("subweapon", w.subweapon) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index f8245b260..dd5e9e386 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -102,7 +102,7 @@ struct player_struct }; // input handles angle and horizon as fixed16 numbers. We need to account for that as well. - fixed_t q16ang, q16horiz, q16horizoff, q16rotscrnang, q16look_ang, q16angvel; + fixed_t q16ang, q16horiz, q16horizoff, q16rotscrnang, q16look_ang; fixed_t oq16ang, oq16horiz, oq16horizoff, oq16rotscrnang, oq16look_ang; // These are only needed with synchronous mouse input. fixed_t one_eighty_count; @@ -124,6 +124,8 @@ struct player_struct unsigned char hard_landing; unsigned char ohard_landing; + // Store current psectlotag as determined in processinput() for use with scaling angle aiming. + short psectlotag; // 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;