Fixed offline trader issues.
This commit is contained in:
		| @@ -329,7 +329,7 @@ public class OfflineTraderTable | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public static synchronized void onTransaction(Player trader, boolean finished, boolean firstCall) | ||||
| 	public synchronized void onTransaction(Player trader, boolean finished, boolean firstCall) | ||||
| 	{ | ||||
| 		try (Connection con = DatabaseFactory.getConnection(); | ||||
| 			PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); | ||||
| @@ -340,14 +340,12 @@ public class OfflineTraderTable | ||||
| 			String title = null; | ||||
| 			stm1.setInt(1, trader.getObjectId()); // Char Id | ||||
| 			stm1.execute(); | ||||
| 			stm1.close(); | ||||
| 			 | ||||
| 			// Trade is done - clear info | ||||
| 			if (finished) | ||||
| 			{ | ||||
| 				stm2.setInt(1, trader.getObjectId()); // Char Id | ||||
| 				stm2.execute(); | ||||
| 				stm2.close(); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| @@ -425,7 +423,6 @@ public class OfflineTraderTable | ||||
| 								break; | ||||
| 							} | ||||
| 						} | ||||
| 						stm3.close(); | ||||
| 						if (firstCall) | ||||
| 						{ | ||||
| 							stm4.setInt(1, trader.getObjectId()); // Char Id | ||||
| @@ -434,23 +431,22 @@ public class OfflineTraderTable | ||||
| 							stm4.setString(4, title); | ||||
| 							stm4.executeUpdate(); | ||||
| 							stm4.clearParameters(); | ||||
| 							stm4.close(); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				catch (Exception e) | ||||
| 				{ | ||||
| 					LOGGER.log(Level.WARNING, "OfflineTradersTable[storeTradeItems()]: Error while saving offline trader: " + trader.getObjectId() + " " + e, e); | ||||
| 					LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error while saving offline trader: " + trader.getObjectId() + " " + e, e); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		catch (Exception e) | ||||
| 		{ | ||||
| 			LOGGER.log(Level.WARNING, "OfflineTradersTable[storeTradeItems()]: Error while saving offline traders: " + e, e); | ||||
| 			LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error while saving offline traders: " + e, e); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public static synchronized void removeTrader(int traderObjId) | ||||
| 	public synchronized void removeTrader(int traderObjId) | ||||
| 	{ | ||||
| 		World.OFFLINE_TRADE_COUNT--; | ||||
| 		 | ||||
| @@ -460,15 +456,13 @@ public class OfflineTraderTable | ||||
| 		{ | ||||
| 			stm1.setInt(1, traderObjId); | ||||
| 			stm1.execute(); | ||||
| 			stm1.close(); | ||||
| 			 | ||||
| 			stm2.setInt(1, traderObjId); | ||||
| 			stm2.execute(); | ||||
| 			stm2.close(); | ||||
| 		} | ||||
| 		catch (Exception e) | ||||
| 		{ | ||||
| 			LOGGER.log(Level.WARNING, "OfflineTradersTable[removeTrader()]: Error while removing offline trader: " + traderObjId + " " + e, e); | ||||
| 			LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Error while removing offline trader: " + traderObjId + " " + e, e); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -63,6 +63,7 @@ import org.l2jmobius.gameserver.data.ItemTable; | ||||
| import org.l2jmobius.gameserver.data.sql.CharNameTable; | ||||
| import org.l2jmobius.gameserver.data.sql.CharSummonTable; | ||||
| import org.l2jmobius.gameserver.data.sql.ClanTable; | ||||
| import org.l2jmobius.gameserver.data.sql.OfflineTraderTable; | ||||
| import org.l2jmobius.gameserver.data.xml.AdminData; | ||||
| import org.l2jmobius.gameserver.data.xml.AttendanceRewardData; | ||||
| import org.l2jmobius.gameserver.data.xml.CategoryData; | ||||
| @@ -4131,11 +4132,11 @@ public class Player extends Playable | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Send a Server->Client packet UserInfo to this Player and CharInfo to all Player in its _KnownPlayers. <b><u>Concept</u>:</b> Others Player in the detection area of the Player are identified in <b>_knownPlayers</b>. In order to inform other players of this | ||||
| 	 * Player state modifications, server just need to go through _knownPlayers to send Server->Client Packet <b><u> Actions</u>:</b> | ||||
| 	 * Send a Server->Client packet UserInfo to this Player and CharInfo to all Player in its _KnownPlayers. <b><u>Concept</u>:</b> Others Player in the detection area of the Player are identified in <b>_knownPlayers</b>. In order to inform other players of this Player state modifications, server | ||||
| 	 * just need to go through _knownPlayers to send Server->Client Packet <b><u> Actions</u>:</b> | ||||
| 	 * <li>Send a Server->Client packet UserInfo to this Player (Public and Private Data)</li> | ||||
| 	 * <li>Send a Server->Client packet CharInfo to all Player in _KnownPlayers of the Player (Public data only)</li> <font color=#FF0000><b><u>Caution</u>: DON'T SEND UserInfo packet to other players instead of CharInfo packet. Indeed, UserInfo packet contains PRIVATE DATA as MaxHP, | ||||
| 	 * STR, DEX...</b></font> | ||||
| 	 * <li>Send a Server->Client packet CharInfo to all Player in _KnownPlayers of the Player (Public data only)</li> <font color=#FF0000><b><u>Caution</u>: DON'T SEND UserInfo packet to other players instead of CharInfo packet. Indeed, UserInfo packet contains PRIVATE DATA as MaxHP, STR, | ||||
| 	 * DEX...</b></font> | ||||
| 	 */ | ||||
| 	public void broadcastUserInfo() | ||||
| 	{ | ||||
| @@ -5747,8 +5748,8 @@ public class Player extends Playable | ||||
| 		_privateStoreType = privateStoreType; | ||||
| 		if (Config.OFFLINE_DISCONNECT_FINISHED && (privateStoreType == PrivateStoreType.NONE) && ((_client == null) || _client.isDetached())) | ||||
| 		{ | ||||
| 			OfflineTraderTable.getInstance().removeTrader(getObjectId()); | ||||
| 			Disconnection.of(this).storeMe().deleteMe(); | ||||
| 			World.OFFLINE_TRADE_COUNT--; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -599,7 +599,7 @@ public class EnterWorld implements IClientIncomingPacket | ||||
| 		 | ||||
| 		if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.STORE_OFFLINE_TRADE_IN_REALTIME) | ||||
| 		{ | ||||
| 			OfflineTraderTable.onTransaction(player, true, false); | ||||
| 			OfflineTraderTable.getInstance().onTransaction(player, true, false); | ||||
| 		} | ||||
| 		 | ||||
| 		// Check if expoff is enabled. | ||||
|   | ||||
| @@ -153,7 +153,7 @@ public class RequestPrivateStoreBuy implements IClientIncomingPacket | ||||
| 		// Update offline trade record, if realtime saving is enabled | ||||
| 		if (Config.OFFLINE_TRADE_ENABLE && Config.STORE_OFFLINE_TRADE_IN_REALTIME && ((storePlayer.getClient() == null) || storePlayer.getClient().isDetached())) | ||||
| 		{ | ||||
| 			OfflineTraderTable.onTransaction(storePlayer, storeList.getItemCount() == 0, false); | ||||
| 			OfflineTraderTable.getInstance().onTransaction(storePlayer, storeList.getItemCount() == 0, false); | ||||
| 		} | ||||
| 		 | ||||
| 		if (storeList.getItemCount() == 0) | ||||
|   | ||||
| @@ -141,7 +141,7 @@ public class RequestPrivateStoreSell implements IClientIncomingPacket | ||||
| 		// Update offline trade record, if realtime saving is enabled | ||||
| 		if (Config.OFFLINE_TRADE_ENABLE && Config.STORE_OFFLINE_TRADE_IN_REALTIME && ((storePlayer.getClient() == null) || storePlayer.getClient().isDetached())) | ||||
| 		{ | ||||
| 			OfflineTraderTable.onTransaction(storePlayer, storeList.getItemCount() == 0, false); | ||||
| 			OfflineTraderTable.getInstance().onTransaction(storePlayer, storeList.getItemCount() == 0, false); | ||||
| 		} | ||||
| 		 | ||||
| 		if (storeList.getItemCount() == 0) | ||||
|   | ||||
| @@ -151,7 +151,7 @@ public class OfflineTradeUtil | ||||
| 		// Store trade on exit, if realtime saving is enabled. | ||||
| 		if (Config.STORE_OFFLINE_TRADE_IN_REALTIME) | ||||
| 		{ | ||||
| 			OfflineTraderTable.onTransaction(player, false, true); | ||||
| 			OfflineTraderTable.getInstance().onTransaction(player, false, true); | ||||
| 		} | ||||
| 		 | ||||
| 		player.storeMe(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment