JIV 15 years ago
parent
commit
fdc1bec6ea

+ 1 - 4
L2_GameServer/java/com/l2jserver/gameserver/GameServer.java

@@ -251,15 +251,12 @@ public class GameServer
 		
 		printSection("NPCs");
 		NpcTable.getInstance();
+		NpcWalkerRoutesTable.getInstance();
 		ZoneManager.getInstance();
 		DoorTable.getInstance();
 		StaticObjects.getInstance();
 		CastleManager.getInstance().loadInstances();
 		FortManager.getInstance().loadInstances();
-		if (Config.ALLOW_NPC_WALKERS)
-		{
-			NpcWalkerRoutesTable.getInstance().load();
-		}
 		NpcBufferTable.getInstance();
 		SpawnTable.getInstance();
 		RaidBossSpawnManager.getInstance();

+ 2 - 3
L2_GameServer/java/com/l2jserver/gameserver/ai/L2NpcWalkerAI.java

@@ -14,10 +14,9 @@
  */
 package com.l2jserver.gameserver.ai;
 
+import java.util.List;
 import java.util.logging.Level;
 
-import javolution.util.FastList;
-
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.datatables.NpcWalkerRoutesTable;
@@ -42,7 +41,7 @@ public class L2NpcWalkerAI extends L2CharacterAI implements Runnable
 	/**
 	 * route of the current npc
 	 */
-	private FastList<L2NpcWalkerNode> _route;
+	private List<L2NpcWalkerNode> _route;
 	
 	/**
 	 * current node

+ 23 - 18
L2_GameServer/java/com/l2jserver/gameserver/datatables/NpcWalkerRoutesTable.java

@@ -14,17 +14,20 @@
  */
 package com.l2jserver.gameserver.datatables;
 
+import gnu.trove.TIntObjectHashMap;
+
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.model.L2NpcWalkerNode;
 
-import javolution.util.FastList;
-
 /**
  * Main Table to Load Npc Walkers Routes and Chat SQL Table.<br>
  * 
@@ -37,7 +40,7 @@ public class NpcWalkerRoutesTable
 {
 	private final static Logger _log = Logger.getLogger(SpawnTable.class.getName());
 	
-	private FastList<L2NpcWalkerNode> _routes = new FastList<L2NpcWalkerNode>();
+	private TIntObjectHashMap<List<L2NpcWalkerNode>> _routes = new TIntObjectHashMap<List<L2NpcWalkerNode>>();
 	
 	public static NpcWalkerRoutesTable getInstance()
 	{
@@ -46,7 +49,11 @@ public class NpcWalkerRoutesTable
 	
 	private NpcWalkerRoutesTable()
 	{
-		_log.info("Initializing Walkers Routes Table.");
+		if (Config.ALLOW_NPC_WALKERS)
+		{
+			_log.info("Initializing Walkers Routes Table.");
+			load();
+		}
 	}
 	
 	public void load()
@@ -63,7 +70,8 @@ public class NpcWalkerRoutesTable
 			{
 				route = new L2NpcWalkerNode();
 				route.setRouteId(rset.getInt("route_id"));
-				route.setNpcId(rset.getInt("npc_id"));
+				int npcid = rset.getInt("npc_id");
+				route.setNpcId(npcid);
 				route.setMovePoint(rset.getString("move_point"));
 				route.setChatText(rset.getString("chatText"));
 				
@@ -73,12 +81,19 @@ public class NpcWalkerRoutesTable
 				route.setDelay(rset.getInt("delay"));
 				route.setRunning(rset.getBoolean("running"));
 				
-				_routes.add(route);
+				if (_routes.get(npcid) == null)
+				{
+					_routes.put(npcid, new ArrayList<L2NpcWalkerNode>());
+				}
+				_routes.get(npcid).add(route);
 			}
 			
 			rset.close();
 			statement.close();
 			
+			for (Object list : _routes.getValues())
+				((ArrayList<?>)list).trimToSize();
+			
 			_log.info("WalkerRoutesTable: Loaded " + _routes.size() + " Npc Walker Routes.");
 		}
 		catch (Exception e)
@@ -91,19 +106,9 @@ public class NpcWalkerRoutesTable
 		}
 	}
 	
-	public FastList<L2NpcWalkerNode> getRouteForNpc(int id)
+	public List<L2NpcWalkerNode> getRouteForNpc(int id)
 	{
-		FastList<L2NpcWalkerNode> _return = new FastList<L2NpcWalkerNode>();
-		
-		for (FastList.Node<L2NpcWalkerNode> n = _routes.head(), end = _routes.tail(); (n = n.getNext()) != end;)
-		{
-			if (n.getValue().getNpcId() == id)
-			{
-				_return.add(n.getValue());
-			}
-		}
-		return _return;
-		
+		return _routes.get(id);
 	}
 	
 	@SuppressWarnings("synthetic-access")