Procházet zdrojové kódy

castle treasury int -> long

janiii před 16 roky
rodič
revize
a36402610a

+ 5 - 4
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2CastleChamberlainInstance.java

@@ -32,6 +32,7 @@ import net.sf.l2j.gameserver.model.L2Clan;
 import net.sf.l2j.gameserver.model.L2Skill;
 import net.sf.l2j.gameserver.model.L2TeleportLocation;
 import net.sf.l2j.gameserver.model.entity.Castle;
+import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.network.serverpackets.ExShowCropInfo;
@@ -292,17 +293,17 @@ public class L2CastleChamberlainInstance extends L2MerchantInstance
 				if ((player.getClanPrivileges() & L2Clan.CP_CS_TAXES) == L2Clan.CP_CS_TAXES)
 				{
 					String filename = "data/html/chamberlain/chamberlain-vault.htm";
-					int amount = 0;
+					long amount = 0;
 					if (val.equalsIgnoreCase("deposit"))
 					{
 						try
 						{
-							amount = Integer.parseInt(st.nextToken());
+							amount = Long.parseLong(st.nextToken());
 						}
 						catch (NoSuchElementException e)
 						{
 						}
-						if (amount > 0 && (long) getCastle().getTreasury() + amount < Integer.MAX_VALUE)
+						if (amount > 0 && getCastle().getTreasury() + amount < PcInventory.MAX_ADENA)
 						{
 							if (player.reduceAdena("Castle", amount, this, true))
 								getCastle().addToTreasuryNoTax(amount);
@@ -314,7 +315,7 @@ public class L2CastleChamberlainInstance extends L2MerchantInstance
 					{
 						try
 						{
-							amount = Integer.parseInt(st.nextToken());
+							amount = Long.parseLong(st.nextToken());
 						}
 						catch (NoSuchElementException e)
 						{

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2MerchantInstance.java

@@ -246,7 +246,7 @@ public class L2MerchantInstance extends L2NpcInstance
         price *= cost[val - 1];
         int time = ridetime[val - 1];
 
-        if (!player.reduceAdena("Rent", (int) price, player.getLastFolkNPC(), true)) return;
+        if (!player.reduceAdena("Rent", (long) price, player.getLastFolkNPC(), true)) return;
 
         player.mount(petId, 0, false);
         SetupGauge sg = new SetupGauge(3, time*1000);

+ 11 - 10
L2_GameServer/java/net/sf/l2j/gameserver/model/entity/Castle.java

@@ -47,6 +47,7 @@ import net.sf.l2j.gameserver.model.L2Object;
 import net.sf.l2j.gameserver.model.L2Skill;
 import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
 import net.sf.l2j.gameserver.model.zone.L2ZoneType;
 import net.sf.l2j.gameserver.model.zone.type.L2CastleTeleportZone;
 import net.sf.l2j.gameserver.model.zone.type.L2CastleZone;
@@ -84,7 +85,7 @@ public class Castle
     private Calendar _siegeTimeRegistrationEndDate; // last siege end date + 1 day
 	private int _taxPercent = 0;
 	private double _taxRate = 0;
-	private int _treasury = 0;
+	private long _treasury = 0;
 	private L2CastleZone _zone = null;
 	private L2CastleTeleportZone _teleZone;
 	private L2Clan _formerOwner = null;
@@ -333,7 +334,7 @@ public class Castle
 			Castle rune = CastleManager.getInstance().getCastle("rune");
 			if (rune != null)
 			{
-				int runeTax = (int) (amount * rune.getTaxRate());
+				long runeTax = (long) (amount * rune.getTaxRate());
 				if (rune.getOwnerId() > 0)
 					rune.addToTreasury(runeTax);
 				amount -= runeTax;
@@ -344,7 +345,7 @@ public class Castle
 			Castle aden = CastleManager.getInstance().getCastle("aden");
 			if (aden != null)
 			{
-				int adenTax = (int) (amount * aden.getTaxRate()); // Find out what Aden gets from the current castle instance's income
+				long adenTax = (long) (amount * aden.getTaxRate()); // Find out what Aden gets from the current castle instance's income
 				if (aden.getOwnerId() > 0)
 					aden.addToTreasury(adenTax); // Only bother to really add the tax to the treasury if not npc owned
 					
@@ -370,8 +371,8 @@ public class Castle
 		}
 		else
 		{
-			if (_treasury + amount > Integer.MAX_VALUE) // TODO is this valid after gracia final?
-				_treasury = Integer.MAX_VALUE;
+			if (_treasury + amount > PcInventory.MAX_ADENA) // TODO is this valid after gracia final?
+				_treasury = PcInventory.MAX_ADENA;
 			else
 				_treasury += amount;
 		}
@@ -381,7 +382,7 @@ public class Castle
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("Update castle set treasury = ? where id = ?");
-			statement.setInt(1, getTreasury());
+			statement.setLong(1, getTreasury());
 			statement.setInt(2, getCastleId());
 			statement.execute();
 			statement.close();
@@ -698,7 +699,7 @@ public class Castle
         	    _isTimeRegistrationOver = rs.getBoolean("regTimeOver");
 				
 				_taxPercent = rs.getInt("taxPercent");
-				_treasury = rs.getInt("treasury");
+				_treasury = rs.getLong("treasury");
 			}
 			rs.close();
 			statement.close();
@@ -1110,7 +1111,7 @@ public class Castle
 		return _taxRate;
 	}
 	
-	public final int getTreasury()
+	public final long getTreasury()
 	{
 		return _treasury;
 	}
@@ -1165,7 +1166,7 @@ public class Castle
 		return null;
 	}
 	
-	public int getManorCost(int period)
+	public long getManorCost(int period)
 	{
 		FastList<CropProcure> procure;
 		FastList<SeedProduction> production;
@@ -1181,7 +1182,7 @@ public class Castle
 			production = _productionNext;
 		}
 		
-		int total = 0;
+		long total = 0;
 		if (production != null)
 		{
 			for (SeedProduction seed : production)

+ 8 - 7
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestBuyItem.java

@@ -34,6 +34,7 @@ import net.sf.l2j.gameserver.model.actor.instance.L2MerchantInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2MerchantSummonInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PetManagerInstance;
+import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.network.serverpackets.ItemList;
@@ -194,8 +195,8 @@ public final class RequestBuyItem extends L2GameClientPacket
             baseTaxRate = ((L2MerchantInstance)merchant).getMpc().getBaseTaxRate();
         }
 		long subTotal = 0;
-		int castleTax = 0;
-        int baseTax = 0;
+		long castleTax = 0;
+        long baseTax = 0;
 
 		// Check for buylist validity and calculates summary values
 		long slots = 0;
@@ -260,11 +261,11 @@ public final class RequestBuyItem extends L2GameClientPacket
             }
             
 			subTotal += count * price;	// Before tax
-			castleTax = (int) (subTotal * castleTaxRate);
-            baseTax = (int) (subTotal * baseTaxRate);
-            if (subTotal + castleTax + baseTax > Integer.MAX_VALUE)
+			castleTax = (long) (subTotal * castleTaxRate);
+            baseTax = (long) (subTotal * baseTaxRate);
+            if (subTotal + castleTax + baseTax > PcInventory.MAX_ADENA)
             {
-                Util.handleIllegalPlayerAction(player,"Warning!! Character "+player.getName()+" of account "+player.getAccountName()+" tried to purchase over "+Integer.MAX_VALUE+" adena worth of goods.", Config.DEFAULT_PUNISH);
+                Util.handleIllegalPlayerAction(player,"Warning!! Character "+player.getName()+" of account "+player.getAccountName()+" tried to purchase over "+PcInventory.MAX_ADENA+" adena worth of goods.", Config.DEFAULT_PUNISH);
                 return;
             }
 
@@ -286,7 +287,7 @@ public final class RequestBuyItem extends L2GameClientPacket
 		}
 
 		// Charge buyer and add tax to castle treasury if not owned by npc clan
-		if ((subTotal < 0) || !player.reduceAdena("Buy", (int)(subTotal + baseTax + castleTax), player.getLastFolkNPC(), false))
+		if ((subTotal < 0) || !player.reduceAdena("Buy", (subTotal + baseTax + castleTax), player.getLastFolkNPC(), false))
 		{
 			sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
 			return;

+ 5 - 4
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestBuySeed.java

@@ -24,6 +24,7 @@ import net.sf.l2j.gameserver.model.L2Object;
 import net.sf.l2j.gameserver.model.actor.instance.L2ManorManagerInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.entity.Castle;
+import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
@@ -137,12 +138,12 @@ public class RequestBuySeed extends L2GameClientPacket
 				slots++;
 		}
 
-		if (totalPrice > Integer.MAX_VALUE)
+		if (totalPrice > PcInventory.MAX_ADENA)
 		{
 			Util.handleIllegalPlayerAction(player, "Warning!! Character "
 					+ player.getName() + " of account "
 					+ player.getAccountName() + " tried to purchase over "
-					+ Integer.MAX_VALUE + " adena worth of goods.",
+					+ PcInventory.MAX_ADENA + " adena worth of goods.",
 					Config.DEFAULT_PUNISH);
 			return;
 		}
@@ -160,14 +161,14 @@ public class RequestBuySeed extends L2GameClientPacket
 		}
 
 		// Charge buyer
