mirror of
https://github.com/bearstonem/openmohaa-vr.git
synced 2026-10-17 23:00:21 +02:00
Check for valid event on listener and print an error if the command cannot be executed
This commit is contained in:
2 files changed
+18
No files matched your search
@@ -541,6 +541,8 @@ void ScriptVM::executeCommandInternal<false>(
|
||||
)
|
||||
{
|
||||
transferVarsToEvent(ev, fromVar, iParamCount);
|
||||
checkValidEvent(ev, listener);
|
||||
|
||||
listener->ProcessScriptEvent(ev);
|
||||
}
|
||||
|
||||
@@ -550,6 +552,7 @@ void ScriptVM::executeCommandInternal<true>(
|
||||
)
|
||||
{
|
||||
transferVarsToEvent(ev, fromVar, iParamCount);
|
||||
checkValidEvent(ev, listener);
|
||||
|
||||
try {
|
||||
listener->ProcessScriptEvent(ev);
|
||||
@@ -595,6 +598,20 @@ void ScriptVM::transferVarsToEvent(Event& ev, ScriptVariable *fromVar, op_parmNu
|
||||
ev.CopyValues(fromVar, count);
|
||||
}
|
||||
|
||||
void ScriptVM::checkValidEvent(Event& ev, Listener* listener) {
|
||||
ClassDef *c = listener->classinfo();
|
||||
|
||||
if (!c->GetDef(&ev)) {
|
||||
if (listener == m_Thread) {
|
||||
ScriptError("Failed execution of command '%s'", ev.getName());
|
||||
} else if (listener->isSubclassOf(SimpleEntity)) {
|
||||
ScriptError("Failed execution of command '%s' for class '%s' Targetname '%s'", ev.getName(), c->classname, static_cast<SimpleEntity*>(listener)->targetname.c_str());
|
||||
} else {
|
||||
ScriptError("Failed execution of command '%s' for class '%s'", ev.getName(), c->classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptVM::executeGetter(Listener *listener, op_evName_t eventName)
|
||||
{
|
||||
int eventNum = Event::FindGetterEventNum(eventName);
|
||||
|
||||
Reference in new issue
Block a user