Procházet zdrojové kódy

Move-based knownlist update method as a config option (default now false). This is
the old and less CPU consuming method but including bug fixes from [1920] which
may increase CPU use when comparing to pre-[1920]. The knownlist-forget timing and
methods are still not optimal. See [1920] for some more info. The knownlist concept
requires more optimizations and concentration.

Sami před 17 roky
rodič
revize
28e95135e1

+ 8 - 1
L2_GameServer_T1/java/config/General.properties

@@ -249,9 +249,16 @@ MaxMonsterAnimation = 20
 #   1 - partial synchronization Client --> Server only * using this option it is difficult for players to bypass obstacles
 #   2 - partial synchronization Server --> Client only
 #   3 - full synchronization Client <--> Server
-#  -1 - Old system: will synchronize Z only
+#  -1 - Will synchronize Z only. Suggested with geodata.
 CoordSynchronize = -1
 
+# Knownlist (the list of things a character sees) update method. Default is currently
+# time based updating, which also makes it possible to use config options for guards 
+# to see moving monsters. Alternatively move based update can be used to cut down CPU
+# use. Guards cannot track mobs with that option but otherwise it should
+# work well. 
+MoveBasedKnownlist = False
+
 #============================================================#
 #                         Geodata                            #
 #============================================================#

+ 2 - 0
L2_GameServer_T1/java/net/sf/l2j/Config.java

@@ -339,6 +339,7 @@ public final class Config
     public static int		GRID_NEIGHBOR_TURNOFF_TIME;
     public static int		GEODATA;
     public static boolean	FORCE_GEODATA;
+    public static boolean 	MOVE_BASED_KNOWNLIST;
     public static int		ZONE_TOWN;
     public static boolean	ACTIVATE_POSITION_RECORDER;
     public static String	DEFAULT_GLOBAL_CHAT;
@@ -1391,6 +1392,7 @@ public final class Config
                 GRID_NEIGHBOR_TURNOFF_TIME					= Integer.parseInt(General.getProperty("GridNeighborTurnOffTime", "90"));
                 GEODATA										= Integer.parseInt(General.getProperty("GeoData", "0"));
                 FORCE_GEODATA								= Boolean.parseBoolean(General.getProperty("ForceGeoData", "True"));
+                MOVE_BASED_KNOWNLIST						= Boolean.parseBoolean(General.getProperty("MoveBasedKnownlist", "False"));
                 ZONE_TOWN									= Integer.parseInt(General.getProperty("ZoneTown", "0"));
                 ACTIVATE_POSITION_RECORDER					= Boolean.parseBoolean(General.getProperty("ActivatePositionRecorder", "False"));
                 DEFAULT_GLOBAL_CHAT							= General.getProperty("GlobalChat", "ON");

+ 4 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/GameTimeController.java

@@ -22,6 +22,7 @@ import java.util.logging.Logger;
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
+import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.ai.CtrlEvent;
 import net.sf.l2j.gameserver.instancemanager.DayNightSpawnManager;
 import net.sf.l2j.gameserver.model.L2Character;
@@ -228,7 +229,10 @@ public class GameTimeController
             try
             {
             	if (_ended.hasAI()) // AI could be just disabled due to region turn off
+            	{
+            		if (Config.MOVE_BASED_KNOWNLIST) _ended.getKnownList().findObjects();
             		_ended.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
+            	}
             }
             catch (NullPointerException e)
             {

+ 2 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/ai/L2PlayerAI.java

@@ -346,7 +346,8 @@ public class L2PlayerAI extends L2CharacterAI
     @Override
 	protected void onEvtArrivedRevalidate()
     {
-        super.onEvtArrivedRevalidate();
+    	if (Config.MOVE_BASED_KNOWNLIST) getActor().getKnownList().findObjects();
+    	super.onEvtArrivedRevalidate();
     }
 
 }

+ 1 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/L2Character.java

@@ -4166,6 +4166,7 @@ public abstract class L2Character extends L2Object
 			if (this instanceof L2PcInstance) ((L2PcInstance)this).revalidateZone(true);
 		}
 		sendPacket(new StopMove(this));
