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

Function updatePauseCountdown

src/bzflag/guiplaying.cpp:5394–5469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5392
5393
5394static void updatePauseCountdown(float dt) {
5395 if (!myTank) {
5396 pauseCountdown = 0.0f;
5397 }
5398
5399 if (pauseWaiting && pauseCountdown > 0.0f && !myTank->isAlive()) {
5400 pauseCountdown = 0.0f;
5401 hud->setAlert(1, NULL, 0.0f, true);
5402 }
5403 if (pauseCountdown > 0.0f) {
5404 const int oldPauseCountdown = (int)(pauseCountdown + 0.99f);
5405 pauseCountdown -= dt;
5406 if (pauseCountdown <= 0.0f) {
5407 // make sure it is really safe to pause.. since the server
5408 // might make us drop our flag, make sure the player is on the
5409 // ground and not in a building. prevents getting kicked
5410 // later for being in places we shouldn't without holding the
5411 // right flags.
5412 ServerLink* server = ServerLink::getServer();
5413 if (myTank->getLocation() == LocalPlayer::InBuilding) {
5414 // custom message when trying to pause while in a building
5415 // (could get stuck on un-pause if flag is taken/lost)
5416 server->sendPaused(false);
5417 hud->setAlert(1, "Can't pause while inside a building", 1.0f, false);
5418 }
5419 else if (myTank->getLocation() == LocalPlayer::InAir || myTank->isFalling()) {
5420 // custom message when trying to pause when jumping/falling
5421 server->sendPaused(false);
5422 hud->setAlert(1, "Can't pause when you are in the air", 1.0f, false);
5423 }
5424 else if (myTank->getLocation() != LocalPlayer::OnGround &&
5425 myTank->getLocation() != LocalPlayer::OnBuilding) {
5426 // catch-all message when trying to pause when you should not
5427 server->sendPaused(false);
5428 hud->setAlert(1, "Unable to pause right now", 1.0f, false);
5429 }
5430 else if (myTank->isPhantomZoned()) {
5431 // custom message when trying to pause while zoned
5432 server->sendPaused(false);
5433 hud->setAlert(1, "Can't pause when you are in the phantom zone", 1.0f, false);
5434 }
5435 else {
5436 // okay, now we pause. first drop any team flag we may have.
5437 const FlagType* flagd = myTank->getFlagType();
5438 if (flagd->flagTeam != NoTeam) {
5439 serverLink->sendDropFlag(myTank->getPosition());
5440 myTank->setShotType(StandardShot);
5441 }
5442
5443 if (World::getWorld() && World::getWorld()->allowRabbit() &&
5444 (myTank->getTeam() == RabbitTeam)) {
5445 serverLink->sendNewRabbit();
5446 }
5447
5448 // now actually pause
5449//FIXME myTank->setPause(true);
5450//FIXME hud->setAlert(1, NULL, 0.0f, true);
5451//FIXME showMessage("Paused");

Callers 1

updateTimesFunction · 0.85

Calls 15

setAlertMethod · 0.80
getLocationMethod · 0.80
sendPausedMethod · 0.80
isFallingMethod · 0.80
isPhantomZonedMethod · 0.80
sendDropFlagMethod · 0.80
allowRabbitMethod · 0.80
sendNewRabbitMethod · 0.80
setMuteMethod · 0.80
isAliveMethod · 0.45
getFlagTypeMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected