diff --git a/client/battle/BattleSiegeController.cpp b/client/battle/BattleSiegeController.cpp index 63d5bd9e5..63c8cab10 100644 --- a/client/battle/BattleSiegeController.cpp +++ b/client/battle/BattleSiegeController.cpp @@ -65,16 +65,12 @@ std::string BattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisua { case EWallVisual::BACKGROUND_WALL: { - switch(town->town->faction->getIndex()) - { - case ETownType::RAMPART: - case ETownType::NECROPOLIS: - case ETownType::DUNGEON: - case ETownType::STRONGHOLD: + auto faction = town->town->faction->getIndex(); + + if (faction == ETownType::RAMPART || faction == ETownType::NECROPOLIS || faction == ETownType::DUNGEON || faction == ETownType::STRONGHOLD) return prefix + "TPW1.BMP"; - default: + else return prefix + "TPWL.BMP"; - } } case EWallVisual::KEEP: return prefix + "MAN" + addit + ".BMP"; diff --git a/cmake_modules/VCMI_lib.cmake b/cmake_modules/VCMI_lib.cmake index 04c94015b..ddbd7815b 100644 --- a/cmake_modules/VCMI_lib.cmake +++ b/cmake_modules/VCMI_lib.cmake @@ -42,6 +42,8 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE) ${MAIN_LIB_DIR}/campaign/CampaignHandler.cpp ${MAIN_LIB_DIR}/campaign/CampaignState.cpp + ${MAIN_LIB_DIR}/constants/EntityIdentifiers.cpp + ${MAIN_LIB_DIR}/events/ApplyDamage.cpp ${MAIN_LIB_DIR}/events/GameResumed.cpp ${MAIN_LIB_DIR}/events/ObjectVisitEnded.cpp @@ -246,7 +248,6 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE) ${MAIN_LIB_DIR}/CStack.cpp ${MAIN_LIB_DIR}/CThreadHelper.cpp ${MAIN_LIB_DIR}/CTownHandler.cpp - ${MAIN_LIB_DIR}/GameConstants.cpp ${MAIN_LIB_DIR}/GameSettings.cpp ${MAIN_LIB_DIR}/IGameCallback.cpp ${MAIN_LIB_DIR}/IHandlerBase.cpp diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index 4ef0e7ea7..c103a6af7 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -55,7 +55,7 @@ public: CreatureID idNumber; h & idNumber; if(idNumber != CreatureID::NONE) - setType(dynamic_cast(VLC->creatures()->getByIndex(idNumber))); + setType(dynamic_cast(VLC->creatures()->getById(idNumber))); else type = nullptr; } diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index ac01e787a..cb19a3983 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -186,7 +186,7 @@ EAlignment CFaction::getAlignment() const BoatId CFaction::getBoatType() const { - return boatType.toEnum(); + return boatType; } TerrainId CFaction::getNativeTerrain() const diff --git a/lib/GameConstants.cpp b/lib/constants/EntityIdentifiers.cpp similarity index 71% rename from lib/GameConstants.cpp rename to lib/constants/EntityIdentifiers.cpp index 1b528ec7e..37815f8ab 100644 --- a/lib/GameConstants.cpp +++ b/lib/constants/EntityIdentifiers.cpp @@ -1,5 +1,5 @@ /* - * GameConstants.cpp, part of VCMI engine + * EntityIdentifiers.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -8,8 +8,6 @@ * */ -#define INSTANTIATE_BASE_FOR_ID_HERE - #include "StdInc.h" #ifndef VCMI_NO_EXTRA_VERSION @@ -56,6 +54,44 @@ const PlayerColor PlayerColor::NEUTRAL = PlayerColor(255); const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I); const TeamID TeamID::NO_TEAM = TeamID(255); +const SpellSchool SpellSchool::ANY = -1; +const SpellSchool SpellSchool::AIR = 0; +const SpellSchool SpellSchool::FIRE = 1; +const SpellSchool SpellSchool::WATER = 2; +const SpellSchool SpellSchool::EARTH = 3; + +const FactionID FactionID::NONE = -2; +const FactionID FactionID::DEFAULT = -1; +const FactionID FactionID::RANDOM = -1; +const FactionID FactionID::ANY = -1; +const FactionID FactionID::CASTLE = 0; +const FactionID FactionID::RAMPART = 1; +const FactionID FactionID::TOWER = 2; +const FactionID FactionID::INFERNO = 3; +const FactionID FactionID::NECROPOLIS = 4; +const FactionID FactionID::DUNGEON = 5; +const FactionID FactionID::STRONGHOLD = 6; +const FactionID FactionID::FORTRESS = 7; +const FactionID FactionID::CONFLUX = 8; +const FactionID FactionID::NEUTRAL = 9; + +const BoatId BoatId::NONE = -1; +const BoatId BoatId::NECROPOLIS = 0; +const BoatId BoatId::CASTLE = 1; +const BoatId BoatId::FORTRESS = 2; + +const RiverId RiverId::NO_RIVER = 0; +const RiverId RiverId::WATER_RIVER = 1; +const RiverId RiverId::ICY_RIVER = 2; +const RiverId RiverId::MUD_RIVER = 3; +const RiverId RiverId::LAVA_RIVER = 4; + +const RoadId RoadId::NO_ROAD = 0; +const RoadId RoadId::DIRT_ROAD = 1; +const RoadId RoadId::GRAVEL_ROAD = 2; +const RoadId RoadId::COBBLESTONE_ROAD = 3; + + namespace GameConstants { #ifdef VCMI_NO_EXTRA_VERSION @@ -192,7 +228,7 @@ std::string PlayerColor::getStrCap(bool L10n) const return ret; } -si32 FactionIDBase::decode(const std::string & identifier) +si32 FactionID::decode(const std::string & identifier) { auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), entityType(), identifier); if(rawId) @@ -201,17 +237,16 @@ si32 FactionIDBase::decode(const std::string & identifier) return FactionID::DEFAULT; } -std::string FactionIDBase::encode(const si32 index) +std::string FactionID::encode(const si32 index) { return VLC->factions()->getByIndex(index)->getJsonKey(); } -std::string FactionIDBase::entityType() +std::string FactionID::entityType() { return "faction"; } - si32 TerrainIdBase::decode(const std::string & identifier) { auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), entityType(), identifier); @@ -231,68 +266,8 @@ std::string TerrainIdBase::entityType() return "terrain"; } -std::ostream & operator<<(std::ostream & os, const EActionType actionType) -{ - static const std::map actionTypeToString = - { - {EActionType::END_TACTIC_PHASE, "End tactic phase"}, - {EActionType::NO_ACTION, "No action"}, - {EActionType::HERO_SPELL, "Hero spell"}, - {EActionType::WALK, "Walk"}, - {EActionType::DEFEND, "Defend"}, - {EActionType::RETREAT, "Retreat"}, - {EActionType::SURRENDER, "Surrender"}, - {EActionType::WALK_AND_ATTACK, "Walk and attack"}, - {EActionType::SHOOT, "Shoot"}, - {EActionType::WAIT, "Wait"}, - {EActionType::CATAPULT, "Catapult"}, - {EActionType::MONSTER_SPELL, "Monster spell"}, - {EActionType::BAD_MORALE, "Bad morale"}, - {EActionType::STACK_HEAL, "Stack heal"}, - }; - - auto it = actionTypeToString.find(actionType); - if (it == actionTypeToString.end()) return os << ""; - else return os << it->second; -} - -std::ostream & operator<<(std::ostream & os, const EPathfindingLayer & pathfindingLayer) -{ - static const std::map pathfinderLayerToString - { - #define DEFINE_ELEMENT(element) {EPathfindingLayer::element, #element} - DEFINE_ELEMENT(WRONG), - DEFINE_ELEMENT(AUTO), - DEFINE_ELEMENT(LAND), - DEFINE_ELEMENT(SAIL), - DEFINE_ELEMENT(WATER), - DEFINE_ELEMENT(AIR), - DEFINE_ELEMENT(NUM_LAYERS) - #undef DEFINE_ELEMENT - }; - - auto it = pathfinderLayerToString.find(pathfindingLayer.num); - if (it == pathfinderLayerToString.end()) return os << ""; - else return os << it->second; -} - const BattleField BattleField::NONE; -bool operator==(const BattleField & l, const BattleField & r) -{ - return l.num == r.num; -} - -bool operator!=(const BattleField & l, const BattleField & r) -{ - return l.num != r.num; -} - -bool operator<(const BattleField & l, const BattleField & r) -{ - return l.num < r.num; -} - const BattleFieldInfo * BattleField::getInfo() const { return VLC->battlefields()->getById(*this); diff --git a/lib/constants/EntityIdentifiers.h b/lib/constants/EntityIdentifiers.h index 921ac83f9..dba54dc5c 100644 --- a/lib/constants/EntityIdentifiers.h +++ b/lib/constants/EntityIdentifiers.h @@ -1,5 +1,5 @@ /* - * GameConstants.h, part of VCMI engine + * EntityIdentifiers.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -41,6 +41,8 @@ protected: constexpr IdentifierBase(int32_t value = -1 ): num(value) {} + + ~IdentifierBase() = default; public: int32_t num; @@ -57,6 +59,16 @@ public: } }; + constexpr void advance(int change) + { + num += change; + } + + constexpr operator int32_t () const + { + return num; + } + friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt) { return os << dt.num; @@ -69,7 +81,7 @@ public: template class Identifier : public IdentifierBase { - using T = IdentifierBase; + using BaseClass = IdentifierBase; public: constexpr Identifier(int32_t _num = -1) :IdentifierBase(_num) @@ -77,110 +89,90 @@ public: template void serialize(Handler &h, const int version) { - h & T::num; + h & BaseClass::num; } - constexpr bool operator == (const Identifier & b) const { return T::num == b.num; } - constexpr bool operator <= (const Identifier & b) const { return T::num <= b.num; } - constexpr bool operator >= (const Identifier & b) const { return T::num >= b.num; } - constexpr bool operator != (const Identifier & b) const { return T::num != b.num; } - constexpr bool operator < (const Identifier & b) const { return T::num < b.num; } - constexpr bool operator > (const Identifier & b) const { return T::num > b.num; } + constexpr bool operator == (const Identifier & b) const { return BaseClass::num == b.num; } + constexpr bool operator <= (const Identifier & b) const { return BaseClass::num <= b.num; } + constexpr bool operator >= (const Identifier & b) const { return BaseClass::num >= b.num; } + constexpr bool operator != (const Identifier & b) const { return BaseClass::num != b.num; } + constexpr bool operator < (const Identifier & b) const { return BaseClass::num < b.num; } + constexpr bool operator > (const Identifier & b) const { return BaseClass::num > b.num; } constexpr FinalClass & operator++() { - ++T::num; + ++BaseClass::num; return static_cast(*this); } constexpr FinalClass operator++(int) { FinalClass ret(num); - ++T::num; + ++BaseClass::num; return ret; } - - constexpr operator int32_t () const - { - return T::num; - } - - constexpr void advance(int change) - { - T::num += change; - } }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template -class IdentifierWithEnum : public T +template +class IdentifierWithEnum : public BaseClass { - using EnumType = typename T::Type; + using EnumType = typename BaseClass::Type; static_assert(std::is_same_v, int32_t>, "Entity Identifier must use int32_t"); public: constexpr int32_t getNum() const { - return T::num; + return BaseClass::num; } constexpr EnumType toEnum() const { - return static_cast(T::num); + return static_cast(BaseClass::num); } template void serialize(Handler &h, const int version) { - h & T::num; + h & BaseClass::num; } constexpr IdentifierWithEnum(const EnumType & enumValue) { - T::num = static_cast(enumValue); + BaseClass::num = static_cast(enumValue); } constexpr IdentifierWithEnum(int32_t _num = -1) { - T::num = _num; + BaseClass::num = _num; } - constexpr void advance(int change) + constexpr bool operator == (const EnumType & b) const { return BaseClass::num == static_cast(b); } + constexpr bool operator <= (const EnumType & b) const { return BaseClass::num <= static_cast(b); } + constexpr bool operator >= (const EnumType & b) const { return BaseClass::num >= static_cast(b); } + constexpr bool operator != (const EnumType & b) const { return BaseClass::num != static_cast(b); } + constexpr bool operator < (const EnumType & b) const { return BaseClass::num < static_cast(b); } + constexpr bool operator > (const EnumType & b) const { return BaseClass::num > static_cast(b); } + + constexpr bool operator == (const IdentifierWithEnum & b) const { return BaseClass::num == b.num; } + constexpr bool operator <= (const IdentifierWithEnum & b) const { return BaseClass::num <= b.num; } + constexpr bool operator >= (const IdentifierWithEnum & b) const { return BaseClass::num >= b.num; } + constexpr bool operator != (const IdentifierWithEnum & b) const { return BaseClass::num != b.num; } + constexpr bool operator < (const IdentifierWithEnum & b) const { return BaseClass::num < b.num; } + constexpr bool operator > (const IdentifierWithEnum & b) const { return BaseClass::num > b.num; } + + constexpr FinalClass & operator++() { - T::num += change; + ++BaseClass::num; + return static_cast(*this); } - constexpr bool operator == (const EnumType & b) const { return T::num == static_cast(b); } - constexpr bool operator <= (const EnumType & b) const { return T::num <= static_cast(b); } - constexpr bool operator >= (const EnumType & b) const { return T::num >= static_cast(b); } - constexpr bool operator != (const EnumType & b) const { return T::num != static_cast(b); } - constexpr bool operator < (const EnumType & b) const { return T::num < static_cast(b); } - constexpr bool operator > (const EnumType & b) const { return T::num > static_cast(b); } - - constexpr bool operator == (const IdentifierWithEnum & b) const { return T::num == b.num; } - constexpr bool operator <= (const IdentifierWithEnum & b) const { return T::num <= b.num; } - constexpr bool operator >= (const IdentifierWithEnum & b) const { return T::num >= b.num; } - constexpr bool operator != (const IdentifierWithEnum & b) const { return T::num != b.num; } - constexpr bool operator < (const IdentifierWithEnum & b) const { return T::num < b.num; } - constexpr bool operator > (const IdentifierWithEnum & b) const { return T::num > b.num; } - - constexpr IdentifierWithEnum & operator++() + constexpr FinalClass operator++(int) { - ++T::num; - return *this; - } - - constexpr IdentifierWithEnum operator++(int) - { - IdentifierWithEnum ret(*this); - ++T::num; + FinalClass ret(BaseClass::num); + ++BaseClass::num; return ret; } - - constexpr operator int32_t () const - { - return T::num; - } }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -284,54 +276,70 @@ public: { WRONG = -2, DEFAULT = -1, - PATHFINDING = 0, ARCHERY, LOGISTICS, SCOUTING, DIPLOMACY, NAVIGATION, LEADERSHIP, WISDOM, MYSTICISM, - LUCK, BALLISTICS, EAGLE_EYE, NECROMANCY, ESTATES, FIRE_MAGIC, AIR_MAGIC, WATER_MAGIC, EARTH_MAGIC, - SCHOLAR, TACTICS, ARTILLERY, LEARNING, OFFENCE, ARMORER, INTELLIGENCE, SORCERY, RESISTANCE, - FIRST_AID, SKILL_SIZE + PATHFINDING = 0, + ARCHERY, + LOGISTICS, + SCOUTING, + DIPLOMACY, + NAVIGATION, + LEADERSHIP, + WISDOM, + MYSTICISM, + LUCK, + BALLISTICS, + EAGLE_EYE, + NECROMANCY, + ESTATES, + FIRE_MAGIC, + AIR_MAGIC, + WATER_MAGIC, + EARTH_MAGIC, + SCHOLAR, + TACTICS, + ARTILLERY, + LEARNING, + OFFENCE, + ARMORER, + INTELLIGENCE, + SORCERY, + RESISTANCE, + FIRST_AID, + SKILL_SIZE }; static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills"); }; -class SecondarySkill : public IdentifierWithEnum +class SecondarySkill : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; -class FactionIDBase : public IdentifierBase +class DLL_LINKAGE FactionID : public Identifier { public: - enum Type : int32_t - { - NONE = -2, - DEFAULT = -1, - RANDOM = -1, - ANY = -1, - CASTLE, - RAMPART, - TOWER, - INFERNO, - NECROPOLIS, - DUNGEON, - STRONGHOLD, - FORTRESS, - CONFLUX, - NEUTRAL - }; + using Identifier::Identifier; + + static const FactionID NONE; + static const FactionID DEFAULT; + static const FactionID RANDOM; + static const FactionID ANY; + static const FactionID CASTLE; + static const FactionID RAMPART; + static const FactionID TOWER; + static const FactionID INFERNO; + static const FactionID NECROPOLIS; + static const FactionID DUNGEON; + static const FactionID STRONGHOLD; + static const FactionID FORTRESS; + static const FactionID CONFLUX; + static const FactionID NEUTRAL; static si32 decode(const std::string& identifier); static std::string encode(const si32 index); static std::string entityType(); }; -class FactionID : public IdentifierWithEnum -{ -public: - using IdentifierWithEnum::IdentifierWithEnum; -}; - -using ETownType = FactionID; - class BuildingIDBase : public IdentifierBase { public: @@ -379,10 +387,10 @@ public: } }; -class BuildingID : public IdentifierWithEnum +class BuildingID : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; class ObjBase : public IdentifierBase @@ -530,56 +538,35 @@ public: }; }; -class Obj : public IdentifierWithEnum +class Obj : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; -class RoadIdBase : public IdentifierBase +class DLL_LINKAGE RoadId : public Identifier { public: - enum Type : int32_t - { - NO_ROAD = 0, - FIRST_REGULAR_ROAD = 1, - DIRT_ROAD = 1, - GRAVEL_ROAD = 2, - COBBLESTONE_ROAD = 3, - ORIGINAL_ROAD_COUNT //+1 - }; + using Identifier::Identifier; + + static const RoadId NO_ROAD; + static const RoadId DIRT_ROAD; + static const RoadId GRAVEL_ROAD; + static const RoadId COBBLESTONE_ROAD; }; -class RoadId : public IdentifierWithEnum +class DLL_LINKAGE RiverId : public Identifier { public: - using IdentifierWithEnum::IdentifierWithEnum; -}; + using Identifier::Identifier; -class RiverIdBase : public IdentifierBase -{ -public: - enum Type : int32_t - { - NO_RIVER = 0, - FIRST_REGULAR_RIVER = 1, - WATER_RIVER = 1, - ICY_RIVER = 2, - MUD_RIVER = 3, - LAVA_RIVER = 4, - ORIGINAL_RIVER_COUNT //+1 - }; + static const RiverId NO_RIVER; + static const RiverId WATER_RIVER; + static const RiverId ICY_RIVER; + static const RiverId MUD_RIVER; + static const RiverId LAVA_RIVER; }; -class RiverId : public IdentifierWithEnum -{ -public: - using IdentifierWithEnum::IdentifierWithEnum; -}; - -using River = RiverId; -using Road = RoadId; - class DLL_LINKAGE EPathfindingLayerBase : public IdentifierBase { public: @@ -589,10 +576,10 @@ public: }; }; -class EPathfindingLayer : public IdentifierWithEnum +class EPathfindingLayer : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; class ArtifactPositionBase : public IdentifierBase @@ -622,10 +609,10 @@ public: static std::string encode(const si32 index); }; -class ArtifactPosition : public IdentifierWithEnum +class ArtifactPosition : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; class ArtifactIDBase : public IdentifierBase @@ -656,10 +643,10 @@ public: static std::string encode(const si32 index); }; -class ArtifactID : public IdentifierWithEnum +class ArtifactID : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; class CreatureIDBase : public IdentifierBase @@ -695,10 +682,10 @@ public: static std::string encode(const si32 index); }; -class CreatureID : public IdentifierWithEnum +class CreatureID : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; class SpellIDBase : public IdentifierBase @@ -812,10 +799,10 @@ public: static std::string encode(const si32 index); }; -class SpellID : public IdentifierWithEnum +class SpellID : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; class BattleFieldInfo; @@ -828,22 +815,15 @@ public: DLL_LINKAGE const BattleFieldInfo * getInfo() const; }; -class BoatIdBase : public IdentifierBase +class DLL_LINKAGE BoatId : public Identifier { public: - enum Type : int32_t - { - NONE = -1, - NECROPOLIS = 0, - CASTLE, - FORTRESS - }; -}; + using Identifier::Identifier; -class BoatId : public IdentifierWithEnum -{ -public: - using IdentifierWithEnum::IdentifierWithEnum; + static const BoatId NONE; + static const BoatId NECROPOLIS; + static const BoatId CASTLE; + static const BoatId FORTRESS; }; class TerrainIdBase : public IdentifierBase @@ -873,14 +853,12 @@ public: static std::string entityType(); }; -class TerrainId : public IdentifierWithEnum +class TerrainId : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; -using ETerrainId = TerrainId; - class ObstacleInfo; class Obstacle : public Identifier { @@ -889,27 +867,18 @@ public: DLL_LINKAGE const ObstacleInfo * getInfo() const; }; -class SpellSchoolBase : public IdentifierBase +class DLL_LINKAGE SpellSchool : public Identifier { public: - enum Type : int32_t - { - ANY = -1, - AIR = 0, - FIRE = 1, - WATER = 2, - EARTH = 3, - }; -}; + using Identifier::Identifier; -class SpellSchool : public IdentifierWithEnum -{ -public: - using IdentifierWithEnum::IdentifierWithEnum; + static const SpellSchool ANY; + static const SpellSchool AIR; + static const SpellSchool FIRE; + static const SpellSchool WATER; + static const SpellSchool EARTH; }; -using ESpellSchool = SpellSchool; - class GameResIDBase : public IdentifierBase { public: @@ -930,12 +899,21 @@ public: }; }; -class GameResID : public IdentifierWithEnum +class GameResID : public IdentifierWithEnum { public: - using IdentifierWithEnum::IdentifierWithEnum; + using IdentifierWithEnum::IdentifierWithEnum; }; +// Deprecated +// TODO: remove +using ESpellSchool = SpellSchool; +using ETownType = FactionID; using EGameResID = GameResID; +using River = RiverId; +using Road = RoadId; +using ETerrainId = TerrainId; + + VCMI_LIB_NAMESPACE_END diff --git a/lib/constants/Enumerations.h b/lib/constants/Enumerations.h index 778bd14ef..452cfbcd1 100644 --- a/lib/constants/Enumerations.h +++ b/lib/constants/Enumerations.h @@ -1,5 +1,5 @@ /* - * GameConstants.h, part of VCMI engine + * Enumerations.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * diff --git a/lib/constants/NumericConstants.h b/lib/constants/NumericConstants.h index 7973ac21d..e291f4c3b 100644 --- a/lib/constants/NumericConstants.h +++ b/lib/constants/NumericConstants.h @@ -1,5 +1,5 @@ /* - * GameConstants.h, part of VCMI engine + * NumericConstants.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * diff --git a/lib/mapping/MapFeaturesH3M.cpp b/lib/mapping/MapFeaturesH3M.cpp index b5d3a4b7b..4be3af4d4 100644 --- a/lib/mapping/MapFeaturesH3M.cpp +++ b/lib/mapping/MapFeaturesH3M.cpp @@ -58,6 +58,8 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesROE() result.terrainsCount = 10; result.artifactSlotsCount = 18; result.buildingsCount = 41; + result.roadsCount = 3; + result.riversCount = 4; result.heroIdentifierInvalid = 0xff; result.artifactIdentifierInvalid = 0xff; diff --git a/lib/mapping/MapFeaturesH3M.h b/lib/mapping/MapFeaturesH3M.h index 4757d4223..75e1515d5 100644 --- a/lib/mapping/MapFeaturesH3M.h +++ b/lib/mapping/MapFeaturesH3M.h @@ -47,6 +47,8 @@ public: int spellsCount; int skillsCount; int terrainsCount; + int roadsCount; + int riversCount; int artifactSlotsCount; int buildingsCount; diff --git a/lib/mapping/MapReaderH3M.cpp b/lib/mapping/MapReaderH3M.cpp index 5757316e1..5c8a13d97 100644 --- a/lib/mapping/MapReaderH3M.cpp +++ b/lib/mapping/MapReaderH3M.cpp @@ -147,14 +147,14 @@ TerrainId MapReaderH3M::readTerrain() RoadId MapReaderH3M::readRoad() { RoadId result(readInt8()); - assert(result < Road::ORIGINAL_ROAD_COUNT); + assert(result.getNum() < features.roadsCount); return result; } RiverId MapReaderH3M::readRiver() { RiverId result(readInt8()); - assert(result < River::ORIGINAL_RIVER_COUNT); + assert(result.getNum() < features.riversCount); return result; }