1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 10:53:54 +00:00
openmw/apps/opencs/model/world/land.cpp

38 lines
839 B
C++
Raw Normal View History

#include "land.hpp"
#include <sstream>
2017-09-04 23:31:09 +00:00
#include <stdexcept>
2023-03-18 09:30:48 +00:00
#include <components/misc/strings/conversion.hpp>
2022-10-19 17:02:00 +00:00
namespace ESM
{
class ESMReader;
}
namespace CSMWorld
{
2022-09-22 18:26:05 +00:00
void Land::load(ESM::ESMReader& esm, bool& isDeleted)
{
ESM::Land::load(esm, isDeleted);
2017-09-04 05:06:58 +00:00
}
std::string Land::createUniqueRecordId(int x, int y)
{
std::ostringstream stream;
2017-09-04 05:06:58 +00:00
stream << "#" << x << " " << y;
return stream.str();
}
void Land::parseUniqueRecordId(const std::string& id, int& x, int& y)
{
size_t mid = id.find(' ');
if (mid == std::string::npos || id[0] != '#')
throw std::runtime_error("Invalid Land ID");
2023-03-18 09:30:48 +00:00
x = Misc::StringUtils::toNumeric<int>(id.substr(1, mid - 1), 0);
y = Misc::StringUtils::toNumeric<int>(id.substr(mid + 1), 0);
}
}