fixed global variable search to properly handle injected variables (DaysPassed)

This commit is contained in:
Marc Zinnschlag 2010-07-21 15:01:35 +02:00
parent e670753497
commit 77e03f0f31
5 changed files with 22 additions and 13 deletions

View file

@ -17,19 +17,7 @@ namespace MWScript
char CompilerContext::getGlobalType (const std::string& name) const
{
if (const ESM::Global *global = mEnvironment.mWorld->getStore().globals.find (name))
{
switch (global->type)
{
case ESM::VT_Short: return 's';
case ESM::VT_Int: return 'l';
case ESM::VT_Float: return 'f';
default: return ' ';
}
}
return ' ';
return mEnvironment.mWorld->getGlobalVariableType (name);
}
bool CompilerContext::isId (const std::string& name) const

View file

@ -145,5 +145,15 @@ namespace MWWorld
default: throw std::runtime_error ("unsupported global variable type");
}
}
char Globals::getType (const std::string& name) const
{
Collection::const_iterator iter = mVariables.find (name);
if (iter==mVariables.end())
return ' ';
return iter->second.first;
}
}

View file

@ -53,6 +53,9 @@ namespace MWWorld
float getFloat (const std::string& name) const;
///< Get value independently from real type.
char getType (const std::string& name) const;
///< If there is no global variable with this name, ' ' is returned.
};
}

View file

@ -228,6 +228,11 @@ namespace MWWorld
return (*mGlobalVariables)[name];
}
char World::getGlobalVariableType (const std::string& name) const
{
return mGlobalVariables->getType (name);
}
Ptr World::getPtr (const std::string& name, bool activeOnly)
{
// the player is always in an active cell.

View file

@ -82,6 +82,9 @@ namespace MWWorld
Globals::Data& getGlobalVariable (const std::string& name);
char getGlobalVariableType (const std::string& name) const;
///< Return ' ', if there is no global variable with this name.
Ptr getPtr (const std::string& name, bool activeOnly);
///< Return a pointer to a liveCellRef with the given name.
/// \param activeOnly do non search inactive cells.