From b38bfe1f214aa39cf1e7f183b3b77ff2f39c9f8c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 10 Dec 2013 15:22:38 +0100 Subject: [PATCH] removed a redundant function for listing global variables --- apps/openmw/mwbase/world.hpp | 2 -- apps/openmw/mwscript/interpretercontext.cpp | 16 +++++++++++++--- apps/openmw/mwscript/miscextensions.cpp | 5 +++-- apps/openmw/mwworld/globals.cpp | 10 ---------- apps/openmw/mwworld/globals.hpp | 2 -- apps/openmw/mwworld/worldimp.cpp | 5 ----- apps/openmw/mwworld/worldimp.hpp | 2 -- 7 files changed, 16 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 717012f72..740114aff 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -164,8 +164,6 @@ namespace MWBase virtual char getGlobalVariableType (const std::string& name) const = 0; ///< Return ' ', if there is no global variable with this name. - virtual std::vector getGlobals () const = 0; - virtual std::string getCellName (const MWWorld::CellStore *cell = 0) const = 0; ///< Return name of the cell. /// diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index a977d3440..aedaec208 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -156,10 +156,20 @@ namespace MWScript MWBase::Environment::get().getWorld()->setGlobalFloat (name, value); } - std::vector InterpreterContext::getGlobals () const + std::vector InterpreterContext::getGlobals() const { - MWBase::World *world = MWBase::Environment::get().getWorld(); - return world->getGlobals(); + std::vector ids; + + const MWWorld::Store& globals = + MWBase::Environment::get().getWorld()->getStore().get(); + + for (MWWorld::Store::iterator iter = globals.begin(); iter!=globals.end(); + ++iter) + { + ids.push_back (iter->mId); + } + + return ids; } char InterpreterContext::getGlobalType (const std::string& name) const diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index d7b147970..8ca97d288 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -652,13 +652,14 @@ namespace MWScript void printGlobalVars(Interpreter::Runtime &runtime) { - Interpreter::Context& context = runtime.getContext(); + InterpreterContext& context = + static_cast (runtime.getContext()); std::stringstream str; str<< "Global variables:"; MWBase::World *world = MWBase::Environment::get().getWorld(); - std::vector names = world->getGlobals(); + std::vector names = context.getGlobals(); for(size_t i = 0;i < names.size();++i) { char type = world->getGlobalVariableType (names[i]); diff --git a/apps/openmw/mwworld/globals.cpp b/apps/openmw/mwworld/globals.cpp index 19bfa1529..d8e96ddc3 100644 --- a/apps/openmw/mwworld/globals.cpp +++ b/apps/openmw/mwworld/globals.cpp @@ -7,16 +7,6 @@ namespace MWWorld { - std::vector Globals::getGlobals() const - { - std::vector ids; - - for (Collection::const_iterator iter = mVariables.begin(); iter!=mVariables.end(); ++iter) - ids.push_back (iter->first); - - return ids; - } - Globals::Collection::const_iterator Globals::find (const std::string& name) const { Collection::const_iterator iter = mVariables.find (name); diff --git a/apps/openmw/mwworld/globals.hpp b/apps/openmw/mwworld/globals.hpp index 587dd2092..ad140b0c1 100644 --- a/apps/openmw/mwworld/globals.hpp +++ b/apps/openmw/mwworld/globals.hpp @@ -33,8 +33,6 @@ namespace MWWorld char getType (const std::string& name) const; ///< If there is no global variable with this name, ' ' is returned. - std::vector getGlobals() const; - void fill (const MWWorld::ESMStore& store); ///< Replace variables with variables from \a store with default values. }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 7e9647167..c4e63fad0 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -464,11 +464,6 @@ namespace MWWorld return mGlobalVariables.getType (name); } - std::vector World::getGlobals() const - { - return mGlobalVariables.getGlobals(); - } - std::string World::getCellName (const MWWorld::CellStore *cell) const { if (!cell) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 92c99733e..845668449 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -237,8 +237,6 @@ namespace MWWorld virtual char getGlobalVariableType (const std::string& name) const; ///< Return ' ', if there is no global variable with this name. - virtual std::vector getGlobals () const; - virtual std::string getCellName (const MWWorld::CellStore *cell = 0) const; ///< Return name of the cell. ///