network time cleanups
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3336 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -424,7 +424,7 @@ void gets2c() // get updates from the server
|
||||
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
if(discmillis) conoutf("attempting to disconnect...");
|
||||
else localservertoclient(event.channelID, event.packet->data, (int)event.packet->dataLength);
|
||||
else servertoclient(event.channelID, event.packet->data, (int)event.packet->dataLength);
|
||||
enet_packet_destroy(event.packet);
|
||||
break;
|
||||
|
||||
|
||||
@@ -862,15 +862,18 @@ void receivefile(uchar *data, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void localservertoclient(int chan, uchar *buf, int len) // processes any updates from the server
|
||||
void servertoclient(int chan, uchar *buf, int len) // processes any updates from the server
|
||||
{
|
||||
ucharbuf p(buf, len);
|
||||
lastmillis -= curtime; // make sure local packets get processed with the same time as network packets
|
||||
switch(chan)
|
||||
{
|
||||
case 0: parsepositions(p); break;
|
||||
case 1: parsemessages(-1, NULL, p); break;
|
||||
case 2: receivefile(p.buf, p.maxlen); break;
|
||||
}
|
||||
lastmillis += curtime; // restore time
|
||||
}
|
||||
|
||||
void localservertoclient(int chan, uchar *buf, int len) // processes any updates from the server
|
||||
{
|
||||
servertoclient(chan, buf, len);
|
||||
}
|
||||
|
||||
+2
-2
@@ -688,11 +688,11 @@ int main(int argc, char **argv)
|
||||
|
||||
checkinput();
|
||||
|
||||
if(lastmillis) updateworld(curtime, lastmillis);
|
||||
|
||||
lastmillis += curtime;
|
||||
totalmillis = millis;
|
||||
|
||||
if(lastmillis) updateworld(curtime, lastmillis);
|
||||
|
||||
serverslice(0);
|
||||
|
||||
fps = (1000.0f/elapsed+fps*10)/11;
|
||||
|
||||
@@ -614,7 +614,7 @@ int physsteps = 0, physframetime = PHYSFRAMETIME, lastphysframe = 0;
|
||||
|
||||
void physicsframe() // optimally schedule physics frames inside the graphics frames
|
||||
{
|
||||
int diff = lastmillis + curtime - lastphysframe;
|
||||
int diff = lastmillis - lastphysframe;
|
||||
if(diff <= 0) physsteps = 0;
|
||||
else
|
||||
{
|
||||
@@ -632,7 +632,7 @@ void interppos(physent *pl)
|
||||
pl->o = pl->newpos;
|
||||
pl->o.z += pl->eyeheight;
|
||||
|
||||
int diff = lastphysframe - (lastmillis + curtime);
|
||||
int diff = lastphysframe - lastmillis;
|
||||
if(diff <= 0 || !physinterp) return;
|
||||
|
||||
vec deltapos(pl->deltapos);
|
||||
|
||||
@@ -623,6 +623,7 @@ extern int stringsort(const char **a, const char **b);
|
||||
|
||||
// server
|
||||
extern int modeacronyms;
|
||||
extern void servertoclient(int chan, uchar *buf, int len);
|
||||
extern void localservertoclient(int chan, uchar *buf, int len);
|
||||
extern const char *modestr(int n, bool acronyms = false);
|
||||
extern const char *voteerrorstr(int n);
|
||||
|
||||
Reference in New Issue
Block a user