diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a89e9de499..f64f259ce6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -52,7 +52,7 @@ Before you submit your pull request consider the following guidelines: cd runelite/ ``` * After cloning, set a new remote [upstream](https://help.github.com/articles/configuring-a-remote-for-a-fork/) (this helps to keep your fork up to date) - + ```shell git remote add upstream https://github.com/open-osrs/runelite.git ``` diff --git a/cache/src/main/java/net/runelite/cache/ItemManager.java b/cache/src/main/java/net/runelite/cache/ItemManager.java index bff27593d6..8e05bc80eb 100644 --- a/cache/src/main/java/net/runelite/cache/ItemManager.java +++ b/cache/src/main/java/net/runelite/cache/ItemManager.java @@ -70,6 +70,30 @@ public class ItemManager implements ItemProvider } } + public void link() + { + for (ItemDefinition oc : items.values()) + { + link(oc); + } + } + + private void link(ItemDefinition item) + { + if (item.notedTemplate != -1) + { + item.linkNote(getItem(item.notedTemplate), getItem(item.notedID)); + } + if (item.boughtTemplateId != -1) + { + item.linkBought(getItem(item.boughtTemplateId), getItem(item.boughtId)); + } + if (item.placeholderTemplateId != -1) + { + item.linkPlaceholder(getItem(item.placeholderTemplateId), getItem(item.placeholderId)); + } + } + public Collection getItems() { return Collections.unmodifiableCollection(items.values()); diff --git a/cache/src/main/java/net/runelite/cache/definitions/ItemDefinition.java b/cache/src/main/java/net/runelite/cache/definitions/ItemDefinition.java index f918da5a54..ebd97409a0 100644 --- a/cache/src/main/java/net/runelite/cache/definitions/ItemDefinition.java +++ b/cache/src/main/java/net/runelite/cache/definitions/ItemDefinition.java @@ -60,19 +60,13 @@ public class ItemDefinition public int ambient; public int contrast; - + public int[] countCo; public int[] countObj; - public String[] options = new String[] - { - null, null, "Take", null, null - }; - - public String[] interfaceOptions = new String[] - { - null, null, null, null, "Drop" - }; + public String[] options = new String[]{null, null, "Take", null, null}; + + public String[] interfaceOptions = new String[]{null, null, null, null, "Drop"}; public int maleModel0 = -1; public int maleModel1 = -1; @@ -87,7 +81,7 @@ public class ItemDefinition public int femaleOffset; public int femaleHeadModel = -1; public int femaleHeadModel2 = -1; - + public int category; public int notedID = -1; @@ -99,13 +93,13 @@ public class ItemDefinition public int boughtId = -1; public int boughtTemplateId = -1; - + public int placeholderId = -1; public int placeholderTemplateId = -1; public Map params = null; - public void updateNote(ItemDefinition notedItem, ItemDefinition unnotedItem) + public void linkNote(ItemDefinition notedItem, ItemDefinition unnotedItem) { this.inventoryModel = notedItem.inventoryModel; this.zoom2d = notedItem.zoom2d; @@ -123,4 +117,65 @@ public class ItemDefinition this.cost = unnotedItem.cost; this.stackable = 1; } + + public void linkBought(ItemDefinition var1, ItemDefinition var2) + { + this.inventoryModel = var1.inventoryModel; + this.zoom2d = var1.zoom2d; + this.xan2d = var1.xan2d; + this.yan2d = var1.yan2d; + this.zan2d = var1.zan2d; + this.xOffset2d = var1.xOffset2d; + this.yOffset2d = var1.yOffset2d; + this.colorFind = var2.colorFind; + this.colorReplace = var2.colorReplace; + this.textureFind = var2.textureFind; + this.textureReplace = var2.textureReplace; + this.name = var2.name; + this.members = var2.members; + this.stackable = var2.stackable; + this.maleModel0 = var2.maleModel0; + this.maleModel1 = var2.maleModel1; + this.maleModel2 = var2.maleModel2; + this.femaleModel0 = var2.femaleModel0; + this.femaleModel1 = var2.femaleModel1; + this.femaleModel2 = var2.femaleModel2; + this.maleHeadModel = var2.maleHeadModel; + this.maleHeadModel2 = var2.maleHeadModel2; + this.femaleHeadModel = var2.femaleHeadModel; + this.femaleHeadModel2 = var2.femaleHeadModel2; + this.team = var2.team; + this.options = var2.options; + this.interfaceOptions = new String[5]; + if (var2.interfaceOptions != null) + { + for (int var3 = 0; var3 < 4; ++var3) + { + this.interfaceOptions[var3] = var2.interfaceOptions[var3]; + } + } + + this.interfaceOptions[4] = "Discard"; + this.cost = 0; + } + + public void linkPlaceholder(ItemDefinition var1, ItemDefinition var2) + { + this.inventoryModel = var1.inventoryModel; + this.zoom2d = var1.zoom2d; + this.xan2d = var1.xan2d; + this.yan2d = var1.yan2d; + this.zan2d = var1.zan2d; + this.xOffset2d = var1.xOffset2d; + this.yOffset2d = var1.yOffset2d; + this.colorFind = var1.colorFind; + this.colorReplace = var1.colorReplace; + this.textureFind = var1.textureFind; + this.textureReplace = var1.textureReplace; + this.stackable = var1.stackable; + this.name = var2.name; + this.cost = 0; + this.members = false; + this.isTradeable = false; + } } diff --git a/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java b/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java index 3898850920..16147b1a97 100644 --- a/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java +++ b/cache/src/main/java/net/runelite/cache/item/ItemSpriteFactory.java @@ -72,11 +72,6 @@ public class ItemSpriteFactory } } - if (item.notedTemplate != -1) - { - item.updateNote(itemProvider.provide(item.notedTemplate), itemProvider.provide(item.notedID)); - } - Model itemModel = getModel(modelProvider, item); if (itemModel == null) { @@ -96,7 +91,11 @@ public class ItemSpriteFactory else if (item.boughtTemplateId != -1) { auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider, +<<<<<<< HEAD item.boughtId, quantity, border, shadowColor, false); +======= + item.boughtId, quantity, border, 0, false); +>>>>>>> runelite/master if (auxSpritePixels == null) { return null; diff --git a/cache/src/main/java/net/runelite/cache/item/RSTextureProvider.java b/cache/src/main/java/net/runelite/cache/item/RSTextureProvider.java index a38f14dce3..dfe885d504 100644 --- a/cache/src/main/java/net/runelite/cache/item/RSTextureProvider.java +++ b/cache/src/main/java/net/runelite/cache/item/RSTextureProvider.java @@ -69,13 +69,16 @@ public class RSTextureProvider TextureDefinition var2 = this.textures[var1]; if (var2 != null) { - if (var2.pixels != null) + synchronized (var2) { + if (var2.pixels != null) + { + return var2.pixels; + } + + var2.method2680(this.brightness, this.width, spriteProvider); return var2.pixels; } - - boolean var3 = var2.method2680(this.brightness, this.width, spriteProvider); - return var2.pixels; } return null; diff --git a/cache/src/test/java/net/runelite/cache/item/ItemSpriteFactoryTest.java b/cache/src/test/java/net/runelite/cache/item/ItemSpriteFactoryTest.java new file mode 100644 index 0000000000..86140bf4e8 --- /dev/null +++ b/cache/src/test/java/net/runelite/cache/item/ItemSpriteFactoryTest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.cache.item; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import lombok.extern.slf4j.Slf4j; +import net.runelite.cache.IndexType; +import net.runelite.cache.ItemManager; +import net.runelite.cache.SpriteManager; +import net.runelite.cache.StoreLocation; +import net.runelite.cache.TextureManager; +import net.runelite.cache.definitions.ItemDefinition; +import net.runelite.cache.definitions.ModelDefinition; +import net.runelite.cache.definitions.loaders.ModelLoader; +import net.runelite.cache.definitions.providers.ModelProvider; +import net.runelite.cache.fs.Archive; +import net.runelite.cache.fs.Index; +import net.runelite.cache.fs.Store; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +@Slf4j +public class ItemSpriteFactoryTest +{ + @Rule + public TemporaryFolder folder = StoreLocation.getTemporaryFolder(); + + @Test + @Ignore + public void test() throws IOException + { + File base = StoreLocation.LOCATION, + outDir = folder.newFolder(); + + int count = 0; + + try (Store store = new Store(base)) + { + store.load(); + + ItemManager itemManager = new ItemManager(store); + itemManager.load(); + itemManager.link(); + + ModelProvider modelProvider = new ModelProvider() + { + @Override + public ModelDefinition provide(int modelId) throws IOException + { + Index models = store.getIndex(IndexType.MODELS); + Archive archive = models.getArchive(modelId); + + byte[] data = archive.decompress(store.getStorage().loadArchive(archive)); + ModelDefinition inventoryModel = new ModelLoader().load(modelId, data); + return inventoryModel; + } + }; + + SpriteManager spriteManager = new SpriteManager(store); + spriteManager.load(); + + TextureManager textureManager = new TextureManager(store); + textureManager.load(); + + for (ItemDefinition itemDef : itemManager.getItems()) + { + if (itemDef.name == null || itemDef.name.equalsIgnoreCase("null")) + { + continue; + } + + try + { + BufferedImage sprite = ItemSpriteFactory.createSprite(itemManager, modelProvider, spriteManager, textureManager, + itemDef.id, 1, 1, 3153952, false); + + File out = new File(outDir, itemDef.id + ".png"); + BufferedImage img = sprite; + ImageIO.write(img, "PNG", out); + + ++count; + } + catch (Exception ex) + { + log.warn("error dumping item {}", itemDef.id, ex); + } + } + } + + log.info("Dumped {} item images to {}", count, outDir); + } +} \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/ObjectComposition.java b/runelite-api/src/main/java/net/runelite/api/ObjectComposition.java index 771731bc02..11e2e72f2a 100644 --- a/runelite-api/src/main/java/net/runelite/api/ObjectComposition.java +++ b/runelite-api/src/main/java/net/runelite/api/ObjectComposition.java @@ -24,6 +24,8 @@ */ package net.runelite.api; +import net.runelite.api.annotations.Varbit; + /** * Information about a specific {@link ObjectID} */ @@ -75,8 +77,26 @@ public interface ObjectComposition extends ParamHolder ObjectComposition getImpostor(); /** +<<<<<<< HEAD * Get the bitmask that contains information on which directions you can interact * with this object from. */ int getAccessBitMask(); +======= + * Gets the {@link Varbits} used to switch this multiloc, or {@code -1} if this is not switched by a Varbit + * + * @see #getImpostor() + * @see #getImpostorIds() + */ + @Varbit + int getVarbitId(); + + /** + * Gets the {@link VarPlayer} used to switch this multiloc, or {@code -1} if this is not switched by a VarPlayer + * + * @see #getImpostor() + * @see #getImpostorIds() + */ + int getVarPlayerId(); +>>>>>>> runelite/master } diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index cd5ac42f64..33417b38c6 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -549,9 +549,15 @@ public class RuneLite { OkHttpClient.Builder builder = new OkHttpClient.Builder() .pingInterval(30, TimeUnit.SECONDS) - .addNetworkInterceptor(chain -> + .addInterceptor(chain -> { - Request userAgentRequest = chain.request() + Request request = chain.request(); + if (request.header("User-Agent") != null) + { + return chain.proceed(request); + } + + Request userAgentRequest = request .newBuilder() .header("User-Agent", USER_AGENT) .build(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java index 2f55fd4d79..08e5f9ba08 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java @@ -218,6 +218,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(2318, 2954, 0), new CoordinateClueInfo("North-east corner of the Isle of Souls.", BANDOSIAN_GUARD)) .put(new WorldPoint(2094, 2889, 0), new CoordinateClueInfo("West side of the Isle of Souls.", ARMADYLEAN_GUARD)) .put(new WorldPoint(1451, 3509, 0), new CoordinateClueInfo("Ruins of Morra.", ARMADYLEAN_OR_BANDOSIAN_GUARD)) + .put(new WorldPoint(3318, 2706, 0), new CoordinateClueInfo("Necropolis mine", ARMADYLEAN_OR_BANDOSIAN_GUARD)) // Master .put(new WorldPoint(2178, 3209, 0), new CoordinateClueInfo("South of Iorwerth Camp.", BRASSICAN_MAGE)) .put(new WorldPoint(2155, 3100, 0), new CoordinateClueInfo("South of Port Tyras (BJS if 76 Agility).", BRASSICAN_MAGE)) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index 785ffce336..b494082b01 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java @@ -153,7 +153,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Search the crates in the Port Sarim Fishing shop.", CRATE_9534, new WorldPoint(3012, 3222, 0), "Search the crates, by the door, in Gerrant's Fishy Business in Port Sarim."), new CrypticClue("Speak to The Lady of the Lake.", "The Lady of the Lake", new WorldPoint(2924, 3405, 0), "Talk to The Lady of the Lake in Taverley."), new CrypticClue("Rotting next to a ditch. Dig next to the fish.", new WorldPoint(3547, 3183, 0), "Dig next to a fishing spot on the south-east side of Burgh de Rott."), - new CrypticClue("The King's magic won't be wasted by me.", "Guardian mummy", new WorldPoint(1934, 4427, 0), "Talk to the Guardian mummy inside the Pyramid Plunder minigame in Sophanem."), + new CrypticClue("The King's magic shouldn't be wasted by me.", "Guardian mummy", new WorldPoint(1934, 4427, 0), "Talk to the Guardian mummy inside the Pyramid Plunder minigame in Sophanem."), new CrypticClue("Dig where the forces of Zamorak and Saradomin collide.", new WorldPoint(3049, 4839, 0), "Dig next to the law rift in the Abyss."), new CrypticClue("Search the boxes in the goblin house near Lumbridge.", BOXES, new WorldPoint(3245, 3245, 0), "Goblin house on the eastern side of the river outside of Lumbridge."), new CrypticClue("W marks the spot.", new WorldPoint(2867, 3546, 0), "Dig in the middle of the Warriors' Guild entrance hall."), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index fd66d3c91a..d158b151a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -186,36 +186,36 @@ public class DpsCounterPlugin extends Plugin Hitsplat hitsplat = hitsplatApplied.getHitsplat(); + final int npcId = ((NPC) actor).getId(); + final boolean isBoss = BOSSES.contains(npcId); + if (hitsplat.isMine()) { - final int npcId = ((NPC) actor).getId(); - boolean isBoss = BOSSES.contains(npcId); + int hit = hitsplat.getAmount(); + PartyMember localMember = partyService.getLocalMember(); + + // broadcast damage + if (localMember != null) + { + final DpsUpdate dpsUpdate = new DpsUpdate(hit, isBoss); + dpsUpdate.setMemberId(localMember.getMemberId()); + wsClient.send(dpsUpdate); + } + if (dpsConfig.bossDamage() && !isBoss) { return; } - int hit = hitsplat.getAmount(); - // Update local member - PartyMember localMember = partyService.getLocalMember(); // If not in a party, user local player name final String name = localMember == null ? player.getName() : localMember.getName(); DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new); dpsMember.addDamage(hit); - // broadcast damage - if (localMember != null) - { - final DpsUpdate specialCounterUpdate = new DpsUpdate(hit); - specialCounterUpdate.setMemberId(localMember.getMemberId()); - wsClient.send(specialCounterUpdate); - } // apply to total } else if (hitsplat.isOthers()) { - final int npcId = ((NPC) actor).getId(); - boolean isBoss = BOSSES.contains(npcId); if ((dpsConfig.bossDamage() || actor != player.getInteracting()) && !isBoss) { // only track damage to npcs we are attacking, or is a nearby common boss @@ -246,6 +246,12 @@ public class DpsCounterPlugin extends Plugin return; } + // Received non-boss damage, but we only want boss damage + if (!dpsUpdate.isBoss() && dpsConfig.bossDamage()) + { + return; + } + unpause(); DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java index 81e5859b38..ee1b652c34 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2020 Adam + * Copyright (c) 2021, Jonathan Rousseau * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,4 +34,5 @@ import net.runelite.http.api.ws.messages.party.PartyMemberMessage; public class DpsUpdate extends PartyMemberMessage { private int hit; + private boolean isBoss; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRings.java b/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRings.java index cf4f2456da..5fd9f83c3a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRings.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRings.java @@ -36,6 +36,7 @@ public enum FairyRings AJQ("Cave south of Dorgesh-Kaan"), AJR("Slayer cave"), AJS("Penguins near Miscellania"), + AKP("Necropolis"), AKQ("Piscatoris Hunter area"), AKS("Feldip Hunter area"), ALP("(Island) Lighthouse"),