mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 04:50:42 +00:00
- input code cleanup.
The input queues are mostly abstracted now and some EDuke specific handling that isn't needed anymore was removed.
This commit is contained in:
parent
9300c0bdeb
commit
f4e763e252
10 changed files with 87 additions and 141 deletions
|
@ -41,17 +41,80 @@ BEGIN_DUKE_NS
|
|||
void GetNextInput();
|
||||
|
||||
|
||||
/*
|
||||
static inline int movefifoend(int myconnectindex)
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// abstract the queue's implementation
|
||||
// All access to the input queues should go through this function interface.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
static input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
||||
static int movefifoend[MAXPLAYERS];
|
||||
static int movefifoplc;
|
||||
|
||||
|
||||
void clearfifo(void)
|
||||
{
|
||||
#if 1
|
||||
return g_player[myconnectindex].movefifoend;
|
||||
#else
|
||||
return movefifoend[myconnectindex];
|
||||
localInput = {};
|
||||
memset(&inputfifo, 0, sizeof(inputfifo));
|
||||
|
||||
for (int p = 0; p <= MAXPLAYERS - 1; ++p)
|
||||
{
|
||||
if (g_player[p].input != NULL)
|
||||
*g_player[p].input = {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
|
||||
movefifoplc++;
|
||||
}
|
||||
|
||||
void advancequeue(int myconnectindex)
|
||||
{
|
||||
movefifoend[myconnectindex]++;
|
||||
}
|
||||
|
||||
input_t& nextinput(int myconnectindex)
|
||||
{
|
||||
return inputfifo[movefifoend[myconnectindex] & (MOVEFIFOSIZ - 1)][myconnectindex];
|
||||
}
|
||||
|
||||
bool shouldprocessinput(int myconnectindex)
|
||||
{
|
||||
if (movefifoend[myconnectindex] - movefifoplc > bufferjitter)
|
||||
{
|
||||
int i;
|
||||
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
if (movefifoplc == movefifoend[i]) return false;
|
||||
if (i >= 0) return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void fakedomovethings()
|
||||
{
|
||||
// prediction
|
||||
}
|
||||
|
||||
static void fakedomovethingscorrect()
|
||||
{
|
||||
// unprediction
|
||||
}
|
||||
|
||||
void prediction()
|
||||
{
|
||||
#if 0
|
||||
// We currently have no net code driving this.
|
||||
if (numplayers > 1)
|
||||
while (fakemovefifoplc < movefifoend[myconnectindex]) fakedomovethings();
|
||||
getpackets();
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -70,22 +133,6 @@ int menuloop(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void fakedomovethings()
|
||||
{
|
||||
// prediction
|
||||
}
|
||||
|
||||
static void fakedomovethingscorrect()
|
||||
{
|
||||
// unprediction
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -254,28 +301,20 @@ int domovethings()
|
|||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
|
||||
char moveloop()
|
||||
|
||||
int moveloop()
|
||||
{
|
||||
int i;
|
||||
|
||||
if (numplayers > 1)
|
||||
while (fakemovefifoplc < movefifoend[myconnectindex]) fakedomovethings();
|
||||
|
||||
getpackets();
|
||||
prediction();
|
||||
|
||||
if (numplayers < 2) bufferjitter = 0;
|
||||
while (movefifoend(myconnectindex)-movefifoplc > bufferjitter)
|
||||
while (shouldprocessinput(myconnectindex))
|
||||
{
|
||||
for(i=connecthead;i>=0;i=connectpoint2[i])
|
||||
if (movefifoplc == movefifoend(i)) break;
|
||||
if (i >= 0) break;
|
||||
if( domovethings() ) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
END_DUKE_NS
|
||||
|
||||
|
|
|
@ -82,15 +82,11 @@ G_EXTERN uint8_t packbuf[PACKBUF_SIZE];
|
|||
G_EXTERN input_t localInput;
|
||||
G_EXTERN input_t recsync[RECSYNCBUFSIZ];
|
||||
|
||||
//G_EXTERN uint8_t syncstat, syncval[MAXPLAYERS][MOVEFIFOSIZ];
|
||||
//G_EXTERN int32_t syncvalhead[MAXPLAYERS], syncvaltail, syncvaltottail;
|
||||
|
||||
G_EXTERN int32_t avgfvel, avgsvel, avgbits;
|
||||
G_EXTERN fix16_t avgavel, avghorz;
|
||||
G_EXTERN int8_t avgextbits;
|
||||
|
||||
G_EXTERN int32_t movefifosendplc;
|
||||
G_EXTERN int32_t movefifoplc;
|
||||
|
||||
G_EXTERN int32_t predictfifoplc;
|
||||
G_EXTERN vec3_t mypos, omypos, myvel;
|
||||
|
@ -257,7 +253,6 @@ extern playerdata_t *const g_player;
|
|||
#endif
|
||||
G_EXTERN playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
|
||||
#define po g_playerSpawnPoints
|
||||
G_EXTERN input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
||||
#pragma pack(pop)
|
||||
|
||||
G_EXTERN int32_t g_noEnemies;
|
||||
|
|
|
@ -137,7 +137,6 @@ typedef struct {
|
|||
uint32_t bits;
|
||||
int16_t fvel, svel;
|
||||
fix16_t q16avel, q16horz;
|
||||
int8_t extbits;
|
||||
} input_t;
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
@ -315,7 +314,6 @@ typedef struct
|
|||
float horizAngleAdjust;
|
||||
fix16_t horizSkew;
|
||||
|
||||
int32_t movefifoend, syncvalhead, myminlag;
|
||||
int32_t pcolor, pteam;
|
||||
// NOTE: wchoice[HANDREMOTE_WEAPON .. MAX_WEAPONS-1] unused
|
||||
uint8_t frags[MAXPLAYERS];
|
||||
|
@ -366,7 +364,6 @@ typedef struct {
|
|||
int32_t shade;
|
||||
} hudweapon_t;
|
||||
|
||||
extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
||||
extern playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
|
||||
extern playerdata_t *const g_player;
|
||||
extern hudweapon_t hudweap;
|
||||
|
|
|
@ -38,7 +38,7 @@ void P_ResetPlayer(int playerNum);
|
|||
void resetplayerstats(int playerNum);
|
||||
void resetweapons(int playerNum);
|
||||
void resetprestat(int snum, int g);
|
||||
void G_ClearFIFO(void);
|
||||
void clearfifo(void);
|
||||
void G_ResetInterpolations(void);
|
||||
void setmapfog(int fogtype);
|
||||
void G_InitRRRASkies(void);
|
||||
|
|
|
@ -313,14 +313,6 @@ void doanimations(void)
|
|||
{
|
||||
ps[p].posz += v;
|
||||
ps[p].poszv = 0;
|
||||
#if 0
|
||||
if (p == myconnectindex)
|
||||
{
|
||||
myz += v;
|
||||
myzvel = 0;
|
||||
myzbak[((movefifoplc - 1) & (MOVEFIFOSIZ - 1))] = ps[p].posz;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
for (j = headspritesect[dasect]; j >= 0; j = nextspritesect[j])
|
||||
|
|
|
@ -56,8 +56,10 @@ void SetDispatcher();
|
|||
void InitCheats();
|
||||
void checkcommandline();
|
||||
int registerosdcommands(void);
|
||||
int32_t G_MoveLoop(void);
|
||||
int32_t moveloop(void);
|
||||
int menuloop(void);
|
||||
void advancequeue(int myconnectindex);
|
||||
input_t& nextinput(int myconnectindex);
|
||||
|
||||
int16_t max_ammo_amount[MAX_WEAPONS];
|
||||
int32_t spriteqamount = 64;
|
||||
|
@ -203,14 +205,14 @@ void G_HandleLocalKeys(void)
|
|||
if (SHIFTS_IS_PRESSED)
|
||||
{
|
||||
Printf(PRINT_NOTIFY, *CombatMacros[ridiculeNum-1]);
|
||||
Net_SendTaunt(ridiculeNum);
|
||||
//Net_SendTaunt(ridiculeNum);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not SHIFT -- that is, either some ALT or WIN.
|
||||
if (startrts(ridiculeNum, 1))
|
||||
{
|
||||
Net_SendRTS(ridiculeNum);
|
||||
//Net_SendRTS(ridiculeNum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -772,8 +774,6 @@ MAIN_LOOP_RESTART:
|
|||
}
|
||||
|
||||
G_NewGame_EnterLevel();
|
||||
|
||||
Net_WaitForEverybody();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -811,9 +811,6 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
Net_GetPackets();
|
||||
|
||||
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
|
||||
inputState.SetBindsEnabled(!!(g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO)));
|
||||
|
||||
G_HandleLocalKeys();
|
||||
|
||||
C_RunDelayedCommands();
|
||||
|
@ -836,7 +833,7 @@ MAIN_LOOP_RESTART:
|
|||
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
||||
auto const pPlayer = g_player[myconnectindex].ps;
|
||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||
auto & input = inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex];
|
||||
auto& input = nextinput(myconnectindex);
|
||||
|
||||
input = localInput;
|
||||
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||
|
@ -847,12 +844,12 @@ MAIN_LOOP_RESTART:
|
|||
pPlayer->fric.y;
|
||||
localInput = {};
|
||||
|
||||
g_player[myconnectindex].movefifoend++;
|
||||
advancequeue(myconnectindex);
|
||||
|
||||
if (((!System_WantGuiCapture() && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) &&
|
||||
(g_player[myconnectindex].ps->gm&MODE_GAME))
|
||||
{
|
||||
G_MoveLoop();
|
||||
moveloop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -894,39 +891,6 @@ MAIN_LOOP_RESTART:
|
|||
while (1);
|
||||
}
|
||||
|
||||
int domovethings();
|
||||
int32_t G_MoveLoop()
|
||||
{
|
||||
int i;
|
||||
|
||||
if (numplayers > 1)
|
||||
while (predictfifoplc < g_player[myconnectindex].movefifoend) Net_DoPrediction();
|
||||
|
||||
Net_GetPackets();
|
||||
|
||||
if (numplayers < 2) bufferjitter = 0;
|
||||
while (g_player[myconnectindex].movefifoend-movefifoplc > bufferjitter)
|
||||
{
|
||||
for(TRAVERSE_CONNECT(i))
|
||||
{
|
||||
if (movefifoplc == g_player[i].movefifoend) break;
|
||||
}
|
||||
if (i >= 0) break;
|
||||
if (domovethings()) return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetNextInput()
|
||||
{
|
||||
for (bssize_t TRAVERSE_CONNECT(i))
|
||||
Bmemcpy(g_player[i].input, &inputfifo[movefifoplc & (MOVEFIFOSIZ - 1)][i], sizeof(input_t));
|
||||
|
||||
movefifoplc++;
|
||||
}
|
||||
|
||||
void GameInterface::FreeGameData()
|
||||
{
|
||||
setmapfog(0);
|
||||
|
|
|
@ -29,8 +29,6 @@ BEGIN_DUKE_NS
|
|||
|
||||
user_defs ud;
|
||||
|
||||
const char *s_buildDate = "20120522";
|
||||
|
||||
char g_gametypeNames[MAXGAMETYPES][33]
|
||||
= { "DukeMatch (Spawn)", "Cooperative Play", "DukeMatch (No Spawn)", "Team DM (Spawn)", "Team DM (No Spawn)" };
|
||||
|
||||
|
@ -57,8 +55,6 @@ int32_t g_tripbombRadius = 3880;
|
|||
|
||||
int16_t weaponsandammosprites[15];
|
||||
|
||||
char CheatKeys[2] = { sc_D, sc_N };
|
||||
|
||||
TileInfo tileinfo[MAXTILES]; // This is not from EDuke32.
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -106,8 +106,6 @@ void P_GetInput(int const playerNum)
|
|||
|
||||
localInput = {};
|
||||
localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT);
|
||||
localInput.extbits |= (1 << 7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -354,13 +352,6 @@ void P_GetInput(int const playerNum)
|
|||
else if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
input.fvel = 0;
|
||||
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
|
||||
localInput.extbits |= buttonMap.ButtonDown(gamefunc_Turn_Left)<<4;
|
||||
localInput.extbits |= buttonMap.ButtonDown(gamefunc_Turn_Right)<<5;
|
||||
|
||||
int const movementLocked = P_CheckLockedMovement(playerNum);
|
||||
|
||||
if ((ud.scrollmode && ud.overhead_on) || (movementLocked & IL_NOTHING) == IL_NOTHING)
|
||||
|
@ -465,8 +456,6 @@ void P_GetInputMotorcycle(int playerNum)
|
|||
|
||||
localInput = {};
|
||||
localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT);
|
||||
localInput.extbits |= (1 << 7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -533,11 +522,6 @@ void P_GetInputMotorcycle(int playerNum)
|
|||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
input.fvel = 0;
|
||||
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
|
||||
|
||||
int turnAmount;
|
||||
int const turn = input.q16avel / 32;
|
||||
int turnLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
|
||||
|
@ -671,8 +655,6 @@ void P_GetInputBoat(int playerNum)
|
|||
|
||||
localInput = {};
|
||||
localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT);
|
||||
localInput.extbits |= (1 << 7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -739,11 +721,6 @@ void P_GetInputBoat(int playerNum)
|
|||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
input.fvel = 0;
|
||||
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Forward) || (input.fvel > 0));
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Move_Backward) || (input.fvel < 0)) << 1;
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2;
|
||||
localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3;
|
||||
|
||||
int turnAmount;
|
||||
int const turn = input.q16avel / 32;
|
||||
int turnLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
|
||||
|
|
|
@ -184,20 +184,6 @@ void G_ResetTimers(uint8_t keepgtics)
|
|||
actor[camsprite].t_data[0] = 0;
|
||||
}
|
||||
|
||||
void G_ClearFIFO(void)
|
||||
{
|
||||
Net_ClearFIFO();
|
||||
|
||||
memset(&localInput, 0, sizeof(input_t));
|
||||
memset(&inputfifo, 0, sizeof(input_t) * MOVEFIFOSIZ * MAXPLAYERS);
|
||||
|
||||
for (bsize_t p = 0; p <= MAXPLAYERS - 1; ++p)
|
||||
{
|
||||
if (g_player[p].input != NULL)
|
||||
Bmemset(g_player[p].input, 0, sizeof(input_t));
|
||||
}
|
||||
}
|
||||
|
||||
int G_FindLevelByFile(const char *fileName)
|
||||
{
|
||||
for (bssize_t volumeNum = 0; volumeNum < MAXVOLUMES; volumeNum++)
|
||||
|
@ -444,7 +430,7 @@ int G_EnterLevel(int gameMode)
|
|||
|
||||
ud.last_level = ud.level_number+1;
|
||||
|
||||
G_ClearFIFO();
|
||||
clearfifo();
|
||||
|
||||
for (i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i];
|
||||
|
||||
|
|
|
@ -1450,7 +1450,7 @@ static void postloadplayer(int32_t savegamep)
|
|||
if (savegamep)
|
||||
{
|
||||
ready2send = 1;
|
||||
G_ClearFIFO();
|
||||
clearfifo();
|
||||
Net_WaitForEverybody();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue