mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Serialize Enitity classes by their ID
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
#include "constants/StringConstants.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "TerrainHandler.h" //TODO: remove
|
||||
#include "RiverHandler.h"
|
||||
#include "RoadHandler.h"
|
||||
#include "BattleFieldHandler.h"
|
||||
#include "ObstacleHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
@@ -404,6 +406,11 @@ std::string FactionID::entityType()
|
||||
return "faction";
|
||||
}
|
||||
|
||||
const Faction * FactionID::toEntity(const Services * service) const
|
||||
{
|
||||
return service->factions()->getByIndex(num);
|
||||
}
|
||||
|
||||
si32 TerrainId::decode(const std::string & identifier)
|
||||
{
|
||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), entityType(), identifier);
|
||||
@@ -423,6 +430,21 @@ std::string TerrainId::entityType()
|
||||
return "terrain";
|
||||
}
|
||||
|
||||
const TerrainType * TerrainId::toEntity(const Services * service) const
|
||||
{
|
||||
return VLC->terrainTypeHandler->getByIndex(num);
|
||||
}
|
||||
|
||||
const RoadType * RoadId::toEntity(const Services * service) const
|
||||
{
|
||||
return VLC->roadTypeHandler->getByIndex(num);
|
||||
}
|
||||
|
||||
const RiverType * RiverId::toEntity(const Services * service) const
|
||||
{
|
||||
return VLC->riverTypeHandler->getByIndex(num);
|
||||
}
|
||||
|
||||
const BattleField BattleField::NONE;
|
||||
|
||||
const BattleFieldInfo * BattleField::getInfo() const
|
||||
|
||||
Reference in New Issue
Block a user