Skip to content

Commit 9fef9e5

Browse files
committed
Merge pull request OpenXcom#872 from nilekurt/master
Make the game object pointer a static member of the state class, revision 2
2 parents 4a142c9 + f2e1903 commit 9fef9e5

270 files changed

Lines changed: 683 additions & 673 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Basescape/BaseInfoState.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace OpenXcom
4646
* @param base Pointer to the base to get info from.
4747
* @param state Pointer to the Basescape state.
4848
*/
49-
BaseInfoState::BaseInfoState(Game *game, Base *base, BasescapeState *state) : State(game), _base(base), _state(state)
49+
BaseInfoState::BaseInfoState(Base *base, BasescapeState *state) : _base(base), _state(state)
5050
{
5151
// Create objects
5252
_bg = new Surface(320, 200, 0, 0);
@@ -484,7 +484,7 @@ void BaseInfoState::btnOkClick(Action *)
484484
*/
485485
void BaseInfoState::btnTransfersClick(Action *)
486486
{
487-
_game->pushState(new TransfersState(_game, _base));
487+
_game->pushState(new TransfersState(_base));
488488
}
489489

490490
/**
@@ -493,7 +493,7 @@ void BaseInfoState::btnTransfersClick(Action *)
493493
*/
494494
void BaseInfoState::btnStoresClick(Action *)
495495
{
496-
_game->pushState(new StoresState(_game, _base));
496+
_game->pushState(new StoresState(_base));
497497
}
498498

499499
/**
@@ -502,7 +502,7 @@ void BaseInfoState::btnStoresClick(Action *)
502502
*/
503503
void BaseInfoState::btnMonthlyCostsClick(Action *)
504504
{
505-
_game->pushState(new MonthlyCostsState(_game, _base));
505+
_game->pushState(new MonthlyCostsState(_base));
506506
}
507507

508508
}

src/Basescape/BaseInfoState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class BaseInfoState : public State
6161
Bar *_barDefense, *_barShortRange, *_barLongRange;
6262
public:
6363
/// Creates the Base Info state.
64-
BaseInfoState(Game *game, Base *base, BasescapeState *state);
64+
BaseInfoState(Base *base, BasescapeState *state);
6565
/// Cleans up the Base Info state.
6666
~BaseInfoState();
6767
/// Updates the base stats.

src/Basescape/BaseView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ BaseFacility *BaseView::getSelectedFacility() const
132132
*/
133133
void BaseView::resetSelectedFacility()
134134
{
135-
_facilities[_selFacility->getX()][_selFacility->getY()] = 0;
136-
_selFacility = 0;
135+
_facilities[_selFacility->getX()][_selFacility->getY()] = 0;
136+
_selFacility = 0;
137137
}
138138

139139

