From: Jeff M. <jef...@us...> - 2006-08-11 05:35:10
|
Update of /cvsroot/bzflag/bzflag/src/bzflag In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14698/src/bzflag Modified Files: LocalPlayer.cxx LocalPlayer.h Player.cxx Player.h Log Message: move reload timer into base player class, so everyone can get to it Index: LocalPlayer.cxx =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/LocalPlayer.cxx,v retrieving revision 2.47 retrieving revision 2.48 diff -w -u -r2.47 -r2.48 --- LocalPlayer.cxx 5 Aug 2006 23:57:48 -0000 2.47 +++ LocalPlayer.cxx 11 Aug 2006 05:35:06 -0000 2.48 @@ -974,49 +974,6 @@ return; } - -float LocalPlayer::getReloadTime() const -{ - World *world = World::getWorld(); - if (!world) { - return 0.0f; - } - const int numShots = world->getMaxShots(); - if (numShots <= 0) { - return 0.0f; - } - - float time = float(jamTime - TimeKeeper::getCurrent()); - if (time > 0.0f) { - return time; - } - - // look for an empty slot - int i; - for (i = 0; i < numShots; i++) { - if (!shots[i]) { - return 0.0f; - } - } - - // look for the shot fired least recently - float minTime = float(shots[0]->getReloadTime() - - (shots[0]->getCurrentTime() - shots[0]->getStartTime())); - for (i = 1; i < numShots; i++) { - const float t = float(shots[i]->getReloadTime() - - (shots[i]->getCurrentTime() - shots[i]->getStartTime())); - if (t < minTime) { - minTime = t; - } - } - - if (minTime < 0.0f) { - minTime = 0.0f; - } - - return minTime; -} - float LocalPlayer::getFlagShakingTime() const { return flagShakingTime; Index: LocalPlayer.h =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/LocalPlayer.h,v retrieving revision 2.12 retrieving revision 2.13 diff -w -u -r2.12 -r2.13 --- LocalPlayer.h 16 Apr 2006 17:34:58 -0000 2.12 +++ LocalPlayer.h 11 Aug 2006 05:35:07 -0000 2.13 @@ -59,7 +59,6 @@ Location getLocation() const; FiringStatus getFiringStatus() const; - float getReloadTime() const; float getFlagShakingTime() const; int getFlagShakingWins() const; const float* getAntidoteLocation() const; @@ -138,7 +137,6 @@ private: Location location; FiringStatus firingStatus; - TimeKeeper jamTime; TimeKeeper bounceTime; TimeKeeper agilityTime; float flagShakingTime; Index: Player.cxx =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/Player.cxx,v retrieving revision 2.49 retrieving revision 2.50 diff -w -u -r2.49 -r2.50 --- Player.cxx 6 Aug 2006 18:20:22 -0000 2.49 +++ Player.cxx 11 Aug 2006 05:35:07 -0000 2.50 @@ -176,6 +176,48 @@ return ((float)wins - losses) / ((wins+losses>20) ? wins+losses : 20); } +float Player::getReloadTime() const +{ + World *world = World::getWorld(); + if (!world) { + return 0.0f; + } + const int numShots = world->getMaxShots(); + if (numShots <= 0) { + return 0.0f; + } + + float time = float(jamTime - TimeKeeper::getCurrent()); + if (time > 0.0f) { + return time; + } + + // look for an empty slot + int i; + for (i = 0; i < numShots; i++) { + if (!shots[i]) { + return 0.0f; + } + } + + // look for the shot fired least recently + float minTime = float(shots[0]->getReloadTime() - + (shots[0]->getCurrentTime() - shots[0]->getStartTime())); + for (i = 1; i < numShots; i++) { + const float t = float(shots[i]->getReloadTime() - + (shots[i]->getCurrentTime() - shots[i]->getStartTime())); + if (t < minTime) { + minTime = t; + } + } + + if (minTime < 0.0f) { + minTime = 0.0f; + } + + return minTime; +} + float Player::getLocalNormalizedScore() const { return ((float)localWins - localLosses) Index: Player.h =================================================================== RCS file: /cvsroot/bzflag/bzflag/src/bzflag/Player.h,v retrieving revision 2.23 retrieving revision 2.24 diff -w -u -r2.23 -r2.24 --- Player.h 6 Aug 2006 02:41:12 -0000 2.23 +++ Player.h 11 Aug 2006 05:35:07 -0000 2.24 @@ -74,6 +74,8 @@ short getScore() const; const float* getDimensions() const; + float Player::getReloadTime() const; + const float* getAperantVelocity() const; const float getLastUpdateTime() const; @@ -188,6 +190,7 @@ std::vector<ShotPath*> shots; float handicap; + TimeKeeper jamTime; private: // return true if the shot had to be terminated or false if it |