mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Check for valid event on listener and print an error if the command cannot be executed
This commit is contained in:
parent
4399e2ab31
commit
539c2df378
2 changed files with 18 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -177,6 +177,7 @@ private:
|
|||
bool executeGetter(Listener *listener, op_evName_t eventName);
|
||||
bool executeSetter(Listener *listener, op_evName_t eventName);
|
||||
void transferVarsToEvent(Event& ev, ScriptVariable *fromVar, op_parmNum_t count);
|
||||
void checkValidEvent(Event& ev, Listener *listener);
|
||||
|
||||
void loadTopInternal(Listener *listener);
|
||||
ScriptVariable *storeTopInternal(Listener *listener);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue