diff --git a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/AssemblyMediator.java b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/AssemblyMediator.java index f664c09f7..543fda3f3 100644 --- a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/AssemblyMediator.java +++ b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/AssemblyMediator.java @@ -19,6 +19,7 @@ public class AssemblyMediator extends Updatable implements AssemblyAPI { private int selectedRecipeIndex; private final Recipe selectedRecipe = new Recipe(); + private boolean listUpdated = false; private final FlashList recipes = FlashList.ofVector(Recipe::new); private final List filters = new ArrayList<>(); private final FlashList rowSettings = FlashList.ofVector(RowFilter::new); @@ -30,7 +31,7 @@ public void update() { if (address == 0) return; selectedRecipeIndex = readInt(0x48); - recipes.update(readAtom(0x60, 0x20)); + listUpdated = false; selectedRecipe.updateIfChanged(readAtom(0x70)); selectedRecipe.update(); @@ -46,6 +47,15 @@ public void update() { isFilterDropDownOpen = readBoolean(0x78, 0x60, 0x1D0); } + @Override + public List getRecipes() { + if (!listUpdated) { + recipes.update(readAtom(0x60, 0x20)); + listUpdated = true; + } + return recipes; + } + @Getter @ToString private static class Recipe extends Updatable implements AssemblyAPI.Recipe { @@ -64,6 +74,8 @@ private static class Recipe extends Updatable implements AssemblyAPI.Recipe { public void update(long address) { super.update(address); + recipeId = readString(0x58, 0x48); + rewardsArr.update(API.readAtom(address + 0x60)); rewards.clear(); rewardsArr.forEach(ptr -> rewards.add(API.readString(ptr, 0x48))); @@ -76,10 +88,7 @@ public void update() { isCraftable = readBoolean(0x20); craftTimeLeft = (int) readDouble(0x40, 0x28, 0x38); - long recipe = readAtom(0x58); - recipeId = API.readString(recipe, 0x48); - - long data = API.readAtom(recipe, 0x40, 0x20); + long data = readAtom(0x58, 0x40, 0x20); visibility = API.readString(data, 0x90); craftTimeData.update(API.readAtom(data, 0x98)); for (long i : craftTimeData) { diff --git a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/BoosterProxy.java b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/BoosterProxy.java index 871edcc2e..1ad2970c9 100644 --- a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/BoosterProxy.java +++ b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/BoosterProxy.java @@ -24,7 +24,7 @@ public void update() { } } - public static class Booster extends Auto implements BoosterAPI.Booster { + public static class Booster extends Updatable implements BoosterAPI.Booster { public double amount, cd; public String category, name; @@ -37,12 +37,17 @@ public static class Booster extends Auto implements BoosterAPI.Booster { private final FlashListLong categoriesArr = FlashListLong.ofVector(); @Override - public void update() { + public void update(long address) { + super.update(address); String oldCat = this.category; this.category = readString(0x20); if (!Objects.equals(this.category, oldCat)) this.cat = BoosterAPI.Type.of(category); this.name = readString(0x40); //0x48 description; + } + + @Override + public void update() { this.amount = readDouble(0x50); this.subBoostersArr.update(readLong(0x30)); diff --git a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/DispatchRetrieverProxy.java b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/DispatchRetrieverProxy.java index b6d947e27..4742f27f5 100644 --- a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/DispatchRetrieverProxy.java +++ b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/DispatchRetrieverProxy.java @@ -26,12 +26,13 @@ public void update() { availableRetrievers.update(API.readAtom(dispatchRetrieverData + 0x58)); inProgressRetrievers.update(API.readAtom(dispatchRetrieverData + 0x60)); - selectedRetriever.update(API.readAtom(dispatchRetrieverData + 0x68)); + selectedRetriever.updateIfChanged(API.readAtom(dispatchRetrieverData + 0x68)); + selectedRetriever.update(); } @Getter @ToString - private static class Retriever extends Auto implements DispatchAPI.Retriever { + private static class Retriever extends Updatable implements DispatchAPI.Retriever { private int id = -1, slotId = -1, tier = -1; private String iconId = "", type = "", name = "", descriptionId = ""; private double duration = -1; @@ -40,6 +41,22 @@ private static class Retriever extends Auto implements DispatchAPI.Retriever { private final FlashList costList = FlashList.ofVector(Cost::new); private final Cost instantCost = new Cost(); + @Override + public void update(long address) { + super.update(address); + + long retrieverDefinition = readAtom(0x38); + this.id = API.readInt(retrieverDefinition, 0x20); // 1 to 18 + this.tier = API.readInt(retrieverDefinition, 0x24); // 1, 2, 3, 4, 5 or 6 + this.iconId = API.readString(retrieverDefinition, 0x30); // dispatch_retriever_r01 + this.name = API.readString(retrieverDefinition, 0x38); // R-01 + this.type = API.readString(retrieverDefinition, 0x40); // resource + this.descriptionId = API.readString(retrieverDefinition, 0x48); // dispatch_label_description_retriever_r01 + this.costList.update(API.readAtom(retrieverDefinition, 0x50)); + + this.instantCost.update(API.readAtom(retrieverDefinition, 0x58)); + } + @Override public void update() { if (address <= 0) return; @@ -49,17 +66,6 @@ public void update() { long dispatchModule = API.readAtom(address + 0x30); this.slotId = API.readInt(dispatchModule + 0x20); // 0 for available, 1 to 5 for in-progress this.duration = API.readDouble(dispatchModule + 0x28); // time left in seconds, or total time - - long retrieverDefinition = API.readAtom(address + 0x38); - this.id = API.readInt(retrieverDefinition + 0x20); // 1 to 18 - this.tier = API.readInt(retrieverDefinition + 0x24); // 1, 2, 3, 4, 5 or 6 - this.iconId = API.readString(retrieverDefinition, 0x30); // dispatch_retriever_r01 - this.name = API.readString(retrieverDefinition, 0x38); // R-01 - this.type = API.readString(retrieverDefinition, 0x40); // resource - this.descriptionId = API.readString(retrieverDefinition, 0x48); // dispatch_label_description_retriever_r01 - this.costList.update(API.readAtom(retrieverDefinition + 0x50)); - - this.instantCost.update(API.readAtom(retrieverDefinition + 0x58)); } } diff --git a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/SeassonPassMediator.java b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/SeassonPassMediator.java index b014a0026..bd3d07c04 100644 --- a/src/main/java/com/github/manolo8/darkbot/core/objects/facades/SeassonPassMediator.java +++ b/src/main/java/com/github/manolo8/darkbot/core/objects/facades/SeassonPassMediator.java @@ -56,7 +56,6 @@ public void update() { if (questDataAddr == 0) { return; } - dailyQuests.update(API.readAtom(questDataAddr + 0x60)); weeklyQuests.update(API.readAtom(questDataAddr + 0x68)); seassonQuests.update(API.readAtom(questDataAddr + 0x70)); diff --git a/src/main/java/com/github/manolo8/darkbot/core/objects/slotbars/Item.java b/src/main/java/com/github/manolo8/darkbot/core/objects/slotbars/Item.java index aeaedd470..c0c2ea21a 100644 --- a/src/main/java/com/github/manolo8/darkbot/core/objects/slotbars/Item.java +++ b/src/main/java/com/github/manolo8/darkbot/core/objects/slotbars/Item.java @@ -15,7 +15,7 @@ import static com.github.manolo8.darkbot.Main.API; -public class Item extends Updatable.Auto implements eu.darkbot.api.game.items.Item { +public class Item extends Updatable implements eu.darkbot.api.game.items.Item { private static final int START = 36, END = 128 + 8; private static final byte[] BUFFER = new byte[END - START]; @@ -53,6 +53,25 @@ private Set getShortcutSet(SlotBarsProxy.Type type) { return this.associatedSlots.computeIfAbsent(type, l -> new HashSet<>()); } + @Override + public void update(long address) { + super.update(address); + this.id = API.readString(address, 64); + this.counterType = API.readString(address, 72); + this.actionStyle = API.readString(address, 80); + this.iconLootId = API.readString(address, 96); + + if (itemCategory != null) { + this.selectableItem = SelectableItem.ALL_ITEMS.get(itemCategory).stream() + .filter(i -> i.getId().equals(id)) + .findFirst() + .orElse(null); + + if (selectableItem != null && itemsMap != null) + itemsMap.put(selectableItem, this); + } + } + // TODO: 28.08.2022 Sometimes, after reload *some* items are probably invalid? Why? @Override public void update() { @@ -74,27 +93,6 @@ public void update() { this.itemTimer.update(); } - @Override - public void update(long address) { - if (this.address != address) { - this.id = API.readString(address, 64); - this.counterType = API.readString(address, 72); - this.actionStyle = API.readString(address, 80); - this.iconLootId = API.readString(address, 96); - - if (itemCategory != null) { - this.selectableItem = SelectableItem.ALL_ITEMS.get(itemCategory).stream() - .filter(i -> i.getId().equals(id)) - .findFirst() - .orElse(null); - - if (selectableItem != null && itemsMap != null) - itemsMap.put(selectableItem, this); - } - } - super.update(address); - } - public boolean hasShortcut() { return getSlotBarType() != null; }