-		if ((totalPrice < 0) || !player.reduceAdena("Buy", (int) totalPrice, target, false))
+		if ((totalPrice < 0) || !player.reduceAdena("Buy", totalPrice, target, false))
 		{
 			sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
 			return;
 		}
 
 		// Adding to treasury for Manor Castle
-		castle.addToTreasuryNoTax((int) totalPrice);
+		castle.addToTreasuryNoTax(totalPrice);
 
 		// Proceed the purchase
 		InventoryUpdate playerIU = new InventoryUpdate();

+ 4 - 4
L2_GameServer/java/net/sf/l2j/gameserver/util/Util.java

@@ -320,11 +320,11 @@ public final class Util
 	 * @param amount
 	 * @return String formatted adena amount
 	 */
-	public static String formatAdena(int amount)
+	public static String formatAdena(long amount)
 	{
 		String s = "";
-		int rem = amount % 1000;
-		s = Integer.toString(rem);
+		long rem = amount % 1000;
+		s = Long.toString(rem);
 		amount = (amount - rem) / 1000;
 		while (amount > 0)
 		{
@@ -333,7 +333,7 @@ public final class Util
 			if (rem < 9)
 				s = '0' + s;
 			rem = amount % 1000;
-			s = Integer.toString(rem) + "," + s;
+			s = Long.toString(rem) + "," + s;
 			amount = (amount - rem) / 1000;
 		}
 		return s;