|
|
|
@ -20,7 +20,6 @@ import engine.math.Vector3fImmutable;
@@ -20,7 +20,6 @@ import engine.math.Vector3fImmutable;
|
|
|
|
|
import engine.net.Dispatch; |
|
|
|
|
import engine.net.DispatchMessage; |
|
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
|
import engine.net.client.ClientMessagePump; |
|
|
|
|
import engine.net.client.msg.*; |
|
|
|
|
import engine.server.MBServerStatics; |
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
@ -35,9 +34,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
@@ -35,9 +34,6 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
|
|
|
|
|
|
|
|
|
public class CharacterItemManager { |
|
|
|
|
|
|
|
|
|
private static final byte inventoryVer = (byte) 0; |
|
|
|
|
private static final byte bankVer = (byte) 0; |
|
|
|
|
private static final byte vaultVer = (byte) 0; |
|
|
|
|
private final AbstractCharacter absCharacter; |
|
|
|
|
// Mapping of all the items associated with this Manager
|
|
|
|
|
private final ConcurrentHashMap<Integer, Integer> itemIDtoType = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
|
@ -63,58 +59,12 @@ public class CharacterItemManager {
@@ -63,58 +59,12 @@ public class CharacterItemManager {
|
|
|
|
|
private HashSet<Integer> trading; |
|
|
|
|
private int goldTradingAmount; |
|
|
|
|
private int tradeID = 0; |
|
|
|
|
/* |
|
|
|
|
* Item Manager Version data |
|
|
|
|
*/ |
|
|
|
|
private byte equipVer = (byte) 0; |
|
|
|
|
|
|
|
|
|
public CharacterItemManager(AbstractCharacter ac) { |
|
|
|
|
super(); |
|
|
|
|
this.absCharacter = ac; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static byte getInventoryVer() { |
|
|
|
|
return inventoryVer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static byte getBankVer() { |
|
|
|
|
return bankVer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static byte getVaultVer() { |
|
|
|
|
return vaultVer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void takeFromNPC(NPC npc, PlayerCharacter pc, Item take, ClientMessagePump clientMessagePump) { |
|
|
|
|
|
|
|
|
|
ItemBase ib = take.getItemBase(); |
|
|
|
|
ItemTemplate template = take.template; |
|
|
|
|
|
|
|
|
|
if (template == null) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
CharacterItemManager itemMan = pc.charItemManager; |
|
|
|
|
|
|
|
|
|
if (itemMan == null) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
CharacterItemManager npcCim = npc.charItemManager; |
|
|
|
|
|
|
|
|
|
if (npcCim == null) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (!npcCim.inventoryContains(take)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (!itemMan.hasRoomInventory(template.item_wt)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (take != null) { |
|
|
|
|
itemMan.buyFromNPC(take, npc); |
|
|
|
|
itemMan.updateInventory(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void load() { |
|
|
|
|
loadForGeneric(); |
|
|
|
|
|
|
|
|
@ -122,7 +72,6 @@ public class CharacterItemManager {
@@ -122,7 +72,6 @@ public class CharacterItemManager {
|
|
|
|
|
loadForPlayerCharacter(); |
|
|
|
|
else if (this.absCharacter.getObjectType().equals(GameObjectType.NPC)) |
|
|
|
|
loadForNPC(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void loadGoldItems() { |
|
|
|
@ -2008,27 +1957,6 @@ public class CharacterItemManager {
@@ -2008,27 +1957,6 @@ public class CharacterItemManager {
|
|
|
|
|
updateInventory(this.getInventory(), false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public synchronized void purgeInventory() { |
|
|
|
|
|
|
|
|
|
if (!this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (this.goldInventory != null) |
|
|
|
|
if (this.getGoldInventory().getNumOfItems() > 0) { |
|
|
|
|
if (DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) { |
|
|
|
|
this.goldInventory.setNumOfItems(0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.inventory.size() > 0) |
|
|
|
|
DbManager.ItemQueries.ORPHAN_INVENTORY(this.inventory); |
|
|
|
|
|
|
|
|
|
// clear the inventory.
|
|
|
|
|
this.inventory.clear(); |
|
|
|
|
//re-calculate inventory weight
|
|
|
|
|
calculateInventoryWeight(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Note that this method returns a <b>copy</b> of the internally stored |
|
|
|
|
* list. |
|
|
|
@ -2135,10 +2063,6 @@ public class CharacterItemManager {
@@ -2135,10 +2063,6 @@ public class CharacterItemManager {
|
|
|
|
|
return this.vaultWeight; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getTradingForWeight() { |
|
|
|
|
return calculateTradingForWeight(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getTradingWeight() { |
|
|
|
|
|
|
|
|
|
int weight = 0; |
|
|
|
|