|
|
@ -9,7 +9,6 @@
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -102,10 +101,10 @@ namespace MWWorld
|
|
|
|
const T *IndexedStore<T>::find(int index) const
|
|
|
|
const T *IndexedStore<T>::find(int index) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const T *ptr = search(index);
|
|
|
|
const T *ptr = search(index);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << T::getRecordType() << " with index " << index << " not found";
|
|
|
|
const std::string msg = T::getRecordType() + " with index " + std::to_string(index) + " not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -171,10 +170,10 @@ namespace MWWorld
|
|
|
|
const T *Store<T>::find(const std::string &id) const
|
|
|
|
const T *Store<T>::find(const std::string &id) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const T *ptr = search(id);
|
|
|
|
const T *ptr = search(id);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << T::getRecordType() << " '" << id << "' not found";
|
|
|
|
const std::string msg = T::getRecordType() + " '" + id + "' not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -184,14 +183,13 @@ namespace MWWorld
|
|
|
|
const T *ptr = searchRandom(id);
|
|
|
|
const T *ptr = searchRandom(id);
|
|
|
|
if(ptr == 0)
|
|
|
|
if(ptr == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::ostringstream msg;
|
|
|
|
const std::string msg = T::getRecordType() + " starting with '" + id + "' not found";
|
|
|
|
msg << T::getRecordType() << " starting with '"<<id<<"' not found";
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
|
|
template<typename T>
|
|
|
|
RecordId Store<T>::load(ESM::ESMReader &esm)
|
|
|
|
RecordId Store<T>::load(ESM::ESMReader &esm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
T record;
|
|
|
|
T record;
|
|
|
|
bool isDeleted = false;
|
|
|
|
bool isDeleted = false;
|
|
|
@ -364,10 +362,10 @@ namespace MWWorld
|
|
|
|
const ESM::LandTexture *Store<ESM::LandTexture>::find(size_t index, size_t plugin) const
|
|
|
|
const ESM::LandTexture *Store<ESM::LandTexture>::find(size_t index, size_t plugin) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::LandTexture *ptr = search(index, plugin);
|
|
|
|
const ESM::LandTexture *ptr = search(index, plugin);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << "Land texture with index " << index << " not found";
|
|
|
|
const std::string msg = "Land texture with index " + std::to_string(index) + " not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -456,10 +454,10 @@ namespace MWWorld
|
|
|
|
const ESM::Land *Store<ESM::Land>::find(int x, int y) const
|
|
|
|
const ESM::Land *Store<ESM::Land>::find(int x, int y) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Land *ptr = search(x, y);
|
|
|
|
const ESM::Land *ptr = search(x, y);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << "Land at (" << x << ", " << y << ") not found";
|
|
|
|
const std::string msg = "Land at (" + std::to_string(x) + ", " + std::to_string(y) + ") not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -591,20 +589,20 @@ namespace MWWorld
|
|
|
|
const ESM::Cell *Store<ESM::Cell>::find(const std::string &id) const
|
|
|
|
const ESM::Cell *Store<ESM::Cell>::find(const std::string &id) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Cell *ptr = search(id);
|
|
|
|
const ESM::Cell *ptr = search(id);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << "Cell '" << id << "' not found";
|
|
|
|
const std::string msg = "Cell '" + id + "' not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const ESM::Cell *Store<ESM::Cell>::find(int x, int y) const
|
|
|
|
const ESM::Cell *Store<ESM::Cell>::find(int x, int y) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Cell *ptr = search(x, y);
|
|
|
|
const ESM::Cell *ptr = search(x, y);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << "Exterior at (" << x << ", " << y << ") not found";
|
|
|
|
const std::string msg = "Exterior at (" + std::to_string(x) + ", " + std::to_string(y) + ") not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -784,13 +782,10 @@ namespace MWWorld
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ESM::Cell *Store<ESM::Cell>::insert(const ESM::Cell &cell)
|
|
|
|
ESM::Cell *Store<ESM::Cell>::insert(const ESM::Cell &cell)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (search(cell) != 0) {
|
|
|
|
if (search(cell) != 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << "Failed to create ";
|
|
|
|
const std::string cellType = (cell.isExterior()) ? "exterior" : "interior";
|
|
|
|
msg << ((cell.isExterior()) ? "exterior" : "interior");
|
|
|
|
throw std::runtime_error("Failed to create " + cellType + " cell");
|
|
|
|
msg << " cell";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ESM::Cell *ptr;
|
|
|
|
ESM::Cell *ptr;
|
|
|
|
if (cell.isExterior()) {
|
|
|
|
if (cell.isExterior()) {
|
|
|
@ -931,9 +926,8 @@ namespace MWWorld
|
|
|
|
const ESM::Pathgrid* pathgrid = search(x,y);
|
|
|
|
const ESM::Pathgrid* pathgrid = search(x,y);
|
|
|
|
if (!pathgrid)
|
|
|
|
if (!pathgrid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::ostringstream msg;
|
|
|
|
const std::string msg = "Pathgrid in cell '" + std::to_string(x) + " " + std::to_string(y) + "' not found";
|
|
|
|
msg << "Pathgrid in cell '" << x << " " << y << "' not found";
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pathgrid;
|
|
|
|
return pathgrid;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -942,9 +936,8 @@ namespace MWWorld
|
|
|
|
const ESM::Pathgrid* pathgrid = search(name);
|
|
|
|
const ESM::Pathgrid* pathgrid = search(name);
|
|
|
|
if (!pathgrid)
|
|
|
|
if (!pathgrid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::ostringstream msg;
|
|
|
|
const std::string msg = "Pathgrid in cell '" + name + "' not found";
|
|
|
|
msg << "Pathgrid in cell '" << name << "' not found";
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pathgrid;
|
|
|
|
return pathgrid;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -998,10 +991,10 @@ namespace MWWorld
|
|
|
|
const ESM::Attribute *Store<ESM::Attribute>::find(size_t index) const
|
|
|
|
const ESM::Attribute *Store<ESM::Attribute>::find(size_t index) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::Attribute *ptr = search(index);
|
|
|
|
const ESM::Attribute *ptr = search(index);
|
|
|
|
if (ptr == 0) {
|
|
|
|
if (ptr == 0)
|
|
|
|
std::ostringstream msg;
|
|
|
|
{
|
|
|
|
msg << "Attribute with index " << index << " not found";
|
|
|
|
const std::string msg = "Attribute with index " + std::to_string(index) + " not found";
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|