Removed enhanced For from World and WorldRegion.
This commit is contained in:
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.model.Skill;
|
||||
@@ -30,9 +29,8 @@ public interface ISkillHandler
|
||||
* @param creature
|
||||
* @param skill
|
||||
* @param targets
|
||||
* @throws IOException
|
||||
*/
|
||||
void useSkill(Creature creature, Skill skill, List<Creature> targets) throws IOException;
|
||||
void useSkill(Creature creature, Skill skill, List<Creature> targets);
|
||||
|
||||
/**
|
||||
* this method is called at initialization to register all the item ids automatically
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.handler.skillhandlers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
@@ -675,14 +674,14 @@ public class Disablers implements ISkillHandler
|
||||
final List<Creature> tgts = new ArrayList<>();
|
||||
tgts.add(target);
|
||||
|
||||
try
|
||||
{
|
||||
healhandler.useSkill(creature, skill, tgts);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(e.getMessage());
|
||||
}
|
||||
// try
|
||||
// {
|
||||
healhandler.useSkill(creature, skill, tgts);
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// LOGGER.warning(e.getMessage());
|
||||
// }
|
||||
}
|
||||
}
|
||||
for (String stat : negateEffectTypes)
|
||||
|
@@ -115,21 +115,9 @@ public class World
|
||||
*/
|
||||
public void removeObjects(List<WorldObject> list)
|
||||
{
|
||||
for (WorldObject o : list)
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
_allObjects.remove(o.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the objects.
|
||||
* @param objects the objects
|
||||
*/
|
||||
public void removeObjects(WorldObject[] objects)
|
||||
{
|
||||
for (WorldObject o : objects)
|
||||
{
|
||||
_allObjects.remove(o.getObjectId());
|
||||
_allObjects.remove(list.get(i).getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,12 +126,12 @@ public class World
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li><br>
|
||||
* @param oID Identifier of the WorldObject
|
||||
* @param objectId Identifier of the WorldObject
|
||||
* @return the object
|
||||
*/
|
||||
public WorldObject findObject(int oID)
|
||||
public WorldObject findObject(int objectId)
|
||||
{
|
||||
return _allObjects.get(oID);
|
||||
return _allObjects.get(objectId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,12 +296,10 @@ public class World
|
||||
}
|
||||
|
||||
// Go through the visible objects contained in the circular area
|
||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
||||
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||
for (int i = 0; i < visibleObjects.size(); i++)
|
||||
{
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final WorldObject wo = visibleObjects.get(i);
|
||||
|
||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||
// - Creature is visible
|
||||
@@ -342,8 +328,11 @@ public class World
|
||||
}
|
||||
|
||||
// Go through the visible objects contained in the circular area
|
||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
||||
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||
for (int i = 0; i < visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(i);
|
||||
|
||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||
// - Creature is visible
|
||||
// - object is not already known
|
||||
@@ -417,10 +406,14 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
|
||||
// Remove the WorldObject from the WorldObjectHashSet(WorldObject) _knownObjects of the surrounding WorldRegion Creatures
|
||||
// If object is a PlayerInstance, remove the WorldObject from the WorldObjectHashSet(PlayerInstance) _knownPlayer of the surrounding WorldRegion Creatures
|
||||
// If object is targeted by one of the surrounding WorldRegion Creatures, cancel ATTACK and cast
|
||||
@@ -489,10 +482,13 @@ public class World
|
||||
final List<WorldObject> result = new ArrayList<>();
|
||||
|
||||
// Go through the list of region
|
||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
@@ -552,11 +548,14 @@ public class World
|
||||
final List<WorldObject> result = new ArrayList<>();
|
||||
|
||||
// Go through the list of region
|
||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
// Go through visible objects of the selected region
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
@@ -614,10 +613,13 @@ public class World
|
||||
final List<WorldObject> result = new ArrayList<>();
|
||||
|
||||
// Go through visible object of the selected region
|
||||
for (WorldRegion worldRegion : object.getWorldRegion().getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = object.getWorldRegion().getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
@@ -644,58 +646,6 @@ public class World
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all visible players of the WorldRegion object's and of its surrounding WorldRegion.<br>
|
||||
* <br>
|
||||
* <b><u>Concept</u>:</b><br>
|
||||
* <br>
|
||||
* All visible object are identified in <b>_visibleObjects</b> of their current WorldRegion<br>
|
||||
* All surrounding WorldRegion are identified in <b>_surroundingRegions</b> of the selected WorldRegion in order to scan a large area around a WorldObject<br>
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>Find Close Objects for Creature</li><br>
|
||||
* @param object WorldObject that determine the current WorldRegion
|
||||
* @return the visible playable
|
||||
*/
|
||||
public List<PlayerInstance> getVisiblePlayers(WorldObject object)
|
||||
{
|
||||
final WorldRegion region = object.getWorldRegion();
|
||||
if (region == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// Create a list in order to contain all visible WorldObject
|
||||
final List<PlayerInstance> result = new ArrayList<>();
|
||||
|
||||
// Go through the list of region
|
||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
||||
{
|
||||
// Go through visible object of the selected region
|
||||
for (PlayerInstance playable : worldRegion.getAllPlayers())
|
||||
{
|
||||
if (playable == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (playable.equals(object))
|
||||
{
|
||||
continue; // skip our own character
|
||||
}
|
||||
|
||||
if (!playable.isSpawned())
|
||||
{
|
||||
continue; // skip dying objects
|
||||
}
|
||||
|
||||
result.add(playable);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the current WorldRegions of the object according to its position (x,y).<br>
|
||||
* <br>
|
||||
@@ -793,24 +743,6 @@ public class World
|
||||
LOGGER.info("All visible NPCs deleted.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the account players.
|
||||
* @param account the account_name
|
||||
* @return the account players
|
||||
*/
|
||||
public List<PlayerInstance> getAccountPlayers(String account)
|
||||
{
|
||||
final List<PlayerInstance> result = new ArrayList<>();
|
||||
for (PlayerInstance actual : _allPlayers.values())
|
||||
{
|
||||
if (actual.getAccountName().equals(account))
|
||||
{
|
||||
result.add(actual);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static World getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -31,9 +30,7 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
|
||||
import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||
@@ -44,8 +41,7 @@ public class WorldRegion
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
||||
|
||||
private final Collection<PlayerInstance> _playerObjects = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<WorldObject> _visibleObjects = ConcurrentHashMap.newKeySet();
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -74,7 +70,6 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_zoneManager.unregisterZone(zone);
|
||||
}
|
||||
|
||||
@@ -127,8 +122,9 @@ public class WorldRegion
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects)
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo instanceof Attackable)
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -174,8 +170,9 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects)
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo instanceof Attackable)
|
||||
{
|
||||
// Start HP/MP/CP Regeneration task
|
||||
@@ -190,20 +187,28 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isActive()
|
||||
public boolean isActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
||||
// returns true if the above condition is met.
|
||||
public Boolean areNeighborsEmpty()
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && !worldRegion.getAllPlayers().isEmpty())
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -246,9 +251,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -272,8 +277,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -296,18 +302,19 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.add(object);
|
||||
|
||||
if (object instanceof PlayerInstance)
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_playerObjects.add((PlayerInstance) object);
|
||||
|
||||
// if this is the first player to enter the region, activate self & neighbors
|
||||
if ((_playerObjects.size() == 1) && !Config.GRIDS_ALWAYS_ON)
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
startActivation();
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startActivation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,22 +330,36 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object instanceof Playable)
|
||||
if (_visibleObjects.isEmpty())
|
||||
{
|
||||
_playerObjects.remove(object);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_playerObjects.isEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
||||
// Make sure that this region is always the first region to improve bulk operations when this region should be updated first.
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (_surroundingRegions[i] == this)
|
||||
{
|
||||
final WorldRegion first = _surroundingRegions[0];
|
||||
_surroundingRegions[0] = this;
|
||||
_surroundingRegions[i] = first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,12 +370,7 @@ public class WorldRegion
|
||||
return _surroundingRegions;
|
||||
}
|
||||
|
||||
public Collection<PlayerInstance> getAllPlayers()
|
||||
{
|
||||
return _playerObjects;
|
||||
}
|
||||
|
||||
public Collection<WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
@@ -370,8 +386,9 @@ public class WorldRegion
|
||||
public synchronized void deleteVisibleNpcSpawns()
|
||||
{
|
||||
LOGGER.info("Deleting all visible NPCs in Region: " + getName());
|
||||
for (WorldObject obj : _visibleObjects)
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject obj = _visibleObjects.get(i);
|
||||
if (obj instanceof NpcInstance)
|
||||
{
|
||||
final NpcInstance target = (NpcInstance) obj;
|
||||
@@ -404,8 +421,10 @@ public class WorldRegion
|
||||
final int down = y - range;
|
||||
final int left = x + range;
|
||||
final int right = x - range;
|
||||
for (ZoneType e : _zoneManager.getZones())
|
||||
final List<ZoneType> zones = _zoneManager.getZones();
|
||||
for (int i = 0; i < zones.size(); i++)
|
||||
{
|
||||
final ZoneType e = zones.get(i);
|
||||
if (e instanceof PeaceZone)
|
||||
{
|
||||
if (e.isInsideZone(x, up, z))
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -141,9 +141,9 @@ public class WorldObjectKnownList
|
||||
else
|
||||
{
|
||||
// Go through all visible WorldObject near the Creature
|
||||
for (WorldObject playable : World.getInstance().getVisiblePlayers(_activeObject))
|
||||
for (WorldObject object : World.getInstance().getVisibleObjects(_activeObject))
|
||||
{
|
||||
if (playable == null)
|
||||
if ((object == null) || !object.isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class WorldObjectKnownList
|
||||
// Try to add object to active object's known objects
|
||||
// Creature only needs to see visible PlayerInstance and PlayableInstance, when moving. Other creatures are currently only known from initial spawn area.
|
||||
// Possibly look into getDistanceToForgetObject values before modifying this approach...
|
||||
addKnownObject(playable);
|
||||
addKnownObject(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.items;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -404,36 +403,36 @@ public class Weapon extends Item
|
||||
continue; // Skill condition not met
|
||||
}
|
||||
|
||||
try
|
||||
// try
|
||||
// {
|
||||
// Get the skill handler corresponding to the skill type
|
||||
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
||||
final List<Creature> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
|
||||
// Launch the magic skill and calculate its effects
|
||||
if (handler != null)
|
||||
{
|
||||
// Get the skill handler corresponding to the skill type
|
||||
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
||||
final List<Creature> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
|
||||
// Launch the magic skill and calculate its effects
|
||||
if (handler != null)
|
||||
{
|
||||
handler.useSkill(caster, skill, targets);
|
||||
}
|
||||
else
|
||||
{
|
||||
skill.useSkill(caster, targets);
|
||||
}
|
||||
|
||||
if ((caster instanceof PlayerInstance) && (target instanceof NpcInstance))
|
||||
{
|
||||
for (Quest quest : ((NpcInstance) target).getTemplate().getEventQuests(EventType.ON_SKILL_USE))
|
||||
{
|
||||
quest.notifySkillUse((NpcInstance) target, (PlayerInstance) caster, skill);
|
||||
}
|
||||
}
|
||||
|
||||
output = true;
|
||||
handler.useSkill(caster, skill, targets);
|
||||
}
|
||||
catch (IOException e)
|
||||
else
|
||||
{
|
||||
skill.useSkill(caster, targets);
|
||||
}
|
||||
|
||||
if ((caster instanceof PlayerInstance) && (target instanceof NpcInstance))
|
||||
{
|
||||
for (Quest quest : ((NpcInstance) target).getTemplate().getEventQuests(EventType.ON_SKILL_USE))
|
||||
{
|
||||
quest.notifySkillUse((NpcInstance) target, (PlayerInstance) caster, skill);
|
||||
}
|
||||
}
|
||||
|
||||
output = true;
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// }
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.model.Skill;
|
||||
@@ -30,9 +29,8 @@ public interface ISkillHandler
|
||||
* @param creature
|
||||
* @param skill
|
||||
* @param targets
|
||||
* @throws IOException
|
||||
*/
|
||||
void useSkill(Creature creature, Skill skill, List<Creature> targets) throws IOException;
|
||||
void useSkill(Creature creature, Skill skill, List<Creature> targets);
|
||||
|
||||
/**
|
||||
* this method is called at initialization to register all the item ids automatically
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.handler.skillhandlers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
@@ -675,14 +674,14 @@ public class Disablers implements ISkillHandler
|
||||
final List<Creature> tgts = new ArrayList<>();
|
||||
tgts.add(target);
|
||||
|
||||
try
|
||||
{
|
||||
healhandler.useSkill(creature, skill, tgts);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(e.getMessage());
|
||||
}
|
||||
// try
|
||||
// {
|
||||
healhandler.useSkill(creature, skill, tgts);
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// LOGGER.warning(e.getMessage());
|
||||
// }
|
||||
}
|
||||
}
|
||||
for (String stat : negateEffectTypes)
|
||||
|
@@ -115,21 +115,9 @@ public class World
|
||||
*/
|
||||
public void removeObjects(List<WorldObject> list)
|
||||
{
|
||||
for (WorldObject o : list)
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
_allObjects.remove(o.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the objects.
|
||||
* @param objects the objects
|
||||
*/
|
||||
public void removeObjects(WorldObject[] objects)
|
||||
{
|
||||
for (WorldObject o : objects)
|
||||
{
|
||||
_allObjects.remove(o.getObjectId());
|
||||
_allObjects.remove(list.get(i).getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,12 +126,12 @@ public class World
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>Client packets : Action, AttackRequest, RequestJoinParty, RequestJoinPledge...</li><br>
|
||||
* @param oID Identifier of the WorldObject
|
||||
* @param objectId Identifier of the WorldObject
|
||||
* @return the object
|
||||
*/
|
||||
public WorldObject findObject(int oID)
|
||||
public WorldObject findObject(int objectId)
|
||||
{
|
||||
return _allObjects.get(oID);
|
||||
return _allObjects.get(objectId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,12 +296,10 @@ public class World
|
||||
}
|
||||
|
||||
// Go through the visible objects contained in the circular area
|
||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
||||
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||
for (int i = 0; i < visibleObjects.size(); i++)
|
||||
{
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final WorldObject wo = visibleObjects.get(i);
|
||||
|
||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||
// - Creature is visible
|
||||
@@ -342,8 +328,11 @@ public class World
|
||||
}
|
||||
|
||||
// Go through the visible objects contained in the circular area
|
||||
for (WorldObject wo : getVisibleObjects(object, 2000))
|
||||
final List<WorldObject> visibleObjects = getVisibleObjects(object, 2000);
|
||||
for (int i = 0; i < visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(i);
|
||||
|
||||
// Add the object in WorldObjectHashSet(WorldObject) _knownObjects of the visible Creature according to conditions :
|
||||
// - Creature is visible
|
||||
// - object is not already known
|
||||
@@ -417,10 +406,14 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
|
||||
// Remove the WorldObject from the WorldObjectHashSet(WorldObject) _knownObjects of the surrounding WorldRegion Creatures
|
||||
// If object is a PlayerInstance, remove the WorldObject from the WorldObjectHashSet(PlayerInstance) _knownPlayer of the surrounding WorldRegion Creatures
|
||||
// If object is targeted by one of the surrounding WorldRegion Creatures, cancel ATTACK and cast
|
||||
@@ -489,10 +482,13 @@ public class World
|
||||
final List<WorldObject> result = new ArrayList<>();
|
||||
|
||||
// Go through the list of region
|
||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
@@ -552,11 +548,14 @@ public class World
|
||||
final List<WorldObject> result = new ArrayList<>();
|
||||
|
||||
// Go through the list of region
|
||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = region.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
// Go through visible objects of the selected region
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
@@ -614,10 +613,13 @@ public class World
|
||||
final List<WorldObject> result = new ArrayList<>();
|
||||
|
||||
// Go through visible object of the selected region
|
||||
for (WorldRegion worldRegion : object.getWorldRegion().getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = object.getWorldRegion().getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == null)
|
||||
{
|
||||
continue;
|
||||
@@ -644,58 +646,6 @@ public class World
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all visible players of the WorldRegion object's and of its surrounding WorldRegion.<br>
|
||||
* <br>
|
||||
* <b><u>Concept</u>:</b><br>
|
||||
* <br>
|
||||
* All visible object are identified in <b>_visibleObjects</b> of their current WorldRegion<br>
|
||||
* All surrounding WorldRegion are identified in <b>_surroundingRegions</b> of the selected WorldRegion in order to scan a large area around a WorldObject<br>
|
||||
* <br>
|
||||
* <b><u>Example of use</u>:</b><br>
|
||||
* <li>Find Close Objects for Creature</li><br>
|
||||
* @param object WorldObject that determine the current WorldRegion
|
||||
* @return the visible playable
|
||||
*/
|
||||
public List<PlayerInstance> getVisiblePlayers(WorldObject object)
|
||||
{
|
||||
final WorldRegion region = object.getWorldRegion();
|
||||
if (region == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// Create a list in order to contain all visible WorldObject
|
||||
final List<PlayerInstance> result = new ArrayList<>();
|
||||
|
||||
// Go through the list of region
|
||||
for (WorldRegion worldRegion : region.getSurroundingRegions())
|
||||
{
|
||||
// Go through visible object of the selected region
|
||||
for (PlayerInstance playable : worldRegion.getAllPlayers())
|
||||
{
|
||||
if (playable == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (playable.equals(object))
|
||||
{
|
||||
continue; // skip our own character
|
||||
}
|
||||
|
||||
if (!playable.isSpawned())
|
||||
{
|
||||
continue; // skip dying objects
|
||||
}
|
||||
|
||||
result.add(playable);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the current WorldRegions of the object according to its position (x,y).<br>
|
||||
* <br>
|
||||
@@ -793,24 +743,6 @@ public class World
|
||||
LOGGER.info("All visible NPCs deleted.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the account players.
|
||||
* @param account the account_name
|
||||
* @return the account players
|
||||
*/
|
||||
public List<PlayerInstance> getAccountPlayers(String account)
|
||||
{
|
||||
final List<PlayerInstance> result = new ArrayList<>();
|
||||
for (PlayerInstance actual : _allPlayers.values())
|
||||
{
|
||||
if (actual.getAccountName().equals(account))
|
||||
{
|
||||
result.add(actual);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static World getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
|
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -31,9 +30,7 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
|
||||
import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||
@@ -44,8 +41,7 @@ public class WorldRegion
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(WorldRegion.class.getName());
|
||||
|
||||
private final Collection<PlayerInstance> _playerObjects = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<WorldObject> _visibleObjects = ConcurrentHashMap.newKeySet();
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -74,7 +70,6 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_zoneManager.unregisterZone(zone);
|
||||
}
|
||||
|
||||
@@ -127,8 +122,9 @@ public class WorldRegion
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects)
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo instanceof Attackable)
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -174,8 +170,9 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects)
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo instanceof Attackable)
|
||||
{
|
||||
// Start HP/MP/CP Regeneration task
|
||||
@@ -190,20 +187,28 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isActive()
|
||||
public boolean isActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
// check if all 9 neighbors (including self) are inactive or active but with no players.
|
||||
// returns true if the above condition is met.
|
||||
public Boolean areNeighborsEmpty()
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && !worldRegion.getAllPlayers().isEmpty())
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -246,9 +251,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -272,8 +277,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -296,18 +302,19 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.add(object);
|
||||
|
||||
if (object instanceof PlayerInstance)
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_playerObjects.add((PlayerInstance) object);
|
||||
|
||||
// if this is the first player to enter the region, activate self & neighbors
|
||||
if ((_playerObjects.size() == 1) && !Config.GRIDS_ALWAYS_ON)
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
startActivation();
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startActivation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,22 +330,36 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.remove(object);
|
||||
|
||||
if (object instanceof Playable)
|
||||
if (_visibleObjects.isEmpty())
|
||||
{
|
||||
_playerObjects.remove(object);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_playerObjects.isEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
startDeactivation();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSurroundingRegions(WorldRegion[] regions)
|
||||
{
|
||||
_surroundingRegions = regions;
|
||||
|
||||
// Make sure that this region is always the first region to improve bulk operations when this region should be updated first.
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (_surroundingRegions[i] == this)
|
||||
{
|
||||
final WorldRegion first = _surroundingRegions[0];
|
||||
_surroundingRegions[0] = this;
|
||||
_surroundingRegions[i] = first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,12 +370,7 @@ public class WorldRegion
|
||||
return _surroundingRegions;
|
||||
}
|
||||
|
||||
public Collection<PlayerInstance> getAllPlayers()
|
||||
{
|
||||
return _playerObjects;
|
||||
}
|
||||
|
||||
public Collection<WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
@@ -370,8 +386,9 @@ public class WorldRegion
|
||||
public synchronized void deleteVisibleNpcSpawns()
|
||||
{
|
||||
LOGGER.info("Deleting all visible NPCs in Region: " + getName());
|
||||
for (WorldObject obj : _visibleObjects)
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject obj = _visibleObjects.get(i);
|
||||
if (obj instanceof NpcInstance)
|
||||
{
|
||||
final NpcInstance target = (NpcInstance) obj;
|
||||
@@ -404,8 +421,10 @@ public class WorldRegion
|
||||
final int down = y - range;
|
||||
final int left = x + range;
|
||||
final int right = x - range;
|
||||
for (ZoneType e : _zoneManager.getZones())
|
||||
final List<ZoneType> zones = _zoneManager.getZones();
|
||||
for (int i = 0; i < zones.size(); i++)
|
||||
{
|
||||
final ZoneType e = zones.get(i);
|
||||
if (e instanceof PeaceZone)
|
||||
{
|
||||
if (e.isInsideZone(x, up, z))
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -141,9 +141,9 @@ public class WorldObjectKnownList
|
||||
else
|
||||
{
|
||||
// Go through all visible WorldObject near the Creature
|
||||
for (WorldObject playable : World.getInstance().getVisiblePlayers(_activeObject))
|
||||
for (WorldObject object : World.getInstance().getVisibleObjects(_activeObject))
|
||||
{
|
||||
if (playable == null)
|
||||
if ((object == null) || !object.isPlayable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class WorldObjectKnownList
|
||||
// Try to add object to active object's known objects
|
||||
// Creature only needs to see visible PlayerInstance and PlayableInstance, when moving. Other creatures are currently only known from initial spawn area.
|
||||
// Possibly look into getDistanceToForgetObject values before modifying this approach...
|
||||
addKnownObject(playable);
|
||||
addKnownObject(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.items;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -404,36 +403,36 @@ public class Weapon extends Item
|
||||
continue; // Skill condition not met
|
||||
}
|
||||
|
||||
try
|
||||
// try
|
||||
// {
|
||||
// Get the skill handler corresponding to the skill type
|
||||
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
||||
final List<Creature> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
|
||||
// Launch the magic skill and calculate its effects
|
||||
if (handler != null)
|
||||
{
|
||||
// Get the skill handler corresponding to the skill type
|
||||
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
|
||||
final List<Creature> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
|
||||
// Launch the magic skill and calculate its effects
|
||||
if (handler != null)
|
||||
{
|
||||
handler.useSkill(caster, skill, targets);
|
||||
}
|
||||
else
|
||||
{
|
||||
skill.useSkill(caster, targets);
|
||||
}
|
||||
|
||||
if ((caster instanceof PlayerInstance) && (target instanceof NpcInstance))
|
||||
{
|
||||
for (Quest quest : ((NpcInstance) target).getTemplate().getEventQuests(EventType.ON_SKILL_USE))
|
||||
{
|
||||
quest.notifySkillUse((NpcInstance) target, (PlayerInstance) caster, skill);
|
||||
}
|
||||
}
|
||||
|
||||
output = true;
|
||||
handler.useSkill(caster, skill, targets);
|
||||
}
|
||||
catch (IOException e)
|
||||
else
|
||||
{
|
||||
skill.useSkill(caster, targets);
|
||||
}
|
||||
|
||||
if ((caster instanceof PlayerInstance) && (target instanceof NpcInstance))
|
||||
{
|
||||
for (Quest quest : ((NpcInstance) target).getTemplate().getEventQuests(EventType.ON_SKILL_USE))
|
||||
{
|
||||
quest.notifySkillUse((NpcInstance) target, (PlayerInstance) caster, skill);
|
||||
}
|
||||
}
|
||||
|
||||
output = true;
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// }
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -402,10 +402,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -462,15 +465,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -518,15 +525,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
||||
{
|
||||
continue;
|
||||
@@ -606,27 +617,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
||||
if (wo.getInstanceId() != object.getInstanceId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -658,29 +672,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
||||
if (wo.getInstanceId() != object.getInstanceId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -402,10 +402,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -462,15 +465,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -518,15 +525,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceId() != object.getInstanceId()))
|
||||
{
|
||||
continue;
|
||||
@@ -606,27 +617,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
||||
if (wo.getInstanceId() != object.getInstanceId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -658,29 +672,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceId() != object.getInstanceId())
|
||||
if (wo.getInstanceId() != object.getInstanceId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ sp_cleanup.always_use_parentheses_in_expressions=true
|
||||
sp_cleanup.always_use_this_for_non_static_field_access=false
|
||||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_functional_interfaces=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=true
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
@@ -106,18 +106,23 @@ sp_cleanup.make_type_abstract_if_missing_method=false
|
||||
sp_cleanup.make_variable_declarations_final=true
|
||||
sp_cleanup.never_use_blocks=false
|
||||
sp_cleanup.never_use_parentheses_in_expressions=false
|
||||
sp_cleanup.number_suffix=false
|
||||
sp_cleanup.on_save_use_additional_actions=true
|
||||
sp_cleanup.organize_imports=true
|
||||
sp_cleanup.push_down_negation=false
|
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
|
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
|
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
|
||||
sp_cleanup.remove_private_constructors=true
|
||||
sp_cleanup.remove_redundant_modifiers=false
|
||||
sp_cleanup.remove_redundant_semicolons=false
|
||||
sp_cleanup.remove_redundant_type_arguments=false
|
||||
sp_cleanup.remove_trailing_whitespaces=false
|
||||
sp_cleanup.remove_trailing_whitespaces_all=true
|
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
|
||||
sp_cleanup.remove_unnecessary_array_creation=false
|
||||
sp_cleanup.remove_unnecessary_casts=true
|
||||
sp_cleanup.remove_unnecessary_nls_tags=true
|
||||
sp_cleanup.remove_unused_imports=true
|
||||
@@ -126,11 +131,14 @@ sp_cleanup.remove_unused_private_fields=true
|
||||
sp_cleanup.remove_unused_private_members=false
|
||||
sp_cleanup.remove_unused_private_methods=true
|
||||
sp_cleanup.remove_unused_private_types=true
|
||||
sp_cleanup.simplify_lambda_expression_and_method_ref=false
|
||||
sp_cleanup.sort_members=false
|
||||
sp_cleanup.sort_members_all=false
|
||||
sp_cleanup.use_anonymous_class_creation=false
|
||||
sp_cleanup.use_autoboxing=false
|
||||
sp_cleanup.use_blocks=true
|
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false
|
||||
sp_cleanup.use_directly_map_method=false
|
||||
sp_cleanup.use_lambda=true
|
||||
sp_cleanup.use_parentheses_in_expressions=true
|
||||
sp_cleanup.use_this_for_non_static_field_access=false
|
||||
@@ -138,3 +146,4 @@ sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
|
||||
sp_cleanup.use_this_for_non_static_method_access=false
|
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
|
||||
sp_cleanup.use_type_arguments=false
|
||||
sp_cleanup.use_unboxing=false
|
||||
|
@@ -406,10 +406,13 @@ public class World
|
||||
oldRegion.removeVisibleObject(object);
|
||||
|
||||
// Go through all surrounding WorldRegion Creatures
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -466,15 +469,19 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : oldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < oldSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = oldSurroundingRegions[i];
|
||||
if (newRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if (wo == object)
|
||||
{
|
||||
continue;
|
||||
@@ -522,15 +529,19 @@ public class World
|
||||
}
|
||||
}
|
||||
|
||||
for (WorldRegion worldRegion : newRegion.getSurroundingRegions())
|
||||
final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < newSurroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = newSurroundingRegions[i];
|
||||
if (oldRegion.isSurroundingRegion(worldRegion))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (WorldObject wo : worldRegion.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
|
||||
{
|
||||
continue;
|
||||
@@ -610,27 +621,30 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,29 +676,32 @@ public class World
|
||||
return;
|
||||
}
|
||||
|
||||
final WorldRegion centerWorldRegion = getRegion(object);
|
||||
if (centerWorldRegion == null)
|
||||
final WorldRegion worldRegion = getRegion(object);
|
||||
if (worldRegion == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (WorldRegion region : centerWorldRegion.getSurroundingRegions())
|
||||
final WorldRegion[] surroundingRegions = worldRegion.getSurroundingRegions();
|
||||
for (int i = 0; i < surroundingRegions.length; i++)
|
||||
{
|
||||
for (WorldObject visibleObject : region.getVisibleObjects().values())
|
||||
final List<WorldObject> visibleObjects = surroundingRegions[i].getVisibleObjects();
|
||||
for (int j = 0; j < visibleObjects.size(); j++)
|
||||
{
|
||||
if ((visibleObject == null) || (visibleObject == object) || !clazz.isInstance(visibleObject))
|
||||
final WorldObject wo = visibleObjects.get(j);
|
||||
if ((wo == null) || (wo == object) || !clazz.isInstance(wo))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.getInstanceWorld() != object.getInstanceWorld())
|
||||
if (wo.getInstanceWorld() != object.getInstanceWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visibleObject.calculateDistance3D(object) <= range)
|
||||
if (wo.calculateDistance3D(object) <= range)
|
||||
{
|
||||
c.accept(clazz.cast(visibleObject));
|
||||
c.accept(clazz.cast(wo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -28,9 +28,9 @@ import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||
|
||||
public class WorldRegion
|
||||
{
|
||||
/** Map containing visible objects in this world region. */
|
||||
private final Map<Integer, WorldObject> _visibleObjects = new ConcurrentHashMap<>();
|
||||
/** Map containing nearby regions forming this world region's effective area. */
|
||||
/** List containing visible objects in this world region. */
|
||||
private final List<WorldObject> _visibleObjects = new ArrayList<>();
|
||||
/** Array containing nearby regions forming this world region's effective area. */
|
||||
private WorldRegion[] _surroundingRegions;
|
||||
private final int _regionX;
|
||||
private final int _regionY;
|
||||
@@ -52,8 +52,9 @@ public class WorldRegion
|
||||
|
||||
if (!isOn)
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
final Attackable mob = (Attackable) wo;
|
||||
@@ -87,15 +88,16 @@ public class WorldRegion
|
||||
}
|
||||
else
|
||||
{
|
||||
for (WorldObject wo : _visibleObjects.values())
|
||||
for (int i = 0; i < _visibleObjects.size(); i++)
|
||||
{
|
||||
final WorldObject wo = _visibleObjects.get(i);
|
||||
if (wo.isAttackable())
|
||||
{
|
||||
// Start HP/MP/CP regeneration task.
|
||||
((Attackable) wo).getStatus().startHpMpRegeneration();
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
else if (wo instanceof Npc)
|
||||
else if (wo.isNpc())
|
||||
{
|
||||
RandomAnimationTaskManager.getInstance().add((Npc) wo);
|
||||
}
|
||||
@@ -110,11 +112,19 @@ public class WorldRegion
|
||||
|
||||
public boolean areNeighborsEmpty()
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
if (worldRegion.isActive() && worldRegion.getVisibleObjects().values().stream().anyMatch(WorldObject::isPlayable))
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.isActive())
|
||||
{
|
||||
return false;
|
||||
final List<WorldObject> regionObjects = worldRegion.getVisibleObjects();
|
||||
for (int j = 0; j < regionObjects.size(); j++)
|
||||
{
|
||||
if (regionObjects.get(j).isPlayable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -157,9 +167,9 @@ public class WorldRegion
|
||||
// Then, set a timer to activate the neighbors.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
worldRegion.setActive(true);
|
||||
_surroundingRegions[i].setActive(true);
|
||||
}
|
||||
}, 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
|
||||
}
|
||||
@@ -183,8 +193,9 @@ public class WorldRegion
|
||||
// Suggest means: first check if a neighbor has PlayerInstances in it. If not, deactivate.
|
||||
_neighborsTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
for (WorldRegion worldRegion : _surroundingRegions)
|
||||
for (int i = 0; i < _surroundingRegions.length; i++)
|
||||
{
|
||||
final WorldRegion worldRegion = _surroundingRegions[i];
|
||||
if (worldRegion.areNeighborsEmpty())
|
||||
{
|
||||
worldRegion.setActive(false);
|
||||
@@ -206,7 +217,13 @@ public class WorldRegion
|
||||
return;
|
||||
}
|
||||
|
||||
_visibleObjects.put(object.getObjectId(), object);
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
if (!_visibleObjects.contains(object))
|
||||
{
|
||||
_visibleObjects.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the first player to enter the region, activate self and neighbors.
|
||||
if (object.isPlayable() && !_active && !Config.GRIDS_ALWAYS_ON)
|
||||
@@ -230,7 +247,11 @@ public class WorldRegion
|
||||
{
|
||||
return;
|
||||
}
|
||||
_visibleObjects.remove(object.getObjectId());
|
||||
|
||||
synchronized (_visibleObjects)
|
||||
{
|
||||
_visibleObjects.remove(object);
|
||||
}
|
||||
|
||||
if (object.isPlayable() && areNeighborsEmpty() && !Config.GRIDS_ALWAYS_ON)
|
||||
{
|
||||
@@ -238,7 +259,7 @@ public class WorldRegion
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, WorldObject> getVisibleObjects()
|
||||
public List<WorldObject> getVisibleObjects()
|
||||
{
|
||||
return _visibleObjects;
|
||||
}
|
||||
|
Reference in New Issue
Block a user