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

Function updateRobots

src/clientbase/playing.cpp:695–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693
694
695void updateRobots(float dt) {
696 static float newTargetTimeout = 1.0f;
697 static float clock = 0.0f;
698 bool pickTarget = false;
699 int i;
700
701 // see if we should look for new targets
702 clock += dt;
703 if (clock > newTargetTimeout) {
704 while (clock > newTargetTimeout) {
705 clock -= newTargetTimeout;
706 }
707 pickTarget = true;
708 }
709
710 // start dead robots
711 for (i = 0; i < numRobots; i++)
712 if (!gameOver && robots[i] && !robots[i]->isAlive() &&
713 !robots[i]->isExploding() && pickTarget) {
714 serverLink->sendAlive(robots[i]->getId());
715 }
716
717 // retarget robots
718 for (i = 0; i < numRobots; i++) {
719 if (robots[i] && robots[i]->isAlive() &&
720 (pickTarget || !robots[i]->getTarget() ||
721 !robots[i]->getTarget()->isAlive())) {
722 setRobotTarget(robots[i]);
723 }
724 }
725
726 // do updates
727 for (i = 0; i < numRobots; i++) {
728 if (robots[i]) {
729 robots[i]->update();
730 }
731 }
732}
733
734void sendRobotUpdates() {
735 for (int i = 0; i < numRobots; i++) {

Callers 2

updatePositionsFunction · 0.85
updatePositionsFunction · 0.85

Calls 7

setRobotTargetFunction · 0.85
isExplodingMethod · 0.80
sendAliveMethod · 0.80
getIdMethod · 0.80
isAliveMethod · 0.45
getTargetMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected