1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #431 from vcmi/ISSUE_2918

Fixed Issue 2914 & 2918
This commit is contained in:
Alexander Shishkin 2018-03-17 02:49:11 +03:00 committed by GitHub
commit 1e9a3e0fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -178,6 +178,13 @@ bool CAddInfo::operator!=(si32 value) const
return !operator==(value); 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 si32 CAddInfo::operator[](size_type pos) const
{ {
return pos < size() ? vector::operator[](pos) : CAddInfo::NONE; return pos < size() ? vector::operator[](pos) : CAddInfo::NONE;

View File

@ -90,7 +90,7 @@ private:
class DLL_LINKAGE CAddInfo : public std::vector<si32> class DLL_LINKAGE CAddInfo : public std::vector<si32>
{ {
public: public:
static const si32 NONE = -1; enum { NONE = -1 };
CAddInfo(); CAddInfo();
CAddInfo(si32 value); CAddInfo(si32 value);
@ -98,7 +98,7 @@ public:
bool operator==(si32 value) const; bool operator==(si32 value) const;
bool operator!=(si32 value) const; bool operator!=(si32 value) const;
using std::vector<si32>::operator[]; si32 & operator[](size_type pos);
si32 operator[](size_type pos) const; si32 operator[](size_type pos) const;
std::string toString() const; std::string toString() const;