Use UnboundArrayList for GameTimeController.
This commit is contained in:
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -28,6 +28,7 @@ import org.l2jmobius.commons.util.Chronos;
|
|||||||
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Revision: 1.1.4.8 $ $Date: 2005/04/06 16:13:24 $
|
* @version $Revision: 1.1.4.8 $ $Date: 2005/04/06 16:13:24 $
|
||||||
@@ -45,7 +46,7 @@ public class GameTimeController
|
|||||||
protected static long _gameStartTime;
|
protected static long _gameStartTime;
|
||||||
protected static boolean _isNight = false;
|
protected static boolean _isNight = false;
|
||||||
|
|
||||||
private static List<Creature> _movingObjects = new ArrayList<>();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
|
|
||||||
protected static TimerThread _timer;
|
protected static TimerThread _timer;
|
||||||
private final ScheduledFuture<?> _timerWatcher;
|
private final ScheduledFuture<?> _timerWatcher;
|
||||||
@@ -94,17 +95,14 @@ public class GameTimeController
|
|||||||
* All Creature in movement are identified in <b>movingObjects</b> of GameTimeController.
|
* All Creature in movement are identified in <b>movingObjects</b> of GameTimeController.
|
||||||
* @param creature The Creature to add to movingObjects of GameTimeController
|
* @param creature The Creature to add to movingObjects of GameTimeController
|
||||||
*/
|
*/
|
||||||
public synchronized void registerMovingObject(Creature creature)
|
public void registerMovingObject(Creature creature)
|
||||||
{
|
{
|
||||||
if (creature == null)
|
if (creature == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,39 +117,34 @@ public class GameTimeController
|
|||||||
* <li>If movement is finished, the Creature is removed from movingObjects</li>
|
* <li>If movement is finished, the Creature is removed from movingObjects</li>
|
||||||
* <li>Create a task to update the _knownObject and _knowPlayers of each Creature that finished its movement and of their already known WorldObject then notify AI with EVT_ARRIVED</li>
|
* <li>Create a task to update the _knownObject and _knowPlayers of each Creature that finished its movement and of their already known WorldObject then notify AI with EVT_ARRIVED</li>
|
||||||
*/
|
*/
|
||||||
protected synchronized void moveObjects()
|
protected void moveObjects()
|
||||||
{
|
{
|
||||||
// Get all Creature from the ArrayList movingObjects and put them into a table
|
List<Creature> finished = null;
|
||||||
final Creature[] chars = _movingObjects.toArray(new Creature[_movingObjects.size()]);
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
|
||||||
// Create an ArrayList to contain all Creature that are arrived to destination
|
|
||||||
List<Creature> ended = null;
|
|
||||||
|
|
||||||
// Go throw the table containing Creature in movement
|
|
||||||
for (Creature creature : chars)
|
|
||||||
{
|
{
|
||||||
// Update the position of the Creature and return True if the movement is finished
|
final Creature creature = _movingObjects.get(i);
|
||||||
final boolean end = creature.updatePosition(_gameTicks);
|
if (creature == null)
|
||||||
|
|
||||||
// If movement is finished, the Creature is removed from movingObjects and added to the ArrayList ended
|
|
||||||
if (end)
|
|
||||||
{
|
{
|
||||||
_movingObjects.remove(creature);
|
continue;
|
||||||
if (ended == null)
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition(_gameTicks))
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
{
|
{
|
||||||
ended = new ArrayList<>();
|
finished = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
finished.add(creature);
|
||||||
ended.add(creature);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a task to update the _knownObject and _knowPlayers of each Creature that finished its movement and of their already known WorldObject
|
if (finished != null)
|
||||||
// then notify AI with EVT_ARRIVED
|
|
||||||
// TODO: maybe a general TP is needed for that kinda stuff (all knownlist updates should be done in a TP anyway).
|
|
||||||
if (ended != null)
|
|
||||||
{
|
{
|
||||||
ThreadPool.execute(new MovingObjectArrived(ended));
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
ThreadPool.execute(new MovingObjectArrived(finished));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,24 +228,25 @@ public class GameTimeController
|
|||||||
*/
|
*/
|
||||||
class MovingObjectArrived implements Runnable
|
class MovingObjectArrived implements Runnable
|
||||||
{
|
{
|
||||||
private final List<Creature> _ended;
|
private final List<Creature> _finished;
|
||||||
|
|
||||||
MovingObjectArrived(List<Creature> ended)
|
MovingObjectArrived(List<Creature> finished)
|
||||||
{
|
{
|
||||||
_ended = ended;
|
_finished = finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (Creature creature : _ended)
|
for (int i = 0; i < _finished.size(); i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
final Creature creature = _finished.get(i);
|
||||||
creature.getKnownList().updateKnownObjects();
|
creature.getKnownList().updateKnownObjects();
|
||||||
creature.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
|
creature.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@ import org.l2jmobius.commons.util.Chronos;
|
|||||||
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Revision: 1.1.4.8 $ $Date: 2005/04/06 16:13:24 $
|
* @version $Revision: 1.1.4.8 $ $Date: 2005/04/06 16:13:24 $
|
||||||
@@ -45,7 +46,7 @@ public class GameTimeController
|
|||||||
protected static long _gameStartTime;
|
protected static long _gameStartTime;
|
||||||
protected static boolean _isNight = false;
|
protected static boolean _isNight = false;
|
||||||
|
|
||||||
private static List<Creature> _movingObjects = new ArrayList<>();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
|
|
||||||
protected static TimerThread _timer;
|
protected static TimerThread _timer;
|
||||||
private final ScheduledFuture<?> _timerWatcher;
|
private final ScheduledFuture<?> _timerWatcher;
|
||||||
@@ -94,17 +95,14 @@ public class GameTimeController
|
|||||||
* All Creature in movement are identified in <b>movingObjects</b> of GameTimeController.
|
* All Creature in movement are identified in <b>movingObjects</b> of GameTimeController.
|
||||||
* @param creature The Creature to add to movingObjects of GameTimeController
|
* @param creature The Creature to add to movingObjects of GameTimeController
|
||||||
*/
|
*/
|
||||||
public synchronized void registerMovingObject(Creature creature)
|
public void registerMovingObject(Creature creature)
|
||||||
{
|
{
|
||||||
if (creature == null)
|
if (creature == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,39 +117,34 @@ public class GameTimeController
|
|||||||
* <li>If movement is finished, the Creature is removed from movingObjects</li>
|
* <li>If movement is finished, the Creature is removed from movingObjects</li>
|
||||||
* <li>Create a task to update the _knownObject and _knowPlayers of each Creature that finished its movement and of their already known WorldObject then notify AI with EVT_ARRIVED</li>
|
* <li>Create a task to update the _knownObject and _knowPlayers of each Creature that finished its movement and of their already known WorldObject then notify AI with EVT_ARRIVED</li>
|
||||||
*/
|
*/
|
||||||
protected synchronized void moveObjects()
|
protected void moveObjects()
|
||||||
{
|
{
|
||||||
// Get all Creature from the ArrayList movingObjects and put them into a table
|
List<Creature> finished = null;
|
||||||
final Creature[] chars = _movingObjects.toArray(new Creature[_movingObjects.size()]);
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
|
||||||
// Create an ArrayList to contain all Creature that are arrived to destination
|
|
||||||
List<Creature> ended = null;
|
|
||||||
|
|
||||||
// Go throw the table containing Creature in movement
|
|
||||||
for (Creature creature : chars)
|
|
||||||
{
|
{
|
||||||
// Update the position of the Creature and return True if the movement is finished
|
final Creature creature = _movingObjects.get(i);
|
||||||
final boolean end = creature.updatePosition(_gameTicks);
|
if (creature == null)
|
||||||
|
|
||||||
// If movement is finished, the Creature is removed from movingObjects and added to the ArrayList ended
|
|
||||||
if (end)
|
|
||||||
{
|
{
|
||||||
_movingObjects.remove(creature);
|
continue;
|
||||||
if (ended == null)
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition(_gameTicks))
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
{
|
{
|
||||||
ended = new ArrayList<>();
|
finished = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
finished.add(creature);
|
||||||
ended.add(creature);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a task to update the _knownObject and _knowPlayers of each Creature that finished its movement and of their already known WorldObject
|
if (finished != null)
|
||||||
// then notify AI with EVT_ARRIVED
|
|
||||||
// TODO: maybe a general TP is needed for that kinda stuff (all knownlist updates should be done in a TP anyway).
|
|
||||||
if (ended != null)
|
|
||||||
{
|
{
|
||||||
ThreadPool.execute(new MovingObjectArrived(ended));
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
ThreadPool.execute(new MovingObjectArrived(finished));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,24 +228,25 @@ public class GameTimeController
|
|||||||
*/
|
*/
|
||||||
class MovingObjectArrived implements Runnable
|
class MovingObjectArrived implements Runnable
|
||||||
{
|
{
|
||||||
private final List<Creature> _ended;
|
private final List<Creature> _finished;
|
||||||
|
|
||||||
MovingObjectArrived(List<Creature> ended)
|
MovingObjectArrived(List<Creature> finished)
|
||||||
{
|
{
|
||||||
_ended = ended;
|
_finished = finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (Creature creature : _ended)
|
for (int i = 0; i < _finished.size(); i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
final Creature creature = _finished.get(i);
|
||||||
creature.getKnownList().updateKnownObjects();
|
creature.getKnownList().updateKnownObjects();
|
||||||
creature.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
|
creature.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Set;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -44,7 +45,7 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -108,10 +109,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +128,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Set;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -44,7 +45,7 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -108,10 +109,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +128,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
@@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -28,6 +30,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
import org.l2jmobius.gameserver.model.events.impl.OnDayNightChange;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||||
|
import org.l2jmobius.gameserver.util.UnboundArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game Time controller class.
|
* Game Time controller class.
|
||||||
@@ -47,8 +50,8 @@ public class GameTimeController extends Thread
|
|||||||
|
|
||||||
private static GameTimeController _instance;
|
private static GameTimeController _instance;
|
||||||
|
|
||||||
private final Set<Creature> _movingObjects = ConcurrentHashMap.newKeySet();
|
private static final UnboundArrayList<Creature> _movingObjects = new UnboundArrayList<>();
|
||||||
private final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
private static final Set<Creature> _shadowSenseCharacters = ConcurrentHashMap.newKeySet();
|
||||||
private final long _referenceTime;
|
private final long _referenceTime;
|
||||||
|
|
||||||
private GameTimeController()
|
private GameTimeController()
|
||||||
@@ -112,10 +115,7 @@ public class GameTimeController extends Thread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_movingObjects.contains(creature))
|
_movingObjects.addIfAbsent(creature);
|
||||||
{
|
|
||||||
_movingObjects.add(creature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,32 @@ public class GameTimeController extends Thread
|
|||||||
*/
|
*/
|
||||||
private void moveObjects()
|
private void moveObjects()
|
||||||
{
|
{
|
||||||
_movingObjects.removeIf(Creature::updatePosition);
|
List<Creature> finished = null;
|
||||||
|
for (int i = 0; i < _movingObjects.size(); i++)
|
||||||
|
{
|
||||||
|
final Creature creature = _movingObjects.get(i);
|
||||||
|
if (creature == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (creature.updatePosition())
|
||||||
|
{
|
||||||
|
if (finished == null)
|
||||||
|
{
|
||||||
|
finished = new ArrayList<>();
|
||||||
|
}
|
||||||
|
finished.add(creature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < finished.size(); i++)
|
||||||
|
{
|
||||||
|
_movingObjects.remove(finished.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer()
|
public void stopTimer()
|
||||||
|
Reference in New Issue
Block a user