diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 55d1c5fc..1735a306 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -64,7 +64,7 @@ public class dbItemHandler extends dbHandlerBase { preparedStatement.setInt(2, toAdd.getTemplsteID()); preparedStatement.setInt(3, (byte) toAdd.chargesRemaining); preparedStatement.setInt(4, (short) toAdd.durabilityCurrent); - preparedStatement.setInt(5, toAdd.getDurabilityMax()); + preparedStatement.setInt(5, (int) toAdd.template.item_health_full); if (toAdd.getNumOfItems() < 1) preparedStatement.setInt(6, 1); diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 45a8baa0..956ee270 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -514,7 +514,7 @@ public class InfoCmd extends AbstractDevCmd { output += StringUtils.addWS("Qty: " + df.format(item.getNumOfItems()), 20); output += "Charges: " + (byte) item.chargesRemaining - + '/' + item.getChargesMax(); + + '/' + item.template.item_initial_charges; output += newline; output += "Name: " + template.item_base_name; output += newline; diff --git a/src/engine/devcmd/cmds/PrintInventoryCmd.java b/src/engine/devcmd/cmds/PrintInventoryCmd.java index f3dbbd8e..28d58568 100644 --- a/src/engine/devcmd/cmds/PrintInventoryCmd.java +++ b/src/engine/devcmd/cmds/PrintInventoryCmd.java @@ -75,14 +75,17 @@ public class PrintInventoryCmd extends AbstractDevCmd { int goldCount = 0; for (Item item : inventory) { - if (item.getItemBase().getType().equals(ItemType.GOLD) == false) { + ItemTemplate template = ItemTemplate.itemTemplates.get(item.templsteID); + + if (item.template.item_type.equals(ItemType.GOLD) == false) { + String chargeInfo = ""; - byte chargeMax = item.getChargesMax(); + int chargeMax = template.item_initial_charges; + if (chargeMax > 0) { - byte charges = (byte) item.chargesRemaining; + int charges = item.chargesRemaining; chargeInfo = " charges: " + charges + '/' + chargeMax; } - ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems() + chargeInfo); } else goldCount += item.getNumOfItems(); diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 89170e62..c672b319 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1246,7 +1246,7 @@ public class ClientMessagePump implements NetMsgHandler { //apply damaged value reduction float durabilityCurrent = (short) sell.durabilityCurrent; - float durabilityMax = sell.getDurabilityMax(); + float durabilityMax = sell.template.item_health_full; float damagedModifier = durabilityCurrent / durabilityMax; cost *= damagedModifier; float bargain = player.getBargain(); @@ -1640,7 +1640,8 @@ public class ClientMessagePump implements NetMsgHandler { //make sure item is damaged and not destroyed short dur = (short) toRepair.durabilityCurrent; - short max = toRepair.getDurabilityMax(); + short max = (short) toRepair.template.item_health_full; + //account for durability modifications float durMod = toRepair.getBonusPercent(ModType.Durability, SourceType.NONE); max *= (1 + (durMod * 0.01f)); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 483afd9c..017db1be 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -2444,13 +2444,14 @@ public class CharacterItemManager { return; //don't damage noob gear, hair or beards. - if (item.getDurabilityMax() == 0) + if (item.template.item_health_full == 0) return; if (!item.isCanDestroy()) return; int dur = (int) (short) item.durabilityCurrent; + if (dur - amount <= 0) { //destroy the item junk(item); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index baa43c1d..a5203dba 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -39,8 +39,6 @@ import java.util.concurrent.locks.ReentrantLock; public class Item extends AbstractWorldObject { private static ConcurrentHashMap enchantValues = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private short durabilityMax; - private byte chargesMax; private final ConcurrentHashMap bonuses = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final ArrayList effectNames = new ArrayList<>(); public Enum.ItemContainerType containerType; @@ -87,7 +85,11 @@ public class Item extends AbstractWorldObject { super(rs); this.templsteID = rs.getInt("item_itemBaseID"); + this.template = ItemTemplate.itemTemplates.get(this.templsteID); + if (this.template == null) + Logger.error("Null template of " + this.templsteID) + ; // Set container enumeration String container = rs.getString("item_container"); @@ -115,15 +117,9 @@ public class Item extends AbstractWorldObject { this.ownerID = rs.getInt("parent"); - if (this.getItemBase() != null) - this.chargesMax = (byte) this.getItemBase().getNumCharges(); - else - this.chargesMax = 0; - this.chargesRemaining = rs.getByte("item_chargesRemaining"); this.durabilityCurrent = rs.getShort("item_durabilityCurrent"); - this.durabilityMax = rs.getShort("item_durabilityMax"); DbObjectType ownerType; ownerType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerID); @@ -221,7 +217,7 @@ public class Item extends AbstractWorldObject { writer.putString(item.customName); // Unknown. pad? writer.put((byte) 1); // End Datablock byte - writer.putFloat((float) item.durabilityMax); + writer.putFloat(item.template.item_health_full); writer.putFloat((float) item.durabilityCurrent); writer.put((byte) 1); // End Datablock byte @@ -708,18 +704,10 @@ public class Item extends AbstractWorldObject { return true; } - public byte getChargesMax() { - return chargesMax; - } - public void setDurabilityCurrent(float value) { this.durabilityCurrent = value; } - public short getDurabilityMax() { - return durabilityMax; - } - public boolean isCanDestroy() { return canDestroy; }