forked from teamnwah/openmw-tes3coop
fixed global variable search to properly handle injected variables (DaysPassed)
This commit is contained in:
parent
e670753497
commit
77e03f0f31
5 changed files with 22 additions and 13 deletions
|
@ -17,19 +17,7 @@ namespace MWScript
|
||||||
|
|
||||||
char CompilerContext::getGlobalType (const std::string& name) const
|
char CompilerContext::getGlobalType (const std::string& name) const
|
||||||
{
|
{
|
||||||
if (const ESM::Global *global = mEnvironment.mWorld->getStore().globals.find (name))
|
return mEnvironment.mWorld->getGlobalVariableType (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 ' ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilerContext::isId (const std::string& name) const
|
bool CompilerContext::isId (const std::string& name) const
|
||||||
|
|
|
@ -145,5 +145,15 @@ namespace MWWorld
|
||||||
default: throw std::runtime_error ("unsupported global variable type");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ namespace MWWorld
|
||||||
|
|
||||||
float getFloat (const std::string& name) const;
|
float getFloat (const std::string& name) const;
|
||||||
///< Get value independently from real type.
|
///< Get value independently from real type.
|
||||||
|
|
||||||
|
char getType (const std::string& name) const;
|
||||||
|
///< If there is no global variable with this name, ' ' is returned.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,11 @@ namespace MWWorld
|
||||||
return (*mGlobalVariables)[name];
|
return (*mGlobalVariables)[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char World::getGlobalVariableType (const std::string& name) const
|
||||||
|
{
|
||||||
|
return mGlobalVariables->getType (name);
|
||||||
|
}
|
||||||
|
|
||||||
Ptr World::getPtr (const std::string& name, bool activeOnly)
|
Ptr World::getPtr (const std::string& name, bool activeOnly)
|
||||||
{
|
{
|
||||||
// the player is always in an active cell.
|
// the player is always in an active cell.
|
||||||
|
|
|
@ -82,6 +82,9 @@ namespace MWWorld
|
||||||
|
|
||||||
Globals::Data& getGlobalVariable (const std::string& name);
|
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);
|
Ptr getPtr (const std::string& name, bool activeOnly);
|
||||||
///< Return a pointer to a liveCellRef with the given name.
|
///< Return a pointer to a liveCellRef with the given name.
|
||||||
/// \param activeOnly do non search inactive cells.
|
/// \param activeOnly do non search inactive cells.
|
||||||
|
|
Loading…
Reference in a new issue