From 506a0cdda041285530be11f95bf1b29cb537177e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Wed, 5 Jul 2023 21:08:32 +0200 Subject: [PATCH] - Better name as suggested in PR - Compile fix --- lib/GameConstants.cpp | 8 ++++---- lib/GameConstants.h | 4 ++-- lib/serializer/JsonSerializeFormat.h | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/GameConstants.cpp b/lib/GameConstants.cpp index bc89a8ee2..76dcc54ed 100644 --- a/lib/GameConstants.cpp +++ b/lib/GameConstants.cpp @@ -204,7 +204,7 @@ const FactionID FactionID::NEUTRAL = FactionID(9); si32 FactionID::decode(const std::string & identifier) { - auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), scope(), identifier); + auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), entityType(), identifier); if(rawId) return rawId.value(); else @@ -216,7 +216,7 @@ std::string FactionID::encode(const si32 index) return VLC->factions()->getByIndex(index)->getJsonKey(); } -std::string FactionID::scope() +std::string FactionID::entityType() { return "faction"; } @@ -224,7 +224,7 @@ std::string FactionID::scope() si32 TerrainID::decode(const std::string & identifier) { - auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), scope(), identifier); + auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), entityType(), identifier); if(rawId) return rawId.value(); else @@ -236,7 +236,7 @@ std::string TerrainID::encode(const si32 index) return VLC->terrainTypeHandler->getByIndex(index)->getJsonKey(); } -std::string TerrainID::scope() +std::string TerrainID::entityType() { return "terrain"; } diff --git a/lib/GameConstants.h b/lib/GameConstants.h index ae05c9534..4a58b77a5 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -461,7 +461,7 @@ class FactionID : public BaseForID static si32 decode(const std::string& identifier); static std::string encode(const si32 index); - static std::string scope(); + static std::string entityType(); }; class TerrainID @@ -470,7 +470,7 @@ class TerrainID public: static si32 decode(const std::string & identifier); static std::string encode(const si32 index); - static std::string scope(); + static std::string entityType(); }; class BuildingID diff --git a/lib/serializer/JsonSerializeFormat.h b/lib/serializer/JsonSerializeFormat.h index 3a23f6944..4dd826a5c 100644 --- a/lib/serializer/JsonSerializeFormat.h +++ b/lib/serializer/JsonSerializeFormat.h @@ -10,6 +10,7 @@ #pragma once #include "../JsonNode.h" +#include "../CModHandler.h" VCMI_LIB_NAMESPACE_BEGIN @@ -367,7 +368,7 @@ public: for(const auto & id : node.Vector()) { - VLC->modh->identifiers.requestIdentifier(U::scope(), id, [&value](int32_t identifier) + VLC->modh->identifiers.requestIdentifier(U::entityType(), id, [&value](int32_t identifier) { value.emplace(identifier); });