src/Basescape/BasescapeState.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace OpenXcom
6161
* @param base Pointer to the base to get info from.
6262
* @param globe Pointer to the Geoscape globe.
6363
*/
64-
BasescapeState::BasescapeState(Game *game, Base *base, Globe *globe) : State(game), _base(base), _globe(globe)
64+
BasescapeState::BasescapeState(Base *base, Globe *globe) : _base(base), _globe(globe)
6565
{
6666
// Create objects
6767
_txtFacility = new Text(192, 9, 0, 0);
@@ -268,7 +268,7 @@ void BasescapeState::btnNewBaseClick(Action *)
268268
{
269269
Base *base = new Base(_game->getRuleset());
270270
_game->popState();
271-
_game->pushState(new BuildNewBaseState(_game, base, _globe, false));
271+
_game->pushState(new BuildNewBaseState(base, _globe, false));
272272
}
273273

274274
/**
@@ -277,7 +277,7 @@ void BasescapeState::btnNewBaseClick(Action *)
277277
*/
278278
void BasescapeState::btnBaseInfoClick(Action *)
279279
{
280-
_game->pushState(new BaseInfoState(_game, _base, this));
280+
_game->pushState(new BaseInfoState(_base, this));
281281
}
282282

283283
/**
@@ -286,7 +286,7 @@ void BasescapeState::btnBaseInfoClick(Action *)
286286
*/
287287
void BasescapeState::btnSoldiersClick(Action *)
288288
{
289-
_game->pushState(new SoldiersState(_game, _base));
289+
_game->pushState(new SoldiersState(_base));
290290
}
291291

292292
/**
@@ -295,7 +295,7 @@ void BasescapeState::btnSoldiersClick(Action *)
295295
*/
296296
void BasescapeState::btnCraftsClick(Action *)
297297
{
298-
_game->pushState(new CraftsState(_game, _base));
298+
_game->pushState(new CraftsState(_base));
299299
}
300300

301301
/**
@@ -304,7 +304,7 @@ void BasescapeState::btnCraftsClick(Action *)
304304
*/
305305
void BasescapeState::btnFacilitiesClick(Action *)
306306
{
307-
_game->pushState(new BuildFacilitiesState(_game, _base, this));
307+
_game->pushState(new BuildFacilitiesState(_base, this));
308308
}
309309

310310
/**
@@ -313,7 +313,7 @@ void BasescapeState::btnFacilitiesClick(Action *)
313313
*/
314314
void BasescapeState::btnResearchClick(Action *)
315315
{
316-
_game->pushState(new ResearchState(_game, _base));
316+
_game->pushState(new ResearchState(_base));
317317
}
318318

319319
/**
@@ -322,7 +322,7 @@ void BasescapeState::btnResearchClick(Action *)
322322
*/
323323
void BasescapeState::btnManufactureClick(Action *)
324324
{
325-
_game->pushState(new ManufactureState(_game, _base));
325+
_game->pushState(new ManufactureState(_base));
326326
}
327327

328328
/**
@@ -331,7 +331,7 @@ void BasescapeState::btnManufactureClick(Action *)
331331
*/
332332
void BasescapeState::btnPurchaseClick(Action *)
333333
{
334-
_game->pushState(new PurchaseState(_game, _base));
334+
_game->pushState(new PurchaseState(_base));
335335
}
336336

337337
/**
@@ -340,7 +340,7 @@ void BasescapeState::btnPurchaseClick(Action *)
340340
*/
341341
void BasescapeState::btnSellClick(Action *)
342342
{
343-
_game->pushState(new SellState(_game, _base));
343+
_game->pushState(new SellState(_base));
344344
}
345345

346346
/**
@@ -349,7 +349,7 @@ void BasescapeState::btnSellClick(Action *)
349349
*/
350350
void BasescapeState::btnTransferClick(Action *)
351351
{
352-
_game->pushState(new TransferBaseState(_game, _base));
352+
_game->pushState(new TransferBaseState(_base));
353353
}
354354

355355
/**
@@ -373,16 +373,16 @@ void BasescapeState::viewLeftClick(Action *)
373373
// Is facility in use?
374374
if (fac->inUse())
375375
{
376-
_game->pushState(new ErrorMessageState(_game, "STR_FACILITY_IN_USE", _palette, Palette::blockOffset(15)+1, "BACK13.SCR", 6));
376+
_game->pushState(new ErrorMessageState(tr("STR_FACILITY_IN_USE"), _palette, Palette::blockOffset(15)+1, "BACK13.SCR", 6));
377377
}
378378
// Would base become disconnected?
379379
else if (!_base->getDisconnectedFacilities(fac).empty())
380380
{
381-
_game->pushState(new ErrorMessageState(_game, "STR_CANNOT_DISMANTLE_FACILITY", _palette, Palette::blockOffset(15)+1, "BACK13.SCR", 6));
381+
_game->pushState(new ErrorMessageState(tr("STR_CANNOT_DISMANTLE_FACILITY"), _palette, Palette::blockOffset(15)+1, "BACK13.SCR", 6));
382382
}
383383
else
384384
{
385-
_game->pushState(new DismantleFacilityState(_game, _base, _view, fac));
385+
_game->pushState(new DismantleFacilityState(_base, _view, fac));
386386
}
387387
}
388388
}
@@ -396,47 +396,47 @@ void BasescapeState::viewRightClick(Action *)
396396
BaseFacility *f = _view->getSelectedFacility();
397397
if (f == 0)
398398
{
399-
_game->pushState(new BaseInfoState(_game, _base, this));
399+
_game->pushState(new BaseInfoState(_base, this));
400400
}
401401
else if (f->getRules()->getCrafts() > 0)
402402
{
403403
if (f->getCraft() == 0)
404404
{
405-
_game->pushState(new CraftsState(_game, _base));
405+
_game->pushState(new CraftsState(_base));
406406
}
407407
else
408408
for (size_t craft = 0; craft < _base->getCrafts()->size(); ++craft)
409409
{
410410
if (f->getCraft() == _base->getCrafts()->at(craft))
411411
{
412-
_game->pushState(new CraftInfoState(_game, _base, craft));
412+
_game->pushState(new CraftInfoState(_base, craft));
413413
break;
414414
}
415415
}
416416
}
417417
else if (f->getRules()->getStorage() > 0)
418418
{
419-
_game->pushState(new SellState(_game, _base));
419+
_game->pushState(new SellState(_base));
420420
}
421421
else if (f->getRules()->getPersonnel() > 0)
422422
{
423-
_game->pushState(new SoldiersState(_game, _base));
423+
_game->pushState(new SoldiersState(_base));
424424
}
425425
else if (f->getRules()->getPsiLaboratories() > 0 && Options::anytimePsiTraining && _base->getAvailablePsiLabs() > 0)
426426
{
427-
_game->pushState(new AllocatePsiTrainingState(_game, _base));
427+
_game->pushState(new AllocatePsiTrainingState(_base));
428428
}
429429
else if (f->getRules()->getLaboratories() > 0)
430430
{
431-
_game->pushState(new ResearchState(_game, _base));
431+
_game->pushState(new ResearchState(_base));
432432
}
433433
else if (f->getRules()->getWorkshops() > 0)
434434
{
435-
_game->pushState(new ManufactureState(_game, _base));
435+
_game->pushState(new ManufactureState(_base));
436436
}
437437
else if (f->getRules()->getAliens() > 0)
438438
{
439-
_game->pushState(new ManageAlienContainmentState(_game, _base, OPT_GEOSCAPE));
439+
_game->pushState(new ManageAlienContainmentState(_base, OPT_GEOSCAPE));
440440
}
441441
else if (f->getRules()->isLift() || f->getRules()->getRadarRange() > 0)
442442
{

src/Basescape/BasescapeState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class BasescapeState : public State
4848
Globe *_globe;
4949
public:
5050
/// Creates the Basescape state.
51-
BasescapeState(Game *game, Base *base, Globe *globe);
51+
BasescapeState(Base *base, Globe *globe);
5252
/// Cleans up the Basescape state.
5353
~BasescapeState();
5454
/// Updates the base stats.

src/Basescape/BuildFacilitiesState.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace OpenXcom
4040
* @param base Pointer to the base to get info from.
4141
* @param state Pointer to the base state to refresh.
4242
*/
43-
BuildFacilitiesState::BuildFacilitiesState(Game *game, Base *base, State *state) : State(game), _base(base), _state(state), _facilities()
43+
BuildFacilitiesState::BuildFacilitiesState(Base *base, State *state) : _base(base), _state(state), _facilities()
4444
{
4545
_screen = false;
4646

@@ -138,7 +138,7 @@ void BuildFacilitiesState::btnOkClick(Action *)
138138
*/
139139
void BuildFacilitiesState::lstFacilitiesClick(Action *)
140140
{
141-
_game->pushState(new PlaceFacilityState(_game, _base, _facilities[_lstFacilities->getSelectedRow()]));
141+
_game->pushState(new PlaceFacilityState(_base, _facilities[_lstFacilities->getSelectedRow()]));
142142
}
143143

144144
}

src/Basescape/BuildFacilitiesState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class BuildFacilitiesState : public State
4949
TextList *_lstFacilities;
5050
public:
5151
/// Creates the Build Facilities state.
52-
BuildFacilitiesState(Game *game, Base *base, State *state);
52+
BuildFacilitiesState(Base *base, State *state);
5353
/// Cleans up the Build Facilities state.
5454
~BuildFacilitiesState();
5555
/// Populates the build option list.

src/Basescape/CraftArmorState.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace OpenXcom
4343
* @param base Pointer to the base to get info from.
4444
* @param craft ID of the selected craft.
4545
*/
46-
CraftArmorState::CraftArmorState(Game *game, Base *base, size_t craft) : State(game), _base(base), _craft(craft)
46+
CraftArmorState::CraftArmorState(Base *base, size_t craft) : _base(base), _craft(craft)
4747
{
4848
// Create objects
4949
_window = new Window(this, 320, 200, 0, 0);
@@ -159,7 +159,7 @@ void CraftArmorState::lstSoldiersClick(Action *)
159159
{
160160
Soldier *s = _base->getSoldiers()->at(_lstSoldiers->getSelectedRow());
161161
if (!(s->getCraft() && s->getCraft()->getStatus() == "STR_OUT"))
162-
_game->pushState(new SoldierArmorState(_game, _base, _lstSoldiers->getSelectedRow()));
162+
_game->pushState(new SoldierArmorState(_base, _lstSoldiers->getSelectedRow()));
163163
}
164164

165165
}

src/Basescape/CraftArmorState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CraftArmorState : public State
4646
size_t _craft;
4747
public:
4848
/// Creates the Craft Armor state.
49-
CraftArmorState(Game *game, Base *base, size_t craft);
49+
CraftArmorState(Base *base, size_t craft);
5050
/// Cleans up the Craft Armor state.
5151
~CraftArmorState();
5252
/// Updates the soldier armors.

src/Basescape/CraftEquipmentState.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ namespace OpenXcom
5959
* @param base Pointer to the base to get info from.
6060
* @param craft ID of the selected craft.
6161
*/
62-
CraftEquipmentState::CraftEquipmentState(Game *game, Base *base, size_t craft) : State(game), _sel(0), _craft(craft), _base(base)
62+
CraftEquipmentState::CraftEquipmentState(Base *base, size_t craft) : _sel(0), _craft(craft), _base(base)
6363
{
6464
Craft *c = _base->getCrafts()->at(_craft);
6565
bool craftHasACrew = c->getNumSoldiers() > 0;
66-
bool isNewBattle = game->getSavedGame()->getMonthsPassed() == -1;
66+
bool isNewBattle = _game->getSavedGame()->getMonthsPassed() == -1;
6767

6868
// Create objects
6969
_window = new Window(this, 320, 200, 0, 0);
@@ -566,7 +566,7 @@ void CraftEquipmentState::moveRightByValue(int change)
566566
// So we haven't managed to increase the count of vehicles because of the ammo
567567
_timerRight->stop();
568568
LocalizedText msg(tr("STR_NOT_ENOUGH_AMMO_TO_ARM_HWP").arg(tr(ammo->getType())));
569-
_game->pushState(new ErrorMessageState(_game, msg, _palette, Palette::blockOffset(15)+1, "BACK04.SCR", 2));
569+
_game->pushState(new ErrorMessageState(msg, _palette, Palette::blockOffset(15)+1, "BACK04.SCR", 2));
570570
}
571571
}
572572
else
@@ -623,7 +623,7 @@ void CraftEquipmentState::btnInventoryClick(Action *)
623623
_game->getFpsCounter()->setColor(Palette::blockOffset(9));
624624

625625
_game->getScreen()->clear();
626-
_game->pushState(new InventoryState(_game, false, 0));
626+
_game->pushState(new InventoryState(false, 0));
627627
}
628628
}
629629

0 commit comments

Comments
 (0)