- renamed playerdata_t::input back to sync and made it a static array again.

This commit is contained in:
Christoph Oelckers 2020-07-15 13:10:18 +02:00
parent a9f152c1fe
commit 381e15a9b2
9 changed files with 13 additions and 55 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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)
*/
//-------------------------------------------------------------------------

View file

@ -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++;
}

View file

@ -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;
}
//---------------------------------------------------------------------------
//
//

View file

@ -111,37 +111,37 @@ inline bool isIn(int value, const std::initializer_list<int>& 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()

View file

@ -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])

View file

@ -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<MAXPLAYERS; i++)
G_MaybeAllocPlayer(i);
G_Startup(); // a bunch of stuff including compiling cons
ps[myconnectindex].palette = BASEPAL;
@ -730,12 +705,6 @@ MAIN_LOOP_RESTART:
while (1);
}
void GameInterface::FreeGameData()
{
setmapfog(0);
G_Cleanup();
}
::GameInterface* CreateInterface()
{
return new GameInterface;

View file

@ -54,6 +54,7 @@ int32_t g_timerTicsPerSecond = TICRATE;
int32_t g_tripbombRadius = 3880;
uint16_t frags[MAXPLAYERS][MAXPLAYERS];
input_t sync[MAXPLAYERS];
int16_t weaponsandammosprites[15];