Issue #31: added function for creating cell records

actorid
Marc Zinnschlag 13 years ago
parent cd7aaab48e
commit 8da15440e0

@ -722,4 +722,27 @@ namespace MWWorld
return std::make_pair (stream.str(), created);
}
const ESM::Cell *World::createRecord (const ESM::Cell& record)
{
if (record.data.flags & ESM::Cell::Interior)
{
if (mStore.cells.searchInt (record.name))
throw std::runtime_error ("failed creating interior cell");
ESM::Cell *cell = new ESM::Cell (record);
mStore.cells.intCells.insert (std::make_pair (record.name, cell));
return cell;
}
else
{
if (mStore.cells.searchExt (record.data.gridX, record.data.gridY))
throw std::runtime_error ("failed creating exterior cell");
ESM::Cell *cell = new ESM::Cell (record);
mStore.cells.extCells.insert (
std::make_pair (std::make_pair (record.data.gridX, record.data.gridY), cell));
return cell;
}
}
}

@ -207,6 +207,10 @@ namespace MWWorld
std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record);
///< Create a new recrod (of type class) in the ESM store.
/// \return ID, pointer to created record
const ESM::Cell *createRecord (const ESM::Cell& record);
///< Create a new recrod (of type cell) in the ESM store.
/// \return ID, pointer to created record
};
}

@ -305,15 +305,24 @@ namespace ESMS
delete it->second;
}
const ESM::Cell* searchInt(const std::string &id) const
{
IntCells::const_iterator iter = intCells.find(id);
if (iter!=intCells.end())
return iter->second;
return 0;
}
const ESM::Cell* findInt(const std::string &id) const
{
IntCells::const_iterator it = intCells.find(id);
const ESM::Cell *cell = searchInt (id);
if(it == intCells.end())
if (!cell)
throw std::runtime_error ("Interior cell not found - " + id);
return it->second;
return cell;
}
const ESM::Cell *searchExt (int x, int y) const

Loading…
Cancel
Save