Kaynağa Gözat

BETA: Reworking GameTimeController (Now's less CPU Hungry, no more synchronizations, no more time diff)
* Patch by: Forsaiken
* Thanks to: nBd

Rumen Nikiforov 12 yıl önce
ebeveyn
işleme
a71dbb4f59
21 değiştirilmiş dosya ile 357 ekleme ve 260 silme
  1. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java
  2. 147 187
      L2J_Server_BETA/java/com/l2jserver/gameserver/GameTimeController.java
  3. 3 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/ai/AbstractAI.java
  4. 5 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java
  5. 2 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2CharacterAI.java
  6. 7 7
      L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2FortSiegeGuardAI.java
  7. 7 7
      L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2SiegeGuardAI.java
  8. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/HitConditionBonus.java
  9. 2 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/DayNightSpawnManager.java
  10. 2 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2Party.java
  11. 15 15
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java
  12. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Summon.java
  13. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Vehicle.java
  14. 15 15
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  15. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/conditions/ConditionGameTime.java
  16. 3 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/L2Effect.java
  17. 3 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/itemcontainer/ItemContainer.java
  18. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java
  19. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/UseItem.java
  20. 2 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/util/FloodProtectorAction.java
  21. 137 0
      L2J_Server_BETA/java/com/l2jserver/util/StackTrace.java

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java

@@ -201,7 +201,7 @@ public class GameServer
 		
 		printSection("World");
 		// start game time control early
-		GameTimeController.getInstance();
+		GameTimeController.init();
 		InstanceManager.getInstance();
 		L2World.getInstance();
 		MapRegionManager.getInstance();

+ 147 - 187
L2J_Server_BETA/java/com/l2jserver/gameserver/GameTimeController.java

@@ -18,280 +18,240 @@
  */
 package com.l2jserver.gameserver;
 
-import java.util.concurrent.locks.ReentrantLock;
+import java.util.Calendar;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javolution.util.FastMap;
+
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.ai.CtrlEvent;
+import com.l2jserver.gameserver.ai.L2CharacterAI;
 import com.l2jserver.gameserver.instancemanager.DayNightSpawnManager;
 import com.l2jserver.gameserver.model.actor.L2Character;
-
-import gnu.trove.map.hash.TIntObjectHashMap;
-import gnu.trove.procedure.TObjectProcedure;
+import com.l2jserver.util.StackTrace;
 
 /**
- * Removed TimerThread watcher [DrHouse]<br>
- * One in-game day is 240 real minutes.
- * @version $Date: 2010/02/02 22:43:00 $
+ * @author Unknown, Forsaiken
  */
-public class GameTimeController
+public final class GameTimeController extends Thread
 {
-	protected static final Logger _log = Logger.getLogger(GameTimeController.class.getName());
+	static final Logger _log = Logger.getLogger(GameTimeController.class.getName());
 	
 	public static final int TICKS_PER_SECOND = 10; // not able to change this without checking through code
 	public static final int MILLIS_IN_TICK = 1000 / TICKS_PER_SECOND;
+	public static final int IG_DAYS_PER_DAY = 6;
+	public static final int MILLIS_PER_IG_DAY = (1000 * 60 * 60 * 24) / IG_DAYS_PER_DAY;
+	public static final int SECONDS_PER_IG_DAY = MILLIS_PER_IG_DAY / 1000;
+	public static final int MINUTES_PER_IG_DAY = SECONDS_PER_IG_DAY / 60;
+	public static final int TICKS_PER_IG_DAY = SECONDS_PER_IG_DAY * TICKS_PER_SECOND;
+	public static final int TICKS_SUN_STATE_CHANGE = TICKS_PER_IG_DAY / 4;
 	
-	protected static int _gameTicks;
-	protected static long _gameStartTime;
-	protected static boolean _isNight = false;
-	protected static boolean _interruptRequest = false;
-	
-	protected static final TIntObjectHashMap<L2Character> _movingObjects = new TIntObjectHashMap<>();
-	private static final ReentrantLock _lock = new ReentrantLock();
+	private static GameTimeController _instance;
 	
-	protected static TimerThread _timer;
+	public static final void init()
+	{
+		_instance = new GameTimeController();
+	}
 	
-	/**
-	 * Gets the single instance of GameTimeController.
-	 * @return single instance of GameTimeController
-	 */
-	public static GameTimeController getInstance()
+	public static final GameTimeController getInstance()
 	{
-		return SingletonHolder._instance;
+		return _instance;
 	}
 	
-	/**
-	 * Instantiates a new game time controller.
-	 */
-	protected GameTimeController()
+	private final FastMap<Integer, L2Character> _movingObjects;
+	private final long _referenceTime;
+	
+	private GameTimeController()
 	{
-		_gameStartTime = System.currentTimeMillis() - 3600000; // offset so that the server starts a day begin
-		_gameTicks = 3600000 / MILLIS_IN_TICK; // offset so that the server starts a day begin
+		super("GameTimeController");
+		super.setDaemon(true);
+		super.setPriority(MAX_PRIORITY);
 		
-		_timer = new TimerThread();
-		_timer.start();
+		_movingObjects = new FastMap<Integer, L2Character>().shared();
 		
-		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new BroadcastSunState(), 0, 600000);
+		final Calendar c = Calendar.getInstance();
+		c.set(Calendar.HOUR_OF_DAY, 0);
+		c.set(Calendar.MINUTE, 0);
+		c.set(Calendar.SECOND, 0);
+		c.set(Calendar.MILLISECOND, 0);
+		_referenceTime = c.getTimeInMillis();
 		
+		super.start();
 	}
 	
-	/**
-	 * Checks if is now night.
-	 * @return true, if is now night
-	 */
-	public boolean isNowNight()
+	public final int getGameTime()
 	{
-		return _isNight;
+		return (getGameTicks() % TICKS_PER_IG_DAY) / MILLIS_IN_TICK;
 	}
 	
-	/**
-	 * Gets the game time.
-	 * @return the game time
-	 */
-	public int getGameTime()
+	public final int getGameHour()
+	{
+		return getGameTime() / 60;
+	}
+	
+	public final int getGameMinute()
 	{
-		return (_gameTicks / (TICKS_PER_SECOND * 10));
+		return getGameTime() % 60;
+	}
+	
+	public final boolean isNight()
+	{
+		return getGameHour() < 6;
 	}
 	
 	/**
-	 * Gets the game ticks.
-	 * @return the game ticks
+	 * The true GameTime tick. Directly taken from current time. This represents the tick of the time.
+	 * @return
 	 */
-	public static int getGameTicks()
+	public final int getGameTicks()
 	{
-		return _gameTicks;
+		return (int) ((System.currentTimeMillis() - _referenceTime) / MILLIS_IN_TICK);
 	}
 	
 	/**
-	 * Add a L2Character to movingObjects of GameTimeController.<br>
-	 * All characters in movement are identified in <b>movingObjects</b> of GameTimeController.
-	 * @param cha the character to add to movingObjects of GameTimeController
+	 * Add a L2Character to movingObjects of GameTimeController.<BR>
+	 * <BR>
+	 * <B><U> Concept</U> :</B><BR>
+	 * <BR>
+	 * All L2Character in movement are identified in <B>movingObjects</B> of GameTimeController.<BR>
+	 * <BR>
+	 * @param cha The L2Character to add to movingObjects of GameTimeController
 	 */
-	public void registerMovingObject(L2Character cha)
+	public final void registerMovingObject(final L2Character cha)
 	{
 		if (cha == null)
 		{
 			return;
 		}
 		
-		_lock.lock();
-		try
-		{
-			_movingObjects.putIfAbsent(cha.getObjectId(), cha);
-		}
-		finally
-		{
-			_lock.unlock();
-		}
+		_movingObjects.putIfAbsent(cha.getObjectId(), cha);
 	}
 	
 	/**
-	 * Move all characters contained in movingObjects of GameTimeController.<br>
-	 * All characters in movement are identified in <b>movingObjects</b> of GameTimeController.<br>
-	 * <b><u> Actions</u> :</b><br>
+	 * Move all L2Characters contained in movingObjects of GameTimeController.<BR>
+	 * <BR>
+	 * <B><U> Concept</U> :</B><BR>
+	 * <BR>
+	 * All L2Character in movement are identified in <B>movingObjects</B> of GameTimeController.<BR>
+	 * <BR>
+	 * <B><U> Actions</U> :</B><BR>
+	 * <BR>
 	 * <li>Update the position of each L2Character</li> <li>If movement is finished, the L2Character is removed from movingObjects</li> <li>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</li>
+	 * EVT_ARRIVED</li><BR>
+	 * <BR>
 	 */
-	protected void moveObjects()
+	private final void moveObjects()
 	{
-		_lock.lock();
-		try
-		{
-			_movingObjects.forEachValue(new MoveObjects());
-		}
-		finally
+		L2Character character;
+		for (FastMap.Entry<Integer, L2Character> e = _movingObjects.head(), tail = _movingObjects.tail(); (e = e.getNext()) != tail;)
 		{
-			_lock.unlock();
-		}
-	}
-	
-	protected final class MoveObjects implements TObjectProcedure<L2Character>
-	{
-		@Override
-		public final boolean execute(final L2Character ch)
-		{
-			if (ch.updatePosition(_gameTicks))
+			character = e.getValue();
+			
+			if (character.updatePosition(getGameTicks()))
 			{
-				// If movement is finished, the L2Character is removed from
-				// movingObjects and added to the ArrayList ended
-				_movingObjects.remove(ch.getObjectId());
-				ThreadPoolManager.getInstance().executeTask(new MovingObjectArrived(ch));
+				// Destination reached. Remove from map and execute arrive event.
+				_movingObjects.remove(e.getKey());
+				fireCharacterArrived(character);
 			}
-			return true;
 		}
 	}
 	
-	/**
-	 * Stop timer.
-	 */
-	public void stopTimer()
-	{
-		_interruptRequest = true;
-		_timer.interrupt();
-	}
-	
-	class TimerThread extends Thread
+	private final void fireCharacterArrived(final L2Character character)
 	{
-		/**
-		 * Instantiates a new timer thread.
-		 */
-		public TimerThread()
+		final L2CharacterAI ai = character.getAI();
+		if (ai == null)
 		{
-			super("GameTimeController");
-			setDaemon(true);
-			setPriority(MAX_PRIORITY);
+			return;
 		}
 		
-		@Override
-		public void run()
+		ThreadPoolManager.getInstance().executeTask(new Runnable()
 		{
-			int oldTicks;
-			long runtime;
-			int sleepTime;
-			
-			for (;;)
+			@Override
+			public final void run()
 			{
 				try
 				{
-					oldTicks = _gameTicks; // save old ticks value to avoid moving objects 2x in same tick
-					runtime = System.currentTimeMillis() - _gameStartTime; // from server boot to now
-					
-					_gameTicks = (int) (runtime / MILLIS_IN_TICK); // new ticks value (ticks now)
-					
-					if (oldTicks != _gameTicks)
-					{
-						moveObjects(); // Runs possibly too often
-					}
-					
-					runtime = (System.currentTimeMillis() - _gameStartTime) - runtime;
-					
-					// calculate sleep time... time needed to next tick minus time it takes to call moveObjects()
-					sleepTime = (1 + MILLIS_IN_TICK) - (((int) runtime) % MILLIS_IN_TICK);
-					
-					// _log.finest("TICK: "+_gameTicks);
-					
-					if (sleepTime > 0)
-					{
-						Thread.sleep(sleepTime);
-					}
-				}
-				catch (InterruptedException ie)
-				{
-					if (_interruptRequest)
+					if (Config.MOVE_BASED_KNOWNLIST)
 					{
-						return;
+						character.getKnownList().findObjects();
 					}
 					
-					_log.log(Level.WARNING, "", ie);
+					ai.notifyEvent(CtrlEvent.EVT_ARRIVED);
 				}
-				catch (Exception e)
+				catch (final Throwable e)
 				{
-					_log.log(Level.WARNING, "", e);
+					StackTrace.displayStackTraceInformation(e);
 				}
 			}
-		}
+		});
 	}
 	
