mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed map startup
This commit is contained in:
parent
f9e6d1467f
commit
f53a53051b
@ -34,6 +34,7 @@
|
||||
#include "CCreatureHandler.h"//todo: remove
|
||||
#include "spells/CSpellHandler.h" //todo: remove
|
||||
#include "CSkillHandler.h"//todo: remove
|
||||
#include "mapObjectConstructors/AObjectTypeHandler.h"
|
||||
#include "constants/StringConstants.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "TerrainHandler.h" //TODO: remove
|
||||
@ -165,14 +166,14 @@ std::string MapObjectID::encode(int32_t index)
|
||||
{
|
||||
if (index == -1)
|
||||
return "";
|
||||
return VLC->objtypeh->getObjectHandlerName(MapObjectID(index));
|
||||
return VLC->objtypeh->getJsonKey(MapObjectID(index));
|
||||
}
|
||||
|
||||
si32 MapObjectID::decode(const std::string & identifier)
|
||||
{
|
||||
if (identifier.empty())
|
||||
return -1;
|
||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "objects", identifier);
|
||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "object", identifier);
|
||||
return rawId.value();
|
||||
}
|
||||
|
||||
@ -180,14 +181,14 @@ std::string BoatId::encode(int32_t index)
|
||||
{
|
||||
if (index == -1)
|
||||
return "";
|
||||
return VLC->objtypeh->getObjectHandlerName(MapObjectID(index));
|
||||
return VLC->objtypeh->getHandlerFor(MapObjectID::BOAT, index)->getJsonKey();
|
||||
}
|
||||
|
||||
si32 BoatId::decode(const std::string & identifier)
|
||||
{
|
||||
if (identifier.empty())
|
||||
return -1;
|
||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "objects", identifier);
|
||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "core:boat", identifier);
|
||||
return rawId.value();
|
||||
}
|
||||
|
||||
@ -345,6 +346,8 @@ si32 SpellID::decode(const std::string & identifier)
|
||||
|
||||
std::string SpellID::encode(const si32 index)
|
||||
{
|
||||
if (index == -1)
|
||||
return "";
|
||||
return VLC->spells()->getByIndex(index)->getJsonKey();
|
||||
}
|
||||
|
||||
@ -450,6 +453,8 @@ si32 TerrainId::decode(const std::string & identifier)
|
||||
{
|
||||
if (identifier.empty())
|
||||
return static_cast<si32>(TerrainId::NONE);
|
||||
if (identifier == "native")
|
||||
return TerrainId::NATIVE_TERRAIN;
|
||||
|
||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), entityType(), identifier);
|
||||
return rawId.value();
|
||||
@ -459,6 +464,8 @@ std::string TerrainId::encode(const si32 index)
|
||||
{
|
||||
if (index == TerrainId::NONE)
|
||||
return "";
|
||||
if (index == TerrainId::NATIVE_TERRAIN)
|
||||
return "native";
|
||||
return VLC->terrainTypeHandler->getByIndex(index)->getJsonKey();
|
||||
}
|
||||
|
||||
@ -506,7 +513,7 @@ std::string RiverId::encode(const si32 index)
|
||||
|
||||
std::string RiverId::entityType()
|
||||
{
|
||||
return "road";
|
||||
return "river";
|
||||
}
|
||||
|
||||
const TerrainType * TerrainId::toEntity(const Services * service) const
|
||||
|
@ -37,6 +37,9 @@ void MapIdentifiersH3M::loadMapping(std::map<IdentifierID, IdentifierID> & resul
|
||||
|
||||
void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
||||
{
|
||||
if (!mapping["supported"].Bool())
|
||||
throw std::runtime_error("Unsupported map format!");
|
||||
|
||||
for (auto entryFaction : mapping["buildings"].Struct())
|
||||
{
|
||||
FactionID factionID (*VLC->identifiers()->getIdentifier(entryFaction.second.meta, "faction", entryFaction.first));
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
const ui32 SERIALIZATION_VERSION = 830;
|
||||
const ui32 MINIMAL_SERIALIZATION_VERSION = 830;
|
||||
const ui32 SERIALIZATION_VERSION = 831;
|
||||
const ui32 MINIMAL_SERIALIZATION_VERSION = 831;
|
||||
const std::string SAVEGAME_MAGIC = "VCMISVG";
|
||||
|
||||
class CHero;
|
||||
|
Loading…
Reference in New Issue
Block a user