2014-10-08 17:17:31 +02:00
|
|
|
#include "land.hpp"
|
|
|
|
|
|
|
|
#include <sstream>
|
2017-09-04 19:31:09 -04:00
|
|
|
#include <stdexcept>
|
2014-10-08 17:17:31 +02:00
|
|
|
|
2023-03-18 09:30:48 +00:00
|
|
|
#include <components/misc/strings/conversion.hpp>
|
|
|
|
|
2022-10-19 19:02:00 +02:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMReader;
|
|
|
|
}
|
|
|
|
|
2014-10-08 17:17:31 +02:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2015-07-21 20:25:43 +03:00
|
|
|
void Land::load(ESM::ESMReader& esm, bool& isDeleted)
|
2014-10-08 17:17:31 +02:00
|
|
|
{
|
2015-11-13 01:34:36 +01:00
|
|
|
ESM::Land::load(esm, isDeleted);
|
2017-09-04 01:06:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Land::createUniqueRecordId(int x, int y)
|
|
|
|
{
|
2014-10-08 17:17:31 +02:00
|
|
|
std::ostringstream stream;
|
2017-09-04 01:06:58 -04: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);
|
2014-10-08 17:17:31 +02:00
|
|
|
}
|
|
|
|
}
|