mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-03 01:45:33 +00:00
replaced getCurrentCellName function with a more general getCellName function
This commit is contained in:
parent
eea433f141
commit
bc6fe682c9
4 changed files with 20 additions and 33 deletions
|
@ -149,7 +149,11 @@ namespace MWBase
|
||||||
|
|
||||||
virtual std::vector<std::string> getGlobals () const = 0;
|
virtual std::vector<std::string> getGlobals () const = 0;
|
||||||
|
|
||||||
virtual std::string getCurrentCellName() const = 0;
|
virtual std::string getCellName (const MWWorld::CellStore *cell = 0) const = 0;
|
||||||
|
///< Return name of the cell.
|
||||||
|
///
|
||||||
|
/// \note If cell==0, the cell the player is currently in will be used instead to
|
||||||
|
/// generate a name.
|
||||||
|
|
||||||
virtual void removeRefScript (MWWorld::RefData *ref) = 0;
|
virtual void removeRefScript (MWWorld::RefData *ref) = 0;
|
||||||
//< Remove the script attached to ref from mLocalScripts
|
//< Remove the script attached to ref from mLocalScripts
|
||||||
|
|
|
@ -322,8 +322,7 @@ namespace MWScript
|
||||||
|
|
||||||
std::string InterpreterContext::getCurrentCellName() const
|
std::string InterpreterContext::getCurrentCellName() const
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
return MWBase::Environment::get().getWorld()->getCellName();
|
||||||
return world->getCurrentCellName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterpreterContext::isScriptRunning (const std::string& name) const
|
bool InterpreterContext::isScriptRunning (const std::string& name) const
|
||||||
|
|
|
@ -442,40 +442,20 @@ namespace MWWorld
|
||||||
return mGlobalVariables->getGlobals();
|
return mGlobalVariables->getGlobals();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string World::getCurrentCellName () const
|
std::string World::getCellName (const MWWorld::CellStore *cell) const
|
||||||
{
|
{
|
||||||
std::string name;
|
if (!cell)
|
||||||
|
cell = mWorldScene->getCurrentCell();
|
||||||
|
|
||||||
Ptr::CellStore *cell = mWorldScene->getCurrentCell();
|
if (!cell->mCell->isExterior() || !cell->mCell->mName.empty())
|
||||||
if (cell->mCell->isExterior())
|
return cell->mCell->mName;
|
||||||
{
|
|
||||||
if (cell->mCell->mName != "")
|
|
||||||
{
|
|
||||||
name = cell->mCell->mName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const ESM::Region* region =
|
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion);
|
|
||||||
if (region)
|
|
||||||
name = region->mName;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const ESM::GameSetting *setting =
|
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search("sDefaultCellname");
|
|
||||||
|
|
||||||
if (setting && setting->mValue.getType()==ESM::VT_String)
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
name = setting->mValue.getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (const ESM::Region* region = store.get<ESM::Region>().search (cell->mCell->mRegion))
|
||||||
}
|
return region->mName;
|
||||||
else
|
|
||||||
{
|
|
||||||
name = cell->mCell->mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return store.get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::removeRefScript (MWWorld::RefData *ref)
|
void World::removeRefScript (MWWorld::RefData *ref)
|
||||||
|
|
|
@ -213,7 +213,11 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual std::vector<std::string> getGlobals () const;
|
virtual std::vector<std::string> getGlobals () const;
|
||||||
|
|
||||||
virtual std::string getCurrentCellName () const;
|
virtual std::string getCellName (const MWWorld::CellStore *cell = 0) const;
|
||||||
|
///< Return name of the cell.
|
||||||
|
///
|
||||||
|
/// \note If cell==0, the cell the player is currently in will be used instead to
|
||||||
|
/// generate a name.
|
||||||
|
|
||||||
virtual void removeRefScript (MWWorld::RefData *ref);
|
virtual void removeRefScript (MWWorld::RefData *ref);
|
||||||
//< Remove the script attached to ref from mLocalScripts
|
//< Remove the script attached to ref from mLocalScripts
|
||||||
|
|
Loading…
Reference in a new issue