From 1a95f514ee0ca435cb0c7ebaff22748cd3eba276 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 25 Dec 2008 10:17:32 -0500 Subject: Added more limit checking to Rules --- sigmod/Rules.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'sigmod/Rules.cpp') diff --git a/sigmod/Rules.cpp b/sigmod/Rules.cpp index 0e3c260e..90f176b9 100644 --- a/sigmod/Rules.cpp +++ b/sigmod/Rules.cpp @@ -82,8 +82,12 @@ void Sigmod::Rules::validate() TEST(setMaxPlayers, maxPlayers); TEST(setMaxMoves, maxMoves); TEST(setMaxLevel, maxLevel); + TEST(setMaxStages, maxStages); if (!m_maxMoney) emit(warning("Player cannot carry any money")); + else + TEST(setMaxMoney, maxMoney); + TEST(setMaxTotalWeight, maxTotalWeight); if (m_effortValuesAllowed) { TEST(setMaxEVPerStat, maxEVPerStat); @@ -251,17 +255,26 @@ void Sigmod::Rules::setMaxLevel(const int maxLevel) void Sigmod::Rules::setMaxStages(const int maxStages) { - CHECK(maxStages); + if (maxStages < 0) + emit(error(bounds("maxStages", 0, INT_MAX, maxStages))); + else + CHECK(maxStages); } void Sigmod::Rules::setMaxMoney(const int maxMoney) { - CHECK(maxMoney); + if (maxMoney < 0) + emit(error(bounds("maxMoney", 0, INT_MAX, maxMoney))); + else + CHECK(maxMoney); } void Sigmod::Rules::setMaxTotalWeight(const int maxTotalWeight) { - CHECK(maxTotalWeight); + if (maxTotalWeight < 0) + emit(error(bounds("maxTotalWeight", 0, INT_MAX, maxTotalWeight))); + else + CHECK(maxTotalWeight); } void Sigmod::Rules::setAllowSwitchStyle(const bool allowSwitchStyle) -- cgit