mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 20:15:33 +00:00
Add a way of filtering out ingame scripts for upcoming script packets
This commit is contained in:
parent
aaf4cc0d7e
commit
75f6d82f08
5 changed files with 36 additions and 2 deletions
|
@ -77,6 +77,13 @@ void OMW::Engine::executeLocalScripts()
|
|||
{
|
||||
MWScript::InterpreterContext interpreterContext (
|
||||
&script.second.getRefData().getLocals(), script.second);
|
||||
|
||||
// Added by tes3mp
|
||||
if (mwmp::Main::isValidPacketScript(script.first))
|
||||
{
|
||||
interpreterContext.sendPackets = true;
|
||||
}
|
||||
|
||||
mEnvironment.getScriptManager()->run (script.first, interpreterContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,4 +224,23 @@ void Main::PressedKey(int key)
|
|||
if (pMain == nullptr) return;
|
||||
if (get().getGUIController()->pressedKey(key))
|
||||
return; // if any gui bind pressed
|
||||
}
|
||||
}
|
||||
|
||||
// When sending packets with ingame script values, certain packets
|
||||
// should be ignored because of their potential for spam
|
||||
bool Main::isValidPacketScript(std::string script)
|
||||
{
|
||||
static const int invalidPacketScriptsCount = 2;
|
||||
static const std::string invalidPacketScripts[invalidPacketScriptsCount] = {
|
||||
"OutsideBanner",
|
||||
"sleeperScript"
|
||||
};
|
||||
|
||||
for (int i = 0; i < invalidPacketScriptsCount; i++)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(script, invalidPacketScripts[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace mwmp
|
|||
static void Frame(float dt);
|
||||
static void PressedKey(int key);
|
||||
|
||||
static bool isValidPacketScript(std::string script);
|
||||
|
||||
Networking *getNetworking() const;
|
||||
LocalPlayer *getLocalPlayer() const;
|
||||
GUIController *getGUIController() const;
|
||||
|
@ -38,7 +40,6 @@ namespace mwmp
|
|||
LocalPlayer *mLocalPlayer;
|
||||
|
||||
GUIController *mGUIController;
|
||||
|
||||
std::string server;
|
||||
unsigned short port;
|
||||
};
|
||||
|
|
|
@ -177,6 +177,10 @@ namespace MWScript
|
|||
throw std::runtime_error ("local variables not available in this context");
|
||||
|
||||
mLocals->mShorts.at (index) = value;
|
||||
|
||||
if (sendPackets)
|
||||
printf("Sending ID_SCRIPT_LOCAL_SHORT for %s\n",
|
||||
this->mReference.getClass().getScript(mReference));
|
||||
}
|
||||
|
||||
void InterpreterContext::setLocalLong (int index, int value)
|
||||
|
|
|
@ -55,6 +55,9 @@ namespace MWScript
|
|||
const std::string& targetId = "");
|
||||
///< The ownership of \a locals is not transferred. 0-pointer allowed.
|
||||
|
||||
// Added by tes3mp
|
||||
bool sendPackets = false;
|
||||
|
||||
virtual int getLocalShort (int index) const;
|
||||
|
||||
virtual int getLocalLong (int index) const;
|
||||
|
|
Loading…
Reference in a new issue