-	/**
-	 * Update the _knownObject and _knowPlayers of each L2Character that finished its movement and of their already known L2Object then notify AI with EVT_ARRIVED.
-	 */
-	private static class MovingObjectArrived implements Runnable
+	public final void stopTimer()
+	{
+		super.interrupt();
+		System.out.println("Stopping GameTimeController.");
+	}
+	
+	@Override
+	public final void run()
 	{
-		private final L2Character _ended;
+		_log.log(Level.CONFIG, "GameClientController: Started.");
+		
+		long nextTickTime, sleepTime;
+		boolean isNight = isNight();
 		
-		/**
-		 * Instantiates a new moving object arrived.
-		 * @param ended the ended
-		 */
-		MovingObjectArrived(L2Character ended)
+		if (isNight)
 		{
-			_ended = ended;
+			ThreadPoolManager.getInstance().executeTask(new Runnable()
+			{
+				@Override
+				public final void run()
+				{
+					DayNightSpawnManager.getInstance().notifyChangeMode();
+				}
+			});
 		}
 		
-		@Override
-		public void run()
+		while (true)
 		{
+			nextTickTime = ((System.currentTimeMillis() / MILLIS_IN_TICK) * MILLIS_IN_TICK) + 100;
+			
 			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);
-				}
+				moveObjects();
 			}
