2013-04-10 20:49:22 +00:00
|
|
|
|
|
|
|
#include "scriptcontext.hpp"
|
|
|
|
|
2013-09-19 10:30:42 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
|
|
|
|
|
|
|
#include "data.hpp"
|
|
|
|
|
|
|
|
CSMWorld::ScriptContext::ScriptContext (const Data& data) : mData (data), mIdsUpdated (false) {}
|
|
|
|
|
2013-04-10 20:49:22 +00:00
|
|
|
bool CSMWorld::ScriptContext::canDeclareLocals() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
char CSMWorld::ScriptContext::getGlobalType (const std::string& name) const
|
|
|
|
{
|
|
|
|
return ' ';
|
|
|
|
}
|
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
std::pair<char, bool> CSMWorld::ScriptContext::getMemberType (const std::string& name,
|
|
|
|
const std::string& id) const
|
2013-04-10 20:49:22 +00:00
|
|
|
{
|
2014-02-10 13:45:55 +00:00
|
|
|
return std::make_pair (' ', false);
|
2013-04-10 20:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSMWorld::ScriptContext::isId (const std::string& name) const
|
|
|
|
{
|
2013-09-19 10:30:42 +00:00
|
|
|
if (!mIdsUpdated)
|
|
|
|
{
|
|
|
|
mIds = mData.getIds();
|
|
|
|
|
|
|
|
std::for_each (mIds.begin(), mIds.end(), &Misc::StringUtils::lowerCase);
|
|
|
|
|
|
|
|
mIdsUpdated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::binary_search (mIds.begin(), mIds.end(), Misc::StringUtils::lowerCase (name));
|
|
|
|
}
|
|
|
|
|
2014-02-02 14:08:27 +00:00
|
|
|
bool CSMWorld::ScriptContext::isJournalId (const std::string& name) const
|
|
|
|
{
|
|
|
|
/// \todo fix this after isId is fixed
|
|
|
|
return isId (name);
|
|
|
|
}
|
|
|
|
|
2013-09-19 10:30:42 +00:00
|
|
|
void CSMWorld::ScriptContext::invalidateIds()
|
|
|
|
{
|
|
|
|
mIdsUpdated = false;
|
2013-04-10 20:49:22 +00:00
|
|
|
}
|