Browse Source

stack resources completed

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
5e61ef26e1
  1. 10
      src/engine/net/client/ClientMessagePump.java
  2. 22
      src/engine/objects/CharacterItemManager.java

10
src/engine/net/client/ClientMessagePump.java

@ -579,7 +579,7 @@ public class ClientMessagePump implements NetMsgHandler {
} }
if (itemManager.delete(i) == true) { if (itemManager.delete(i) == true) {
sourcePlayer.getCharItemManager().addGoldToInventory(value,false); sourcePlayer.getCharItemManager().addGoldToInventory(value,false);
sourcePlayer.getCharItemManager().updateInventory(); sourcePlayer.getCharItemManager().StackResources();
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
} }
@ -921,7 +921,7 @@ public class ClientMessagePump implements NetMsgHandler {
DispatchMessage.dispatchMsgToInterestArea(corpse, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true); DispatchMessage.dispatchMsgToInterestArea(corpse, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true);
//player.getCharItemManager().updateInventory(); //player.getCharItemManager().StackResources();
} }
//TODO send group loot message if player is grouped and visible //TODO send group loot message if player is grouped and visible
@ -978,7 +978,7 @@ public class ClientMessagePump implements NetMsgHandler {
dispatch = Dispatch.borrow(player, newItemMsg); dispatch = Dispatch.borrow(player, newItemMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
//player.getCharItemManager().updateInventory(); //player.getCharItemManager().StackResources();
} }
//TODO send group loot message if player is grouped and visible //TODO send group loot message if player is grouped and visible
@ -1464,7 +1464,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (buy != null) { if (buy != null) {
me.transferEnchants(buy); me.transferEnchants(buy);
itemMan.addItemToInventory(buy); itemMan.addItemToInventory(buy);
//itemMan.updateInventory(); //itemMan.StackResources();
} }
} }
} }
@ -1604,7 +1604,7 @@ public class ClientMessagePump implements NetMsgHandler {
// msg.setItemID(buy.getObjectUUID()); // msg.setItemID(buy.getObjectUUID());
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg); Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
itemMan.updateInventory(); itemMan.StackResources();
} }
} finally { } finally {
origin.buyLock.unlock(); origin.buyLock.unlock();

22
src/engine/objects/CharacterItemManager.java

@ -103,7 +103,7 @@ public class CharacterItemManager {
return; return;
if (take != null) { if (take != null) {
itemMan.buyFromNPC(take, npc); itemMan.buyFromNPC(take, npc);
itemMan.updateInventory(); itemMan.StackResources();
} }
} }
@ -690,7 +690,7 @@ public class CharacterItemManager {
this.addGoldToTrade(amt); this.addGoldToTrade(amt);
// BONUS CODE BELOW: Thanks some unknown retard! // BONUS CODE BELOW: Thanks some unknown retard!
// sourceItemMan.updateInventory(sourceItemMan.getInventory(), true); // sourceItemMan.StackResources(sourceItemMan.getInventory(), true);
UpdateGoldMsg ugm = new UpdateGoldMsg(source); UpdateGoldMsg ugm = new UpdateGoldMsg(source);
ugm.configure(); ugm.configure();
@ -936,13 +936,13 @@ public class CharacterItemManager {
return junk(i, true); return junk(i, true);
} }
private synchronized boolean junk(Item i, boolean updateInventory) { private synchronized boolean junk(Item i, boolean StackResources) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) { if (i.getItemBase().getType().equals(ItemType.GOLD)) {
if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID()) if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID())
if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) { if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) {
this.getGoldInventory().setNumOfItems(0); this.getGoldInventory().setNumOfItems(0);
if (updateInventory) if (StackResources)
updateInventory(); StackResources();
return true; return true;
} else { } else {
return false; return false;
@ -970,9 +970,9 @@ public class CharacterItemManager {
calculateWeights(); calculateWeights();
if (updateInventory) if (StackResources)
// Send the new inventory // Send the new inventory
//updateInventory(i, false); this line was causing entire inventory to disappear //StackResources(i, false); this line was causing entire inventory to disappear
updateInventory(this.getInventory(), true); updateInventory(this.getInventory(), true);
return true; return true;
@ -1247,7 +1247,7 @@ public class CharacterItemManager {
} else { } else {
int amt = i.getNumOfItems(); int amt = i.getNumOfItems();
if (DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, this.goldInventory.getNumOfItems() + amt)) { if (DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, this.goldInventory.getNumOfItems() + amt)) {
updateInventory(); StackResources();
return true; return true;
} }
return false; return false;
@ -1475,7 +1475,7 @@ public class CharacterItemManager {
if (sdrMerchant) { if (sdrMerchant) {
this.delete(itemToSell); this.delete(itemToSell);
this.updateInventory(); this.StackResources();
} else if (!itemToSell.moveItemToInventory(npc)) } else if (!itemToSell.moveItemToInventory(npc))
return false; return false;
@ -2276,8 +2276,8 @@ public class CharacterItemManager {
return; return;
PlayerCharacter pc = (PlayerCharacter) this.absCharacter; PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
UpdateInventoryMsg updateInventoryMsg = new UpdateInventoryMsg(inventory, this.getBank(), this.getGoldInventory(), add); UpdateInventoryMsg StackResourcesMsg = new UpdateInventoryMsg(inventory, this.getBank(), this.getGoldInventory(), add);
Dispatch dispatch = Dispatch.borrow(pc, updateInventoryMsg); Dispatch dispatch = Dispatch.borrow(pc, StackResourcesMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
} }

Loading…
Cancel
Save