-			catch (NullPointerException e)
+			catch (final Throwable e)
 			{
-				_log.log(Level.WARNING, "", e);
+				StackTrace.displayStackTraceInformation(e);
+			}
+			
+			sleepTime = nextTickTime - System.currentTimeMillis();
+			if (sleepTime > 0)
+			{
+				try
+				{
+					Thread.sleep(sleepTime);
+				}
+				catch (final InterruptedException e)
+				{
+					
+				}
 			}
-		}
-	}
-	
-	class BroadcastSunState implements Runnable
-	{
-		int h;
-		boolean tempIsNight;
-		
-		@Override
-		public void run()
-		{
-			h = ((getGameTime() + 29) / 60) % 24; // Time in hour (+ 29 is to round 60)
-			tempIsNight = (h < 6);
 			
-			if (tempIsNight != _isNight)
+			if (isNight() != isNight)
 			{
-				// If diff day/night state
-				_isNight = tempIsNight; // Set current day/night variable to value of temp variable
-				DayNightSpawnManager.getInstance().notifyChangeMode();
+				isNight = !isNight;
+				
+				ThreadPoolManager.getInstance().executeTask(new Runnable()
+				{
+					@Override
+					public final void run()
+					{
+						DayNightSpawnManager.getInstance().notifyChangeMode();
+					}
+				});
 			}
 		}
 	}
-	
-	private static class SingletonHolder
-	{
-		protected static final GameTimeController _instance = new GameTimeController();
-	}
-}
+}

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/AbstractAI.java

