* Confirms the selected target for the craft. * @param action Pointer to an action. */
| 112 | * @param action Pointer to an action. |
| 113 | */ |
| 114 | void ConfirmDestinationState::btnOkClick(Action *) |
| 115 | { |
| 116 | Waypoint *w = dynamic_cast<Waypoint*>(_target); |
| 117 | if (w != 0 && w->getId() == 0) |
| 118 | { |
| 119 | w->setId(_game->getSavedGame()->getId("STR_WAYPOINT")); |
| 120 | _game->getSavedGame()->getWaypoints()->push_back(w); |
| 121 | } |
| 122 | _craft->setDestination(_target); |
| 123 | _craft->setStatus("STR_OUT"); |
| 124 | if(_craft->getInterceptionOrder() == 0) |
| 125 | { |
| 126 | int maxInterceptionOrder = 0; |
| 127 | for(std::vector<Base*>::iterator baseIt = _game->getSavedGame()->getBases()->begin(); baseIt != _game->getSavedGame()->getBases()->end(); ++baseIt) |
| 128 | { |
| 129 | for(std::vector<Craft*>::iterator craftIt = (*baseIt)->getCrafts()->begin(); craftIt != (*baseIt)->getCrafts()->end(); ++craftIt) |
| 130 | { |
| 131 | if((*craftIt)->getInterceptionOrder() > maxInterceptionOrder) |
| 132 | { |
| 133 | maxInterceptionOrder = (*craftIt)->getInterceptionOrder(); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | _craft->setInterceptionOrder(++maxInterceptionOrder); |
| 138 | } |
| 139 | _game->popState(); |
| 140 | _game->popState(); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Returns to the previous screen. |
nothing calls this directly
no test coverage detected