forked from MagicBane/Server
More ordinal refactor
This commit is contained in:
@@ -1750,7 +1750,7 @@ public class CharacterItemManager {
|
||||
return equipped.containsValue(i);
|
||||
}
|
||||
|
||||
public synchronized Item getItemFromEquipped(int slot) {
|
||||
public synchronized Item getItemFromEquipped(Enum.EquipSlotType slot) {
|
||||
return equipped.get(slot);
|
||||
}
|
||||
|
||||
@@ -1865,7 +1865,7 @@ public class CharacterItemManager {
|
||||
}
|
||||
|
||||
if (!ItemTemplate.validForSkills(item, pc.getSkills())) {
|
||||
this.forceToInventory(slot.ordinal(), item, pc, initialized);
|
||||
this.forceToInventory(slot, item, pc, initialized);
|
||||
pc.applyBonuses();
|
||||
}
|
||||
}
|
||||
@@ -2266,13 +2266,13 @@ public class CharacterItemManager {
|
||||
|
||||
}
|
||||
|
||||
public void forceToInventory(int slot, Item item, PlayerCharacter pc, boolean initialized) {
|
||||
if (item == null || pc == null)
|
||||
public void forceToInventory(Enum.EquipSlotType slot, Item item, PlayerCharacter player, boolean initialized) {
|
||||
|
||||
if (item == null || player == null)
|
||||
return;
|
||||
|
||||
if (!item.moveItemToInventory(pc)) {
|
||||
//TODO well why did this fail? clean it up
|
||||
}
|
||||
if (!item.moveItemToInventory(player))
|
||||
Logger.error("templateL " + item.template.template_id);
|
||||
|
||||
// remove it from other lists:
|
||||
this.remItemFromLists(item);
|
||||
@@ -2284,9 +2284,10 @@ public class CharacterItemManager {
|
||||
calculateWeights();
|
||||
|
||||
//Update players with unequipped item
|
||||
|
||||
if (initialized) {
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(pc, slot);
|
||||
DispatchMessage.dispatchMsgToInterestArea(pc, back, engine.Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(player, slot);
|
||||
DispatchMessage.dispatchMsgToInterestArea(player, back, engine.Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
private int currentID;
|
||||
private long lastAttackTime = 0;
|
||||
private int lastMobPowerToken = 0;
|
||||
public HashMap<Integer, MobEquipment> equip = null;
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> equip = null;
|
||||
private DeferredPowerJob weaponPower;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private boolean lootSync = false;
|
||||
@@ -1218,7 +1218,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
// calculate defense for equipment
|
||||
}
|
||||
|
||||
private float getWeaponDefense(HashMap<Integer, MobEquipment> equipped) {
|
||||
private float getWeaponDefense(HashMap<Enum.EquipSlotType, MobEquipment> equipped) {
|
||||
|
||||
MobEquipment weapon = equipped.get(EquipSlotType.RHELD);
|
||||
ItemBase wb = null;
|
||||
@@ -1836,7 +1836,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
this.lootSync = lootSync;
|
||||
}
|
||||
|
||||
public HashMap<Integer, MobEquipment> getEquip() {
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> getEquip() {
|
||||
return equip;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,10 +110,10 @@ public class MobBase extends AbstractGameObject {
|
||||
|
||||
}
|
||||
|
||||
public static HashMap<Integer, MobEquipment> loadEquipmentSet(int equipmentSetID) {
|
||||
public static HashMap<Enum.EquipSlotType, MobEquipment> loadEquipmentSet(int equipmentSetID) {
|
||||
|
||||
ArrayList<BootySetEntry> equipList;
|
||||
HashMap<Integer, MobEquipment> equip = new HashMap<>();
|
||||
HashMap<Enum.EquipSlotType, MobEquipment> equip = new HashMap<>();
|
||||
|
||||
if (equipmentSetID == 0)
|
||||
return equip;
|
||||
@@ -128,13 +128,12 @@ public class MobBase extends AbstractGameObject {
|
||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
|
||||
ItemBase itemBase = mobEquipment.getItemBase();
|
||||
|
||||
if (itemBase != null) {
|
||||
if (itemBase.getType().equals(Enum.ItemType.WEAPON))
|
||||
if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
|
||||
mobEquipment.setSlot(2);
|
||||
// if (itemBase.getType().equals(Enum.ItemType.WEAPON))
|
||||
// if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
|
||||
// mobEquipment.setSlot(2);
|
||||
|
||||
equip.put(mobEquipment.slot, mobEquipment);
|
||||
|
||||
equip.put(mobEquipment.getSlot(), mobEquipment);
|
||||
}
|
||||
}
|
||||
|
||||
return equip;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
|
||||
private static AtomicInteger equipCounter = new AtomicInteger(0);
|
||||
private final ItemBase itemBase;
|
||||
private int slot;
|
||||
public Enum.EquipSlotType slot;
|
||||
private int parentID;
|
||||
|
||||
//effects
|
||||
@@ -41,7 +41,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
/**
|
||||
* No Id Constructor
|
||||
*/
|
||||
public MobEquipment(ItemBase itemBase, int slot, int parentID) {
|
||||
public MobEquipment(ItemBase itemBase, Enum.EquipSlotType slot, int parentID) {
|
||||
super(MobEquipment.getNewID());
|
||||
this.itemBase = itemBase;
|
||||
this.templateID = this.itemBase.getUUID();
|
||||
@@ -62,7 +62,8 @@ public class MobEquipment extends AbstractGameObject {
|
||||
this.template = ItemTemplate.itemTemplates.get(itemBaseID);
|
||||
|
||||
Enum.EquipSlotType equipSlot = template.item_eq_slots_and.iterator().next();
|
||||
this.slot = equipSlot.ordinal();
|
||||
|
||||
this.slot = equipSlot;
|
||||
this.dropChance = dropChance;
|
||||
|
||||
this.parentID = 0;
|
||||
@@ -86,7 +87,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
public static void _serializeForClientMsg(MobEquipment mobEquipment, ByteBufferWriter writer, boolean useSlot) throws SerializationException {
|
||||
|
||||
if (useSlot)
|
||||
writer.putInt(mobEquipment.slot);
|
||||
writer.putInt(mobEquipment.slot.ordinal());
|
||||
writer.putInt(0); // Pad
|
||||
writer.putInt(mobEquipment.itemBase.getUUID());
|
||||
writer.putInt(mobEquipment.getObjectType().ordinal());
|
||||
@@ -209,15 +210,6 @@ public class MobEquipment extends AbstractGameObject {
|
||||
public ItemBase getItemBase() {
|
||||
return itemBase;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public void setSlot(int value) {
|
||||
this.slot = value;
|
||||
}
|
||||
|
||||
public final void setMagicValue() {
|
||||
float value = 1;
|
||||
if (itemBase != null)
|
||||
|
||||
@@ -52,7 +52,7 @@ public class NPC extends AbstractCharacter {
|
||||
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
||||
public HashMap<Integer, MobEquipment> equip = null;
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> equip = null;
|
||||
public int runeSetID = 0;
|
||||
public int extraRune2 = 0;
|
||||
protected int loadID;
|
||||
@@ -1265,7 +1265,7 @@ public class NPC extends AbstractCharacter {
|
||||
return true;
|
||||
}
|
||||
|
||||
public HashMap<Integer, MobEquipment> getEquip() {
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> getEquip() {
|
||||
return equip;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user