Merge pull request #2737 from ThatGamerBlue/worldmap-dungeon
scriptvmmixin: fix consuming WorldMapEvents and potentially others
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 Abex
|
* Copyright (c) 2018 Abex
|
||||||
* Copyright (c) 2020 ThatGamerBlue
|
* Copyright (c) 2020, ThatGamerBlue <thatgamerblue@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -51,6 +51,9 @@ public abstract class ScriptVMMixin implements RSClient
|
|||||||
@Inject
|
@Inject
|
||||||
private static RSScript currentScript;
|
private static RSScript currentScript;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private static RSScriptEvent rootScriptEvent;
|
||||||
|
|
||||||
// This field is set by the ScriptVM raw injector
|
// This field is set by the ScriptVM raw injector
|
||||||
@Inject
|
@Inject
|
||||||
private static int currentScriptPC;
|
private static int currentScriptPC;
|
||||||
@@ -59,6 +62,17 @@ public abstract class ScriptVMMixin implements RSClient
|
|||||||
@Inject
|
@Inject
|
||||||
static void setCurrentScript(RSScript script)
|
static void setCurrentScript(RSScript script)
|
||||||
{
|
{
|
||||||
|
if (rootScriptEvent != null)
|
||||||
|
{
|
||||||
|
if (script != null)
|
||||||
|
{
|
||||||
|
ScriptPreFired event = new ScriptPreFired((int) script.getHash(), rootScriptEvent);
|
||||||
|
client.getCallbacks().post(ScriptPreFired.class, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
rootScriptEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
currentScript = script;
|
currentScript = script;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,12 +159,11 @@ public abstract class ScriptVMMixin implements RSClient
|
|||||||
client.getLogger().error("Error in JavaScriptCallback", e);
|
client.getLogger().error("Error in JavaScriptCallback", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arguments[0] instanceof Integer)
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final ScriptPreFired pre = new ScriptPreFired((int) arguments[0], event);
|
rootScriptEvent = event;
|
||||||
client.getCallbacks().post(ScriptPreFired.class, pre);
|
|
||||||
rs$runScript(event, maxExecutionTime);
|
rs$runScript(event, maxExecutionTime);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
Reference in New Issue
Block a user