Optimized ScriptVM::EventGoto

This commit is contained in:
smallmodel 2023-08-13 22:07:33 +02:00
parent 7258a2e972
commit 421126db38
No known key found for this signature in database
GPG key ID: A96F163ED4891440

View file

@ -1992,16 +1992,30 @@ EventGoto
*/
void ScriptVM::EventGoto(Event *ev)
{
str label = ev->GetString(1);
unsigned char* codePos;
const ScriptVariable& value = ev->GetValue(1);
if (value.type == VARIABLE_CONSTSTRING)
{
const_str label = value.constStringValue();
codePos = m_ScriptClass->FindLabel(label);
if (!codePos) {
ScriptError("ScriptVM::EventGoto: label '%s' does not exist in '%s'.", value.stringValue().c_str(), Filename().c_str());
}
}
else
{
str label = value.stringValue();
codePos = m_ScriptClass->FindLabel(label);
if (!codePos) {
ScriptError("ScriptVM::EventGoto: label '%s' does not exist in '%s'.", label.c_str(), Filename().c_str());
}
}
SetFastData(ev->data + 1, ev->dataSize - 1);
unsigned char *codePos = m_ScriptClass->FindLabel(label);
if (!codePos) {
ScriptError("ScriptVM::EventGoto: label '%s' does not exist in '%s'.", label.c_str(), Filename().c_str());
}
m_CodePos = codePos;
}