From e5622a47c016bdccfb8aab11c5a917c93ed2453b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Mar 2024 08:26:08 -0400 Subject: [PATCH] Inline templateID --- src/engine/db/handlers/dbItemHandler.java | 2 +- src/engine/devcmd/cmds/InfoCmd.java | 2 +- src/engine/devcmd/cmds/PrintBankCmd.java | 2 +- src/engine/devcmd/cmds/PrintBonusesCmd.java | 2 +- src/engine/devcmd/cmds/PrintVaultCmd.java | 2 +- src/engine/gameManager/ChatManager.java | 2 +- src/engine/gameManager/LootManager.java | 8 ++++---- src/engine/net/client/msg/ItemProductionMsg.java | 4 ++-- src/engine/net/client/msg/ManageNPCMsg.java | 4 ++-- src/engine/objects/Item.java | 4 ---- src/engine/objects/ItemFactory.java | 16 ++++++++-------- src/engine/objects/Warehouse.java | 2 +- 12 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 117b3602..2608ad98 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -62,7 +62,7 @@ public class dbItemHandler extends dbHandlerBase { PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?,?);")) { preparedStatement.setInt(1, toAdd.ownerID); - preparedStatement.setInt(2, toAdd.getTemplateID()); + preparedStatement.setInt(2, toAdd.templateID); preparedStatement.setInt(3, (byte) toAdd.chargesRemaining); preparedStatement.setInt(4, (short) toAdd.combat_health_current); diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 07fce9bd..a8bd662c 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -505,7 +505,7 @@ public class InfoCmd extends AbstractDevCmd { case Item: //intentional passthrough case MobLoot: Item item = (Item) target; - ItemTemplate template = ItemTemplate.templates.get(item.getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(item.templateID); output += StringUtils.addWS("Template: " + template.template_id, 20); output += "Weight: " + template.item_wt; output += newline; diff --git a/src/engine/devcmd/cmds/PrintBankCmd.java b/src/engine/devcmd/cmds/PrintBankCmd.java index fa62bbdb..9ff1dd5b 100644 --- a/src/engine/devcmd/cmds/PrintBankCmd.java +++ b/src/engine/devcmd/cmds/PrintBankCmd.java @@ -52,7 +52,7 @@ public class PrintBankCmd extends AbstractDevCmd { throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); for (Item item : list) { - ItemTemplate template = ItemTemplate.templates.get(item.getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(item.templateID); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems()); } diff --git a/src/engine/devcmd/cmds/PrintBonusesCmd.java b/src/engine/devcmd/cmds/PrintBonusesCmd.java index 99338f8c..bb1015e1 100644 --- a/src/engine/devcmd/cmds/PrintBonusesCmd.java +++ b/src/engine/devcmd/cmds/PrintBonusesCmd.java @@ -33,7 +33,7 @@ public class PrintBonusesCmd extends AbstractDevCmd { if (target instanceof Item) { type = "Item"; tar = (Item) target; - ItemTemplate template = ItemTemplate.templates.get(((Item) tar).getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(((Item) tar).templateID); name = template.item_base_name; } else if (target instanceof AbstractCharacter) { tar = (AbstractCharacter) target; diff --git a/src/engine/devcmd/cmds/PrintVaultCmd.java b/src/engine/devcmd/cmds/PrintVaultCmd.java index 12b66d57..dce217af 100644 --- a/src/engine/devcmd/cmds/PrintVaultCmd.java +++ b/src/engine/devcmd/cmds/PrintVaultCmd.java @@ -50,7 +50,7 @@ public class PrintVaultCmd extends AbstractDevCmd { ArrayList list = cim.getVault(); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); for (Item item : list) { - ItemTemplate template = ItemTemplate.templates.get(item.getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(item.templateID); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems()); } Item gold = cim.getGoldVault(); diff --git a/src/engine/gameManager/ChatManager.java b/src/engine/gameManager/ChatManager.java index 789ae998..a94ae0f7 100644 --- a/src/engine/gameManager/ChatManager.java +++ b/src/engine/gameManager/ChatManager.java @@ -540,7 +540,7 @@ public enum ChatManager { name = amount + " gold "; else { String vowels = "aeiou"; - ItemTemplate template = ItemTemplate.templates.get(item.getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(item.templateID); String iName = template.item_base_name; if (iName.length() > 0) if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index e1dd2a49..564112e2 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -87,9 +87,9 @@ public enum LootManager { if (ib == null) break; - ItemTemplate template = ItemTemplate.templates.get(it.getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(it.templateID); - if ((it.getTemplateID() > 2499 && it.templateID <= 3050) || template.item_base_name.toLowerCase().contains("of the gods")) { + if ((it.templateID > 2499 && it.templateID <= 3050) || template.item_base_name.toLowerCase().contains("of the gods")) { ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?"); chatMsg.setMessageType(10); chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); @@ -381,8 +381,8 @@ public enum LootManager { int tableID = 0; - if (_bootySetMap.get(gift.getTemplateID()) != null) - tableID = _bootySetMap.get(gift.getTemplateID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplateID()).size())).genTable; + if (_bootySetMap.get(gift.templateID) != null) + tableID = _bootySetMap.get(gift.templateID).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.templateID).size())).genTable; if (tableID == 0) return; diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index c54e5f01..dd792e37 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -284,7 +284,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); //items left to produce? if (toRoll != null) { - writer.putInt(toRoll.getTemplateID()); + writer.putInt(toRoll.templateID); writer.putInt(toRoll.getValue()); } else { writer.putInt(0); @@ -301,7 +301,7 @@ public class ItemProductionMsg extends ClientNetMsg { timeLeft /= 1000; writer.putInt((int) timeLeft); - writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplateID())); + writer.putInt(vendor.getRollingTimeInSeconds(toRoll.templateID)); } } else { diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 7d564759..733d3f0b 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -447,14 +447,14 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(item.getObjectUUID()); writer.putInt(0); - writer.putInt(item.getTemplateID()); + writer.putInt(item.templateID); writer.putInt(item.template.item_value); long timeLife = item.getDateToUpgrade() - System.currentTimeMillis(); timeLife /= 1000; writer.putInt((int) timeLife); - writer.putInt(npc.getRollingTimeInSeconds(item.getTemplateID())); + writer.putInt(npc.getRollingTimeInSeconds(item.templateID)); writer.putInt(1); if (item.isComplete()) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 8b3c3e12..e22dd0d2 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -656,10 +656,6 @@ public class Item extends AbstractWorldObject { return 0; } - public int getTemplateID() { - return this.templateID; - } - public int getOwnerID() { return ownerID; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index bb65abb3..59094f12 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -180,7 +180,7 @@ public class ItemFactory { time *= MBServerStatics.ONE_MINUTE; if (ml.templateID > 910010 && ml.templateID < 910019) { - rank = ml.getTemplateID() - 910010; + rank = ml.templateID - 910010; time = rank * 60 * 60 * 3 * 1000; } @@ -201,8 +201,8 @@ public class ItemFactory { if (pc != null) playerID = pc.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, "", "", "", false, playerID); - ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, "", "", "", playerID); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, "", "", "", false, playerID); + ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, false, "", "", "", playerID); pi.setProducedItemID(ml.getObjectUUID()); pi.setAmount(itemsToRoll); pi.setRandom(false); @@ -589,7 +589,7 @@ public class ItemFactory { time *= MBServerStatics.ONE_MINUTE; if (ml.templateID > 910010 && ml.templateID < 910019) { - rank = ml.getTemplateID() - 910010; + rank = ml.templateID - 910010; time = rank * 60 * 60 * 3 * 1000; } @@ -610,8 +610,8 @@ public class ItemFactory { if (pc != null) playerID = pc.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.name, false, playerID); - ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.name, playerID); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, prefixString, suffixString, ml.name, false, playerID); + ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.templateID, dateTime, false, prefixString, suffixString, ml.name, playerID); pi.setProducedItemID(ml.getObjectUUID()); pi.setAmount(itemsToRoll); @@ -749,9 +749,9 @@ public class ItemFactory { if (playerCharacter != null) playerID = playerCharacter.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, prefix, suffix, toRoll.name, true, playerID); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.templateID, dateTime, prefix, suffix, toRoll.name, true, playerID); - ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, true, prefix, suffix, toRoll.name, playerID); + ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.templateID, dateTime, true, prefix, suffix, toRoll.name, playerID); pi.setProducedItemID(toRoll.getObjectUUID()); pi.setAmount(itemsToRoll); ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 0f741752..d0855254 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -316,7 +316,7 @@ public class Warehouse { if (resource.template.item_type.equals(Enum.ItemType.GOLD)) resourceType = Enum.ResourceType.GOLD; else - resourceType = Enum.ResourceType.valueOf(ItemTemplate.templates.get(resource.getTemplateID()).item_base_name.toUpperCase()); + resourceType = Enum.ResourceType.valueOf(ItemTemplate.templates.get(resource.templateID).item_base_name.toUpperCase()); if (transaction) AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);