mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 08:15:37 +00:00
allow 'x' instead of 'getjournalindex x'
This commit is contained in:
parent
cd9b137129
commit
914ab1b8ab
6 changed files with 45 additions and 1 deletions
|
@ -38,6 +38,12 @@ bool CSMWorld::ScriptContext::isId (const std::string& name) const
|
|||
return std::binary_search (mIds.begin(), mIds.end(), Misc::StringUtils::lowerCase (name));
|
||||
}
|
||||
|
||||
bool CSMWorld::ScriptContext::isJournalId (const std::string& name) const
|
||||
{
|
||||
/// \todo fix this after isId is fixed
|
||||
return isId (name);
|
||||
}
|
||||
|
||||
void CSMWorld::ScriptContext::invalidateIds()
|
||||
{
|
||||
mIdsUpdated = false;
|
||||
|
|
|
@ -32,6 +32,9 @@ namespace CSMWorld
|
|||
virtual bool isId (const std::string& name) const;
|
||||
///< Does \a name match an ID, that can be referenced?
|
||||
|
||||
virtual bool isJournalId (const std::string& name) const;
|
||||
///< Does \a name match a journal ID?
|
||||
|
||||
void invalidateIds();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
|
||||
#include <components/esm/loaddial.hpp>
|
||||
|
||||
#include <components/compiler/locals.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -67,4 +69,14 @@ namespace MWScript
|
|||
store.get<ESM::Static>().search (name) ||
|
||||
store.get<ESM::Weapon>().search (name);
|
||||
}
|
||||
|
||||
bool CompilerContext::isJournalId (const std::string& name) const
|
||||
{
|
||||
const MWWorld::ESMStore &store =
|
||||
MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
const ESM::Dialogue *topic = store.get<ESM::Dialogue>().search (name);
|
||||
|
||||
return topic && topic->mType==ESM::Dialogue::Journal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ namespace MWScript
|
|||
|
||||
virtual bool isId (const std::string& name) const;
|
||||
///< Does \a name match an ID, that can be referenced?
|
||||
|
||||
virtual bool isJournalId (const std::string& name) const;
|
||||
///< Does \a name match a journal ID?
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ namespace Compiler
|
|||
|
||||
virtual bool isId (const std::string& name) const = 0;
|
||||
///< Does \a name match an ID, that can be referenced?
|
||||
|
||||
virtual bool isJournalId (const std::string& name) const = 0;
|
||||
///< Does \a name match a journal ID?
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <stack>
|
||||
#include <iterator>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include "generator.hpp"
|
||||
#include "scanner.hpp"
|
||||
#include "errorhandler.hpp"
|
||||
|
@ -14,7 +16,6 @@
|
|||
#include "stringparser.hpp"
|
||||
#include "extensions.hpp"
|
||||
#include "context.hpp"
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
|
@ -308,6 +309,22 @@ namespace Compiler
|
|||
return true;
|
||||
}
|
||||
|
||||
// die in a fire, Morrowind script compiler!
|
||||
if (const Extensions *extensions = getContext().getExtensions())
|
||||
{
|
||||
if (getContext().isJournalId (name2))
|
||||
{
|
||||
// JournalID used as an argument. Use the index of that JournalID
|
||||
Generator::pushString (mCode, mLiterals, name2);
|
||||
int keyword = extensions->searchKeyword ("getjournalindex");
|
||||
extensions->generateFunctionCode (keyword, mCode, mLiterals, mExplicit, 0);
|
||||
mNextOperand = false;
|
||||
mOperands.push_back ('l');
|
||||
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (mExplicit.empty() && getContext().isId (name2))
|
||||
{
|
||||
mExplicit = name2;
|
||||
|
|
Loading…
Reference in a new issue