diff --git a/config/objects/moddables.json b/config/objects/moddables.json index c986c7cdf..bb48baadf 100644 --- a/config/objects/moddables.json +++ b/config/objects/moddables.json @@ -146,21 +146,19 @@ } }, "types" : { - "boatNecropolis" : // Necropolis - { + "boatNecropolis" : { "index" : 0, "actualAnimation" : "AB01_.def", "overlayAnimation" : "ABM01_.def", "flagAnimations" : ["ABF01L", "ABF01G", "ABF01R", "ABF01D", "ABF01B", "ABF01P", "ABF01W", "ABF01K"] }, - "boatCastle" : // Castle - { + "boatCastle" : { "index" : 1, "actualAnimation" : "AB02_.def", "overlayAnimation" : "ABM02_.def", "flagAnimations" : ["ABF02L", "ABF02G", "ABF02R", "ABF02D", "ABF02B", "ABF02P", "ABF02W", "ABF02K"] }, - "boatFortress" : { // Fortress + "boatFortress" : { "index" : 2, "actualAnimation" : "AB03_.def", "overlayAnimation" : "ABM03_.def", diff --git a/config/schemas/faction.json b/config/schemas/faction.json index c646065e1..899c9eb09 100644 --- a/config/schemas/faction.json +++ b/config/schemas/faction.json @@ -124,6 +124,10 @@ "type" : "string", "description" : "Identifier of war machine produced by blacksmith in town" }, + "boat" : { + "type" : "string", + "description" : "Identifier of boat type that is produced by shipyard in town, if any" + }, "horde" : { "type" : "array", "maxItems" : 2, diff --git a/lib/mapObjectConstructors/AObjectTypeHandler.cpp b/lib/mapObjectConstructors/AObjectTypeHandler.cpp index 2273415c9..da12685fc 100644 --- a/lib/mapObjectConstructors/AObjectTypeHandler.cpp +++ b/lib/mapObjectConstructors/AObjectTypeHandler.cpp @@ -11,6 +11,7 @@ #include "StdInc.h" #include "AObjectTypeHandler.h" +#include "IObjectInfo.h" #include "../CGeneralTextHandler.h" #include "../VCMI_Lib.h" #include "../mapObjects/CGObjectInstance.h" @@ -221,5 +222,9 @@ void AObjectTypeHandler::afterLoadFinalization() { } +std::unique_ptr AObjectTypeHandler::getObjectInfo(std::shared_ptr tmpl) const +{ + return nullptr; +} VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjectConstructors/AObjectTypeHandler.h b/lib/mapObjectConstructors/AObjectTypeHandler.h index 56dcec4de..9ce7aabee 100644 --- a/lib/mapObjectConstructors/AObjectTypeHandler.h +++ b/lib/mapObjectConstructors/AObjectTypeHandler.h @@ -107,7 +107,7 @@ public: virtual void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const = 0; /// Returns object configuration, if available. Otherwise returns NULL - virtual std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const = 0; + virtual std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const; template void serialize(Handler &h, const int version) { diff --git a/lib/mapObjectConstructors/CBankInstanceConstructor.cpp b/lib/mapObjectConstructors/CBankInstanceConstructor.cpp index fb55d43f1..348527285 100644 --- a/lib/mapObjectConstructors/CBankInstanceConstructor.cpp +++ b/lib/mapObjectConstructors/CBankInstanceConstructor.cpp @@ -32,11 +32,6 @@ void CBankInstanceConstructor::initTypeData(const JsonNode & input) bankResetDuration = static_cast(input["resetDuration"].Float()); } -CGObjectInstance *CBankInstanceConstructor::create(std::shared_ptr tmpl) const -{ - return createTyped(tmpl); -} - BankConfig CBankInstanceConstructor::generateConfig(const JsonNode & level, CRandomGenerator & rng) const { BankConfig bc; @@ -60,10 +55,8 @@ BankConfig CBankInstanceConstructor::generateConfig(const JsonNode & level, CRan return bc; } -void CBankInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const +void CBankInstanceConstructor::randomizeObject(CBank * bank, CRandomGenerator & rng) const { - auto * bank = dynamic_cast(object); - bank->resetDuration = bankResetDuration; si32 totalChance = 0; diff --git a/lib/mapObjectConstructors/CBankInstanceConstructor.h b/lib/mapObjectConstructors/CBankInstanceConstructor.h index 232e61676..d9685f29c 100644 --- a/lib/mapObjectConstructors/CBankInstanceConstructor.h +++ b/lib/mapObjectConstructors/CBankInstanceConstructor.h @@ -87,8 +87,7 @@ public: // all banks of this type will be reset N days after clearing, si32 bankResetDuration = 0; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; + void randomizeObject(CBank * object, CRandomGenerator & rng) const override; bool hasNameTextID() const override; diff --git a/lib/mapObjectConstructors/CDefaultObjectTypeHandler.h b/lib/mapObjectConstructors/CDefaultObjectTypeHandler.h index 766b01fea..15c545906 100644 --- a/lib/mapObjectConstructors/CDefaultObjectTypeHandler.h +++ b/lib/mapObjectConstructors/CDefaultObjectTypeHandler.h @@ -13,39 +13,40 @@ VCMI_LIB_NAMESPACE_BEGIN -/// Class that is used for objects that do not have dedicated handler +/// Class that is used as base for multiple object constructors template class CDefaultObjectTypeHandler : public AObjectTypeHandler { + void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const final + { + ObjectType * castedObject = dynamic_cast(object); + + if(castedObject == nullptr) + throw std::runtime_error("Unexpected object type!"); + + randomizeObject(castedObject, rng); + } + + CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const final + { + ObjectType * result = createObject(); + + preInitObject(result); + + if(tmpl) + result->appearance = tmpl; + + initializeObject(result); + + return result; + } + protected: - ObjectType * createTyped(std::shared_ptr tmpl /* = nullptr */) const + virtual void initializeObject(ObjectType * object) const {} + virtual void randomizeObject(ObjectType * object, CRandomGenerator & rng) const {} + virtual ObjectType * createObject() const { - auto obj = new ObjectType(); - preInitObject(obj); - - //Set custom template or leave null - if (tmpl) - { - obj->appearance = tmpl; - } - - return obj; - } -public: - CDefaultObjectTypeHandler() {} - - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override - { - return createTyped(tmpl); - } - - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override - { - } - - std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const override - { - return nullptr; + return new ObjectType(); } }; diff --git a/lib/mapObjectConstructors/CObjectClassesHandler.cpp b/lib/mapObjectConstructors/CObjectClassesHandler.cpp index 82416c320..71f47dbcd 100644 --- a/lib/mapObjectConstructors/CObjectClassesHandler.cpp +++ b/lib/mapObjectConstructors/CObjectClassesHandler.cpp @@ -30,6 +30,11 @@ #include "../mapObjects/CGPandoraBox.h" #include "../mapObjects/CQuest.h" #include "../mapObjects/ObjectTemplate.h" +#include "../mapObjects/CGMarket.h" +#include "../mapObjects/MiscObjects.h" +#include "../mapObjects/CGHeroInstance.h" +#include "../mapObjects/CGTownInstance.h" + VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjectConstructors/CommonConstructors.cpp b/lib/mapObjectConstructors/CommonConstructors.cpp index b25ab34d5..8824a75bc 100644 --- a/lib/mapObjectConstructors/CommonConstructors.cpp +++ b/lib/mapObjectConstructors/CommonConstructors.cpp @@ -15,14 +15,18 @@ #include "../CHeroHandler.h" #include "../CModHandler.h" #include "../IGameCallback.h" +#include "../JsonRandom.h" #include "../StringConstants.h" #include "../TerrainHandler.h" + #include "../mapObjects/CBank.h" #include "../mapObjects/CGHeroInstance.h" +#include "../mapObjects/CGMarket.h" #include "../mapObjects/CGTownInstance.h" +#include "../mapObjects/MiscObjects.h" #include "../mapObjects/ObjectTemplate.h" + #include "../mapping/CMapDefines.h" -#include "../JsonRandom.h" VCMI_LIB_NAMESPACE_BEGIN @@ -69,15 +73,13 @@ bool CTownInstanceConstructor::objectFilter(const CGObjectInstance * object, std return filters.count(templ->stringID) != 0 && filters.at(templ->stringID).test(buildTest); } -CGObjectInstance * CTownInstanceConstructor::create(std::shared_ptr tmpl) const +void CTownInstanceConstructor::initializeObject(CGTownInstance * obj) const { - CGTownInstance * obj = createTyped(tmpl); obj->town = faction->town; obj->tempOwner = PlayerColor::NEUTRAL; - return obj; } -void CTownInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const +void CTownInstanceConstructor::randomizeObject(CGTownInstance * object, CRandomGenerator & rng) const { auto templ = getOverride(CGObjectInstance::cb->getTile(object->pos)->terType->getId(), object); if(templ) @@ -121,14 +123,12 @@ bool CHeroInstanceConstructor::objectFilter(const CGObjectInstance * object, std return false; } -CGObjectInstance * CHeroInstanceConstructor::create(std::shared_ptr tmpl) const +void CHeroInstanceConstructor::initializeObject(CGHeroInstance * obj) const { - CGHeroInstance * obj = createTyped(tmpl); obj->type = nullptr; //FIXME: set to valid value. somehow. - return obj; } -void CHeroInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const +void CHeroInstanceConstructor::randomizeObject(CGHeroInstance * object, CRandomGenerator & rng) const { } @@ -172,20 +172,17 @@ bool CDwellingInstanceConstructor::objectFilter(const CGObjectInstance * obj, st return false; } -CGObjectInstance * CDwellingInstanceConstructor::create(std::shared_ptr tmpl) const +void CDwellingInstanceConstructor::initializeObject(CGDwelling * obj) const { - CGDwelling * obj = createTyped(tmpl); - obj->creatures.resize(availableCreatures.size()); for(const auto & entry : availableCreatures) { for(const CCreature * cre : entry) obj->creatures.back().second.push_back(cre->getId()); } - return obj; } -void CDwellingInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator &rng) const +void CDwellingInstanceConstructor::randomizeObject(CGDwelling * object, CRandomGenerator &rng) const { auto * dwelling = dynamic_cast(object); @@ -274,9 +271,8 @@ void BoatInstanceConstructor::initTypeData(const JsonNode & input) bonuses = JsonRandom::loadBonuses(input["bonuses"]); } -CGObjectInstance * BoatInstanceConstructor::create(std::shared_ptr tmpl) const +void BoatInstanceConstructor::initializeObject(CGBoat * boat) const { - CGBoat * boat = createTyped(tmpl); boat->layer = layer; boat->actualAnimation = actualAnimation; boat->overlayAnimation = overlayAnimation; @@ -285,8 +281,6 @@ CGObjectInstance * BoatInstanceConstructor::create(std::shared_ptronboardVisitAllowed = onboardVisitAllowed; for(auto & b : bonuses) boat->addNewBonus(std::make_shared(b)); - - return boat; } std::string BoatInstanceConstructor::getBoatAnimationName() const @@ -294,11 +288,6 @@ std::string BoatInstanceConstructor::getBoatAnimationName() const return actualAnimation; } -void BoatInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const -{ - -} - void BoatInstanceConstructor::afterLoadFinalization() { if (layer == EPathfindingLayer::SAIL) @@ -323,31 +312,25 @@ void MarketInstanceConstructor::initTypeData(const JsonNode & input) speech = input["speech"].String(); } -CGObjectInstance * MarketInstanceConstructor::create(std::shared_ptr tmpl) const +CGMarket * MarketInstanceConstructor::createObject() const { - CGMarket * market = nullptr; if(marketModes.size() == 1) { switch(*marketModes.begin()) { case EMarketMode::ARTIFACT_RESOURCE: case EMarketMode::RESOURCE_ARTIFACT: - market = new CGBlackMarket; - break; - + return new CGBlackMarket; + case EMarketMode::RESOURCE_SKILL: - market = new CGUniversity; - break; + return new CGUniversity; } } - - if(!market) - market = new CGMarket; - - preInitObject(market); + return new CGMarket; +} - if(tmpl) - market->appearance = tmpl; +void MarketInstanceConstructor::initializeObject(CGMarket * market) const +{ market->marketModes = marketModes; market->marketEfficiency = marketEfficiency; @@ -357,11 +340,9 @@ CGObjectInstance * MarketInstanceConstructor::create(std::shared_ptrspeech = VLC->generaltexth->translate(speech); - - return market; } -void MarketInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const +void MarketInstanceConstructor::randomizeObject(CGMarket * object, CRandomGenerator & rng) const { if(auto * university = dynamic_cast(object)) { diff --git a/lib/mapObjectConstructors/CommonConstructors.h b/lib/mapObjectConstructors/CommonConstructors.h index 359c57b93..a93f36943 100644 --- a/lib/mapObjectConstructors/CommonConstructors.h +++ b/lib/mapObjectConstructors/CommonConstructors.h @@ -12,20 +12,19 @@ #include "AObjectTypeHandler.h" #include "CDefaultObjectTypeHandler.h" -#include "../mapObjects/CGMarket.h" -#include "../mapObjects/MiscObjects.h" -#include "../mapObjects/CGHeroInstance.h" -#include "../mapObjects/CGTownInstance.h" #include "../LogicalExpression.h" VCMI_LIB_NAMESPACE_BEGIN +class CGArtifact; class CGObjectInstance; class CGTownInstance; class CGHeroInstance; class CGDwelling; +class CGMarket; class CHeroClass; class CBank; +class CGBoat; class CFaction; class CStackBasicDescriptor; @@ -46,8 +45,8 @@ public: CFaction * faction = nullptr; std::map> filters; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; + void initializeObject(CGTownInstance * object) const override; + void randomizeObject(CGTownInstance * object, CRandomGenerator & rng) const override; void afterLoadFinalization() override; template void serialize(Handler &h, const int version) @@ -70,8 +69,8 @@ public: CHeroClass * heroClass = nullptr; std::map> filters; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; + void initializeObject(CGHeroInstance * object) const override; + void randomizeObject(CGHeroInstance * object, CRandomGenerator & rng) const override; void afterLoadFinalization() override; template void serialize(Handler &h, const int version) @@ -96,8 +95,8 @@ protected: public: bool hasNameTextID() const override; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; + void initializeObject(CGDwelling * object) const override; + void randomizeObject(CGDwelling * object, CRandomGenerator & rng) const override; bool producesCreature(const CCreature * crea) const; std::vector getProducedCreatures() const; @@ -125,8 +124,7 @@ protected: std::array flagAnimations; public: - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; + void initializeObject(CGBoat * object) const override; void afterLoadFinalization() override; /// Returns boat preview animation, for use in Shipyards @@ -157,8 +155,9 @@ protected: std::string title, speech; public: - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; + CGMarket * createObject() const override; + void initializeObject(CGMarket * object) const override; + void randomizeObject(CGMarket * object, CRandomGenerator & rng) const override; template void serialize(Handler &h, const int version) { diff --git a/lib/mapObjectConstructors/HillFortInstanceConstructor.cpp b/lib/mapObjectConstructors/HillFortInstanceConstructor.cpp index 9276fc4c0..b325edde3 100644 --- a/lib/mapObjectConstructors/HillFortInstanceConstructor.cpp +++ b/lib/mapObjectConstructors/HillFortInstanceConstructor.cpp @@ -11,7 +11,6 @@ #include "HillFortInstanceConstructor.h" #include "../mapObjects/MiscObjects.h" -#include "IObjectInfo.h" VCMI_LIB_NAMESPACE_BEGIN @@ -20,26 +19,9 @@ void HillFortInstanceConstructor::initTypeData(const JsonNode & config) parameters = config; } -CGObjectInstance * HillFortInstanceConstructor::create(std::shared_ptr tmpl) const +void HillFortInstanceConstructor::initializeObject(HillFort * fort) const { - HillFort * fort = new HillFort; - - preInitObject(fort); - - if(tmpl) - fort->appearance = tmpl; - fort->upgradeCostPercentage = parameters["upgradeCostFactor"].convertTo>(); - return fort; -} - -void HillFortInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const -{ -} - -std::unique_ptr HillFortInstanceConstructor::getObjectInfo(std::shared_ptr tmpl) const -{ - return nullptr; } VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjectConstructors/HillFortInstanceConstructor.h b/lib/mapObjectConstructors/HillFortInstanceConstructor.h index fc93b8876..526e66571 100644 --- a/lib/mapObjectConstructors/HillFortInstanceConstructor.h +++ b/lib/mapObjectConstructors/HillFortInstanceConstructor.h @@ -9,19 +9,19 @@ */ #pragma once -#include "AObjectTypeHandler.h" +#include "CDefaultObjectTypeHandler.h" VCMI_LIB_NAMESPACE_BEGIN -class HillFortInstanceConstructor final : public AObjectTypeHandler +class HillFort; + +class HillFortInstanceConstructor final : public CDefaultObjectTypeHandler { JsonNode parameters; protected: void initTypeData(const JsonNode & config) override; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; - std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const override; + void initializeObject(HillFort * object) const override; public: template void serialize(Handler &h, const int version) diff --git a/lib/mapObjectConstructors/ShipyardInstanceConstructor.cpp b/lib/mapObjectConstructors/ShipyardInstanceConstructor.cpp index 24b489f10..20052b57f 100644 --- a/lib/mapObjectConstructors/ShipyardInstanceConstructor.cpp +++ b/lib/mapObjectConstructors/ShipyardInstanceConstructor.cpp @@ -11,7 +11,6 @@ #include "ShipyardInstanceConstructor.h" #include "../mapObjects/MiscObjects.h" -#include "IObjectInfo.h" #include "../CModHandler.h" VCMI_LIB_NAMESPACE_BEGIN @@ -21,27 +20,9 @@ void ShipyardInstanceConstructor::initTypeData(const JsonNode & config) parameters = config; } -CGObjectInstance * ShipyardInstanceConstructor::create(std::shared_ptr tmpl) const +void ShipyardInstanceConstructor::initializeObject(CGShipyard * shipyard) const { - CGShipyard * shipyard = new CGShipyard; - - preInitObject(shipyard); - - if(tmpl) - shipyard->appearance = tmpl; - shipyard->createdBoat = BoatId(*VLC->modh->identifiers.getIdentifier("core:boat", parameters["boat"])); - - return shipyard; -} - -void ShipyardInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const -{ -} - -std::unique_ptr ShipyardInstanceConstructor::getObjectInfo(std::shared_ptr tmpl) const -{ - return nullptr; } VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjectConstructors/ShipyardInstanceConstructor.h b/lib/mapObjectConstructors/ShipyardInstanceConstructor.h index 6c2805c1e..c0d47be4f 100644 --- a/lib/mapObjectConstructors/ShipyardInstanceConstructor.h +++ b/lib/mapObjectConstructors/ShipyardInstanceConstructor.h @@ -9,19 +9,19 @@ */ #pragma once -#include "AObjectTypeHandler.h" +#include "CDefaultObjectTypeHandler.h" VCMI_LIB_NAMESPACE_BEGIN -class ShipyardInstanceConstructor final : public AObjectTypeHandler +class CGShipyard; + +class ShipyardInstanceConstructor final : public CDefaultObjectTypeHandler { JsonNode parameters; protected: void initTypeData(const JsonNode & config) override; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; - std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const override; + void initializeObject(CGShipyard * object) const override; public: template void serialize(Handler &h, const int version) diff --git a/lib/mapObjectConstructors/ShrineInstanceConstructor.cpp b/lib/mapObjectConstructors/ShrineInstanceConstructor.cpp index 1e8c8b72d..a9a7dbe78 100644 --- a/lib/mapObjectConstructors/ShrineInstanceConstructor.cpp +++ b/lib/mapObjectConstructors/ShrineInstanceConstructor.cpp @@ -10,7 +10,6 @@ #include "StdInc.h" #include "ShrineInstanceConstructor.h" -#include "IObjectInfo.h" #include "../mapObjects/MiscObjects.h" #include "../JsonRandom.h" #include "../IGameCallback.h" @@ -22,25 +21,8 @@ void ShrineInstanceConstructor::initTypeData(const JsonNode & config) parameters = config; } -CGObjectInstance * ShrineInstanceConstructor::create(std::shared_ptr tmpl) const +void ShrineInstanceConstructor::randomizeObject(CGShrine * shrine, CRandomGenerator & rng) const { - CGShrine * shrine = new CGShrine; - - preInitObject(shrine); - - if(tmpl) - shrine->appearance = tmpl; - - return shrine; -} - -void ShrineInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const -{ - CGShrine * shrine = dynamic_cast(object); - - if (!shrine) - throw std::runtime_error("Unexpected object instance in ShrineInstanceConstructor!"); - auto visitTextParameter = parameters["visitText"]; if (visitTextParameter.isNumber()) @@ -57,9 +39,4 @@ void ShrineInstanceConstructor::configureObject(CGObjectInstance * object, CRand } } -std::unique_ptr ShrineInstanceConstructor::getObjectInfo(std::shared_ptr tmpl) const -{ - return nullptr; -} - VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjectConstructors/ShrineInstanceConstructor.h b/lib/mapObjectConstructors/ShrineInstanceConstructor.h index 1350f92f4..0ceb22690 100644 --- a/lib/mapObjectConstructors/ShrineInstanceConstructor.h +++ b/lib/mapObjectConstructors/ShrineInstanceConstructor.h @@ -9,19 +9,19 @@ */ #pragma once -#include "AObjectTypeHandler.h" +#include "CDefaultObjectTypeHandler.h" VCMI_LIB_NAMESPACE_BEGIN -class ShrineInstanceConstructor final : public AObjectTypeHandler +class CGShrine; + +class ShrineInstanceConstructor final : public CDefaultObjectTypeHandler { JsonNode parameters; protected: void initTypeData(const JsonNode & config) override; - CGObjectInstance * create(std::shared_ptr tmpl = nullptr) const override; - void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override; - std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const override; + void randomizeObject(CGShrine * object, CRandomGenerator & rng) const override; public: template void serialize(Handler &h, const int version) diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 42c168463..c3fdf9bbd 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -1839,8 +1839,15 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const { h->showInfoDialog(48); } - } + +CGBoat::CGBoat() +{ + hero = nullptr; + direction = 4; + layer = EPathfindingLayer::EEPathfindingLayer::SAIL; +} + void CGBoat::initObj(CRandomGenerator & rand) { hero = nullptr; diff --git a/lib/mapObjects/MiscObjects.h b/lib/mapObjects/MiscObjects.h index a13a2c5d4..287f422d3 100644 --- a/lib/mapObjects/MiscObjects.h +++ b/lib/mapObjects/MiscObjects.h @@ -432,15 +432,10 @@ public: std::string overlayAnimation; //waves animations std::array flagAnimations; + CGBoat(); void initObj(CRandomGenerator & rand) override; static int3 translatePos(const int3 &pos, bool reverse = false); - CGBoat() - { - hero = nullptr; - direction = 4; - layer = EPathfindingLayer::EEPathfindingLayer::SAIL; - } template void serialize(Handler &h, const int version) { h & static_cast(*this); diff --git a/lib/rmg/modificators/TreasurePlacer.cpp b/lib/rmg/modificators/TreasurePlacer.cpp index 56a528136..466f712b5 100644 --- a/lib/rmg/modificators/TreasurePlacer.cpp +++ b/lib/rmg/modificators/TreasurePlacer.cpp @@ -23,6 +23,7 @@ #include "../../mapObjectConstructors/AObjectTypeHandler.h" #include "../../mapObjectConstructors/CObjectClassesHandler.h" #include "../../mapObjectConstructors/CommonConstructors.h" +#include "../../mapObjects/CGHeroInstance.h" #include "../../mapObjects/CGPandoraBox.h" #include "../../CCreatureHandler.h" #include "../../spells/CSpellHandler.h" //for choosing random spells