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

Method setBase

src/Basescape/BasescapeState.cpp:229–261  ·  view source on GitHub ↗

* Changes the base currently displayed on screen. * @param base Pointer to new base to display. */

Source from the content-addressed store, hash-verified

227 * @param base Pointer to new base to display.
228 */
229void BasescapeState::setBase(Base *base)
230{
231 if (!_game->getSavedGame()->getBases()->empty())
232 {
233 // Check if base still exists
234 bool exists = false;
235 for (size_t i = 0; i < _game->getSavedGame()->getBases()->size(); ++i)
236 {
237 if (_game->getSavedGame()->getBases()->at(i) == base)
238 {
239 _base = base;
240 _mini->setSelectedBase(i);
241 _game->getSavedGame()->setSelectedBase(i);
242 exists = true;
243 break;
244 }
245 }
246 // If base was removed, select first one
247 if (!exists)
248 {
249 _base = _game->getSavedGame()->getBases()->front();
250 _mini->setSelectedBase(0);
251 _game->getSavedGame()->setSelectedBase(0);
252 }
253 }
254 else
255 {
256 // Use a blank base for special case when player has no bases
257 _base = new Base(_game->getRuleset());
258 _mini->setSelectedBase(0);
259 _game->getSavedGame()->setSelectedBase(0);
260 }
261}
262
263/**
264 * Goes to the Build New Base screen.

Callers 1

initMethod · 0.45

Calls 5

getBasesMethod · 0.80
getSavedGameMethod · 0.80
emptyMethod · 0.45
setSelectedBaseMethod · 0.45
getRulesetMethod · 0.45

Tested by

no test coverage detected