Explorar el Código

- bypass..
- L2BlacksmithInstance class not used anymore
- fort function duplicate entry fix

janiii hace 15 años
padre
commit
370d0167eb

+ 3 - 3
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2AuctioneerInstance.java

@@ -52,13 +52,13 @@ public final class L2AuctioneerInstance extends L2Npc
 	public void onBypassFeedback(L2PcInstance player, String command)
 	{
 		int condition = validateCondition(player);
-		if (condition == COND_ALL_FALSE)
+		if (condition <= COND_ALL_FALSE)
 		{
 			//TODO: html
 			player.sendMessage("Wrong conditions.");
 			return;
 		}
-		if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
+		else if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
 		{
 			String filename = "data/html/auction/auction-busy.htm";
 			NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
@@ -119,7 +119,7 @@ public final class L2AuctioneerInstance extends L2Npc
 				}
 				return;
 			}
-			if (actualCommand.equalsIgnoreCase("confirmAuction"))
+			else if (actualCommand.equalsIgnoreCase("confirmAuction"))
 			{
 				try
 				{

+ 0 - 57
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2BlacksmithInstance.java

@@ -1,57 +0,0 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.model.actor.instance;
-
-import com.l2jserver.gameserver.model.L2Multisell;
-import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
-
-/**
- * @author zabbix
- * Lets drink to code!
- */
-public class L2BlacksmithInstance extends L2NpcInstance
-{
-	public L2BlacksmithInstance(int objectId, L2NpcTemplate template)
-	{
-		super(objectId, template);
-	}
-
-	@Override
-	public void onBypassFeedback(L2PcInstance player, String command)
-	{
-		if (command.startsWith("multisell"))
-		{
-			int listId = Integer.parseInt(command.substring(9).trim());
-			L2Multisell.getInstance().separateAndSend(listId, player, getNpcId(), false, getCastle().getTaxRate());
-		}
-		super.onBypassFeedback(player,command);
-	}
-
-	@Override
-	public String getHtmlPath(int npcId, int val)
-	{
-		String pom = "";
-		if (val == 0)
-		{
-			pom = "" + npcId;
-		}
-		else
-		{
-			pom = npcId + "-" + val;
-		}
-
-		return "data/html/blacksmith/" + pom + ".htm";
-	}
-}

+ 2 - 3
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2CastleBlacksmithInstance.java

@@ -49,10 +49,8 @@ public class L2CastleBlacksmithInstance extends L2NpcInstance
 		int condition = validateCondition(player);
 		if (condition <= COND_ALL_FALSE)
 			return;
-
-		if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
+		else if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
 			return;
-
 		else if (condition == COND_OWNER)
 		{
 			if (command.startsWith("Chat"))
@@ -65,6 +63,7 @@ public class L2CastleBlacksmithInstance extends L2NpcInstance
 				catch (IndexOutOfBoundsException ioobe){}
 				catch (NumberFormatException nfe){}
 				showChatWindow(player, val);
+				return;
 			}
 			else
 				super.onBypassFeedback(player, command);

+ 1 - 2
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2CastleChamberlainInstance.java

@@ -83,8 +83,7 @@ public class L2CastleChamberlainInstance extends L2MerchantInstance
 		int condition = validateCondition(player);
 		if (condition <= COND_ALL_FALSE)
 			return;
-
-		if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
+		else if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
 			return;
 		else if (condition == COND_OWNER)
 		{

+ 3 - 0
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java

@@ -93,6 +93,7 @@ public class L2CastleMagicianInstance extends L2NpcInstance
 			catch (IndexOutOfBoundsException ioobe){}
 			catch (NumberFormatException nfe){}
 			showChatWindow(player, val);
+			return;
 		}
 		else if (command.startsWith("ExchangeKE"))
 		{
@@ -114,6 +115,7 @@ public class L2CastleMagicianInstance extends L2NpcInstance
 				filename = "data/html/castlemagician/magician-no-KE.htm";
 
 			showChatWindow(player, filename);
+			return;
 		}
 		else if (command.equals("gotoleader"))
 		{
@@ -134,6 +136,7 @@ public class L2CastleMagicianInstance extends L2NpcInstance
 				String filename = "data/html/castlemagician/magician-nogate.htm";
 				showChatWindow(player, filename);
 			}
+			return;
 		}
 		else
 			super.onBypassFeedback(player, command);

+ 2 - 2
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2FortManagerInstance.java

@@ -72,8 +72,7 @@ public class L2FortManagerInstance extends L2MerchantInstance
 		int condition = validateCondition(player);
 		if (condition <= COND_ALL_FALSE)
 			return;
-
-		if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
+		else if (condition == COND_BUSY_BECAUSE_OF_SIEGE)
 			return;
 		else if (condition == COND_OWNER)
 		{
@@ -913,6 +912,7 @@ public class L2FortManagerInstance extends L2MerchantInstance
 						+ getFort().getFunction(Fort.FUNC_SUPPORT).getLvl()	+ ".htm");
 				html.replace("%mp%", String.valueOf((int)getStatus().getCurrentMp()));
 				sendHtmlMessage(player, html);
+				return;
 			}
 			else if (actualCommand.equalsIgnoreCase("goto"))
 			{

+ 15 - 36
L2_GameServer/java/com/l2jserver/gameserver/model/entity/Fort.java

@@ -186,24 +186,16 @@ public class Fort
 					if (getOwnerClan().getWarehouse().getAdena() >= _fee || !_cwh)
 					{
 						int fee = _fee;
-						boolean newfc = true;
-						if (getEndTime() == 0 || getEndTime() == -1)
-						{
-							if (getEndTime() == -1)
-							{
-								newfc = false;
-								fee = _tempFee;
-							}
-						}
-						else
-							newfc = false;
+						if (getEndTime() == -1)
+							fee = _tempFee;
+						
 						setEndTime(System.currentTimeMillis() + getRate());
-						dbSave(newfc);
+						dbSave();
 						if (_cwh)
 						{
 							getOwnerClan().getWarehouse().destroyItemByItemId("CS_function_fee", 57, fee, null, null);
 							if (Config.DEBUG)
-								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+								_log.warning("Deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
@@ -216,7 +208,7 @@ public class Fort
 			}
 		}
 		
-		public void dbSave(boolean newFunction)
+		public void dbSave()
 		{
 			Connection con = null;
 			try
@@ -224,32 +216,19 @@ public class Fort
 				PreparedStatement statement;
 				
 				con = L2DatabaseFactory.getInstance().getConnection();
-				if (newFunction)
-				{
-					statement = con.prepareStatement("INSERT INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)");
-					statement.setInt(1, getFortId());
-					statement.setInt(2, getType());
-					statement.setInt(3, getLvl());
-					statement.setInt(4, getLease());
-					statement.setLong(5, getRate());
-					statement.setLong(6, getEndTime());
-				}
-				else
-				{
-					statement = con.prepareStatement("UPDATE fort_functions SET lvl=?, lease=?, endTime=? WHERE fort_id=? AND type=?");
-					statement.setInt(1, getLvl());
-					statement.setInt(2, getLease());
-					statement.setLong(3, getEndTime());
-					statement.setInt(4, getFortId());
-					statement.setInt(5, getType());
-				}
+				statement = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)");
+				statement.setInt(1, getFortId());
+				statement.setInt(2, getType());
+				statement.setInt(3, getLvl());
+				statement.setInt(4, getLease());
+				statement.setLong(5, getRate());
+				statement.setLong(6, getEndTime());
 				statement.execute();
 				statement.close();
 			}
 			catch (Exception e)
 			{
-				_log.log(Level.SEVERE, "Exception: Fort.updateFunctions(int type, int lvl, int lease, long rate, long time, boolean addNew): "
-						+ e.getMessage(), e);
+				_log.log(Level.SEVERE, "Exception: Fort.updateFunctions(int type, int lvl, int lease, long rate, long time, boolean addNew): " + e.getMessage(), e);
 			}
 			finally
 			{
@@ -745,7 +724,7 @@ public class Fort
 				{
 					_function.get(type).setLease(lease);
 					_function.get(type).setLvl(lvl);
-					_function.get(type).dbSave(false);
+					_function.get(type).dbSave();
 				}
 			}
 		}