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

Function CheckShots

src/lua/LuaSpatial.cpp:810–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808
809
810static void CheckShots(ShotCheckFunc checkFunc, const QueryData& data,
811 std::vector<const ShotPath*> hits) {
812 const World* world = World::getWorld();
813 if (world == NULL) {
814 return;
815 }
816 int maxShots = world->getMaxShots();
817
818 // draw check shots
819 LocalPlayer* myTank = LocalPlayer::getMyTank();
820 if (myTank) {
821 for (int i = 0; i < maxShots; i++) {
822 const ShotPath* shot = myTank->getShot(i);
823 if (shot && !shot->isExpired()) {
824 if (checkFunc(shot, data)) {
825 hits.push_back(shot);
826 }
827 }
828 }
829 }
830
831 // check robot tanks' shots
832#ifdef ROBOT
833 for (int i = 0; i < numRobots; i++) {
834 const RobotPlayer* player = robots[i];
835 if (player != NULL) {
836 for (int j = 0; j < maxShots; j++) {
837 const ShotPath* shot = player->getShot(j);
838 if (shot && !shot->isExpired()) {
839 if (checkFunc(shot, data)) {
840 hits.push_back(shot);
841 }
842 }
843 }
844 }
845 }
846#endif
847
848 // check other tanks' shots
849 for (int i = 0; i < curMaxPlayers; i++) {
850 const RemotePlayer* player = world->getPlayer(i);
851 if (player != NULL) {
852 for (int j = 0; j < maxShots; j++) {
853 const ShotPath* shot = player->getShot(j);
854 if (shot && !shot->isExpired()) {
855 if (checkFunc(shot, data)) {
856 hits.push_back(shot);
857 }
858 }
859 }
860 }
861 }
862
863 // check world weapon shots
864 const WorldPlayer* worldWeapons = world->getWorldWeapons();
865 if (worldWeapons != NULL) {
866 const int wwMaxShots = worldWeapons->getMaxShots();
867 for (int i = 0; i < wwMaxShots; i++) {

Callers 6

GetShotsInPlanesMethod · 0.85
GetShotsInSphereMethod · 0.85
GetShotsInCylinderMethod · 0.85
GetShotsInBoxMethod · 0.85
GetVisibleShotsMethod · 0.85
GetRadarShotsMethod · 0.85

Calls 6

isExpiredMethod · 0.80
getPlayerMethod · 0.80
getWorldWeaponsMethod · 0.80
getMaxShotsMethod · 0.45
getShotMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected