Skip to content

Commit

Permalink
Fix CTD
Browse files Browse the repository at this point in the history
  • Loading branch information
MeridianOXC committed Feb 10, 2024
1 parent 03ff6da commit 091e6ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Basescape/CraftSoldiersState.cpp
Expand Up @@ -545,7 +545,7 @@ void CraftSoldiersState::lstSoldiersClick(Action *action)
}
else if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
{
_game->pushState(new SoldierInfoState(_base, row));
_game->pushState(new SoldierInfoState(_base, row, false));
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/Basescape/SoldierInfoState.cpp
Expand Up @@ -56,7 +56,7 @@ namespace OpenXcom
* @param base Pointer to the base to get info from. NULL to use the dead soldiers list.
* @param soldierId ID of the selected soldier.
*/
SoldierInfoState::SoldierInfoState(Base *base, size_t soldierId) : _base(base), _soldierId(soldierId), _soldier(0)
SoldierInfoState::SoldierInfoState(Base *base, size_t soldierId, bool forceLimits) : _base(base), _soldierId(soldierId), _forceLimits(forceLimits), _soldier(0)
{
if (_base == 0)
{
Expand Down Expand Up @@ -661,7 +661,11 @@ void SoldierInfoState::btnOkClick(Action *)
_game->popState();
if (_game->getSavedGame()->getMonthsPassed() > -1 && Options::storageLimitsEnforced && _base != 0 && _base->storesOverfull())
{
_game->pushState(new SellState(_base, 0));
if (_forceLimits)
{
// Note: we could sell a currently opened craft here and crash the game
_game->pushState(new SellState(_base, 0));
}
_game->pushState(new ErrorMessageState(tr("STR_STORAGE_EXCEEDED").arg(_base->getName()), _palette, _game->getMod()->getInterface("soldierInfo")->getElement("errorMessage")->color, "BACK01.SCR", _game->getMod()->getInterface("soldierInfo")->getElement("errorPalette")->color));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Basescape/SoldierInfoState.h
Expand Up @@ -40,6 +40,7 @@ class SoldierInfoState : public State
private:
Base *_base;
size_t _soldierId;
bool _forceLimits;
Soldier *_soldier;
std::vector<Soldier*> *_list;

Expand All @@ -57,7 +58,7 @@ class SoldierInfoState : public State

public:
/// Creates the Soldier Info state.
SoldierInfoState(Base *base, size_t soldierId);
SoldierInfoState(Base *base, size_t soldierId, bool forceLimits = true);
/// Cleans up the Soldier Info state.
~SoldierInfoState();
/// Updates the soldier info.
Expand Down

0 comments on commit 091e6ef

Please sign in to comment.