MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / getReloadTime

Method getReloadTime

src/clientbase/Player.cpp:201–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199
200
201float Player::getReloadTime() const {
202 World* world = World::getWorld();
203 if (!world) {
204 return 0.0f;
205 }
206
207 const int numShots = world->getMaxShots();
208 if (numShots <= 0) {
209 return 0.0f;
210 }
211
212 float time = float(jamTime - BzTime::getCurrent());
213 if (time > 0.0f) {
214 return time;
215 }
216
217 // look for an empty slot
218 int i;
219 for (i = 0; i < numShots; i++) {
220 if (!shots[i]) {
221 return 0.0f;
222 }
223 }
224
225 // look for the shot fired least recently
226 float minTime = float(shots[0]->getReloadTime() - (shots[0]->getCurrentTime() - shots[0]->getStartTime()));
227 for (i = 1; i < numShots; i++) {
228 const float t = float(shots[i]->getReloadTime() - (shots[i]->getCurrentTime() - shots[i]->getStartTime()));
229 if (minTime > t) {
230 minTime = t;
231 }
232 }
233
234 if (minTime < 0.0f) {
235 minTime = 0.0f;
236 }
237
238 return minTime;
239}
240
241
242float Player::getLocalNormalizedScore() const {

Callers 9

RapidFireStrategyMethod · 0.45
ThiefStrategyMethod · 0.45
MachineGunStrategyMethod · 0.45
LaserStrategyMethod · 0.45
trackPlayerShotFunction · 0.45
renderStatusMethod · 0.45
renderShotsMethod · 0.45
GetShotReloadTimeMethod · 0.45
processMethod · 0.45

Calls 3

getCurrentTimeMethod · 0.80
getMaxShotsMethod · 0.45
getStartTimeMethod · 0.45

Tested by

no test coverage detected