Browse Source

Remove unused config.
Some check on reduceAdena
Iterator remove for moving objects.

JIV 15 years ago
parent
commit
3a85762d41

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

@@ -843,8 +843,6 @@ public final class Config
 	public static int MMO_MAX_SEND_PER_PASS;
 	public static int MMO_MAX_READ_PER_PASS;
 	public static int MMO_HELPER_BUFFER_COUNT;
-	public static int MMO_IO_SELECTOR_THREAD_COUNT;
-
 
 	//--------------------------------------------------
 	// Vitality Settings
@@ -1571,7 +1569,6 @@ public final class Config
 					is = new FileInputStream(new File(MMO_CONFIG_FILE));
 					mmoSettings.load(is);
 					MMO_SELECTOR_SLEEP_TIME = Integer.parseInt(mmoSettings.getProperty("SleepTime", "20"));
-					MMO_IO_SELECTOR_THREAD_COUNT = Integer.parseInt(mmoSettings.getProperty("IOSelectorThreadCount", "2"));
 					MMO_MAX_SEND_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxSendPerPass", "12"));
 					MMO_MAX_READ_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxReadPerPass", "12"));
 					MMO_HELPER_BUFFER_COUNT = Integer.parseInt(mmoSettings.getProperty("HelperBufferCount", "20"));
@@ -2548,7 +2545,6 @@ public final class Config
 					is = new FileInputStream(new File(MMO_CONFIG_FILE));
 					mmoSettings.load(is);
 					MMO_SELECTOR_SLEEP_TIME = Integer.parseInt(mmoSettings.getProperty("SleepTime", "20"));
-					MMO_IO_SELECTOR_THREAD_COUNT = Integer.parseInt(mmoSettings.getProperty("IOSelectorThreadCount", "2"));
 					MMO_MAX_SEND_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxSendPerPass", "12"));
 					MMO_MAX_READ_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxReadPerPass", "12"));
 					MMO_HELPER_BUFFER_COUNT = Integer.parseInt(mmoSettings.getProperty("HelperBufferCount", "20"));

+ 8 - 33
L2_GameServer/java/com/l2jserver/gameserver/GameTimeController.java

@@ -14,16 +14,16 @@
  */
 package com.l2jserver.gameserver;
 
+import java.util.Iterator;
 import java.util.logging.Logger;
 
+import javolution.util.FastMap;
+
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.ai.CtrlEvent;
 import com.l2jserver.gameserver.instancemanager.DayNightSpawnManager;
 import com.l2jserver.gameserver.model.actor.L2Character;
 
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
 /**
  * Removed TimerThread watcher [DrHouse]
  *
@@ -42,7 +42,6 @@ public class GameTimeController
 	protected static boolean _interruptRequest = false;
 	
 	private static final FastMap<Integer, L2Character> _movingObjects = new FastMap<Integer, L2Character>().shared();
-	private static final FastList<L2Character> _toDelete = new FastList<L2Character>(20);
 	
 	protected static TimerThread _timer;
 	
@@ -113,42 +112,18 @@ public class GameTimeController
 	protected void moveObjects()
 	{
 		// Go throw the table containing L2Character in movement
-		for (L2Character ch : _movingObjects.values())
+		Iterator<L2Character> it = _movingObjects.values().iterator();
+		while (it.hasNext())
 		{
 			// If movement is finished, the L2Character is removed from
 			// movingObjects and added to the ArrayList ended
+			L2Character ch = it.next();
 			if (ch.updatePosition(_gameTicks))
-				_toDelete.add(ch);				
-		}
-		
-		if (_toDelete.isEmpty())
-			return;
-		
-		/*
-		 * Synchronizing on _movingObjects since this map is set as shared so,
-		 * on every write operation (add/remove) there is already an internal 
-		 * synchronization. This way we avoid the time that every remove()
-		 * call would have to wait until acquiring _movingObjects lock due to
-		 * concurrent writes.
-		 * 
-		 * TODO: Possibly this could be done on the fly, removing while iterating over
-		 * the map, without using any extra list.
-		 * 
-		 * TODO: On the other hand, perhaps we could avoid executing some MovingObjectArrived
-		 * tasks performing some checks in this thread (during loop): for instance,
-		 * only execute it if AI think() will be eventually run.
-		 *   
-		 * [DrHouse]
-		 */
-		synchronized (_movingObjects)
-		{
-			for (L2Character ch : _toDelete)
 			{
-				_movingObjects.remove(ch.getObjectId());
-				ThreadPoolManager.getInstance().executeTask(new MovingObjectArrived(ch));			
+				ThreadPoolManager.getInstance().executeTask(new MovingObjectArrived(ch));
+				it.remove();
 			}
 		}
-		_toDelete.clear();
 	}
 	
 	public void stopTimer()

+ 37 - 35
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -3320,7 +3320,8 @@ public final class L2PcInstance extends L2Playable
 		if (count > 0)
 		{
 			L2ItemInstance adenaItem = _inventory.getAdenaInstance();
-			_inventory.reduceAdena(process, count, this, reference);
+			if (!_inventory.reduceAdena(process, count, this, reference))
+				return false;
 
 			// Send update packet
 			if (!Config.FORCE_INVENTORY_UPDATE)
@@ -3384,40 +3385,41 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public boolean reduceAncientAdena(String process, long count, L2Object reference, boolean sendMessage)
 	{
-	    if (count > getAncientAdena())
-	    {
-	        if (sendMessage)
-	            sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
-
-	        return false;
-	    }
-
-	    if (count > 0)
-	    {
-	        L2ItemInstance ancientAdenaItem = _inventory.getAncientAdenaInstance();
-	        _inventory.reduceAncientAdena(process, count, this, reference);
-
-	        if (!Config.FORCE_INVENTORY_UPDATE)
-	        {
-	            InventoryUpdate iu = new InventoryUpdate();
-	            iu.addItem(ancientAdenaItem);
-	            sendPacket(iu);
-	        }
-	        else
-	        {
-	            sendPacket(new ItemList(this, false));
-	        }
-
-	        if (sendMessage)
-	        {
-	            SystemMessage sm = new SystemMessage(SystemMessageId.S2_S1_DISAPPEARED);
-	            sm.addItemName(PcInventory.ANCIENT_ADENA_ID);
-	            sm.addItemNumber(count);
-	            sendPacket(sm);
-	        }
-	    }
-
-	    return true;
+		if (count > getAncientAdena())
+		{
+			if (sendMessage)
+				sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
+			
+			return false;
+		}
+		
+		if (count > 0)
+		{
+			L2ItemInstance ancientAdenaItem = _inventory.getAncientAdenaInstance();
+			if (!_inventory.reduceAncientAdena(process, count, this, reference))
+				return false;
+			
+			if (!Config.FORCE_INVENTORY_UPDATE)
+			{
+				InventoryUpdate iu = new InventoryUpdate();
+				iu.addItem(ancientAdenaItem);
+				sendPacket(iu);
+			}
+			else
+			{
+				sendPacket(new ItemList(this, false));
+			}
+			
+			if (sendMessage)
+			{
+				SystemMessage sm = new SystemMessage(SystemMessageId.S2_S1_DISAPPEARED);
+				sm.addItemName(PcInventory.ANCIENT_ADENA_ID);
+				sm.addItemNumber(count);
+				sendPacket(sm);
+			}
+		}
+		
+		return true;
 	}
 
 	/**