Skip to content

Commit 2ac7f76

Browse files
committed
Check if removing aliens overfills stores
1 parent 364e8bc commit 2ac7f76

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎src/Basescape/ManageAlienContainmentState.cpp‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "../Engine/Timer.h"
4141
#include "../Engine/Options.h"
4242
#include "../Menu/ErrorMessageState.h"
43+
#include "SellState.h"
4344

4445
namespace OpenXcom
4546
{
@@ -50,9 +51,9 @@ namespace OpenXcom
5051
* @param base Pointer to the base to get info from.
5152
* @param origin Game section that originated this state.
5253
*/
53-
ManageAlienContainmentState::ManageAlienContainmentState(Game *game, Base *base, OptionsOrigin origin) : State(game), _base(base), _qtys(), _aliens(), _sel(0), _aliensSold(0), _researchedAliens(0)
54+
ManageAlienContainmentState::ManageAlienContainmentState(Game *game, Base *base, OptionsOrigin origin) : State(game), _base(base), _origin(origin), _qtys(), _aliens(), _sel(0), _aliensSold(0), _researchedAliens(0)
5455
{
55-
_overCrowded = Options::alienContainmentLimitEnforced && _base->getAvailableContainment() < _base->getUsedContainment();
56+
_overCrowded = Options::storageLimitsEnforced && _base->getAvailableContainment() < _base->getUsedContainment();
5657

5758
for(std::vector<ResearchProject*>::const_iterator iter = _base->getResearch().begin (); iter != _base->getResearch().end (); ++iter)
5859
{
@@ -227,6 +228,15 @@ void ManageAlienContainmentState::btnOkClick(Action *)
227228
}
228229
}
229230
_game->popState();
231+
232+
if (Options::storageLimitsEnforced && _base->storesOverfull())
233+
{
234+
_game->pushState(new SellState(_game, _base, _origin));
235+
if (_origin == OPT_BATTLESCAPE)
236+
_game->pushState(new ErrorMessageState(_game, tr("STR_STORAGE_EXCEEDED").arg(_base->getName()).c_str(), _palette, Palette::blockOffset(8)+5, "BACK01.SCR", 0));
237+
else
238+
_game->pushState(new ErrorMessageState(_game, tr("STR_STORAGE_EXCEEDED").arg(_base->getName()).c_str(), _palette, Palette::blockOffset(15)+1, "BACK13.SCR", 6));
239+
}
230240
}
231241

232242
/**
@@ -416,9 +426,9 @@ void ManageAlienContainmentState::updateStrings()
416426

417427
int aliens = _base->getUsedContainment() - _aliensSold - _researchedAliens;
418428
int spaces = _base->getAvailableContainment() - _base->getUsedContainment() + _aliensSold;
419-
bool enoughSpace = Options::alienContainmentLimitEnforced? spaces >= 0 : true;
429+
bool enoughSpace = Options::storageLimitsEnforced ? spaces >= 0 : true;
420430

421-
_btnCancel->setVisible(enoughSpace && !_overCrowded);
431+
_btnCancel->setVisible(!_overCrowded);
422432
_btnOk->setVisible(enoughSpace);
423433
_txtAvailable->setText(tr("STR_SPACE_AVAILABLE").arg(spaces));
424434
_txtUsed->setText(tr("STR_SPACE_USED").arg(aliens));

‎src/Basescape/ManageAlienContainmentState.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ManageAlienContainmentState : public State
4242
{
4343
private:
4444
Base *_base;
45+
OptionsOrigin _origin;
4546
TextButton *_btnOk, *_btnCancel;
4647
Window *_window;
4748
Text *_txtTitle, *_txtUsed, *_txtAvailable, *_txtItem, *_txtLiveAliens, *_txtDeadAliens;

0 commit comments

Comments
 (0)