1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Several performance improvements, monster template and xml updates and

fixed bug while logging-in

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-31 17:05:39 -03:00
parent d72bb75cb0
commit 657b555fe1
3464 changed files with 3539 additions and 3481 deletions

View File

@@ -20,7 +20,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.l2jserver.service.cache.CacheService;
import com.l2jserver.service.cache.EhCacheService;
import com.l2jserver.service.cache.SoftCacheService;
import com.l2jserver.service.configuration.ConfigurationService;
import com.l2jserver.service.configuration.ProxyConfigurationService;
import com.l2jserver.service.core.Log4JLoggingService;
@@ -78,7 +78,8 @@ public class ServiceModule extends AbstractModule {
Scopes.SINGLETON);
bind(ConfigurationService.class).to(ProxyConfigurationService.class)
.in(Scopes.SINGLETON);
bind(CacheService.class).to(EhCacheService.class).in(Scopes.SINGLETON);
bind(CacheService.class).to(SoftCacheService.class)
.in(Scopes.SINGLETON);
bind(DatabaseService.class).to(JDBCDatabaseService.class).in(
Scopes.SINGLETON);

View File

@@ -18,7 +18,6 @@ package com.l2jserver.service.cache;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -31,7 +30,7 @@ import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
/**
* This {@link Cache} service implementation uses a {@link SoftReference} to
* This {@link Cache} service implementation uses a {@link WeakReference} to
* store values.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>

View File

@@ -162,9 +162,6 @@ public class CharacterServiceImpl extends AbstractService implements
}
};
// start broadcasting -- will broadcast all nearby objects
broadcastService.broadcast(conn);
// leave world event
eventDispatcher.addListener(id, new CharacterListener() {
@Override
@@ -205,6 +202,9 @@ public class CharacterServiceImpl extends AbstractService implements
conn.sendMessage("This an an development version for l2jserver 2.0");
conn.sendMessage("Please note that many of the features are not yet implemented.");
// start broadcasting -- will broadcast all nearby objects
broadcastService.broadcast(conn);
// characters start in run mode
try {
run(character);
@@ -282,9 +282,12 @@ public class CharacterServiceImpl extends AbstractService implements
// check if this Actor can be attacked
if (target instanceof NPC) {
final NPC npc = (NPC) target;
// first try to target this, if it is not already
target(character, target);
// first try to target this, if it is not already
if (!npc.getID().equals(character.getTargetID()))
target(character, target);
// now attack the npc
npcService.attack(npc, conn, character);
} else {
// TODO throw an exception

View File

@@ -115,9 +115,6 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
Preconditions.checkNotNull(character, "character");
Preconditions.checkNotNull(action, "action");
if (npc.getTemplate().isTargetable())
characterService.target(character, npc);
final Lineage2Connection conn = networkService.discover(character
.getID());
try {
@@ -136,9 +133,6 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
if (args == null)
args = new String[0];
if (npc.getTemplate().isTargetable())
characterService.target(character, npc);
final Lineage2Connection conn = networkService.discover(character
.getID());
try {

View File

@@ -33,7 +33,7 @@ public class RangeFilter implements WorldObjectFilter<PositionableObject> {
/**
* The desired maximum distance of the object
*/
private final int range;
private final double range;
/**
* Creates a new instance
@@ -47,13 +47,14 @@ public class RangeFilter implements WorldObjectFilter<PositionableObject> {
Preconditions.checkNotNull(object, "object");
Preconditions.checkState(range >= 0, "range < 0");
this.object = object;
this.range = range;
this.range = Math.pow(range, 2);
}
@Override
public boolean accept(PositionableObject other) {
if (other == null)
return false;
return other.getPosition().getDistance(object.getPosition()) <= range;
return other.getPosition().getDistanceSquared(object.getPosition()) <= range;
}
}

View File

@@ -16,6 +16,8 @@
*/
package com.l2jserver.service.game.world.filter.impl;
import org.apache.commons.math.util.FastMath;
import com.google.common.base.Preconditions;
import com.l2jserver.model.world.PositionableObject;
import com.l2jserver.service.game.world.filter.WorldObjectFilter;
@@ -34,7 +36,11 @@ public class RangePointFilter implements WorldObjectFilter<PositionableObject> {
/**
* The desired maximum distance of the object
*/
private final int range;
private final double range;
/**
* The <tt>range</tt> multiplied by two
*/
private final double doubleRange;
/**
* Creates a new instance
@@ -48,13 +54,25 @@ public class RangePointFilter implements WorldObjectFilter<PositionableObject> {
Preconditions.checkNotNull(point, "point");
Preconditions.checkState(range >= 0, "range < 0");
this.point = point;
this.range = range;
this.range = Math.pow(range, 2);
this.doubleRange = range * 2;
}
@Override
public boolean accept(PositionableObject other) {
if (other == null)
return false;
return other.getPosition().getDistance(point.getCoordinate()) <= range;
final double dx = FastMath.abs(point.getX() - other.getPoint().getX());
final double dy = FastMath.abs(point.getY() - other.getPoint().getY());
final double dz = FastMath.abs(point.getZ() - other.getPoint().getZ());
if (dx > doubleRange)
return false;
if (dy > doubleRange)
return false;
if (dz > doubleRange)
return false;
return ((dx * dx) + (dy * dy) + (dz * dz)) <= range;
}
}

View File

@@ -76,7 +76,7 @@ public class BroadcastServiceImpl extends AbstractService implements
final CharacterID id = character.getID();
// broadcast everything nearby
broadcast(conn);
//broadcast(conn);
// event broadcast listener
// this listener will be filtered so that only interesting events are