mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -2564,7 +2522,7 @@ void InitRunLevel(void)
|
|||
StartAmbientSound();
|
||||
}
|
||||
|
||||
void faketimerhandler();
|
||||
void getinput(SW_PACKET*);
|
||||
|
||||
void RunLevel(void)
|
||||
{
|
||||
|
@ -2573,6 +2531,7 @@ void RunLevel(void)
|
|||
#if 0
|
||||
waitforeverybody();
|
||||
#endif
|
||||
PLAYERp pp = Player + myconnectindex;
|
||||
ready2send = 1;
|
||||
|
||||
while (TRUE)
|
||||
|
@ -2580,7 +2539,6 @@ void RunLevel(void)
|
|||
handleevents();
|
||||
OSD_DispatchQueued();
|
||||
D_ProcessEvents();
|
||||
faketimerhandler();
|
||||
if (LoadGameOutsideMoveLoop)
|
||||
{
|
||||
return; // Stop the game loop if a savegame was loaded from the menu.
|
||||
|
@ -2592,7 +2550,18 @@ void RunLevel(void)
|
|||
}
|
||||
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 ACTORMOVETICS (synctics<<1)
|
||||
#define TICSPERMOVEMENT synctics
|
||||
#define FAKETIMERHANDLER() if (totalclock >= ototalclock + synctics) faketimerhandler()
|
||||
|
||||
// subtract value from clipdist on getzrange calls
|
||||
#define GETZRANGE_CLIP_ADJ 8
|
||||
|
|
Loading…
Reference in a new issue