From 8a0bc99eb5fd53eef5677223a2272aeac2968261 Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 31 Mar 2014 02:58:29 +0200 Subject: [PATCH] fixed #325, fixed ai warping to 0 0 0 --- src/services/SimulationService.java | 2 +- src/services/ai/states/AIState.java | 2 +- src/services/object/ObjectService.java | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 984497d2..054e642f 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -174,7 +174,7 @@ public class SimulationService implements INetworkDispatch { public void insertSnapShotObjects() { List objectList = new ArrayList(core.objectService.getObjectList().values()); for(SWGObject obj : objectList) { - if(obj.getParentId() == 0 && (obj.isInSnapshot() || obj.getAttachment("isBuildout") != null)) + if(obj.getParentId() == 0 && /*(*/obj.isInSnapshot() /*|| obj.getAttachment("isBuildout") != null)*/) add(obj, obj.getPosition().x, obj.getPosition().z); } } diff --git a/src/services/ai/states/AIState.java b/src/services/ai/states/AIState.java index 203a3d3f..e36a8c3a 100644 --- a/src/services/ai/states/AIState.java +++ b/src/services/ai/states/AIState.java @@ -187,7 +187,7 @@ public abstract class AIState { Point3D newPosition = new Point3D(); boolean foundNewPos = findNewPosition(actor, speed, maxDistance, newPosition); - if(!foundNewPos) + if(!foundNewPos || (newPosition.x == 0 && newPosition.z == 0)) return; Point3D newWorldPos = newPosition.getWorldPosition(); diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index b49e0fe7..19c2941d 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -176,9 +176,7 @@ public class ObjectService implements INetworkDispatch { public void loadServerTemplates() { System.out.println("Loading server templates..."); - for(Runnable r : loadServerTemplateTasks) { - r.run(); - } + loadServerTemplateTasks.forEach(Runnable::run); loadServerTemplateTasks.clear(); System.out.println("Finished loading server templates..."); } @@ -882,8 +880,8 @@ public class ObjectService implements INetworkDispatch { if (duplicate.containsKey(containerId)) { containerId = duplicate.get(containerId); } - - if (objectId != 0 && getObject(objectId) != null) { + String planetName = planet.getName(); + if (objectId != 0 && getObject(objectId) != null && (planetName.contains("dungeon") || planetName.contains("adventure"))) { SWGObject container = getObject(containerId); int x = ((int) (px + ((container == null) ? x1 : container.getPosition().x))); int z = ((int) (pz + ((container == null) ? z1 : container.getPosition().z))); @@ -907,6 +905,8 @@ public class ObjectService implements INetworkDispatch { SWGObject object; if(objectId != 0 && containerId == 0) { if(portalCRC != 0) { + if (core.getBuildingODB().contains(objectId, Long.class, BuildingObject.class) && !duplicate.containsValue(objectId)) + continue; containers.add(objectId); object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz), null, true, false); object.setAttachment("childObjects", null); @@ -960,6 +960,7 @@ public class ObjectService implements INetworkDispatch { building.createTransaction(core.getBuildingODB().getEnvironment()); core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction()); building.getTransaction().commitSync(); + destroyObject(building); } }