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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user