MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / getNewGoal

Method getNewGoal

game/state/city/vehicle.cpp:3270–3303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3268}
3269
3270bool Vehicle::getNewGoal(GameState &state, int &turboTiles)
3271{
3272 bool popped = false;
3273 bool acquired = false;
3274 // Pop finished missions if present
3275 popped = popFinishedMissions(state);
3276 int debug_deadlock_preventor = 1000;
3277 do
3278 {
3279 debug_deadlock_preventor--;
3280 // Try to get new destination
3281 if (!missions.empty())
3282 {
3283 acquired = missions.front().getNextDestination(state, *this, goalPosition, goalFacing,
3284 turboTiles);
3285 }
3286 // Pop finished missions if present
3287 popped = popFinishedMissions(state);
3288 } while (popped && !acquired && debug_deadlock_preventor > 0);
3289 if (debug_deadlock_preventor <= 0)
3290 {
3291 LogWarning("Vehicle %s at %s", name, position);
3292 for (auto &m : missions)
3293 {
3294 LogWarning("Mission %s", m.getName());
3295 }
3296 LogError("Vehicle %s deadlocked, please send log to developers. Vehicle will self-destruct "
3297 "now...",
3298 name);
3299 die(state);
3300 return false;
3301 }
3302 return acquired;
3303}
3304
3305float Vehicle::getSpeed() const
3306{

Callers 2

updateMethod · 0.45
updateMethod · 0.45

Calls 3

emptyMethod · 0.80
getNextDestinationMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected