Merge pull request #2844 from open-osrs/better-script-info

runelite-client: script update (thanks TomC) / outdated rework
This commit is contained in:
Tyler Bochard
2020-10-29 13:36:24 -04:00
committed by GitHub
81 changed files with 72 additions and 15 deletions

View File

@@ -2118,4 +2118,8 @@ public interface Client extends GameShell
String getSelectedItemName();
Widget getMessageContinueWidget();
void setOutdatedScript(String outdatedScript);
List<String> getOutdatedScripts();
}

View File

@@ -26,7 +26,6 @@ package net.runelite.api;
import net.runelite.api.hooks.DrawCallbacks;
import java.awt.Canvas;
import net.runelite.api.hooks.DrawCallbacks;
/**
* Represents the client game engine.

View File

@@ -62,6 +62,7 @@ dependencies {
implementation(group = "org.pushing-pixels", name = "radiance-substance", version = "2.5.1")
implementation(group = "net.sf.jopt-simple", name = "jopt-simple", version = "5.0.4")
implementation(group = "org.apache.commons", name = "commons-text", version = "1.9")
implementation(group = "commons-io", name = "commons-io", version = "2.8.0")
implementation(group = "org.jetbrains", name = "annotations", version = "20.1.0")
implementation(group = "org.jooq", name = "jooq", version = "3.14.0")
implementation(group = "org.jooq", name = "jooq-codegen", version = "3.14.0")

View File

@@ -836,8 +836,6 @@ LABEL729:
iload 10
iload 11
iload 28
sconst "addLastRow"
runelite_callback
iload 29
iload 12
iload 13

View File

@@ -53,7 +53,7 @@ LABEL35:
istore 4
LABEL37:
staffmodlevel
iconst -1
iconst 0
if_icmpgt LABEL41
jump LABEL43
LABEL41:

View File

@@ -11,7 +11,7 @@
iconst 0
iload 0
iconst 25
sconst "scrollWheelZoomIncrement"
sconst "scrollWheelZoomIncrement"
runelite_callback
multiply
sub

View File

@@ -29,6 +29,7 @@ dependencies {
compileOnly(group = "com.google.guava", name = "guava", version = "30.0-jre")
compileOnly(group = "javax.inject", name = "javax.inject", version = "1")
compileOnly(group = "org.slf4j", name = "slf4j-api", version = "1.7.30")
compileOnly(group = "commons-io", name = "commons-io", version = "2.8.0")
compileOnly(project(":injection-annotations"))
compileOnly(project(":runescape-api"))
}

View File

@@ -1,11 +1,15 @@
package net.runelite.mixins;
import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteStreams;
import com.google.common.io.CharStreams;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
@@ -15,6 +19,7 @@ import net.runelite.api.overlay.OverlayIndex;
import net.runelite.rs.api.RSAbstractArchive;
import net.runelite.rs.api.RSArchive;
import net.runelite.rs.api.RSClient;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
@Mixin(RSAbstractArchive.class)
@@ -26,6 +31,9 @@ public abstract class RSAbstractArchiveMixin implements RSAbstractArchive
@Inject
private boolean overlayOutdated;
@Inject
private Map<String, String> scriptNames;
@Inject
@Override
public boolean isOverlayOutdated()
@@ -46,6 +54,34 @@ public abstract class RSAbstractArchiveMixin implements RSAbstractArchive
return rsData;
}
if (scriptNames == null)
try
{
scriptNames = new HashMap<>();
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("scripts/");
if (is != null)
{
List<String> files = IOUtils.readLines(is, Charsets.UTF_8);
for (String s : files)
{
if (s.endsWith(".rs2asm"))
continue;
String scriptName = s.replace(".hash", "");
InputStream hashStream = ClassLoader.getSystemClassLoader().getResourceAsStream("scripts/" + scriptName + ".hash");
if (hashStream != null)
{
String scriptHash = (String) IOUtils.readLines(hashStream, Charsets.UTF_8).toArray()[0];
scriptNames.put(scriptHash, scriptName);
}
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
final Logger log = client.getLogger();
final String path = String.format("/runelite/%s/%s", archiveId, groupId);
@@ -68,8 +104,8 @@ public abstract class RSAbstractArchiveMixin implements RSAbstractArchive
// Check if hash is correct first, so we don't have to load the overlay file if it doesn't match
if (!overlayHash.equalsIgnoreCase(originalHash))
{
log.warn("Mismatch in overlaid cache archive hash for {}/{}: {} != {}",
archiveId, groupId, overlayHash, originalHash);
log.error("Script " + scriptNames.get(overlayHash) + " is invalid, and will not be overlaid. This will break plugin(s)!");
client.setOutdatedScript(scriptNames.get(overlayHash));
overlayOutdated = true;
return rsData;
}

View File

@@ -240,6 +240,9 @@ public abstract class RSClientMixin implements RSClient
@Inject
private boolean comparingAppearance = false;
@Inject
private List<String> outdatedScripts = new ArrayList<>();
@Inject
@Override
public void setPrintMenuActions(boolean yes)
@@ -1973,5 +1976,20 @@ public abstract class RSClientMixin implements RSClient
client.setMusicTrackBoolean(var5);
client.setPcmSampleLength(var0);
}
@Inject
@Override
public void setOutdatedScript(String outdatedScript)
{
if (!outdatedScripts.contains(outdatedScript))
outdatedScripts.add(outdatedScript);
}
@Inject
@Override
public List<String> getOutdatedScripts()
{
return this.outdatedScripts;
}
}

View File

@@ -42,7 +42,7 @@ dependencies {
tasks {
register<JavaExec>("assembleMojo") {
outputs.cacheIf { true }
val inp = "${project.extra["rootPath"]}/runelite-client/src/main/scripts"
val inp = "${project.extra["rootPath"]}/runelite-client/src/main/resources/scripts"
val out = "${project.extra["rootPath"]}/runelite-client/build/scripts/runelite"
inputs.dir(inp)
outputs.dir(out)