From 35c8ac02897b0d108d2e26ca6d9ca5db964519b2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 11 Jun 2024 12:53:07 -0400 Subject: [PATCH] Update to resources message --- src/engine/mbEnums.java | 56 ++++++++++--------- .../net/client/msg/ViewResourcesMsg.java | 4 +- src/engine/objects/Mine.java | 4 +- src/engine/objects/Warehouse.java | 6 +- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index e33df9ae..b662d1a2 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -2715,42 +2715,44 @@ public class mbEnums { public enum ResourceType { - GOLD(7, -1670881623, 100000000, 50000), - ADAMANT(1580003, 1557001525, 1000, 10), - AGATE(1580009, -1096157543, 2000, 20), - ANTIMONY(1580014, 1256147265, 1000, 10), - AZOTH(1580012, -1205326951, 2000, 20), - BLOODSTONE(1580020, -1912381716, 500, 5), - BRONZEWOOD(1580006, -519681813, 500, 10), - COAL(1580008, -1672872311, 3000, 30), - DIAMOND(1580010, 1540225085, 2000, 20), - GALVOR(1580017, -1683992404, 2000, 5), - IRON(1580002, -1673518119, 2000, 20), - LUMBER(1580004, 1628412684, 10000, 100), - MANDRAKE(1580007, 1519910613, 1000, 10), - MITHRIL(1580021, 626743397, 500, 5), - OAK(1580005, -1653034775, 3000, 30), - OBSIDIAN(1580019, 778019055, 500, 5), - ONYX(1580011, -1675952151, 1000, 10), - ORICHALK(1580013, -1468730955, 3000, 30), - QUICKSILVER(1580016, -2081208434, 1000, 10), - STONE(1580000, -1094703863, 10000, 100), - SULFUR(1580015, -1763687412, 1000, 10), - TRUESTEEL(1580001, -169012482, 2000, 20), - WORMWOOD(1580018, 1204785075, 500, 5); + GOLD(7, -1670881623, 2308551, 100000000, 50000), + ADAMANT(1580003, 1557001525, -1741189964, 1000, 10), + AGATE(1580009, -1096157543, 75173057, 2000, 20), + ANTIMONY(1580014, 1256147265, 452320058, 1000, 10), + AZOTH(1580012, -1205326951, 78329697, 2000, 20), + BLOODSTONE(1580020, -1912381716, -1569826353, 500, 5), + BRONZEWOOD(1580006, -519681813, 1334770447, 500, 10), + COAL(1580008, -1672872311, 2559427, 3000, 30), + DIAMOND(1580010, 1540225085, -1730704107, 2000, 20), + GALVOR(1580017, -1683992404, -1596311545, 2000, 5), + IRON(1580002, -1673518119, 2504297, 2000, 20), + LUMBER(1580004, 1628412684, -1603256692, 10000, 100), + MANDRAKE(1580007, 1519910613, 1191391799, 1000, 10), + MITHRIL(1580021, 626743397, -1761257186, 500, 5), + OAK(1580005, -1653034775, 74767, 3000, 30), + OBSIDIAN(1580019, 778019055, -697973233, 500, 5), + ONYX(1580011, -1675952151, 2977263, 1000, 10), + ORICHALK(1580013, -1468730955, -2036290524, 3000, 30), + QUICKSILVER(1580016, -2081208434, -472884509, 1000, 10), + STONE(1580000, -1094703863, 74856115, 10000, 100), + SULFUR(1580015, -1763687412, -1586349421, 1000, 10), + TRUESTEEL(1580001, -169012482, -317484979, 2000, 20), + WORMWOOD(1580018, 1204785075, 1532478436, 500, 5); public static HashMap templateLookup = new HashMap<>(); public static HashMap hashLookup = new HashMap<>(); public int templateID; public ItemTemplate template; - public int hash; + public int resourceHash; + public int templateHash; public int deposit_limit; public int mine_production; - ResourceType(int templateID, int hash, int deposit_limit, int mine_production) { + ResourceType(int templateID, int resourceHash, int templateHash, int deposit_limit, int mine_production) { this.templateID = templateID; this.template = ItemTemplate.templates.get(this.templateID); - this.hash = hash; + this.resourceHash = resourceHash; + this.templateHash = templateHash; this.deposit_limit = deposit_limit; this.mine_production = mine_production; } @@ -2759,7 +2761,7 @@ public class mbEnums { for (ResourceType resourceType : ResourceType.values()) { templateLookup.put(resourceType.templateID, resourceType); - hashLookup.put(resourceType.hash, resourceType); + hashLookup.put(resourceType.resourceHash, resourceType); } } diff --git a/src/engine/net/client/msg/ViewResourcesMsg.java b/src/engine/net/client/msg/ViewResourcesMsg.java index b3e5acff..39d6c6f1 100644 --- a/src/engine/net/client/msg/ViewResourcesMsg.java +++ b/src/engine/net/client/msg/ViewResourcesMsg.java @@ -93,7 +93,7 @@ public class ViewResourcesMsg extends ClientNetMsg { for (mbEnums.ResourceType resourceType : (warehouseObject.resources.keySet())) { - writer.putInt(resourceType.hash); + writer.putInt(resourceType.templateHash); writer.putInt((warehouseObject.resources.get(resourceType))); @@ -107,7 +107,7 @@ public class ViewResourcesMsg extends ClientNetMsg { for (mbEnums.ResourceType resourceType : warehouseObject.resources.keySet()) { - writer.putInt(resourceType.hash); + writer.putInt(resourceType.resourceHash); writer.putInt(0); //available? writer.putInt(resourceType.deposit_limit); //max? } diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index c157703a..dabfb557 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -166,7 +166,7 @@ public class Mine extends AbstractGameObject { writer.putInt(mine.getObjectUUID()); //actually a hash of mine writer.putString(mine.mineType.name); writer.putString(mine.zoneName); - writer.putInt(mine.production.hash); + writer.putInt(mine.production.resourceHash); writer.putInt(mine.production.mine_production); writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here writer.putInt(3600); //window in seconds @@ -393,7 +393,7 @@ public class Mine extends AbstractGameObject { // writer.putInt(0x215C92BB); //this.unknown1); writer.putString(this.mineType.name); writer.putString(this.zoneName); - writer.putInt(this.production.hash); + writer.putInt(this.production.resourceHash); writer.putInt(this.production.mine_production); writer.putInt(this.getModifiedProductionAmount()); //TODO calculate range penalty here writer.putInt(3600); //window in seconds diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 8041a689..fada5d47 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -381,7 +381,7 @@ public class Warehouse { int amount = (int) (warehouse.resources.get(resourceType) * taxPercent); if (amount <= 0) { - msg.getResources().put(resourceType.hash, 0); + msg.getResources().put(resourceType.resourceHash, 0); continue; } @@ -395,10 +395,10 @@ public class Warehouse { if (newAmount < amount) continue; - msg.getResources().put(resourceType.hash, amount); + msg.getResources().put(resourceType.resourceHash, amount); if (!DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse)) { - msg.getResources().put(resourceType.hash, 0); + msg.getResources().put(resourceType.resourceHash, 0); warehouse.resources.put(resourceType, oldAmount); continue; }