1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 21:15:33 +00:00

check the presence of OnActivate using the SuppressActivate flag instead of looking for keywords

This commit is contained in:
rexelion 2017-10-30 20:59:36 +00:00
parent 4e6f53d6f1
commit e8743f3f79
6 changed files with 8 additions and 16 deletions

View file

@ -42,10 +42,6 @@ namespace MWBase
///< Compile script with the given namen ///< Compile script with the given namen
/// \return Success? /// \return Success?
virtual bool hasOnActivate (const std::string& name) = 0;
///< Determine if a script with the given name contains OnActivate
/// \return Contains OnActivate?
virtual std::pair<int, int> compileAll() = 0; virtual std::pair<int, int> compileAll() = 0;
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success

View file

@ -663,8 +663,7 @@ namespace MWGui
if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up
return; return;
std::string scriptName = object.getClass().getScript(object); // Objects that have OnActivte in their script cannot be picked up through inventory if (object.getRefData().hasSuppressActivate()) // if Flag_SuppressActivate is set, script that contains OnActivate is attached to the item
if (!scriptName.empty() && MWBase::Environment::get().getScriptManager()->hasOnActivate(scriptName))
{ {
if (std::find(mItemsToActivate.begin(), mItemsToActivate.end(), object) == mItemsToActivate.end()) if (std::find(mItemsToActivate.begin(), mItemsToActivate.end(), object) == mItemsToActivate.end())
{ {

View file

@ -88,12 +88,6 @@ namespace MWScript
return false; return false;
} }
bool ScriptManager::hasOnActivate(const std::string& name)
{
const ESM::Script *script = mStore.get<ESM::Script>().find(name);
return script->mScriptText.find("OnActivate");
}
void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext) void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
{ {
// compile script // compile script

View file

@ -62,10 +62,6 @@ namespace MWScript
///< Compile script with the given namen ///< Compile script with the given namen
/// \return Success? /// \return Success?
virtual bool hasOnActivate(const std::string& name);
///< Determine if a script with the given name contains OnActivate
/// \return Contains OnActivate?
virtual std::pair<int, int> compileAll(); virtual std::pair<int, int> compileAll();
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success

View file

@ -192,6 +192,11 @@ namespace MWWorld
return mEnabled; return mEnabled;
} }
bool RefData::hasSuppressActivate()
{
return mFlags & Flag_SuppressActivate;
}
void RefData::enable() void RefData::enable()
{ {
if (!mEnabled) if (!mEnabled)

View file

@ -111,6 +111,8 @@ namespace MWWorld
bool isEnabled() const; bool isEnabled() const;
bool hasSuppressActivate();
void enable(); void enable();
void disable(); void disable();