Skip to content

Commit cbf9efb

Browse files
committed
better handling for modded items in new battle mode.
1 parent 0cd4b44 commit cbf9efb

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/Engine/Options.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <sstream>
2929
#include <fstream>
3030
#include <algorithm>
31+
#include <climits>
3132
#include <yaml-cpp/yaml.h>
3233
#include "Exception.h"
3334
#include "Logger.h"
@@ -544,7 +545,7 @@ std::string getString(const std::string& id)
544545
int getInt(const std::string& id)
545546
{
546547
std::stringstream ss;
547-
int value;
548+
int value = INT_MAX;
548549
ss << std::dec << _options[id];
549550
ss >> std::dec >> value;
550551
return value;

src/Menu/NewBattleState.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "../Engine/Action.h"
4545
#include "../Engine/Options.h"
4646
#include "../Basescape/CraftInfoState.h"
47+
#include <climits>
4748

4849
namespace OpenXcom
4950
{
@@ -344,8 +345,12 @@ void NewBattleState::initSave()
344345
if (rule->getBattleType() != BT_NONE && !rule->isFixed() && (*i).substr(0, 8) != "STR_HWP_")
345346
{
346347
int amount = Options::getInt("NewBattle_" + rule->getName());
347-
amount = std::max(0, std::min(100, amount));
348-
348+
if (amount = INT_MAX)
349+
{
350+
amount=0;
351+
Options::setInt("NewBattle_" + rule->getName(), 0);
352+
}
353+
amount = std::max(0, std::min(amount, 100));
349354
_craft->getItems()->addItem(*i, amount);
350355
}
351356
}

0 commit comments

Comments
 (0)