@@ -519,7 +519,7 @@ public abstract class AbstractAI implements Ctrl
 			{
 				if (_clientMovingToPawnOffset == offset)
 				{
-					if (GameTimeController.getGameTicks() < _moveToPawnTimeout)
+					if (GameTimeController.getInstance().getGameTicks() < _moveToPawnTimeout)
 					{
 						return;
 					}
@@ -528,7 +528,7 @@ public abstract class AbstractAI implements Ctrl
 				else if (_actor.isOnGeodataPath())
 				{
 					// minimum time to calculate new route is 2 seconds
-					if (GameTimeController.getGameTicks() < (_moveToPawnTimeout + 10))
+					if (GameTimeController.getInstance().getGameTicks() < (_moveToPawnTimeout + 10))
 					{
 						return;
 					}
@@ -539,7 +539,7 @@ public abstract class AbstractAI implements Ctrl
 			_clientMoving = true;
 			_clientMovingToPawnOffset = offset;
 			_target = pawn;
-			_moveToPawnTimeout = GameTimeController.getGameTicks();
+			_moveToPawnTimeout = GameTimeController.getInstance().getGameTicks();
 			_moveToPawnTimeout += 1000 / GameTimeController.MILLIS_IN_TICK;
 			
 			if ((pawn == null) || (_accessor == null))

+ 5 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java

@@ -407,10 +407,10 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 	protected void onIntentionAttack(L2Character target)
 	{
 		// Calculate the attack timeout
-		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// self and buffs
-		if ((lastBuffTick + 30) < GameTimeController.getGameTicks())
+		if ((lastBuffTick + 30) < GameTimeController.getInstance().getGameTicks())
 		{
 			for (L2Skill sk : _skillrender.getBuffSkills())
 			{
@@ -419,7 +419,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 					break;
 				}
 			}
-			lastBuffTick = GameTimeController.getGameTicks();
+			lastBuffTick = GameTimeController.getInstance().getGameTicks();
 		}
 		
 		// Manage the Attack Intention : Stop current Attack (if necessary), Start a new Attack and Launch Think Event
@@ -730,7 +730,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 		
 		L2Character originalAttackTarget = getAttackTarget();
 		// Check if target is dead or if timeout is expired to stop this attack
-		if ((originalAttackTarget == null) || originalAttackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getGameTicks()))
+		if ((originalAttackTarget == null) || originalAttackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks()))
 		{
 			// Stop hating this target after the attack timeout or if target is dead
 			if (originalAttackTarget != null)
@@ -2724,7 +2724,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 		L2Attackable me = getActiveChar();
 		
 		// Calculate the attack timeout
-		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Set the _globalAggro to 0 to permit attack even just after spawn
 		if (_globalAggro < 0)

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2CharacterAI.java

@@ -323,9 +323,9 @@ public class L2CharacterAI extends AbstractAI
 			return;
 		}
 		
-		if (_actor.getBowAttackEndTime() > GameTimeController.getGameTicks())
+		if (_actor.getBowAttackEndTime() > GameTimeController.getInstance().getGameTicks())
 		{
-			ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target), (_actor.getBowAttackEndTime() - GameTimeController.getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
+			ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target), (_actor.getBowAttackEndTime() - GameTimeController.getInstance().getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
 		}
 		else
 		{

+ 7 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2FortSiegeGuardAI.java

@@ -253,7 +253,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	protected void onIntentionAttack(L2Character target)
 	{
 		// Calculate the attack timeout
-		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Manage the Attack Intention : Stop current Attack (if necessary), Start a new Attack and Launch Think Event
 		// if (_actor.getTarget() != null)
@@ -372,10 +372,10 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	{
 		if (Config.DEBUG)
 		{
-			_log.warning(getClass().getSimpleName() + ": thinkAttack(); timeout=" + (_attackTimeout - GameTimeController.getGameTicks()));
+			_log.warning(getClass().getSimpleName() + ": thinkAttack(); timeout=" + (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
 		}
 		
-		if (_attackTimeout < GameTimeController.getGameTicks())
+		if (_attackTimeout < GameTimeController.getInstance().getGameTicks())
 		{
 			// Check if the actor is running
 			if (_actor.isRunning())
@@ -384,13 +384,13 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 				_actor.setWalking();
 				
 				// Calculate a new attack timeout
-				_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+				_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 			}
 		}
 		
 		L2Character attackTarget = getAttackTarget();
 		// Check if target is dead or if timeout is expired to stop this attack
-		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getGameTicks()))
+		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks()))
 		{
 			// Stop hating this target after the attack timeout or if target is dead
 			if (attackTarget != null)
@@ -750,7 +750,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 				attackTarget = hated;
 			}
 			
-			_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+			_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 			
 			// check for close combat skills && heal/buff skills
 			if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5))
@@ -852,7 +852,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	protected void onEvtAttacked(L2Character attacker)
 	{
 		// Calculate the attack timeout
-		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Set the _globalAggro to 0 to permit attack even just after spawn
 		if (_globalAggro < 0)

+ 7 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2SiegeGuardAI.java

@@ -241,7 +241,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	protected void onIntentionAttack(L2Character target)
 	{
 		// Calculate the attack timeout
-		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Manage the Attack Intention : Stop current Attack (if necessary), Start a new Attack and Launch Think Event
 		// if (_actor.getTarget() != null)
@@ -350,10 +350,10 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	{
 		if (Config.DEBUG)
 		{
-			_log.info(getClass().getSimpleName() + ": thinkAttack(); timeout=" + (_attackTimeout - GameTimeController.getGameTicks()));
+			_log.info(getClass().getSimpleName() + ": thinkAttack(); timeout=" + (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
 		}
 		
-		if (_attackTimeout < GameTimeController.getGameTicks())
+		if (_attackTimeout < GameTimeController.getInstance().getGameTicks())
 		{
 			// Check if the actor is running
 			if (_actor.isRunning())
@@ -362,13 +362,13 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 				_actor.setWalking();
 				
 				// Calculate a new attack timeout
-				_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+				_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 			}
 		}
 		
 		L2Character attackTarget = getAttackTarget();
 		// Check if target is dead or if timeout is expired to stop this attack
-		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getGameTicks()))
+		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks()))
 		{
 			// Stop hating this target after the attack timeout or if target is dead
 			if (attackTarget != null)
@@ -718,7 +718,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 				attackTarget = hated;
 			}
 			
-			_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+			_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 			
 			// check for close combat skills && heal/buff skills
 			if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5))
@@ -823,7 +823,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	protected void onEvtAttacked(L2Character attacker)
 	{
 		// Calculate the attack timeout
-		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
+		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Set the _globalAggro to 0 to permit attack even just after spawn
 		if (_globalAggro < 0)

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/HitConditionBonus.java

@@ -120,7 +120,7 @@ public final class HitConditionBonus extends DocumentParser
 		}
 		
 		// Get weather bonus
