|
|
@ -213,22 +213,18 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (wh == null) |
|
|
|
if (wh == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
int itemBaseID = ItemBase.getItemHashIDMap().get(hashID); |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.hashLookup.get(hashID); |
|
|
|
ItemBase ib = ItemBase.getItemBase(itemBaseID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isResourceLocked(wh, ib)) { |
|
|
|
if (isResourceLocked(wh, ItemBase.getItemBase(resourceType.templateID))) { |
|
|
|
boolean worked; |
|
|
|
boolean worked; |
|
|
|
EnumBitSet<Enum.ResourceType> bitSet = EnumBitSet.asEnumBitSet(wh.lockedResourceTypes.toLong(), Enum.ResourceType.class); |
|
|
|
EnumBitSet<Enum.ResourceType> bitSet = EnumBitSet.asEnumBitSet(wh.lockedResourceTypes.toLong(), Enum.ResourceType.class); |
|
|
|
|
|
|
|
|
|
|
|
bitSet.remove(Enum.ResourceType.resourceLookup.get(itemBaseID)); |
|
|
|
bitSet.remove(Enum.ResourceType.resourceLookup.get(ItemBase.getItemBase(resourceType.templateID))); |
|
|
|
|
|
|
|
|
|
|
|
worked = DbManager.WarehouseQueries.updateLocks(wh, bitSet.toLong()); |
|
|
|
worked = DbManager.WarehouseQueries.updateLocks(wh, bitSet.toLong()); |
|
|
|
|
|
|
|
|
|
|
|
if (worked) { |
|
|
|
if (worked) { |
|
|
|
wh.lockedResourceTypes.remove(Enum.ResourceType.resourceLookup.get(itemBaseID)); |
|
|
|
wh.lockedResourceTypes.remove(Enum.ResourceType.resourceLookup.get(ItemBase.getItemBase(resourceType.templateID))); |
|
|
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player); |
|
|
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player); |
|
|
|
vrm.setGuild(player.getGuild()); |
|
|
|
vrm.setGuild(player.getGuild()); |
|
|
|
vrm.setWarehouseBuilding(warehouse); |
|
|
|
vrm.setWarehouseBuilding(warehouse); |
|
|
@ -241,12 +237,12 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
EnumBitSet<Enum.ResourceType> bitSet = EnumBitSet.asEnumBitSet(wh.lockedResourceTypes.toLong(), Enum.ResourceType.class); |
|
|
|
EnumBitSet<Enum.ResourceType> bitSet = EnumBitSet.asEnumBitSet(wh.lockedResourceTypes.toLong(), Enum.ResourceType.class); |
|
|
|
|
|
|
|
|
|
|
|
bitSet.add(Enum.ResourceType.resourceLookup.get(itemBaseID)); |
|
|
|
bitSet.add(Enum.ResourceType.resourceLookup.get(ItemBase.getItemBase(resourceType.templateID))); |
|
|
|
|
|
|
|
|
|
|
|
if (!DbManager.WarehouseQueries.updateLocks(wh, bitSet.toLong())) |
|
|
|
if (!DbManager.WarehouseQueries.updateLocks(wh, bitSet.toLong())) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
wh.lockedResourceTypes.add(Enum.ResourceType.resourceLookup.get(itemBaseID)); |
|
|
|
wh.lockedResourceTypes.add(Enum.ResourceType.resourceLookup.get(ItemBase.getItemBase(resourceType.templateID))); |
|
|
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player); |
|
|
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player); |
|
|
|
vrm.setGuild(player.getGuild()); |
|
|
|
vrm.setGuild(player.getGuild()); |
|
|
|
vrm.setWarehouseBuilding(warehouse); |
|
|
|
vrm.setWarehouseBuilding(warehouse); |
|
|
@ -538,7 +534,8 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (oldAmount < amount) |
|
|
|
if (oldAmount < amount) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int hashID = ib.getHashID(); |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); |
|
|
|
|
|
|
|
int hashID = resourceType.hash; |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
boolean worked = false; |
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
|
|
|
@ -658,7 +655,8 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
int amount = (int) (warehouse.resources.get(ib) * taxPercent); |
|
|
|
int amount = (int) (warehouse.resources.get(ib) * taxPercent); |
|
|
|
|
|
|
|
|
|
|
|
if (amount <= 0) { |
|
|
|
if (amount <= 0) { |
|
|
|
msg.getResources().put(ib.getHashID(), 0); |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); |
|
|
|
|
|
|
|
msg.getResources().put(resourceType.hash, 0); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -672,23 +670,25 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (newAmount < amount) |
|
|
|
if (newAmount < amount) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
if (!WithdrawApproved(ib, amount, warehouse)) { |
|
|
|
if (!WithdrawApproved(ib, amount, warehouse)) { |
|
|
|
msg.getResources().put(ib.getHashID(), 0); |
|
|
|
msg.getResources().put(resourceType.hash, 0); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
msg.getResources().put(ib.getHashID(), amount); |
|
|
|
msg.getResources().put(resourceType.hash, amount); |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
depositRealmTaxes(taxer, ib, amount, warehouse); |
|
|
|
depositRealmTaxes(taxer, ib, amount, warehouse); |
|
|
|
Resource resourceType; |
|
|
|
Resource resource; |
|
|
|
|
|
|
|
|
|
|
|
if (ib.getUUID() == 7) |
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) |
|
|
|
resourceType = Resource.GOLD; |
|
|
|
resource = Resource.GOLD; |
|
|
|
else |
|
|
|
else |
|
|
|
resourceType = Resource.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
resource = Resource.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCE, resourceType, amount); |
|
|
|
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCE, resource, amount); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|