* Equips the weapon on the craft and returns to the previous screen. * @param action Pointer to an action. */
| 150 | * @param action Pointer to an action. |
| 151 | */ |
| 152 | void CraftWeaponsState::lstWeaponsClick(Action *) |
| 153 | { |
| 154 | CraftWeapon *current = _base->getCrafts()->at(_craft)->getWeapons()->at(_weapon); |
| 155 | // Remove current weapon |
| 156 | if (current != 0) |
| 157 | { |
| 158 | _base->getItems()->addItem(current->getRules()->getLauncherItem()); |
| 159 | _base->getItems()->addItem(current->getRules()->getClipItem(), current->getClipsLoaded(_game->getRuleset())); |
| 160 | delete current; |
| 161 | _base->getCrafts()->at(_craft)->getWeapons()->at(_weapon) = 0; |
| 162 | } |
| 163 | |
| 164 | // Equip new weapon |
| 165 | if (_weapons[_lstWeapons->getSelectedRow()] != 0) |
| 166 | { |
| 167 | CraftWeapon *sel = new CraftWeapon(_weapons[_lstWeapons->getSelectedRow()], 0); |
| 168 | sel->setRearming(true); |
| 169 | _base->getItems()->removeItem(sel->getRules()->getLauncherItem()); |
| 170 | _base->getCrafts()->at(_craft)->getWeapons()->at(_weapon) = sel; |
| 171 | if (_base->getCrafts()->at(_craft)->getStatus() == "STR_READY") |
| 172 | { |
| 173 | _base->getCrafts()->at(_craft)->setStatus("STR_REARMING"); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | _game->popState(); |
| 178 | } |
| 179 | |
| 180 | } |
nothing calls this directly
no test coverage detected