-		if (GameTimeController.getInstance().isNowNight())
+		if (GameTimeController.getInstance().isNight())
 		{
 			mod += darkBonus;
 			// else if () No rain support yet.

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/DayNightSpawnManager.java

@@ -169,7 +169,7 @@ public class DayNightSpawnManager
 	{
 		try
 		{
-			if (GameTimeController.getInstance().isNowNight())
+			if (GameTimeController.getInstance().isNight())
 			{
 				changeMode(1);
 			}
@@ -248,7 +248,7 @@ public class DayNightSpawnManager
 			return _bosses.get(spawnDat);
 		}
 		
-		if (GameTimeController.getInstance().isNowNight())
+		if (GameTimeController.getInstance().isNight())
 		{
 			L2RaidBossInstance raidboss = (L2RaidBossInstance) spawnDat.doSpawn();
 			_bosses.put(spawnDat, raidboss);

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2Party.java

@@ -146,7 +146,7 @@ public class L2Party extends AbstractPlayerGroup
 	public void setPendingInvitation(boolean val)
 	{
 		_pendingInvitation = val;
-		_pendingInviteTimeout = GameTimeController.getGameTicks() + (L2PcInstance.REQUEST_TIMEOUT * GameTimeController.TICKS_PER_SECOND);
+		_pendingInviteTimeout = GameTimeController.getInstance().getGameTicks() + (L2PcInstance.REQUEST_TIMEOUT * GameTimeController.TICKS_PER_SECOND);
 	}
 	
 	/**
@@ -156,7 +156,7 @@ public class L2Party extends AbstractPlayerGroup
 	 */
 	public boolean isInvitationRequestExpired()
 	{
-		return (_pendingInviteTimeout <= GameTimeController.getGameTicks());
+		return (_pendingInviteTimeout <= GameTimeController.getInstance().getGameTicks());
 	}
 	
 	/**

+ 15 - 15
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -927,7 +927,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 					}
 					
 					// Verify if the bow can be use
-					if (_disableBowAttackEndTime <= GameTimeController.getGameTicks())
+					if (_disableBowAttackEndTime <= GameTimeController.getInstance().getGameTicks())
 					{
 						// Verify if L2PcInstance owns enough MP
 						int mpConsume = weaponItem.getMpConsume();
@@ -953,7 +953,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 						}
 						
 						// Set the period of bow no re-use
-						_disableBowAttackEndTime = (5 * GameTimeController.TICKS_PER_SECOND) + GameTimeController.getGameTicks();
+						_disableBowAttackEndTime = (5 * GameTimeController.TICKS_PER_SECOND) + GameTimeController.getInstance().getGameTicks();
 					}
 					else
 					{
@@ -989,7 +989,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 					}
 					
 					// Verify if the crossbow can be use
-					if (_disableCrossBowAttackEndTime <= GameTimeController.getGameTicks())
+					if (_disableCrossBowAttackEndTime <= GameTimeController.getInstance().getGameTicks())
 					{
 						// Verify if L2PcInstance owns enough MP
 						int mpConsume = weaponItem.getMpConsume();
@@ -1015,7 +1015,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 						}
 						
 						// Set the period of crossbow no re-use
-						_disableCrossBowAttackEndTime = (5 * GameTimeController.TICKS_PER_SECOND) + GameTimeController.getGameTicks();
+						_disableCrossBowAttackEndTime = (5 * GameTimeController.TICKS_PER_SECOND) + GameTimeController.getInstance().getGameTicks();
 					}
 					else
 					{
@@ -1027,7 +1027,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 				}
 				else if (isNpc())
 				{
-					if (_disableCrossBowAttackEndTime > GameTimeController.getGameTicks())
+					if (_disableCrossBowAttackEndTime > GameTimeController.getInstance().getGameTicks())
 					{
 						return;
 					}
@@ -1053,7 +1053,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 		final int timeAtk = calculateTimeBetweenAttacks(target, weaponItem);
 		// the hit is calculated to happen halfway to the animation - might need further tuning e.g. in bow case
 		final int timeToHit = timeAtk / 2;
-		_attackEndTime = (GameTimeController.getGameTicks() + (timeAtk / GameTimeController.MILLIS_IN_TICK)) - 1;
+		_attackEndTime = (GameTimeController.getInstance().getGameTicks() + (timeAtk / GameTimeController.MILLIS_IN_TICK)) - 1;
 		final int ssGrade = (weaponItem != null) ? weaponItem.getItemGradeSPlus() : 0;
 		// Create a Server->Client packet Attack
 		Attack attack = new Attack(this, target, wasSSCharged, ssGrade);
@@ -1211,7 +1211,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 		ThreadPoolManager.getInstance().scheduleAi(new HitTask(target, damage1, crit1, miss1, attack.soulshot, shld1), sAtk);
 		
 		// Calculate and set the disable delay of the bow in function of the Attack Speed
-		_disableBowAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getGameTicks();
+		_disableBowAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getInstance().getGameTicks();
 		
 		// Add this hit to the Server-Client packet Attack
 		attack.hit(attack.createHit(target, damage1, miss1, crit1, shld1));
@@ -1281,7 +1281,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 		ThreadPoolManager.getInstance().scheduleAi(new HitTask(target, damage1, crit1, miss1, attack.soulshot, shld1), sAtk);
 		
 		// Calculate and set the disable delay of the bow in function of the Attack Speed
-		_disableCrossBowAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getGameTicks();
+		_disableCrossBowAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getInstance().getGameTicks();
 		
 		// Add this hit to the Server-Client packet Attack
 		attack.hit(attack.createHit(target, damage1, miss1, crit1, shld1));
@@ -1813,7 +1813,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 		
 		if (!simultaneously)
 		{
-			_castInterruptTime = -2 + GameTimeController.getGameTicks() + (skillTime / GameTimeController.MILLIS_IN_TICK);
+			_castInterruptTime = -2 + GameTimeController.getInstance().getGameTicks() + (skillTime / GameTimeController.MILLIS_IN_TICK);
 			setLastSkillCast(skill);
 		}
 		else
@@ -2589,7 +2589,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 	 */
 	public boolean isAttackingDisabled()
 	{
-		return isFlying() || isStunned() || isSleeping() || (_attackEndTime > GameTimeController.getGameTicks()) || isAlikeDead() || isParalyzed() || isPhysicalAttackMuted() || isCoreAIDisabled();
+		return isFlying() || isStunned() || isSleeping() || (_attackEndTime > GameTimeController.getInstance().getGameTicks()) || isAlikeDead() || isParalyzed() || isPhysicalAttackMuted() || isCoreAIDisabled();
 	}
 	
 	public final Calculator[] getCalculators()
@@ -4445,7 +4445,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 	 */
 	public final boolean canAbortCast()
 	{
-		return _castInterruptTime > GameTimeController.getGameTicks();
+		return _castInterruptTime > GameTimeController.getInstance().getGameTicks();
 	}
 	
 	public int getCastInterruptTime()
@@ -4458,7 +4458,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 	 */
 	public boolean isAttackingNow()
 	{
-		return _attackEndTime > GameTimeController.getGameTicks();
+		return _attackEndTime > GameTimeController.getInstance().getGameTicks();
 	}
 	
 	/**
@@ -4604,7 +4604,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 		final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER);
 		
 		// Z coordinate will follow geodata or client values
-		if ((Config.GEODATA > 0) && (Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getGameTicks() % 10) == 0 // once a second to reduce possible cpu load
+		if ((Config.GEODATA > 0) && (Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0 // once a second to reduce possible cpu load
 		) && GeoData.getInstance().hasGeo(xPrev, yPrev))
 		{
 			short geoHeight = GeoData.getInstance().getSpawnHeight(xPrev, yPrev, zPrev - 30, zPrev + 30, null);
@@ -5096,7 +5096,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 			setHeading(Util.calculateHeadingFrom(cos, sin));
 		}
 		
-		m._moveStartTime = GameTimeController.getGameTicks();
+		m._moveStartTime = GameTimeController.getInstance().getGameTicks();
 		
 		// Set the L2Character _move object to MoveData object
 		_move = m;
@@ -5177,7 +5177,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 		
 		m._heading = 0; // initial value for coordinate sync
 		
-		m._moveStartTime = GameTimeController.getGameTicks();
+		m._moveStartTime = GameTimeController.getInstance().getGameTicks();
 		
 		// Set the L2Character _move object to MoveData object
 		_move = m;

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Summon.java

@@ -1037,7 +1037,7 @@ public abstract class L2Summon extends L2Playable
 		
 		if (isAttackingDisabled())
 		{
-			if (getAttackEndTime() <= GameTimeController.getGameTicks())
+			if (getAttackEndTime() <= GameTimeController.getInstance().getGameTicks())
 			{
 				return false;
 			}

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Vehicle.java

@@ -163,7 +163,7 @@ public abstract class L2Vehicle extends L2Character
 							setHeading(Util.calculateHeadingFrom(getX(), getY(), point.x, point.y));
 						}
 						
-						m._moveStartTime = GameTimeController.getGameTicks();
+						m._moveStartTime = GameTimeController.getInstance().getGameTicks();
 						_move = m;
 						
 						GameTimeController.getInstance().registerMovingObject(this);

+ 15 - 15
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -733,14 +733,14 @@ public final class L2PcInstance extends L2Playable
 	
 	public boolean isSpawnProtected()
 	{
-		return _protectEndTime > GameTimeController.getGameTicks();
+		return _protectEndTime > GameTimeController.getInstance().getGameTicks();
 	}
 	
 	private long _teleportProtectEndTime = 0;
 	
 	public boolean isTeleportProtected()
 	{
-		return _teleportProtectEndTime > GameTimeController.getGameTicks();
+		return _teleportProtectEndTime > GameTimeController.getInstance().getGameTicks();
 	}
 	
 	// protects a char from agro mobs when getting up from fake death
@@ -4543,20 +4543,20 @@ public final class L2PcInstance extends L2Playable
 	{
 		if (Config.DEVELOPER && (protect || (_protectEndTime > 0)))
 		{
-			_log.warning(getName() + ": Protection " + (protect ? "ON " + (GameTimeController.getGameTicks() + (Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND)) : "OFF") + " (currently " + GameTimeController.getGameTicks() + ")");
+			_log.warning(getName() + ": Protection " + (protect ? "ON " + (GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND)) : "OFF") + " (currently " + GameTimeController.getInstance().getGameTicks() + ")");
 		}
 		
-		_protectEndTime = protect ? GameTimeController.getGameTicks() + (Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
+		_protectEndTime = protect ? GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
 	}
 	
 	public void setTeleportProtection(boolean protect)
 	{
 		if (Config.DEVELOPER && (protect || (_teleportProtectEndTime > 0)))
 		{
-			_log.warning(getName() + ": Tele Protection " + (protect ? "ON " + (GameTimeController.getGameTicks() + (Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND)) : "OFF") + " (currently " + GameTimeController.getGameTicks() + ")");
+			_log.warning(getName() + ": Tele Protection " + (protect ? "ON " + (GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND)) : "OFF") + " (currently " + GameTimeController.getInstance().getGameTicks() + ")");
 		}
 		
-		_teleportProtectEndTime = protect ? GameTimeController.getGameTicks() + (Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
+		_teleportProtectEndTime = protect ? GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
 	}
 	
 	/**
@@ -4565,12 +4565,12 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public void setRecentFakeDeath(boolean protect)
 	{
-		_recentFakeDeathEndTime = protect ? GameTimeController.getGameTicks() + (Config.PLAYER_FAKEDEATH_UP_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
+		_recentFakeDeathEndTime = protect ? GameTimeController.getInstance().getGameTicks() + (Config.PLAYER_FAKEDEATH_UP_PROTECTION * GameTimeController.TICKS_PER_SECOND) : 0;
 	}
 	
 	public boolean isRecentFakeDeath()
 	{
-		return _recentFakeDeathEndTime > GameTimeController.getGameTicks();
+		return _recentFakeDeathEndTime > GameTimeController.getInstance().getGameTicks();
 	}
 	
 	public final boolean isFakeDeath()
@@ -6656,7 +6656,7 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public boolean isProcessingRequest()
 	{
-		return (getActiveRequester() != null) || (_requestExpireTime > GameTimeController.getGameTicks());
+		return (getActiveRequester() != null) || (_requestExpireTime > GameTimeController.getInstance().getGameTicks());
 	}
 	
 	/**
@@ -6664,7 +6664,7 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public boolean isProcessingTransaction()
 	{
-		return (getActiveRequester() != null) || (_activeTradeList != null) || (_requestExpireTime > GameTimeController.getGameTicks());
+		return (getActiveRequester() != null) || (_activeTradeList != null) || (_requestExpireTime > GameTimeController.getInstance().getGameTicks());
 	}
 	
 	/**
@@ -6673,7 +6673,7 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public void onTransactionRequest(L2PcInstance partner)
 	{
-		_requestExpireTime = GameTimeController.getGameTicks() + (REQUEST_TIMEOUT * GameTimeController.TICKS_PER_SECOND);
+		_requestExpireTime = GameTimeController.getInstance().getGameTicks() + (REQUEST_TIMEOUT * GameTimeController.TICKS_PER_SECOND);
 		partner.setActiveRequester(this);
 	}
 	
@@ -6683,7 +6683,7 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public boolean isRequestExpired()
 	{
-		return !(_requestExpireTime > GameTimeController.getGameTicks());
+		return !(_requestExpireTime > GameTimeController.getInstance().getGameTicks());
 	}
 	
 	/**
@@ -6956,7 +6956,7 @@ public final class L2PcInstance extends L2Playable
 				arrows.setLastChange(L2ItemInstance.MODIFIED);
 				
 				// could do also without saving, but let's save approx 1 of 10
-				if ((GameTimeController.getGameTicks() % 10) == 0)
+				if ((GameTimeController.getInstance().getGameTicks() % 10) == 0)
 				{
 					arrows.updateDatabase();
 				}
@@ -7381,7 +7381,7 @@ public final class L2PcInstance extends L2Playable
 	@Override
 	public boolean isInvul()
 	{
-		return super.isInvul() || (_teleportProtectEndTime > GameTimeController.getGameTicks());
+		return super.isInvul() || (_teleportProtectEndTime > GameTimeController.getInstance().getGameTicks());
 	}
 	
 	/**
@@ -12818,7 +12818,7 @@ public final class L2PcInstance extends L2Playable
 		fishs.clear();
 		fishs = null;
 		sendPacket(SystemMessageId.CAST_LINE_AND_START_FISHING);
-		if (!GameTimeController.getInstance().isNowNight() && _lure.isNightLure())
+		if (!GameTimeController.getInstance().isNight() && _lure.isNightLure())
 		{
 			_fish.setFishGroup(-1);
 		}

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/conditions/ConditionGameTime.java

@@ -60,7 +60,7 @@ public class ConditionGameTime extends Condition
 		switch (_check)
 		{
 			case NIGHT:
-				return GameTimeController.getInstance().isNowNight() == _required;
+				return GameTimeController.getInstance().isNight() == _required;
 		}
 		return !_required;
 	}

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/L2Effect.java

@@ -108,7 +108,7 @@ public abstract class L2Effect implements IChanceSkillTrigger
 			try
 			{
 				_periodFirstTime = 0;
-				_periodStartTicks = GameTimeController.getGameTicks();
+				_periodStartTicks = GameTimeController.getInstance().getGameTicks();
 				scheduleEffect();
 			}
 			catch (Exception e)
@@ -175,7 +175,7 @@ public abstract class L2Effect implements IChanceSkillTrigger
 		_eventEffect = template.eventEffect;
 		_abnormalType = template.abnormalType;
 		_abnormalLvl = template.abnormalLvl;
-		_periodStartTicks = GameTimeController.getGameTicks();
+		_periodStartTicks = GameTimeController.getInstance().getGameTicks();
 		_periodFirstTime = 0;
 		_icon = template.icon;
 		_effectPower = template.effectPower;
@@ -252,7 +252,7 @@ public abstract class L2Effect implements IChanceSkillTrigger
 	
 	public int getTime()
 	{
-		return (GameTimeController.getGameTicks() - _periodStartTicks) / GameTimeController.TICKS_PER_SECOND;
+		return (GameTimeController.getInstance().getGameTicks() - _periodStartTicks) / GameTimeController.TICKS_PER_SECOND;
 	}
 	
 	/**

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/itemcontainer/ItemContainer.java

@@ -228,7 +228,7 @@ public abstract class ItemContainer
 			if ((item.getItemId() == PcInventory.ADENA_ID) && (count < (10000 * Config.RATE_DROP_ITEMS_ID.get(PcInventory.ADENA_ID))))
 			{
 				// Small adena changes won't be saved to database all the time
-				if ((GameTimeController.getGameTicks() % 5) == 0)
+				if ((GameTimeController.getInstance().getGameTicks() % 5) == 0)
 				{
 					item.updateDatabase();
 				}
@@ -280,7 +280,7 @@ public abstract class ItemContainer
 			if ((itemId == PcInventory.ADENA_ID) && (count < (10000 * adenaRate)))
 			{
 				// Small adena changes won't be saved to database all the time
-				if ((GameTimeController.getGameTicks() % 5) == 0)
+				if ((GameTimeController.getInstance().getGameTicks() % 5) == 0)
 				{
 					item.updateDatabase();
 				}
@@ -442,7 +442,7 @@ public abstract class ItemContainer
 				item.setLastChange(L2ItemInstance.MODIFIED);
 				
 				// don't update often for untraced items
-				if ((process != null) || ((GameTimeController.getGameTicks() % 10) == 0))
+				if ((process != null) || ((GameTimeController.getInstance().getGameTicks() % 10) == 0))
 				{
 					item.updateDatabase();
 				}

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -3328,7 +3328,7 @@ public class Quest extends ManagedScript
 	 */
 	public int getGameTicks()
 	{
-		return GameTimeController.getGameTicks();
+		return GameTimeController.getInstance().getGameTicks();
 	}
 	
 	/**

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/UseItem.java

@@ -330,7 +330,7 @@ public final class UseItem extends L2GameClientPacket
 			}
 			else if (activeChar.isAttackingNow())
 			{
-				ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), (activeChar.getAttackEndTime() - GameTimeController.getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
+				ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), (activeChar.getAttackEndTime() - GameTimeController.getInstance().getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
 			}
 			else
 			{

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/util/FloodProtectorAction.java

@@ -49,7 +49,7 @@ public final class FloodProtectorAction
 	/**
 	 * Next game tick when new request is allowed.
 	 */
-	private volatile int _nextGameTick = GameTimeController.getGameTicks();
+	private volatile int _nextGameTick = GameTimeController.getInstance().getGameTicks();
 	/**
 	 * Request counter.
 	 */
@@ -82,7 +82,7 @@ public final class FloodProtectorAction
 	 */
 	public boolean tryPerformAction(final String command)
 	{
-		final int curTick = GameTimeController.getGameTicks();
+		final int curTick = GameTimeController.getInstance().getGameTicks();
 		
 		if ((_client.getActiveChar() != null) && _client.getActiveChar().canOverrideCond(PcCondOverride.FLOOD_CONDITIONS))
 		{

+ 137 - 0
L2J_Server_BETA/java/com/l2jserver/util/StackTrace.java

@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2004-2013 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J Server is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.util;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class StackTrace
+{
+	private static Logger _log = Logger.getLogger(StackTrace.class.getName());
+	
+	public static boolean displayStackTraceInformation(Throwable ex)
+	{
+		return displayStackTraceInformation(ex, false);
+	}
+	
+	public static boolean displayStackTraceInformation(Throwable ex, boolean displayAll)
+	{
+		if (ex == null)
+		{
+			return false;
+		}
+		
+		_log.log(Level.INFO, "", ex);
+		
+		if (!displayAll)
+		{
+			return true;
+		}
+		
+		StackTraceElement[] stackElements = ex.getStackTrace();
+		
+		_log.log(Level.INFO, "The " + stackElements.length + " element" + ((stackElements.length == 1) ? "" : "s") + " of the stack trace:\n");
+		
+		for (StackTraceElement stackElement : stackElements)
+		{
+			_log.log(Level.INFO, "File name: " + stackElement.getFileName());
+			_log.log(Level.INFO, "Line number: " + stackElement.getLineNumber());
+			
+			String className = stackElement.getClassName();
+			String packageName = extractPackageName(className);
+			String simpleClassName = extractSimpleClassName(className);
+			
+			_log.log(Level.INFO, "Package name: " + ("".equals(packageName) ? "[default package]" : packageName));
+			_log.log(Level.INFO, "Full class name: " + className);
+			_log.log(Level.INFO, "Simple class name: " + simpleClassName);
+			_log.log(Level.INFO, "Unmunged class name: " + unmungeSimpleClassName(simpleClassName));
+			_log.log(Level.INFO, "Direct class name: " + extractDirectClassName(simpleClassName));
+			
+			_log.log(Level.INFO, "Method name: " + stackElement.getMethodName());
+			_log.log(Level.INFO, "Native method?: " + stackElement.isNativeMethod());
+			
+			_log.log(Level.INFO, "toString(): " + stackElement.toString());
+			_log.log(Level.INFO, "");
+		}
+		_log.log(Level.INFO, "");
+		
+		return true;
+	}
+	
+	private static String extractPackageName(String fullClassName)
+	{
+		if ((null == fullClassName) || ("".equals(fullClassName)))
+		{
+			return "";
+		}
+		
+		int lastDot = fullClassName.lastIndexOf('.');
+		
+		if (0 >= lastDot)
+		{
+			return "";
+		}
+		
+		return fullClassName.substring(0, lastDot);
+	}
+	
+	private static String extractSimpleClassName(String fullClassName)
+	{
+		if ((null == fullClassName) || ("".equals(fullClassName)))
+		{
+			return "";
+		}
+		
+		int lastDot = fullClassName.lastIndexOf('.');
+		
+		if (0 > lastDot)
+		{
+			return fullClassName;
+		}
+		
+		return fullClassName.substring(++lastDot);
+	}
+	
+	private static String extractDirectClassName(String simpleClassName)
+	{
+		if ((null == simpleClassName) || ("".equals(simpleClassName)))
+		{
+			return "";
+		}
+		
+		int lastSign = simpleClassName.lastIndexOf('$');
+		
+		if (0 > lastSign)
+		{
+			return simpleClassName;
+		}
+		
+		return simpleClassName.substring(++lastSign);
+	}
+	
+	private static String unmungeSimpleClassName(String simpleClassName)
+	{
+		if ((null == simpleClassName) || ("".equals(simpleClassName)))
+		{
+			return "";
+		}
+		
+		return simpleClassName.replace('$', '.');
+	}
+}