mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
fix copy of ResourceSet
This commit is contained in:
@@ -30,6 +30,11 @@ ResourceSet::ResourceSet(const JsonNode & node)
|
|||||||
container[i] = static_cast<int>(node[i.toResource()->getJsonKey()].Float());
|
container[i] = static_cast<int>(node[i.toResource()->getJsonKey()].Float());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResourceSet::ResourceSet(const ResourceSet& rhs)
|
||||||
|
: container(rhs.container) // vector copy constructor
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceSet::serializeJson(JsonSerializeFormat & handler, const std::string & fieldName)
|
void ResourceSet::serializeJson(JsonSerializeFormat & handler, const std::string & fieldName)
|
||||||
{
|
{
|
||||||
if(handler.saving && !nonZero())
|
if(handler.saving && !nonZero())
|
||||||
@@ -37,10 +42,8 @@ void ResourceSet::serializeJson(JsonSerializeFormat & handler, const std::string
|
|||||||
auto s = handler.enterStruct(fieldName);
|
auto s = handler.enterStruct(fieldName);
|
||||||
|
|
||||||
for(auto & idx : LIBRARY->resourceTypeHandler->getAllObjects())
|
for(auto & idx : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||||
{
|
|
||||||
handler.serializeInt(idx.toResource()->getJsonKey(), this->operator[](idx), 0);
|
handler.serializeInt(idx.toResource()->getJsonKey(), this->operator[](idx), 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool ResourceSet::nonZero() const
|
bool ResourceSet::nonZero() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
// read resources set from json. Format example: { "gold": 500, "wood":5 }
|
// read resources set from json. Format example: { "gold": 500, "wood":5 }
|
||||||
DLL_LINKAGE ResourceSet(const JsonNode & node);
|
DLL_LINKAGE ResourceSet(const JsonNode & node);
|
||||||
DLL_LINKAGE ResourceSet();
|
DLL_LINKAGE ResourceSet();
|
||||||
|
DLL_LINKAGE ResourceSet(const ResourceSet& rhs);
|
||||||
|
|
||||||
|
|
||||||
#define scalarOperator(OPSIGN) \
|
#define scalarOperator(OPSIGN) \
|
||||||
@@ -179,6 +180,15 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResourceSet& operator=(const ResourceSet& rhs)
|
||||||
|
{
|
||||||
|
if (this != &rhs)
|
||||||
|
{
|
||||||
|
container = rhs.container;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
ResourceSet operator-() const
|
ResourceSet operator-() const
|
||||||
{
|
{
|
||||||
ResourceSet ret;
|
ResourceSet ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user