forked from mirror/openmw-tes3mp
Merge pull request #1376 from spycrab/start_exterior_cell
Allow starting at an (unnamed) exterior cell using --start
This commit is contained in:
commit
4d1582dfc0
3 changed files with 22 additions and 4 deletions
|
@ -278,8 +278,7 @@ void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir)
|
|||
mResDir = parResDir;
|
||||
}
|
||||
|
||||
// Set start cell name (only interiors for now)
|
||||
|
||||
// Set start cell name
|
||||
void OMW::Engine::setCell (const std::string& cellName)
|
||||
{
|
||||
mCellName = cellName;
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace OMW
|
|||
/// Set resource dir
|
||||
void setResourceDir(const boost::filesystem::path& parResDir);
|
||||
|
||||
/// Set start cell name (only interiors for now)
|
||||
/// Set start cell name
|
||||
void setCell(const std::string& cellName);
|
||||
|
||||
/**
|
||||
|
|
|
@ -2582,7 +2582,25 @@ namespace MWWorld
|
|||
{
|
||||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||
|
||||
if (const ESM::Cell *ext = getExterior(name)) {
|
||||
const ESM::Cell *ext = getExterior(name);
|
||||
|
||||
if (!ext && name.find(',') != std::string::npos) {
|
||||
try {
|
||||
int x = std::stoi(name.substr(0, name.find(',')));
|
||||
int y = std::stoi(name.substr(name.find(',')+1));
|
||||
ext = getExterior(x, y)->getCell();
|
||||
}
|
||||
catch (std::invalid_argument)
|
||||
{
|
||||
// This exception can be ignored, as this means that name probably refers to a interior cell instead of comma separated coordinates
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
{
|
||||
throw std::runtime_error("Cell coordinates out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
if (ext) {
|
||||
int x = ext->getGridX();
|
||||
int y = ext->getGridY();
|
||||
indexToPosition(x, y, pos.pos[0], pos.pos[1], true);
|
||||
|
@ -2592,6 +2610,7 @@ namespace MWWorld
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue