1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-03 23:19:22 +02:00

Removed buggy and poorly designed fromString method

Use VLC->modh directly with proper parameters instead
This commit is contained in:
Ivan Savenko
2023-07-25 22:36:45 +03:00
parent 1335a834e2
commit e733b55c90
8 changed files with 16 additions and 46 deletions

View File

@@ -305,44 +305,14 @@ bool operator<(const BattleField & l, const BattleField & r)
return l.num < r.num;
}
BattleField::operator std::string() const
{
return getInfo()->identifier;
}
const BattleFieldInfo * BattleField::getInfo() const
{
return VLC->battlefields()->getById(*this);
}
BattleField BattleField::fromString(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeBuiltin(), "battlefield", identifier);
if(rawId)
return BattleField(rawId.value());
else
return BattleField::NONE;
}
const ObstacleInfo * Obstacle::getInfo() const
{
return VLC->obstacles()->getById(*this);
}
Obstacle::operator std::string() const
{
return getInfo()->identifier;
}
Obstacle Obstacle::fromString(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeBuiltin(), "obstacle", identifier);
if(rawId)
return Obstacle(rawId.value());
else
return Obstacle(-1);
}
VCMI_LIB_NAMESPACE_END