forked from MagicBane/Server
More ordinal refactor
This commit is contained in:
@@ -70,7 +70,7 @@ public class dbContractHandler extends dbHandlerBase {
|
||||
|
||||
if (ib != null) {
|
||||
|
||||
MobEquipment me = new MobEquipment(ib, 0, 0);
|
||||
MobEquipment me = new MobEquipment(ib, Enum.EquipSlotType.NONE, 0);
|
||||
contract.getSellInventory().add(me);
|
||||
|
||||
//handle magic effects
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
||||
if (tar.getObjectType() == GameObjectType.Mob) {
|
||||
Mob tarMob = (Mob) tar;
|
||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
for (int slot : tarMob.getEquip().keySet()) {
|
||||
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) {
|
||||
MobEquipment equip = tarMob.getEquip().get(slot);
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(equip.getItemBase().getUUID());
|
||||
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + template.item_base_name + ", slot: " + slot);
|
||||
@@ -75,7 +75,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
||||
if (tar.getObjectType() == GameObjectType.NPC) {
|
||||
NPC tarMob = (NPC) tar;
|
||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||
for (int slot : tarMob.getEquip().keySet()) {
|
||||
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) {
|
||||
MobEquipment equip = tarMob.getEquip().get(slot);
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(equip.getItemBase().getUUID());
|
||||
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + template.item_base_name + ", slot: " + slot);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
@@ -25,7 +26,7 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||
}
|
||||
|
||||
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
||||
public static ItemBase getWeaponBase(int slot, HashMap<Enum.EquipSlotType, MobEquipment> equip) {
|
||||
if (equip.containsKey(slot)) {
|
||||
MobEquipment item = equip.get(slot);
|
||||
if (item != null && item.getItemBase() != null) {
|
||||
@@ -96,7 +97,7 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
out += "Defense: " + tar.getDefenseRating() + newline;
|
||||
|
||||
//get weapons
|
||||
HashMap<Integer, MobEquipment> equip = tar.getEquip();
|
||||
HashMap<Enum.EquipSlotType, MobEquipment> equip = tar.getEquip();
|
||||
ItemBase main = null;
|
||||
|
||||
if (equip != null)
|
||||
|
||||
@@ -865,10 +865,10 @@ public enum CombatManager {
|
||||
if (acItem == null || tarItem == null)
|
||||
return false;
|
||||
|
||||
Item acMain = acItem.getItemFromEquipped(1);
|
||||
Item acOff = acItem.getItemFromEquipped(2);
|
||||
Item tarMain = tarItem.getItemFromEquipped(1);
|
||||
Item tarOff = tarItem.getItemFromEquipped(2);
|
||||
Item acMain = acItem.getItemFromEquipped(EquipSlotType.RHELD);
|
||||
Item acOff = acItem.getItemFromEquipped(EquipSlotType.LHELD);
|
||||
Item tarMain = tarItem.getItemFromEquipped(EquipSlotType.RHELD);
|
||||
Item tarOff = tarItem.getItemFromEquipped(EquipSlotType.LHELD);
|
||||
|
||||
return !isRanged(acMain) && !isRanged(acOff) && !isRanged(tarMain) && !isRanged(tarOff);
|
||||
}
|
||||
@@ -886,7 +886,7 @@ public enum CombatManager {
|
||||
if (acItem == null || tarItem == null)
|
||||
return false;
|
||||
|
||||
Item tarOff = tarItem.getItemFromEquipped(2);
|
||||
Item tarOff = tarItem.getItemFromEquipped(EquipSlotType.LHELD);
|
||||
|
||||
if (tarOff == null)
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.net.client;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.MsgSendException;
|
||||
@@ -164,7 +165,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (itemManager == null)
|
||||
return;
|
||||
|
||||
int slot = msg.getSlotNumber();
|
||||
Enum.EquipSlotType slot = msg.slot;
|
||||
|
||||
Item i = itemManager.getItemFromEquipped(slot);
|
||||
if (i == null)
|
||||
@@ -754,7 +755,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
for (MobEquipment equip : mobTarget.getEquip().values()) {
|
||||
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.getSlot());
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.slot);
|
||||
DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
|
||||
LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip);
|
||||
|
||||
@@ -44,8 +44,7 @@ public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHa
|
||||
}
|
||||
|
||||
int itemUUID = transferMsg.getUUID();
|
||||
int slotOrdinal = transferMsg.getSlotNumber();
|
||||
Enum.EquipSlotType equipSlot = Enum.EquipSlotType.values()[slotOrdinal];
|
||||
Enum.EquipSlotType equipSlot = transferMsg.slot;
|
||||
|
||||
Item item = itemManager.getItemByUUID(itemUUID);
|
||||
|
||||
@@ -109,7 +108,7 @@ public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHa
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(player, msg.getSlotNumber());
|
||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(player, msg.slot);
|
||||
Dispatch dispatch = Dispatch.borrow(player, back);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
@@ -21,16 +22,16 @@ public class TransferItemFromEquipToInventoryMsg extends ClientNetMsg {
|
||||
|
||||
private int playerType;
|
||||
private int playerUUID;
|
||||
private int slotNumber;
|
||||
public Enum.EquipSlotType slot;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public TransferItemFromEquipToInventoryMsg(AbstractGameObject ago, int slotNumber) {
|
||||
public TransferItemFromEquipToInventoryMsg(AbstractGameObject ago, Enum.EquipSlotType slot) {
|
||||
super(Protocol.UNEQUIP);
|
||||
this.playerType = ago.getObjectType().ordinal();
|
||||
this.playerUUID = ago.getObjectUUID();
|
||||
this.slotNumber = slotNumber;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ public class TransferItemFromEquipToInventoryMsg extends ClientNetMsg {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.playerType = reader.getInt();
|
||||
this.playerUUID = reader.getInt();
|
||||
this.slotNumber = reader.getInt();
|
||||
this.slot = Enum.EquipSlotType.values()[reader.getInt()];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,16 +61,13 @@ public class TransferItemFromEquipToInventoryMsg extends ClientNetMsg {
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
writer.putInt(this.playerType);
|
||||
writer.putInt(this.playerUUID);
|
||||
writer.putInt(this.slotNumber);
|
||||
writer.putInt(this.slot.ordinal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the slotNumber
|
||||
*/
|
||||
public int getSlotNumber() {
|
||||
return slotNumber;
|
||||
}
|
||||
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
@@ -25,7 +26,8 @@ public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {
|
||||
private int itemBase;
|
||||
private int type;
|
||||
private int objectUUID;
|
||||
private int slotNumber;
|
||||
|
||||
public Enum.EquipSlotType slot;
|
||||
private int pad2;
|
||||
private float unknown1, unknown2;
|
||||
|
||||
@@ -36,11 +38,11 @@ public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {
|
||||
super(Protocol.EQUIP);
|
||||
}
|
||||
|
||||
public TransferItemFromInventoryToEquipMsg(AbstractCharacter source, int slot, int itemBaseID) {
|
||||
public TransferItemFromInventoryToEquipMsg(AbstractCharacter source, Enum.EquipSlotType slot, int itemBaseID) {
|
||||
super(Protocol.EQUIP);
|
||||
this.sourceType = source.getObjectType().ordinal();
|
||||
this.sourceID = source.getObjectUUID();
|
||||
this.slotNumber = slot;
|
||||
this.slot = slot;
|
||||
this.itemBase = itemBaseID;
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {
|
||||
itemBase = reader.getInt();
|
||||
type = reader.getInt();
|
||||
objectUUID = reader.getInt();
|
||||
slotNumber = reader.getInt();
|
||||
slot = Enum.EquipSlotType.values()[reader.getInt()];
|
||||
pad2 = reader.getInt();
|
||||
unknown1 = reader.getFloat();
|
||||
unknown2 = reader.getFloat();
|
||||
@@ -82,27 +84,12 @@ public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {
|
||||
writer.putInt(itemBase);
|
||||
writer.putInt(type);
|
||||
writer.putInt(objectUUID);
|
||||
writer.putInt(slotNumber);
|
||||
writer.putInt(slot.ordinal());
|
||||
writer.putInt(pad2);
|
||||
writer.putFloat(unknown1);
|
||||
writer.putFloat(unknown1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the pad1
|
||||
*/
|
||||
public int getPad1() {
|
||||
return pad1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pad1 the pad1 to set
|
||||
*/
|
||||
public void setPad1(int pad1) {
|
||||
this.pad1 = pad1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemBase
|
||||
*/
|
||||
@@ -138,34 +125,6 @@ public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {
|
||||
return objectUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the slotNumber
|
||||
*/
|
||||
public int getSlotNumber() {
|
||||
return slotNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slotNumber the slotNumber to set
|
||||
*/
|
||||
public void setSlotNumber(int slotNumber) {
|
||||
this.slotNumber = slotNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pad2
|
||||
*/
|
||||
public int getPad2() {
|
||||
return pad2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pad2 the pad2 to set
|
||||
*/
|
||||
public void setPad2(int pad2) {
|
||||
this.pad2 = pad2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown1
|
||||
*/
|
||||
@@ -180,20 +139,6 @@ public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {
|
||||
this.unknown1 = unknown1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown2
|
||||
*/
|
||||
public float getUnknown2() {
|
||||
return unknown2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown2 the unknown2 to set
|
||||
*/
|
||||
public void setUnknown2(float unknown2) {
|
||||
this.unknown2 = unknown2;
|
||||
}
|
||||
|
||||
public int getSourceType() {
|
||||
return sourceType;
|
||||
}
|
||||
|
||||
@@ -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