From 381e15a9b2f8c8143a0a50e98071e53a467543df Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Jul 2020 13:10:18 +0200 Subject: [PATCH] - renamed playerdata_t::input back to sync and made it a static array again. --- source/games/duke/src/duke3d.h | 1 - source/games/duke/src/game.h | 3 --- source/games/duke/src/gamedef.cpp | 1 + source/games/duke/src/gameloop.cpp | 9 ++------ source/games/duke/src/hudweapon_d.cpp | 4 +--- source/games/duke/src/inlines.h | 14 ++++++------ source/games/duke/src/player.h | 4 +--- source/games/duke/src/zz_game.cpp | 31 --------------------------- source/games/duke/src/zz_global.cpp | 1 + 9 files changed, 13 insertions(+), 55 deletions(-) diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 746c16fde..662d6b336 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -39,7 +39,6 @@ struct GameInterface : ::GameInterface const char* Name() override { return "Duke"; } int app_main() override; void UpdateScreenSize() override; - void FreeGameData() override; bool GenerateSavePic() override; bool validate_hud(int) override; void set_hud_layout(int size) override; diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index 18e96ad27..c5a5f83a8 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -71,9 +71,6 @@ extern TileInfo tileinfo[MAXTILES]; extern int startrts(int lumpNum, int localPlayer); -extern void G_MaybeAllocPlayer(int32_t pnum); - - static inline void G_NewGame_EnterLevel(MapRecord *map, int skill) { newgame(map, skill); diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index 05072a614..b512821f1 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -28,6 +28,7 @@ EDuke enhancements integrated: 04/13/2003 - Matt Saettler Note: This source file IS NOT USED in EDuke source. It has been split into many sub-files. +Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) */ //------------------------------------------------------------------------- diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index b5589912f..3c8031c8f 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -55,19 +55,14 @@ void clearfifo(void) { localInput = {}; memset(&inputfifo, 0, sizeof(inputfifo)); - - for (int p = 0; p <= MAXPLAYERS - 1; ++p) - { - if (g_player[p].input != NULL) - *g_player[p].input = {}; - } + memset(sync, 0, sizeof(sync)); } static inline void GetNextInput() { for (int i = connecthead; i >= 0; i = connectpoint2[i]) - memcpy(g_player[i].input /*originally: &sync[i] */, &inputfifo[movefifoplc & (MOVEFIFOSIZ - 1)][i], sizeof(input_t)); + memcpy(&sync[i], &inputfifo[movefifoplc & (MOVEFIFOSIZ - 1)][i], sizeof(input_t)); movefifoplc++; } diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index a17f8a382..ef2aa6825 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -38,13 +38,11 @@ source as it is released. BEGIN_DUKE_NS -// wrapped in case it needs to be refactored int getavel(int snum) { - return (g_player[screenpeek].input->q16avel) >> FRACBITS; + return PlayerInputAngVel(screenpeek) >> FRACBITS; } - //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index bbf741d19..1c20b3edb 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -111,37 +111,37 @@ inline bool isIn(int value, const std::initializer_list& list) // these are mainly here to avoid directly accessing the input data so that it can be more easily refactored later. inline bool PlayerInput(int pl, ESyncBits bit) { - return (!!((g_player[pl].input->bits) & bit)); + return (!!((sync[pl].bits) & bit)); } inline void PlayerSetInput(int pl, ESyncBits bit) { - g_player[pl].input->bits |= bit; + sync[pl].bits |= bit; } inline void PlayerClearInput(int pl, ESyncBits bit) { - g_player[pl].input->bits &= ~bit; + sync[pl].bits &= ~bit; } inline ESyncBits PlayerInputBits(int pl, ESyncBits bits) { - return (g_player[pl].input->bits & bits); + return (sync[pl].bits & bits); } inline int PlayerInputSideVel(int pl) { - return g_player[pl].input->svel; + return sync[pl].svel; } inline int PlayerInputForwardVel(int pl) { - return g_player[pl].input->fvel; + return sync[pl].fvel; } inline fixed_t PlayerInputAngVel(int pl) { - return g_player[pl].input->q16avel; + return sync[pl].q16avel; } inline void clearfriction() diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index ebac0a75e..41e8116eb 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -48,8 +48,6 @@ enum gamemode_t { typedef struct { - input_t *input; - bool horizRecenter; float horizAngleAdjust; fix16_t horizSkew; @@ -63,7 +61,7 @@ typedef struct } playerdata_t; extern uint16_t frags[MAXPLAYERS][MAXPLAYERS]; - +extern input_t sync[MAXPLAYERS]; # define PWEAPON(Player, Weapon, Wmember) (aplWeapon ## Wmember [Weapon][Player]) diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index e2bb7d3cd..46b7b736d 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -279,16 +279,6 @@ void G_HandleLocalKeys(void) static int parsedefinitions_game(scriptfile *, int); -static void G_Cleanup(void) -{ - int32_t i; - - for (i=MAXPLAYERS-1; i>=0; i--) - { - Xfree(g_player[i].input); - } -} - /* =================== = @@ -396,12 +386,6 @@ void G_BackToMenu(void) inputState.keyFlushChars(); } -void G_MaybeAllocPlayer(int32_t pnum) -{ - if (g_player[pnum].input == NULL) - g_player[pnum].input = (input_t *)Xcalloc(1, sizeof(input_t)); -} - void app_loop(); // TODO: reorder (net)weaponhit to eliminate slop and update assertion @@ -490,10 +474,6 @@ int GameInterface::app_main() //bufferjitter = 1; //initsynccrc(); - // This needs to happen before G_CheckCommandLine() because G_GameExit() - // accesses g_player[0]. - G_MaybeAllocPlayer(0); - checkcommandline(); ps[0].aim_mode = 1; @@ -527,11 +507,6 @@ int GameInterface::app_main() connectpoint2[0] = -1; - //Net_GetPackets(); - - for (bssize_t i=0; i