All pastes #911054 Raw Edit

Stuff

public diff v1 · immutable
·published 2008-02-20 13:31 UTC
rendered paste body
Index: D:/dev/L2_GameServer_t1_clean/java/net/sf/l2j/gameserver/GameTimeController.java===================================================================--- D:/dev/L2_GameServer_t1_clean/java/net/sf/l2j/gameserver/GameTimeController.java	(revision 1711)+++ D:/dev/L2_GameServer_t1_clean/java/net/sf/l2j/gameserver/GameTimeController.java	(working copy)@@ -16,10 +16,12 @@  import java.text.SimpleDateFormat; import java.util.Date;+import java.util.Map; import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger;  import javolution.util.FastList;+import javolution.util.FastMap; import net.sf.l2j.gameserver.ai.CtrlEvent; import net.sf.l2j.gameserver.instancemanager.DayNightSpawnManager; import net.sf.l2j.gameserver.model.L2Character;@@ -42,7 +44,7 @@ 	protected static long _gameStartTime; 	protected static boolean _isNight = false; -	private static FastList<L2Character> _movingObjects = new FastList<L2Character>();+	private static Map<Integer,L2Character> _movingObjects = new FastMap<Integer,L2Character>().setShared(true);  	protected static TimerThread _timer; 	private ScheduledFuture<?> _timerWatcher;@@ -95,10 +97,7 @@ 	public void registerMovingObject(L2Character cha) 	{ 		if(cha == null) return;-		synchronized (_movingObjects)-        {-		    if (!_movingObjects.contains(cha)) _movingObjects.add(cha);   -        }+		    if (!_movingObjects.containsKey(cha.getObjectId())) _movingObjects.put(cha.getObjectId(),cha);    	}  	/**@@ -120,35 +119,29 @@         FastList<L2Character> ended = null;                  // Go throw the table containing L2Character in movement-        synchronized (_movingObjects)-        {-            for (FastList.Node<L2Character> ch = _movingObjects.head(), e = _movingObjects.tail(); (ch = ch.getNext()) != e;)+            for (L2Character ch: _movingObjects.values())             {-                -                L2Character cha = ch.getValue();-                                 // If movement is finished, the L2Character is removed from                 // movingObjects and added to the ArrayList ended-                if (cha != null)-                    if (cha.updatePosition(_gameTicks))+                if (ch != null)+                    if (ch.updatePosition(_gameTicks))                     {-                        ch = ch.getPrevious();-                        _movingObjects.remove(cha);                         if (ended == null)                             ended = new FastList<L2Character>();                         -                        ended.add(cha);+                        ended.add(ch);                     }             }-        }+            if (ended != null) _movingObjects.values().removeAll(ended); 		// Create a task to update the _knownObject and _knowPlayers of each L2Character that finished its movement and of their already known L2Object 		// then notify AI with EVT_ARRIVED         // KnownObjects updates is kinda expensive operation, so i splited tasks to avoid blocking of too many parts of code (Julian) 		// TODO: maybe a general TP is needed for that kinda stuff (all knownlist updates should be done in a TP anyway). 		if (ended != null) 		{-		    for (FastList.Node<L2Character> ch = ended.head(), e = ended.tail(); (ch = ch.getNext()) != e;)-		        ThreadPoolManager.getInstance().executeTask(new MovingObjectArrived(ch.getValue()));+		    for (L2Character ch: ended)+		    	if (ch != null) // Disconnected?+		    		ThreadPoolManager.getInstance().executeTask(new MovingObjectArrived(ch)); 		    ended.clear(); 		} @@ -203,6 +196,7 @@ 			catch (Exception e) 			{ 				_error = e;+				e.printStackTrace(); 			} 		} 	}@@ -244,6 +238,7 @@             }             catch (NullPointerException e)             {+            	e.printStackTrace();             }         }     }