Browse Source

revert deposit change

lakebane-master
FatBoy-DOTC 7 months ago
parent
commit
a11b590573
  1. 156
      src/engine/objects/Warehouse.java

156
src/engine/objects/Warehouse.java

@ -289,48 +289,170 @@ public class Warehouse extends AbstractWorldObject {
} }
public synchronized boolean deposit(PlayerCharacter pc, Item resource, int amount, boolean removeFromInventory, boolean transaction) { public synchronized boolean deposit(PlayerCharacter pc, Item resource, int amount, boolean removeFromInventory, boolean transaction) {
ClientConnection origin = pc.getClientConnection(); ClientConnection origin = pc.getClientConnection();
if (origin == null || amount < 0 || resource == null) { if (origin == null)
if (amount < 0) Logger.info(pc.getFirstName() + " Attempting to Dupe!!!!!!"); return false;
if (amount < 0) {
Logger.info(pc.getFirstName() + " Attempting to Dupe!!!!!!");
return false; return false;
} }
ItemBase ib = resource.getItemBase(); ItemBase ib = resource.getItemBase();
if (ib == null) return false;
Integer currentResourceAmount = this.resources.get(ib); if (ib == null)
if (currentResourceAmount == null) return false; return false;
if (this.resources.get(ib) == null)
return false;
CharacterItemManager itemMan = pc.getCharItemManager(); CharacterItemManager itemMan = pc.getCharItemManager();
if (itemMan == null || !itemMan.doesCharOwnThisItem(resource.getObjectUUID())) return false;
if (itemMan == null)
return false;
if (itemMan.getGoldTrading() > 0) { if (itemMan.getGoldTrading() > 0) {
ErrorPopupMsg.sendErrorPopup(pc, 195); ErrorPopupMsg.sendErrorPopup(pc, 195);
return false; return false;
} }
if (!resource.validForInventory(origin, pc, itemMan) || resource.getNumOfItems() < amount) return false;
int newAmount = currentResourceAmount + amount; if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID()))
Integer maxResourceAmount = Warehouse.getMaxResources().get(ib.getUUID()); return false;
if (newAmount > (maxResourceAmount != null ? maxResourceAmount : Integer.MAX_VALUE)) {
// ChatManager.chatSystemInfo(pc, "The Warehouse is at its maximum for this type of resource."); if (!resource.validForInventory(origin, pc, itemMan))
return false;
if (resource.getNumOfItems() < amount)
return false;
int oldAmount = resources.get(ib);
int newAmount = oldAmount + amount;
if (newAmount > Warehouse.getMaxResources().get(ib.getUUID())) {
//ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource.");
return false; return false;
} }
if (removeFromInventory) { if (removeFromInventory) {
if (!removeFromInventory(itemMan, ib, amount, pc)) return false; if (ib.getUUID() == 7) {
if (itemMan.getGoldInventory().getNumOfItems() - amount < 0)
return false;
if (itemMan.getGoldInventory().getNumOfItems() - amount > MBServerStatics.PLAYER_GOLD_LIMIT)
return false;
if (!itemMan.modifyInventoryGold(-amount)) {
//ChatManager.chatSystemError(pc, "You do not have this Gold.");
return false;
} }
UpdateGoldMsg ugm = new UpdateGoldMsg(pc);
ugm.configure();
Dispatch dispatch = Dispatch.borrow(pc, ugm);
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
itemMan.updateInventory(); itemMan.updateInventory();
if (!updateDatabase(ib.getUUID(), newAmount)) return false;
this.resources.put(ib, newAmount); } else {
itemMan.delete(resource);
itemMan.updateInventory();
}
}
itemMan.updateInventory();
int itemID = ib.getUUID();
boolean worked = false;
switch (itemID) {
case 7:
worked = DbManager.WarehouseQueries.updateGold(this, newAmount);
break;
case 1580000:
worked = DbManager.WarehouseQueries.updateStone(this, newAmount);
break;
case 1580001:
worked = DbManager.WarehouseQueries.updateTruesteel(this, newAmount);
break;
case 1580002:
worked = DbManager.WarehouseQueries.updateIron(this, newAmount);
break;
case 1580003:
worked = DbManager.WarehouseQueries.updateAdamant(this, newAmount);
break;
case 1580004:
worked = DbManager.WarehouseQueries.updateLumber(this, newAmount);
break;
case 1580005:
worked = DbManager.WarehouseQueries.updateOak(this, newAmount);
break;
case 1580006:
worked = DbManager.WarehouseQueries.updateBronzewood(this, newAmount);
break;
case 1580007:
worked = DbManager.WarehouseQueries.updateMandrake(this, newAmount);
break;
case 1580008:
worked = DbManager.WarehouseQueries.updateCoal(this, newAmount);
break;
case 1580009:
worked = DbManager.WarehouseQueries.updateAgate(this, newAmount);
break;
case 1580010:
worked = DbManager.WarehouseQueries.updateDiamond(this, newAmount);
break;
case 1580011:
worked = DbManager.WarehouseQueries.updateOnyx(this, newAmount);
break;
case 1580012:
worked = DbManager.WarehouseQueries.updateAzoth(this, newAmount);
break;
case 1580013:
worked = DbManager.WarehouseQueries.updateOrichalk(this, newAmount);
break;
case 1580014:
worked = DbManager.WarehouseQueries.updateAntimony(this, newAmount);
break;
case 1580015:
worked = DbManager.WarehouseQueries.updateSulfur(this, newAmount);
break;
case 1580016:
worked = DbManager.WarehouseQueries.updateQuicksilver(this, newAmount);
break;
case 1580017:
worked = DbManager.WarehouseQueries.updateGalvor(this, newAmount);
break;
case 1580018:
worked = DbManager.WarehouseQueries.updateWormwood(this, newAmount);
break;
case 1580019:
worked = DbManager.WarehouseQueries.updateObsidian(this, newAmount);
break;
case 1580020:
worked = DbManager.WarehouseQueries.updateBloodstone(this, newAmount);
break;
case 1580021:
worked = DbManager.WarehouseQueries.updateMithril(this, newAmount);
break;
}
if (!worked)
return false;
if (transaction) { resources.put(ib, newAmount);
Resource resourceType = getResourceType(resource);
Resource resourceType;
if (resource.getItemBase().getType().equals(engine.Enum.ItemType.GOLD))
resourceType = Resource.GOLD;
else
resourceType = Resource.valueOf(resource.getItemBase().getName().toUpperCase());
if (transaction)
this.AddTransactionToWarehouse(pc.getObjectType(), pc.getObjectUUID(), TransactionType.DEPOSIT, resourceType, amount); this.AddTransactionToWarehouse(pc.getObjectType(), pc.getObjectUUID(), TransactionType.DEPOSIT, resourceType, amount);
}
return true; return true;
} }

Loading…
Cancel
Save