+		if (Config.MOVE_BASED_KNOWNLIST) this.getKnownList().findObjects();
 	}
 
 

+ 39 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/actor/knownlist/ObjectKnownList.java

@@ -17,9 +17,12 @@ package net.sf.l2j.gameserver.model.actor.knownlist;
 import java.util.Map;
 
 import javolution.util.FastMap;
+import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.model.L2Character;
 import net.sf.l2j.gameserver.model.L2Object;
+import net.sf.l2j.gameserver.model.L2WorldRegion;
 import net.sf.l2j.gameserver.model.actor.instance.L2BoatInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2GuardInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
 import net.sf.l2j.gameserver.util.Util;
@@ -66,6 +69,42 @@ public class ObjectKnownList
     	return (getKnownObjects().remove(object.getObjectId()) != null);
     }
 
+    // used only in Config.MOVE_BASED_KNOWNLIST and does not support guards seeing
+    // moving monsters
+    public final void findObjects()
+    {
+    	L2WorldRegion region = getActiveObject().getWorldRegion();
+    	if (region == null) return;
+    	
+    	if (getActiveObject() instanceof L2PlayableInstance)
+    	{
+    		for (L2WorldRegion regi : region.getSurroundingRegions()) // offer members of this and surrounding regions
+    		{
+    			for (L2Object _object : regi.getVisibleObjects()) 
+    			{
+    				if (_object != getActiveObject())
+    				{
+    					addKnownObject(_object);
+    					if (_object instanceof L2Character) _object.getKnownList().addKnownObject(getActiveObject());
+    				}
+    			}
+    		}
+    	}
+    	else if (getActiveObject() instanceof L2Character)
+    	{
+    		for (L2WorldRegion regi : region.getSurroundingRegions()) // offer members of this and surrounding regions
+    		{
+    			if (regi.isActive()) for (L2Object _object : regi.getVisiblePlayable()) 
+    			{
+    				if (_object != getActiveObject())
+    				{
+    					addKnownObject(_object);
+    				}
+    			}
+    		}
+    	}
+    }
+    
     // Remove invisible and too far L2Object from _knowObject and if necessary from _knownPlayers of the L2Character
     public final void forgetObjects(boolean fullCheck)
     {

+ 15 - 6
L2_GameServer_T1/java/net/sf/l2j/gameserver/taskmanager/KnownListUpdateTaskManager.java

@@ -34,7 +34,10 @@ public class KnownListUpdateTaskManager
 
     public KnownListUpdateTaskManager()
     {
-    	ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new KnownListUpdate(),1000,750);
+    	if (Config.MOVE_BASED_KNOWNLIST)
+    		ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new KnownListUpdate(),1000,2500);
+    	else
+    		ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new KnownListUpdate(),1000,750);
     }
 
     public static KnownListUpdateTaskManager getInstance()
@@ -47,11 +50,15 @@ public class KnownListUpdateTaskManager
 
     private class KnownListUpdate implements Runnable
     {
-    	boolean toggle = false;
+    	boolean forgetObjects;
     	boolean fullUpdate = true;
     	protected KnownListUpdate()
     	{
-    		// Do nothing
+    		if (Config.MOVE_BASED_KNOWNLIST)
+    			forgetObjects = true;
+    		else
+    			forgetObjects = false;
+    		
     	}
 
         public void run()
@@ -64,12 +71,14 @@ public class KnownListUpdateTaskManager
             		{
             			if (r.isActive()) // and check only if the region is active
             			{
-        					updateRegion(r, fullUpdate, toggle);
+        					updateRegion(r, fullUpdate, forgetObjects);
             			}
             		}
             	}
-            	if (toggle) toggle = false;
-            	else toggle = true;
+            	if (forgetObjects && !Config.MOVE_BASED_KNOWNLIST) 
+            		forgetObjects = false;
+            	else 
+            		forgetObjects = true;
             	if (fullUpdate)
             		fullUpdate = false;