1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 09:23:53 +00:00
openmw/apps/opencs/model/world/landtexture.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
957 B
C++
Raw Normal View History

#include "landtexture.hpp"
#include <sstream>
2017-09-04 23:31:09 +00:00
#include <stdexcept>
#include <components/esm3/esmreader.hpp>
2023-03-18 09:30:48 +00:00
#include <components/misc/strings/conversion.hpp>
namespace CSMWorld
{
void LandTexture::load(ESM::ESMReader& esm, bool& isDeleted)
{
ESM::LandTexture::load(esm, isDeleted);
mPluginIndex = esm.getIndex();
}
std::string LandTexture::createUniqueRecordId(int plugin, int index)
{
std::stringstream ss;
ss << 'L' << plugin << '#' << index;
return ss.str();
}
void LandTexture::parseUniqueRecordId(const std::string& id, int& plugin, int& index)
{
size_t middle = id.find('#');
if (middle == std::string::npos || id[0] != 'L')
throw std::runtime_error("Invalid LandTexture ID");
2023-03-18 09:30:48 +00:00
plugin = Misc::StringUtils::toNumeric<int>(id.substr(1, middle - 1), 0);
index = Misc::StringUtils::toNumeric<int>(id.substr(middle + 1), 0);
}
}