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

Method updateMissions

game/state/shared/organisation.cpp:399–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399void Organisation::updateMissions(GameState &state)
400{
401 if (state.getPlayer().id == id)
402 {
403 return;
404 }
405 StateRef<Organisation> currentOrg{&state, id};
406 auto &raidMissions = raid_missions[state.current_city];
407 auto it = raidMissions.begin();
408 while (it != raidMissions.end())
409 {
410 if (it->time < state.gameTime.getTicks())
411 {
412 // Raid missions are one-time only, erase if triggered
413 it->execute(state, state.current_city, currentOrg);
414 it = raidMissions.erase(it);
415 }
416 else
417 {
418 ++it;
419 }
420 }
421#ifdef DEBUG_TURN_OFF_ORG_MISSIONS
422 return;
423#endif
424 for (auto &m : recurring_missions[state.current_city])
425 {
426 if (m.time < state.gameTime.getTicks())
427 {
428 m.execute(state, state.current_city, currentOrg);
429 }
430 }
431 // Find rescue-capable craft
432 StateRef<Vehicle> rescueTransport;
433 for (auto &v : state.vehicles)
434 {
435 if (v.second->owner.id == id && v.second->missions.empty() &&
436 v.second->type->canRescueCrashed)
437 {
438 rescueTransport = {&state, v.first};
439 break;
440 }
441 }
442 // Attempt rescue someone
443 if (rescueTransport)
444 {
445 // Rescue owned
446 for (auto &v : state.vehicles)
447 {
448 if (v.second->city == rescueTransport->city && v.second->owner.id == id &&
449 VehicleMission::canRecoverVehicle(state, *rescueTransport, *v.second))
450 {
451 bool foundRescuer = false;
452 for (auto &r : state.vehicles)
453 {
454 if (r.second->city == rescueTransport->city && r.second->type->canRescueCrashed)
455 {
456 for (auto &m : r.second->missions)

Callers 1

updateMethod · 0.80

Calls 9

getPlayerMethod · 0.80
endMethod · 0.80
getTicksMethod · 0.80
executeMethod · 0.80
emptyMethod · 0.80
getAliensMethod · 0.80
beginMethod · 0.45
setMissionMethod · 0.45
addMissionMethod · 0.45

Tested by

no test coverage detected