diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 6e7de43f9..1821a0efd 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -178,6 +178,13 @@ bool CAddInfo::operator!=(si32 value) const return !operator==(value); } +si32 & CAddInfo::operator[](size_type pos) +{ + if (pos <= size()) + resize(pos + 1, CAddInfo::NONE); + return vector::operator[](pos); +} + si32 CAddInfo::operator[](size_type pos) const { return pos < size() ? vector::operator[](pos) : CAddInfo::NONE; diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 5eb547189..6dbf89c20 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -90,7 +90,7 @@ private: class DLL_LINKAGE CAddInfo : public std::vector { public: - static const si32 NONE = -1; + enum { NONE = -1 }; CAddInfo(); CAddInfo(si32 value); @@ -98,7 +98,7 @@ public: bool operator==(si32 value) const; bool operator!=(si32 value) const; - using std::vector::operator[]; + si32 & operator[](size_type pos); si32 operator[](size_type pos) const; std::string toString() const;