From 584ec935eddf303dea43283735f7674cf69d6e69 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 7 Sep 2020 20:35:35 +1000 Subject: [PATCH] - SW: Add Duke's input helpers and adjust to suit SW. * These are temporary until a backend solution is available after all games have had initial uplift. --- source/sw/src/game.h | 7 ++++++ source/sw/src/player.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ source/sw/src/player.h | 5 ++++ 3 files changed, 66 insertions(+) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 4e24bf84f..78e822263 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -1007,6 +1007,13 @@ struct PLAYERstruct int cookieTime; char WpnReloadState; + + // Input helper variables and setters. + double horizAdjust, angAdjust, pitchAdjust; + void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; } + void setang(int v) { q16ang = IntToFixed(v); } + void addhoriz(int v) { q16horiz += (IntToFixed(v)); } + void sethoriz(int v) { q16horiz = IntToFixed(v); } }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index fec5fdac7..5c861bc85 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -7785,6 +7785,60 @@ void CheckFootPrints(PLAYERp pp) } } +//--------------------------------------------------------------------------- +// +// Unsynchronised input helpers. +// +//--------------------------------------------------------------------------- + +void playerAddAngle(PLAYERp pp, int ang) +{ + if (!cl_syncinput) + { + pp->angAdjust += ang; + } + else + { + pp->addang(ang); + } +} + +void playerSetAngle(PLAYERp pp, int ang) +{ + if (!cl_syncinput) + { + pp->angAdjust += -1. * ((pp->q16ang / 65536.) - ang); + } + else + { + pp->setang(ang); + } +} + +void playerAddHoriz(PLAYERp pp, int horiz) +{ + if (!cl_syncinput) + { + pp->horizAdjust += horiz; + } + else + { + pp->addhoriz(horiz); + } +} + +void playerSetHoriz(PLAYERp pp, int horiz) +{ + if (!cl_syncinput) + { + pp->horizAdjust += -1. * ((pp->q16horiz / 65536.) - horiz); + } + else + { + pp->sethoriz(horiz); + } +} + //--------------------------------------------------------------------------- // // diff --git a/source/sw/src/player.h b/source/sw/src/player.h index f50cac9c7..608dc40ff 100644 --- a/source/sw/src/player.h +++ b/source/sw/src/player.h @@ -144,6 +144,11 @@ void PlaySOsound(short sectnum,short sound_num); void DoSpawnTeleporterEffectPlace(SPRITEp sp); void FindMainSector(SECTOR_OBJECTp sop); +void playerAddAngle(PLAYERp pp, int ang); +void playerSetAngle(PLAYERp pp, int ang); +void playerAddHoriz(PLAYERp pp, int horiz); +void playerSetHoriz(PLAYERp pp, int horiz); + END_SW_NS #endif