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:
Lee Salzman
2008-10-30 15:44:54 +00:00
parent c380de0426
commit dfe58d1f08
5 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -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;
+6 -3
View File
@@ -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
View File
@@ -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;
+2 -2
View File
@@ -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);
+1
View File
@@ -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);