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

Method lstWeaponsClick

src/Basescape/CraftWeaponsState.cpp:152–178  ·  view source on GitHub ↗

* Equips the weapon on the craft and returns to the previous screen. * @param action Pointer to an action. */

Source from the content-addressed store, hash-verified

150 * @param action Pointer to an action.
151 */
152void 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}

Callers

nothing calls this directly

Calls 15

getLauncherItemMethod · 0.80
getClipItemMethod · 0.80
getClipsLoadedMethod · 0.80
getSelectedRowMethod · 0.80
setRearmingMethod · 0.80
getWeaponsMethod · 0.45
getCraftsMethod · 0.45
addItemMethod · 0.45
getItemsMethod · 0.45
getRulesMethod · 0.45
getRulesetMethod · 0.45
removeItemMethod · 0.45

Tested by

no test coverage detected