From 2d382fad9136e3cc329cb5c5b0c908b91df713e2 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 25 Jun 2016 12:24:23 +0000 Subject: [PATCH] ItemTable slot variable refactor, plus other minor code changes. --- .../handlers/effecthandlers/Disarmor.java | 2 +- .../data/xml/impl/AppearanceItemData.java | 2 +- .../data/xml/impl/EnchantItemGroupsData.java | 2 +- .../gameserver/datatables/ItemTable.java | 85 +++++++++---------- .../gameserver/engines/DocumentBase.java | 4 +- .../model/itemcontainer/Inventory.java | 11 +-- .../gameserver/model/items/L2Item.java | 2 +- .../items/appearance/AppearanceStone.java | 2 +- .../l2jmobius/gameserver/network/Debug.java | 2 +- .../network/serverpackets/UserInfo.java | 11 ++- 10 files changed, 60 insertions(+), 63 deletions(-) diff --git a/trunk/dist/game/data/scripts/handlers/effecthandlers/Disarmor.java b/trunk/dist/game/data/scripts/handlers/effecthandlers/Disarmor.java index 35fe97f079..9d06ee3437 100644 --- a/trunk/dist/game/data/scripts/handlers/effecthandlers/Disarmor.java +++ b/trunk/dist/game/data/scripts/handlers/effecthandlers/Disarmor.java @@ -46,7 +46,7 @@ public final class Disarmor extends AbstractEffect _unequippedItems = new ConcurrentHashMap<>(); final String slot = params.getString("slot", "chest"); - _slot = ItemTable._slots.getOrDefault(slot, L2Item.SLOT_NONE); + _slot = ItemTable.SLOTS.getOrDefault(slot, L2Item.SLOT_NONE); if (_slot == L2Item.SLOT_NONE) { _log.severe("Unknown bodypart slot for effect: " + slot); diff --git a/trunk/java/com/l2jmobius/gameserver/data/xml/impl/AppearanceItemData.java b/trunk/java/com/l2jmobius/gameserver/data/xml/impl/AppearanceItemData.java index 865d3675ba..f0a0535f59 100644 --- a/trunk/java/com/l2jmobius/gameserver/data/xml/impl/AppearanceItemData.java +++ b/trunk/java/com/l2jmobius/gameserver/data/xml/impl/AppearanceItemData.java @@ -113,7 +113,7 @@ public class AppearanceItemData implements IGameXmlReader } case "bodyPart": { - final int part = ItemTable._slots.get(c.getTextContent()); + final int part = ItemTable.SLOTS.get(c.getTextContent()); stone.addBodyPart(part); break; } diff --git a/trunk/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java b/trunk/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java index 41ca1f8cf3..6075541412 100644 --- a/trunk/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java +++ b/trunk/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java @@ -118,7 +118,7 @@ public final class EnchantItemGroupsData implements IGameXmlReader final NamedNodeMap attrs = z.getAttributes(); if (attrs.getNamedItem("slot") != null) { - rateGroup.addSlot(ItemTable._slots.get(parseString(attrs, "slot"))); + rateGroup.addSlot(ItemTable.SLOTS.get(parseString(attrs, "slot"))); } if (attrs.getNamedItem("magicWeapon") != null) { diff --git a/trunk/java/com/l2jmobius/gameserver/datatables/ItemTable.java b/trunk/java/com/l2jmobius/gameserver/datatables/ItemTable.java index 47d3a93991..f506bb6e4f 100644 --- a/trunk/java/com/l2jmobius/gameserver/datatables/ItemTable.java +++ b/trunk/java/com/l2jmobius/gameserver/datatables/ItemTable.java @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.logging.Level; import java.util.logging.Logger; @@ -58,53 +57,52 @@ public class ItemTable private static Logger LOGGER = Logger.getLogger(ItemTable.class.getName()); private static Logger LOGGER_ITEMS = Logger.getLogger("item"); - public static final Map _slots = new HashMap<>(); + public static final Map SLOTS = new HashMap<>(); private L2Item[] _allTemplates; - private final Map _etcItems; - private final Map _armors; - private final Map _weapons; - + private final Map _etcItems = new HashMap<>(); + private final Map _armors = new HashMap<>(); + private final Map _weapons = new HashMap<>(); static { - _slots.put("shirt", L2Item.SLOT_UNDERWEAR); - _slots.put("lbracelet", L2Item.SLOT_L_BRACELET); - _slots.put("rbracelet", L2Item.SLOT_R_BRACELET); - _slots.put("talisman", L2Item.SLOT_DECO); - _slots.put("chest", L2Item.SLOT_CHEST); - _slots.put("fullarmor", L2Item.SLOT_FULL_ARMOR); - _slots.put("head", L2Item.SLOT_HEAD); - _slots.put("hair", L2Item.SLOT_HAIR); - _slots.put("hairall", L2Item.SLOT_HAIRALL); - _slots.put("underwear", L2Item.SLOT_UNDERWEAR); - _slots.put("back", L2Item.SLOT_BACK); - _slots.put("neck", L2Item.SLOT_NECK); - _slots.put("legs", L2Item.SLOT_LEGS); - _slots.put("feet", L2Item.SLOT_FEET); - _slots.put("gloves", L2Item.SLOT_GLOVES); - _slots.put("chest,legs", L2Item.SLOT_CHEST | L2Item.SLOT_LEGS); - _slots.put("belt", L2Item.SLOT_BELT); - _slots.put("rhand", L2Item.SLOT_R_HAND); - _slots.put("lhand", L2Item.SLOT_L_HAND); - _slots.put("lrhand", L2Item.SLOT_LR_HAND); - _slots.put("rear;lear", L2Item.SLOT_R_EAR | L2Item.SLOT_L_EAR); - _slots.put("rfinger;lfinger", L2Item.SLOT_R_FINGER | L2Item.SLOT_L_FINGER); - _slots.put("wolf", L2Item.SLOT_WOLF); - _slots.put("greatwolf", L2Item.SLOT_GREATWOLF); - _slots.put("hatchling", L2Item.SLOT_HATCHLING); - _slots.put("strider", L2Item.SLOT_STRIDER); - _slots.put("babypet", L2Item.SLOT_BABYPET); - _slots.put("brooch", L2Item.SLOT_BROOCH); - _slots.put("brooch_jewel", L2Item.SLOT_BROOCH_JEWEL); - _slots.put("none", L2Item.SLOT_NONE); + SLOTS.put("shirt", L2Item.SLOT_UNDERWEAR); + SLOTS.put("lbracelet", L2Item.SLOT_L_BRACELET); + SLOTS.put("rbracelet", L2Item.SLOT_R_BRACELET); + SLOTS.put("talisman", L2Item.SLOT_DECO); + SLOTS.put("chest", L2Item.SLOT_CHEST); + SLOTS.put("fullarmor", L2Item.SLOT_FULL_ARMOR); + SLOTS.put("head", L2Item.SLOT_HEAD); + SLOTS.put("hair", L2Item.SLOT_HAIR); + SLOTS.put("hairall", L2Item.SLOT_HAIRALL); + SLOTS.put("underwear", L2Item.SLOT_UNDERWEAR); + SLOTS.put("back", L2Item.SLOT_BACK); + SLOTS.put("neck", L2Item.SLOT_NECK); + SLOTS.put("legs", L2Item.SLOT_LEGS); + SLOTS.put("feet", L2Item.SLOT_FEET); + SLOTS.put("gloves", L2Item.SLOT_GLOVES); + SLOTS.put("chest,legs", L2Item.SLOT_CHEST | L2Item.SLOT_LEGS); + SLOTS.put("belt", L2Item.SLOT_BELT); + SLOTS.put("rhand", L2Item.SLOT_R_HAND); + SLOTS.put("lhand", L2Item.SLOT_L_HAND); + SLOTS.put("lrhand", L2Item.SLOT_LR_HAND); + SLOTS.put("rear;lear", L2Item.SLOT_R_EAR | L2Item.SLOT_L_EAR); + SLOTS.put("rfinger;lfinger", L2Item.SLOT_R_FINGER | L2Item.SLOT_L_FINGER); + SLOTS.put("wolf", L2Item.SLOT_WOLF); + SLOTS.put("greatwolf", L2Item.SLOT_GREATWOLF); + SLOTS.put("hatchling", L2Item.SLOT_HATCHLING); + SLOTS.put("strider", L2Item.SLOT_STRIDER); + SLOTS.put("babypet", L2Item.SLOT_BABYPET); + SLOTS.put("brooch", L2Item.SLOT_BROOCH); + SLOTS.put("brooch_jewel", L2Item.SLOT_BROOCH_JEWEL); + SLOTS.put("none", L2Item.SLOT_NONE); // retail compatibility - _slots.put("onepiece", L2Item.SLOT_FULL_ARMOR); - _slots.put("hair2", L2Item.SLOT_HAIR2); - _slots.put("dhair", L2Item.SLOT_HAIRALL); - _slots.put("alldress", L2Item.SLOT_ALLDRESS); - _slots.put("deco1", L2Item.SLOT_DECO); - _slots.put("waist", L2Item.SLOT_BELT); + SLOTS.put("onepiece", L2Item.SLOT_FULL_ARMOR); + SLOTS.put("hair2", L2Item.SLOT_HAIR2); + SLOTS.put("dhair", L2Item.SLOT_HAIRALL); + SLOTS.put("alldress", L2Item.SLOT_ALLDRESS); + SLOTS.put("deco1", L2Item.SLOT_DECO); + SLOTS.put("waist", L2Item.SLOT_BELT); } /** @@ -117,9 +115,6 @@ public class ItemTable protected ItemTable() { - _etcItems = new ConcurrentHashMap<>(); - _armors = new ConcurrentHashMap<>(); - _weapons = new ConcurrentHashMap<>(); load(); } diff --git a/trunk/java/com/l2jmobius/gameserver/engines/DocumentBase.java b/trunk/java/com/l2jmobius/gameserver/engines/DocumentBase.java index da6ebac300..a58df9dbe8 100644 --- a/trunk/java/com/l2jmobius/gameserver/engines/DocumentBase.java +++ b/trunk/java/com/l2jmobius/gameserver/engines/DocumentBase.java @@ -1151,9 +1151,9 @@ public abstract class DocumentBase { final int old = mask; final String item = st.nextToken().trim(); - if (ItemTable._slots.containsKey(item)) + if (ItemTable.SLOTS.containsKey(item)) { - mask |= ItemTable._slots.get(item); + mask |= ItemTable.SLOTS.get(item); } if (old == mask) diff --git a/trunk/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/trunk/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java index d1c64d2af2..7b7b6db643 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/trunk/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -1727,14 +1727,11 @@ public abstract class Inventory extends ItemContainer // find same (or incompatible) brooch jewel type for (int i = PAPERDOLL_BROOCH_JEWEL1; i < (PAPERDOLL_BROOCH_JEWEL1 + getBroochJewelSlots()); i++) { - if (_paperdoll[i] != null) + if ((_paperdoll[i] != null) && (getPaperdollItemId(i) == item.getId())) { - if (getPaperdollItemId(i) == item.getId()) - { - // overwtite - setPaperdollItem(i, item); - return; - } + // overwtite + setPaperdollItem(i, item); + return; } } diff --git a/trunk/java/com/l2jmobius/gameserver/model/items/L2Item.java b/trunk/java/com/l2jmobius/gameserver/model/items/L2Item.java index 92b8d91cb9..2277b05ee1 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/items/L2Item.java +++ b/trunk/java/com/l2jmobius/gameserver/model/items/L2Item.java @@ -199,7 +199,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable _duration = set.getInt("duration", -1); _time = set.getInt("time", -1); _autoDestroyTime = set.getInt("auto_destroy_time", -1) * 1000; - _bodyPart = ItemTable._slots.get(set.getString("bodypart", "none")); + _bodyPart = ItemTable.SLOTS.get(set.getString("bodypart", "none")); _referencePrice = set.getInt("price", 0); _crystalType = set.getEnum("crystal_type", CrystalType.class, CrystalType.NONE); _crystalCount = set.getInt("crystal_count", 0); diff --git a/trunk/java/com/l2jmobius/gameserver/model/items/appearance/AppearanceStone.java b/trunk/java/com/l2jmobius/gameserver/model/items/appearance/AppearanceStone.java index e7bff5f2f4..c4610960aa 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/items/appearance/AppearanceStone.java +++ b/trunk/java/com/l2jmobius/gameserver/model/items/appearance/AppearanceStone.java @@ -84,7 +84,7 @@ public class AppearanceStone addTargetType(targetType); } - final int bodyPart = ItemTable._slots.get(set.getString("bodyPart", "none")); + final int bodyPart = ItemTable.SLOTS.get(set.getString("bodyPart", "none")); if (bodyPart != L2Item.SLOT_NONE) { addBodyPart(bodyPart); diff --git a/trunk/java/com/l2jmobius/gameserver/network/Debug.java b/trunk/java/com/l2jmobius/gameserver/network/Debug.java index 6ae84774b3..ae80603903 100644 --- a/trunk/java/com/l2jmobius/gameserver/network/Debug.java +++ b/trunk/java/com/l2jmobius/gameserver/network/Debug.java @@ -138,7 +138,7 @@ public class Debug private static String getBodyPart(int bodyPart) { - for (Entry entry : ItemTable._slots.entrySet()) + for (Entry entry : ItemTable.SLOTS.entrySet()) { if ((entry.getValue() & bodyPart) == bodyPart) { diff --git a/trunk/java/com/l2jmobius/gameserver/network/serverpackets/UserInfo.java b/trunk/java/com/l2jmobius/gameserver/network/serverpackets/UserInfo.java index 7c33257633..275d949b36 100644 --- a/trunk/java/com/l2jmobius/gameserver/network/serverpackets/UserInfo.java +++ b/trunk/java/com/l2jmobius/gameserver/network/serverpackets/UserInfo.java @@ -21,6 +21,7 @@ import com.l2jmobius.commons.network.PacketWriter; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.enums.AttributeType; import com.l2jmobius.gameserver.enums.UserInfoType; +import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager; import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Party; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; @@ -325,7 +326,10 @@ public class UserInfo extends AbstractMaskPacket packet.writeC(_activeChar.getInventory().getTalismanSlots()); // Confirmed packet.writeC(_activeChar.getInventory().getBroochJewelSlots()); // Confirmed packet.writeC(_activeChar.getTeam().getId()); // Confirmed - packet.writeD(0x00); // (1 = Red, 2 = White, 3 = White Pink, there is higher values (23, 50, 100 produces different aura) dotted / straight circle ring on the floor + packet.writeC(0x00); // (1 = Red, 2 = White, 3 = White Pink) dotted ring on the floor + packet.writeC(0x00); + packet.writeC(0x00); + packet.writeC(0x00); } if (containsMask(UserInfoType.MOVEMENTS)) @@ -345,9 +349,10 @@ public class UserInfo extends AbstractMaskPacket if (containsMask(UserInfoType.INVENTORY_LIMIT)) { packet.writeH(9); - packet.writeD(0x00); + packet.writeH(0x00); + packet.writeH(0x00); packet.writeH(_activeChar.getInventoryLimit()); - packet.writeC(0x00); // if greater than 1 show the attack cursor when interacting, CoC or Cursed Weapon level ? + packet.writeC(_activeChar.isCursedWeaponEquipped() ? CursedWeaponsManager.getInstance().getLevel(_activeChar.getCursedWeaponEquippedId()) : 0); } if (containsMask(UserInfoType.UNK_3))