* Returns a list of all the targets currently near a certain * cartesian point over the globe. * @param x X coordinate of point. * @param y Y coordinate of point. * @param craft Only get craft targets. * @return List of pointers to targets. */
| 865 | * @return List of pointers to targets. |
| 866 | */ |
| 867 | std::vector<Target*> Globe::getTargets(int x, int y, bool craft) const |
| 868 | { |
| 869 | std::vector<Target*> v; |
| 870 | if (!craft) |
| 871 | { |
| 872 | for (std::vector<Base*>::iterator i = _game->getSavedGame()->getBases()->begin(); i != _game->getSavedGame()->getBases()->end(); ++i) |
| 873 | { |
| 874 | if ((*i)->getLongitude() == 0.0 && (*i)->getLatitude() == 0.0) |
| 875 | continue; |
| 876 | |
| 877 | if (targetNear((*i), x, y)) |
| 878 | { |
| 879 | v.push_back(*i); |
| 880 | } |
| 881 | |
| 882 | for (std::vector<Craft*>::iterator j = (*i)->getCrafts()->begin(); j != (*i)->getCrafts()->end(); ++j) |
| 883 | { |
| 884 | if ((*j)->getLongitude() == (*i)->getLongitude() && (*j)->getLatitude() == (*i)->getLatitude() && (*j)->getDestination() == 0) |
| 885 | continue; |
| 886 | |
| 887 | if (targetNear((*j), x, y)) |
| 888 | { |
| 889 | v.push_back(*j); |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | } |
| 894 | for (std::vector<Ufo*>::iterator i = _game->getSavedGame()->getUfos()->begin(); i != _game->getSavedGame()->getUfos()->end(); ++i) |
| 895 | { |
| 896 | if (!(*i)->getDetected()) |
| 897 | continue; |
| 898 | |
| 899 | if (targetNear((*i), x, y)) |
| 900 | { |
| 901 | v.push_back(*i); |
| 902 | } |
| 903 | } |
| 904 | for (std::vector<Waypoint*>::iterator i = _game->getSavedGame()->getWaypoints()->begin(); i != _game->getSavedGame()->getWaypoints()->end(); ++i) |
| 905 | { |
| 906 | if (targetNear((*i), x, y)) |
| 907 | { |
| 908 | v.push_back(*i); |
| 909 | } |
| 910 | } |
| 911 | for (std::vector<TerrorSite*>::iterator i = _game->getSavedGame()->getTerrorSites()->begin(); i != _game->getSavedGame()->getTerrorSites()->end(); ++i) |
| 912 | { |
| 913 | if (targetNear((*i), x, y)) |
| 914 | { |
| 915 | v.push_back(*i); |
| 916 | } |
| 917 | } |
| 918 | for (std::vector<AlienBase*>::iterator i = _game->getSavedGame()->getAlienBases()->begin(); i != _game->getSavedGame()->getAlienBases()->end(); ++i) |
| 919 | { |
| 920 | if (!(*i)->isDiscovered()) |
| 921 | { |
| 922 | continue; |
| 923 | } |
| 924 | if (targetNear((*i), x, y)) |
no test coverage detected