MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getLandPoint

Method getLandPoint

src/Savegame/AlienMission.cpp:699–717  ·  view source on GitHub ↗

* Get a random point inside the given region zone. * The point will be used to land a UFO, so it HAS to be on land. */

Source from the content-addressed store, hash-verified

697 * The point will be used to land a UFO, so it HAS to be on land.
698 */
699std::pair<double, double> AlienMission::getLandPoint(const Globe &globe, const RuleRegion &region, size_t zone)
700{
701 int tries = 0;
702 std::pair<double, double> pos;
703 do
704 {
705 pos = region.getRandomPoint(zone);
706 ++tries;
707 }
708 while (!(globe.insideLand(pos.first, pos.second)
709 && region.insideRegion(pos.first, pos.second))
710 && tries < 100);
711 if (tries == 100)
712 {
713 Log(LOG_DEBUG) << "Region: " << region.getType() << " Longitude: " << pos.first << " Lattitude: " << pos.second << " invalid zone: " << zone << " ufo forced to land on water!";
714 }
715 return pos;
716
717}
718
719}

Callers

nothing calls this directly

Calls 4

getRandomPointMethod · 0.80
insideLandMethod · 0.80
insideRegionMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected