1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

- Extended cap or removed sign for some values that may potentially overflow

- Fixed #851
This commit is contained in:
DjWarmonger
2012-01-26 16:48:53 +00:00
parent b72a19cdb1
commit 1cbd7e94e4
10 changed files with 37 additions and 27 deletions

View File

@@ -4,6 +4,7 @@
#include <climits>
typedef si32 TResource;
typedef ui64 TResourceCap; //to avoid overflow when adding integers
namespace Res
{
@@ -102,7 +103,7 @@ namespace Res
h & static_cast<std::vector<int>&>(*this);
}
DLL_LINKAGE void amax(const TResource &val); //performs vstd::amax on each element
DLL_LINKAGE void amax(const TResourceCap &val); //performs vstd::amax on each element
DLL_LINKAGE bool nonZero() const; //returns true if at least one value is non-zero;
DLL_LINKAGE bool canAfford(const ResourceSet &price) const;
DLL_LINKAGE bool canBeAfforded(const ResourceSet &res) const;
@@ -112,7 +113,7 @@ namespace Res
{
struct ResEntry
{
TResource resType, resVal;
TResourceCap resType, resVal;
} cur;
const ResourceSet &rs;
void advance();