mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
Minor refactor
This commit is contained in:
parent
b3a457c71a
commit
49c029ea6c
@ -243,9 +243,13 @@ std::map<TResource, ui16> ZoneOptions::getMinesInfo() const
|
|||||||
void ZoneOptions::setTreasureInfo(const std::vector<CTreasureInfo> & value)
|
void ZoneOptions::setTreasureInfo(const std::vector<CTreasureInfo> & value)
|
||||||
{
|
{
|
||||||
treasureInfo = value;
|
treasureInfo = value;
|
||||||
|
recalculateMaxTreasureValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneOptions::recalculateMaxTreasureValue()
|
||||||
|
{
|
||||||
maxTreasureValue = 0;
|
maxTreasureValue = 0;
|
||||||
for (const auto& ti : value)
|
for (const auto& ti : treasureInfo)
|
||||||
{
|
{
|
||||||
vstd::amax(maxTreasureValue, ti.max);
|
vstd::amax(maxTreasureValue, ti.max);
|
||||||
}
|
}
|
||||||
@ -401,8 +405,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
|||||||
treasureData.serializeStruct(treasureInfo);
|
treasureData.serializeStruct(treasureInfo);
|
||||||
if (!handler.saving)
|
if (!handler.saving)
|
||||||
{
|
{
|
||||||
//Just in order to calculate maxTreasureValue
|
recalculateMaxTreasureValue();
|
||||||
setTreasureInfo(treasureInfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ public:
|
|||||||
void addTreasureInfo(const CTreasureInfo & value);
|
void addTreasureInfo(const CTreasureInfo & value);
|
||||||
const std::vector<CTreasureInfo> & getTreasureInfo() const;
|
const std::vector<CTreasureInfo> & getTreasureInfo() const;
|
||||||
ui32 getMaxTreasureValue() const;
|
ui32 getMaxTreasureValue() const;
|
||||||
|
void recalculateMaxTreasureValue();
|
||||||
|
|
||||||
TRmgTemplateZoneId getMinesLikeZone() const;
|
TRmgTemplateZoneId getMinesLikeZone() const;
|
||||||
TRmgTemplateZoneId getTerrainTypeLikeZone() const;
|
TRmgTemplateZoneId getTerrainTypeLikeZone() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user