diff --git a/lib/ResourceSet.cpp b/lib/ResourceSet.cpp index b1d12f0d3..b36a3d0b5 100644 --- a/lib/ResourceSet.cpp +++ b/lib/ResourceSet.cpp @@ -22,20 +22,20 @@ VCMI_LIB_NAMESPACE_BEGIN Res::ResourceSet::ResourceSet(const JsonNode & node) { for(auto i = 0; i < GameConstants::RESOURCE_QUANTITY; i++) - this[i] = static_cast(node[GameConstants::RESOURCE_NAMES[i]].Float()); + container[i] = static_cast(node[GameConstants::RESOURCE_NAMES[i]].Float()); } Res::ResourceSet::ResourceSet(TResource wood, TResource mercury, TResource ore, TResource sulfur, TResource crystal, TResource gems, TResource gold, TResource mithril) { - this[Res::WOOD] = wood; - this[Res::MERCURY] = mercury; - this[Res::ORE] = ore; - this[Res::SULFUR] = sulfur; - this[Res::CRYSTAL] = crystal; - this[Res::GEMS] = gems; - this[Res::GOLD] = gold; - this[Res::MITHRIL] = mithril; + container[Res::WOOD] = wood; + container[Res::MERCURY] = mercury; + container[Res::ORE] = ore; + container[Res::SULFUR] = sulfur; + container[Res::CRYSTAL] = crystal; + container[Res::GEMS] = gems; + container[Res::GOLD] = gold; + container[Res::MITHRIL] = mithril; } void Res::ResourceSet::serializeJson(JsonSerializeFormat & handler, const std::string & fieldName) diff --git a/lib/ResourceSet.h b/lib/ResourceSet.h index a1c546ad4..b551765e2 100644 --- a/lib/ResourceSet.h +++ b/lib/ResourceSet.h @@ -36,7 +36,7 @@ namespace Res class ResourceSet { private: - std::array container; + std::array container; public: // read resources set from json. Format example: { "gold": 500, "wood":5 } DLL_LINKAGE ResourceSet(const JsonNode & node); @@ -105,12 +105,12 @@ namespace Res TResource & operator[](size_t index) { - return container[index]; + return container.at(index); } const TResource & operator[](size_t index) const { - return container[index]; + return container.at(index); } bool empty () const