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

Method maximumDistance

src/Geoscape/DogfightState.cpp:1237–1257  ·  view source on GitHub ↗

* Sets the craft to the maximum distance * required to fire a weapon. */

Source from the content-addressed store, hash-verified

1235 * required to fire a weapon.
1236 */
1237void DogfightState::maximumDistance()
1238{
1239 int min = 1000;
1240 for (std::vector<CraftWeapon*>::iterator i = _craft->getWeapons()->begin(); i < _craft->getWeapons()->end(); ++i)
1241 {
1242 if (*i == 0)
1243 continue;
1244 if ((*i)->getRules()->getRange() < min && (*i)->getAmmo() > 0)
1245 {
1246 min = (*i)->getRules()->getRange();
1247 }
1248 }
1249 if (min == 1000)
1250 {
1251 _targetDist = STANDOFF_DIST;
1252 }
1253 else
1254 {
1255 _targetDist = min * 8;
1256 }
1257}
1258
1259/**
1260 * Updates the status text and restarts

Callers

nothing calls this directly

Calls 4

getWeaponsMethod · 0.45
getRangeMethod · 0.45
getRulesMethod · 0.45
getAmmoMethod · 0.45

Tested by

no test coverage detected