Browse Source

Option for store Dwarven Manufacture shoplist. Thx Gnacik. Req [DP6824]

JIV 15 years ago
parent
commit
8345debb0e

+ 2 - 0
L2_GameServer/java/com/l2jserver/Config.java

@@ -193,6 +193,7 @@ public final class Config
 	public static int PARTY_XP_CUTOFF_LEVEL;
 	public static boolean DISABLE_TUTORIAL;
 	public static boolean EXPERTISE_PENALTY;
+	public static boolean STORE_RECIPE_SHOPLIST;
 
 	//--------------------------------------------------
 	// ClanHall Settings
@@ -1421,6 +1422,7 @@ public final class Config
 					PARTY_XP_CUTOFF_LEVEL = Integer.parseInt(Character.getProperty("PartyXpCutoffLevel", "30"));
 					DISABLE_TUTORIAL = Boolean.parseBoolean(Character.getProperty("DisableTutorial", "False"));
 					EXPERTISE_PENALTY = Boolean.parseBoolean(Character.getProperty("ExpertisePenalty", "True"));
+					STORE_RECIPE_SHOPLIST = Boolean.parseBoolean(Character.getProperty("StoreRecipeShopList", "False"));
 				}
 				catch (Exception e)
 				{

+ 3 - 0
L2_GameServer/java/com/l2jserver/gameserver/idfactory/IdFactory.java

@@ -42,6 +42,7 @@ public abstract class IdFactory
 	        "UPDATE character_friends     SET friendId = ?   WHERE friendId = ?",
 	        "UPDATE character_hennas      SET charId = ? WHERE charId = ?",
 	        "UPDATE character_recipebook  SET charId = ? WHERE charId = ?",
+	        "UPDATE character_recipeshoplist  SET charId = ? WHERE charId = ?",
 	        "UPDATE character_shortcuts   SET charId = ? WHERE charId = ?",
 	        "UPDATE character_shortcuts   SET shortcut_id = ? WHERE shortcut_id = ? AND type = 1", // items
 	        "UPDATE character_macroses    SET charId = ? WHERE charId = ?",
@@ -69,6 +70,7 @@ public abstract class IdFactory
 	        "SELECT charId     FROM character_friends     WHERE friendId >= ?   AND friendId < ?",
 	        "SELECT charId     FROM character_hennas      WHERE charId >= ? AND charId < ?",
 	        "SELECT charId     FROM character_recipebook  WHERE charId >= ?     AND charId < ?",
+	        "SELECT charId     FROM character_recipeshoplist  WHERE charId >= ?     AND charId < ?",
 	        "SELECT charId     FROM character_shortcuts   WHERE charId >= ? AND charId < ?",
 	        "SELECT charId     FROM character_macroses    WHERE charId >= ? AND charId < ?",
 	        "SELECT charId     FROM character_skills      WHERE charId >= ? AND charId < ?",
@@ -193,6 +195,7 @@ public abstract class IdFactory
 			cleanCount += stmt.executeUpdate("DELETE FROM character_macroses WHERE character_macroses.charId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_quests WHERE character_quests.charId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_recipebook WHERE character_recipebook.charId NOT IN (SELECT charId FROM characters);");
+			cleanCount += stmt.executeUpdate("DELETE FROM character_recipeshoplist WHERE character_recipeshoplist.charId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_shortcuts WHERE character_shortcuts.charId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_skills WHERE character_skills.charId NOT IN (SELECT charId FROM characters);");
 			cleanCount += stmt.executeUpdate("DELETE FROM character_skills_save WHERE character_skills_save.charId NOT IN (SELECT charId FROM characters);");

+ 92 - 0
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -100,6 +100,7 @@ import com.l2jserver.gameserver.model.L2Fishing;
 import com.l2jserver.gameserver.model.L2HennaInstance;
 import com.l2jserver.gameserver.model.L2ItemInstance;
 import com.l2jserver.gameserver.model.L2Macro;
+import com.l2jserver.gameserver.model.L2ManufactureItem;
 import com.l2jserver.gameserver.model.L2ManufactureList;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Party;
@@ -7554,6 +7555,10 @@ public final class L2PcInstance extends L2Playable
 
 		// Retrieve from the database the recipe book of this L2PcInstance.
 		restoreRecipeBook(true);
+		
+		// Restore Recipe Shop list
+		if(Config.STORE_RECIPE_SHOPLIST)
+			restoreRecipeShopList();
 	}
 
 	/**
@@ -7619,6 +7624,8 @@ public final class L2PcInstance extends L2Playable
 		storeCharSub();
 		storeEffect(storeActiveEffects);
 		transformInsertInfo();
+		if(Config.STORE_RECIPE_SHOPLIST)
+			storeRecipeShopList();
 	}
 	
 	public void store()
@@ -14448,6 +14455,91 @@ public final class L2PcInstance extends L2Playable
 		_silenceMode = mode;
 		sendPacket(new EtcStatusUpdate(this));
 	}
+	
+	private void storeRecipeShopList()
+	{
+		Connection con = null;
 
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement;
+			L2ManufactureList list = getCreateList();
 
+			if (list != null && list.size() > 0)
+			{
+				int	_position = 1;
+				statement = con.prepareStatement("DELETE FROM character_recipeshoplist WHERE charId=? ");
+				statement.setInt(1, getObjectId());
+				statement.execute();
+				statement.close();
+				for (L2ManufactureItem item : list.getList())
+				{
+					statement = con.prepareStatement("INSERT INTO character_recipeshoplist (charId, Recipeid, Price, Pos) VALUES (?, ?, ?, ?)");
+					statement.setInt(1, getObjectId());	
+					statement.setInt(2, item.getRecipeId());
+					statement.setLong(3, item.getCost());
+					statement.setInt(4, _position);
+					statement.execute();
+					statement.close();
+					_position++;
+				}
+			}
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Could not store recipe shop for playerID " + getObjectId() + ": ", e);
+		}
+		finally
+		{
+			try
+			{
+				if (con != null)
+					con.close();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	private void restoreRecipeShopList()
+	{
+		Connection con = null;
+
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("SELECT Recipeid,Price FROM character_recipeshoplist WHERE charId=? ORDER BY Pos ASC");
+			statement.setInt(1, getObjectId());
+			ResultSet rset = statement.executeQuery();
+			
+			
+			L2ManufactureList createList = new L2ManufactureList();
+			while (rset.next())
+			{
+				createList.add(new L2ManufactureItem(rset.getInt("Recipeid"), rset.getLong("Price")));
+			}
+			setCreateList(createList);
+			rset.close();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "Could not restore recipe shop list data for playerId: "+getObjectId(), e);
+		}
+		finally
+		{
+			try
+			{
+				if (con != null)
+					con.close();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+		}
+	}
 }

+ 9 - 9
L2_GameServer/java/com/l2jserver/gameserver/network/serverpackets/RecipeShopManageList.java

@@ -42,15 +42,15 @@ public class RecipeShopManageList  extends L2GameServerPacket
 			_recipes = _seller.getCommonRecipeBook();
 
 		// clean previous recipes
-        if (_seller.getCreateList() != null)
-        {
-            L2ManufactureList list = _seller.getCreateList();
-            for (L2ManufactureItem item : list.getList())
-            {
-            	if (item.isDwarven() != _isDwarven)
-            		list.getList().remove(item);
-            }
-        }
+		if (_seller.getCreateList() != null)
+		{
+			L2ManufactureList list = _seller.getCreateList();
+			for (L2ManufactureItem item : list.getList())
+			{
+				if (item.isDwarven() != _isDwarven || !seller.hasRecipeList(item.getRecipeId()))
+					list.getList().remove(item);
+			}
+		}
 	}
 
 	@Override

+ 4 - 0
L2_GameServer/java/config/Character.properties

@@ -437,6 +437,10 @@ AltGameCreationRareXpSpRate = 2
 # Default: True
 AltBlacksmithUseRecipes = True
 
+# Store/Restore Dwarven Manufacture list
+# Keep manufacture shoplist after relog
+# Default: False
+StoreRecipeShopList = False
 
 # ---------------------------------------------------------------------------
 # Clan