mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
SW: Improve main game loop.
- Remove MoveLoop() as it's only ever called by RunLevel(). - Continuously call getinput() and domovethings() within the game's tic rate.
This commit is contained in:
parent
5af0217db7
commit
e878c5bab8
2 changed files with 14 additions and 46 deletions
|
@ -2409,48 +2409,6 @@ void dsprintf_null(char *str, const char *format, ...)
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveLoop(void)
|
|
||||||
{
|
|
||||||
int pnum;
|
|
||||||
|
|
||||||
getpackets();
|
|
||||||
|
|
||||||
if (PredictionOn && CommEnabled)
|
|
||||||
{
|
|
||||||
while (predictmovefifoplc < Player[myconnectindex].movefifoend)
|
|
||||||
{
|
|
||||||
DoPrediction(ppp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//While you have new input packets to process...
|
|
||||||
if (!CommEnabled)
|
|
||||||
bufferjitter = 0;
|
|
||||||
|
|
||||||
while (Player[myconnectindex].movefifoend - movefifoplc > bufferjitter)
|
|
||||||
{
|
|
||||||
//Make sure you have at least 1 packet from everyone else
|
|
||||||
for (pnum=connecthead; pnum>=0; pnum=connectpoint2[pnum])
|
|
||||||
{
|
|
||||||
if (movefifoplc == Player[pnum].movefifoend)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Pnum is >= 0 only if last loop was broken, meaning a player wasn't caught up
|
|
||||||
if (pnum >= 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
domovethings();
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
//if (DemoSyncRecord)
|
|
||||||
// demosync_record();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InitPlayerGameSettings(void)
|
void InitPlayerGameSettings(void)
|
||||||
{
|
{
|
||||||
|
@ -2564,7 +2522,7 @@ void InitRunLevel(void)
|
||||||
StartAmbientSound();
|
StartAmbientSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
void faketimerhandler();
|
void getinput(SW_PACKET*);
|
||||||
|
|
||||||
void RunLevel(void)
|
void RunLevel(void)
|
||||||
{
|
{
|
||||||
|
@ -2573,6 +2531,7 @@ void RunLevel(void)
|
||||||
#if 0
|
#if 0
|
||||||
waitforeverybody();
|
waitforeverybody();
|
||||||
#endif
|
#endif
|
||||||
|
PLAYERp pp = Player + myconnectindex;
|
||||||
ready2send = 1;
|
ready2send = 1;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
|
@ -2580,7 +2539,6 @@ void RunLevel(void)
|
||||||
handleevents();
|
handleevents();
|
||||||
OSD_DispatchQueued();
|
OSD_DispatchQueued();
|
||||||
D_ProcessEvents();
|
D_ProcessEvents();
|
||||||
faketimerhandler();
|
|
||||||
if (LoadGameOutsideMoveLoop)
|
if (LoadGameOutsideMoveLoop)
|
||||||
{
|
{
|
||||||
return; // Stop the game loop if a savegame was loaded from the menu.
|
return; // Stop the game loop if a savegame was loaded from the menu.
|
||||||
|
@ -2592,7 +2550,18 @@ void RunLevel(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MoveLoop();
|
while ((totalclock - ototalclock) >= synctics)
|
||||||
|
{
|
||||||
|
ototalclock += synctics;
|
||||||
|
|
||||||
|
getinput(&loc);
|
||||||
|
pp->inputfifo[Player[myconnectindex].movefifoend & (MOVEFIFOSIZ - 1)] = loc;
|
||||||
|
pp->movefifoend++;
|
||||||
|
|
||||||
|
domovethings();
|
||||||
|
|
||||||
|
timerUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2230,7 +2230,6 @@ extern int lockspeed,totalsynctics;
|
||||||
#define synctics 3
|
#define synctics 3
|
||||||
#define ACTORMOVETICS (synctics<<1)
|
#define ACTORMOVETICS (synctics<<1)
|
||||||
#define TICSPERMOVEMENT synctics
|
#define TICSPERMOVEMENT synctics
|
||||||
#define FAKETIMERHANDLER() if (totalclock >= ototalclock + synctics) faketimerhandler()
|
|
||||||
|
|
||||||
// subtract value from clipdist on getzrange calls
|
// subtract value from clipdist on getzrange calls
|
||||||
#define GETZRANGE_CLIP_ADJ 8
|
#define GETZRANGE_CLIP_ADJ 8
|
||||||
|
|
Loading…
Reference in a new issue