From 335c980650395a5a9c2d709027677d278f1ad59c Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 30 Jul 2008 00:11:01 +0000 Subject: [PATCH] movement prediction fixes git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2256 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 5 ++--- source/src/clients2c.cpp | 6 +++--- source/src/entity.h | 4 ++-- source/src/protos.h | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index f42bd0ef..20c91aa4 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -247,7 +247,6 @@ void predictplayer(playerent *d, bool move) else if(d->yaw>=360) d->yaw -= 360; d->pitch += d->deltapitch*k; } - d->lastpredict = lastmillis; } void moveotherplayers() @@ -298,10 +297,10 @@ void updateworld(int curtime, int lastmillis) // main game update loop checkweaponswitch(); checkakimbo(); if(getclientnum()>=0) shoot(player1, worldpos); // only shoot when connected to server - gets2c(); // do this first, so we have most accurate information when our player moves movebounceents(); moveotherplayers(); - + gets2c(); + // Added by Rick: let bots think if(m_botmode) BotManager.Think(); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index f7249998..afc9e56f 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -80,8 +80,6 @@ void parsepositions(ucharbuf &p) int f = getuint(p), seqcolor = (f>>6)&1; playerent *d = getclient(cn); if(!d || seqcolor!=(d->lifesequence&1)) continue; - extern int smoothmove, smoothdist; - if(smoothmove && d->smoothmillis>=0 && d->lastpredict < lastmillis) predictplayer(d, false); vec oldpos(d->o); float oldyaw = d->yaw, oldpitch = d->pitch; d->o = o; @@ -100,6 +98,7 @@ void parsepositions(ucharbuf &p) updatecrouch(d, f&1); updatepos(d); updatelagtime(d); + extern int smoothmove, smoothdist; if(d->state==CS_DEAD) { d->resetinterp(); @@ -760,11 +759,12 @@ void receivefile(uchar *data, int len) void localservertoclient(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 } diff --git a/source/src/entity.h b/source/src/entity.h index 8b3b3222..3e58740c 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -339,7 +339,7 @@ struct playerstate struct playerent : dynent, playerstate { - int clientnum, lastupdate, lastpredict, plag, ping; + int clientnum, lastupdate, plag, ping; int lifesequence; // sequence id for each respawn, used in damage test int frags, flagscore, deaths; int lastaction, lastmove, lastpain, lastvoicecom; @@ -362,7 +362,7 @@ struct playerent : dynent, playerstate float deltayaw, deltapitch, newyaw, newpitch; int smoothmillis; - playerent() : clientnum(-1), lastupdate(0), lastpredict(0), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), deaths(0), lastpain(0), lastvoicecom(0), clientrole(CR_DEFAULT), + playerent() : clientnum(-1), lastupdate(0), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), deaths(0), lastpain(0), lastvoicecom(0), clientrole(CR_DEFAULT), skin(0), nextskin(0), spectatemode(SM_NONE), followplayercn(-1), eardamagemillis(0), weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), smoothmillis(-1) diff --git a/source/src/protos.h b/source/src/protos.h index 024f1fb3..8564d86e 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -293,7 +293,6 @@ extern char *getclientmap(); extern void zapplayer(playerent *&d); extern playerent *getclient(int cn); extern playerent *newclient(int cn); -extern void predictplayer(playerent *d, bool move); extern void timeupdate(int timeremain); extern void respawnself(); extern void setskin(playerent *pl, uint skin);