Browse Source

Removed ordering junk

combat-2
MagicBot 8 months ago
parent
commit
5c731894b1
  1. 65
      src/engine/objects/CharacterItemManager.java
  2. 7
      src/engine/objects/PlayerCharacter.java

65
src/engine/objects/CharacterItemManager.java

@ -47,7 +47,6 @@ public class CharacterItemManager {
private final HashSet<Item> inventory = new HashSet<>(); private final HashSet<Item> inventory = new HashSet<>();
private final HashSet<Item> bank = new HashSet<>(); private final HashSet<Item> bank = new HashSet<>();
private final HashSet<Item> vault = new HashSet<>(); private final HashSet<Item> vault = new HashSet<>();
private final HashSet<Enum.EquipSlotType> equipOrder = new HashSet<>();
public Item goldVault; public Item goldVault;
private Account account; private Account account;
private Item goldInventory; private Item goldInventory;
@ -182,10 +181,8 @@ public class CharacterItemManager {
switch (i.containerType) { switch (i.containerType) {
case EQUIPPED: case EQUIPPED:
if (this.equipped.containsValue(i) == false) { if (this.equipped.containsValue(i) == false)
this.equipped.put(i.equipSlot, i); this.equipped.put(i.equipSlot, i);
addEquipOrder(i.equipSlot);
}
break; break;
case BANK: case BANK:
if (i.template.item_type.equals(ItemType.GOLD)) if (i.template.item_type.equals(ItemType.GOLD))
@ -875,14 +872,6 @@ public class CharacterItemManager {
return this.goldVault; return this.goldVault;
} }
public void addEquipOrder(Enum.EquipSlotType slot) {
synchronized (this.equipOrder) {
if (this.equipOrder.contains(slot))
this.equipOrder.remove(slot);
this.equipOrder.add(slot);
}
}
public synchronized boolean doesCharOwnThisItem(int itemID) { public synchronized boolean doesCharOwnThisItem(int itemID) {
return this.itemIDtoType.containsKey(itemID); return this.itemIDtoType.containsKey(itemID);
} }
@ -1311,8 +1300,6 @@ public class CharacterItemManager {
i.addToCache(); i.addToCache();
addEquipOrder(slot);
//calculateWeights(); //calculateWeights();
} }
@ -1622,7 +1609,7 @@ public class CharacterItemManager {
// make sure current player has item in inventory // make sure current player has item in inventory
if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob))) if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
return null; return null;
else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD)) else if (!this.inventory.contains(lootItem) && !this.equipped.containsValue(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD))
return null; return null;
// get weight of item // get weight of item
@ -1882,27 +1869,6 @@ public class CharacterItemManager {
} }
} }
public ArrayList<Item> getEquippedList() {
ArrayList<Item> ret = new ArrayList<>();
synchronized (this.equipOrder) {
synchronized (this.equipped) {
for (Enum.EquipSlotType slot : this.equipOrder) {
if (this.equipped.containsKey(slot))
ret.add(this.equipped.get(slot));
}
if (ret.size() != this.equipped.size())
//missed adding some items, figure out what.
for (Enum.EquipSlotType slot : this.equipped.keySet()) {
if (!(this.equipOrder.contains(slot))) {
this.equipOrder.add(slot);
ret.add(this.equipped.get(slot));
}
}
}
}
return ret;
}
public Item getEquipped(Enum.EquipSlotType slot) { public Item getEquipped(Enum.EquipSlotType slot) {
synchronized (this.equipped) { synchronized (this.equipped) {
return this.equipped.get(slot); return this.equipped.get(slot);
@ -2547,33 +2513,8 @@ public class CharacterItemManager {
public synchronized void clearEquip() { public synchronized void clearEquip() {
ArrayList<Item> equipCopy = new ArrayList<>(this.getEquippedList()); this.equipped.clear();
Iterator<Item> ii = equipCopy.iterator();
while (ii.hasNext()) {
Item itm = ii.next();
this.getEquippedList().remove(itm);
this.delete(itm);
}
}
public byte getEquipVer() {
return this.equipVer;
}
public void incEquipVer() {
this.equipVer++;
}
public void incInventoryVer() {
this.equipVer++;
}
public void incBankVer() {
this.equipVer++;
}
public void incVaultVer() {
this.equipVer++;
} }
public int getTradeID() { public int getTradeID() {

7
src/engine/objects/PlayerCharacter.java

@ -448,11 +448,8 @@ public class PlayerCharacter extends AbstractCharacter {
} else } else
writer.putInt(0); writer.putInt(0);
writer.putInt(playerCharacter.charItemManager.equipped.size());
ArrayList<Item> equipped = playerCharacter.charItemManager.getEquippedList(); for (Item item : playerCharacter.charItemManager.equipped.values()) {
writer.putInt(equipped.size());
for (Item item : equipped) {
Item._serializeForClientMsg(item, writer); Item._serializeForClientMsg(item, writer);
} }
writer.putInt(playerCharacter.getRank()); writer.putInt(playerCharacter.getRank());

Loading…
Cancel
Save