From e0bdbe3f2344407dc24e8b1601dbd96e72091a6b Mon Sep 17 00:00:00 2001 From: Treeku Date: Wed, 4 Jun 2014 01:00:28 +0100 Subject: [PATCH] Minor movement changes for vehicles --- src/services/SimulationService.java | 60 ++++++++++------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 040a905c..f93defd4 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -341,9 +341,9 @@ public class SimulationService implements INetworkDispatch { CreatureObject creature = (CreatureObject) client.getParent(); - CreatureObject object = (CreatureObject) client.getParent(); + CreatureObject object = creature; - if (core.mountService.isMounted(object)) { + if (core.mountService.isMounted(creature) && creature.getObjectID() == ((CreatureObject) creature.getContainer()).getOwnerId()) { object = (CreatureObject) object.getContainer(); } @@ -371,59 +371,41 @@ public class SimulationService implements INetworkDispatch { add(object, newPos.x, newPos.z); } - - - //object.setParentId(0); //object.setParent(null); // System.out.println("Parsed Height: " + core.terrainService.getHeight(object.getPlanetId(), dataTransform.getXPosition(), dataTransform.getZPosition()) // + " should be: " + dataTransform.getYPosition()); UpdateTransformMessage utm = new UpdateTransformMessage(object.getObjectID(), dataTransform.getTransformedX(), dataTransform.getTransformedY(), dataTransform.getTransformedZ(), dataTransform.getMovementCounter(), (byte) dataTransform.getMovementAngle(), dataTransform.getSpeed()); - - List newAwareObjects = get(object.getPlanet(), newPos.x, newPos.z, 512); - ArrayList oldAwareObjects = new ArrayList(object.getAwareObjects()); - @SuppressWarnings("unchecked") Collection updateAwareObjects = CollectionUtils.intersection(oldAwareObjects, newAwareObjects); object.notifyObservers(utm, false); - + + List newAwareObjects = get(creature.getPlanet(), newPos.x, newPos.z, 512); + ArrayList oldAwareObjects = new ArrayList(creature.getAwareObjects()); + @SuppressWarnings("unchecked") Collection updateAwareObjects = CollectionUtils.intersection(oldAwareObjects, newAwareObjects); + for(int i = 0; i < oldAwareObjects.size(); i++) { SWGObject obj = oldAwareObjects.get(i); - if(!updateAwareObjects.contains(obj) && obj != object && obj.getWorldPosition().getDistance2D(newPos) > 200 && obj.isInQuadtree() /*&& obj.getParentId() == 0*/) { + if(!updateAwareObjects.contains(obj) && obj != creature && obj.getWorldPosition().getDistance2D(newPos) > 200 && obj.isInQuadtree() /*&& obj.getParentId() == 0*/) { if(obj.getAttachment("bigSpawnRange") != null && obj.getWorldPosition().getDistance2D(newPos) < 512) continue; - object.makeUnaware(obj); + creature.makeUnaware(obj); if(obj.getClient() != null) - obj.makeUnaware(object); - } else if(obj != object && obj.getWorldPosition().getDistance2D(newPos) > 200 && obj.isInQuadtree() && obj.getAttachment("bigSpawnRange") == null) { - object.makeUnaware(obj); + obj.makeUnaware(creature); + } else if(obj != creature && obj.getWorldPosition().getDistance2D(newPos) > 200 && obj.isInQuadtree() && obj.getAttachment("bigSpawnRange") == null) { + creature.makeUnaware(obj); if(obj.getClient() != null) - obj.makeUnaware(object); + obj.makeUnaware(creature); } } + for(int i = 0; i < newAwareObjects.size(); i++) { SWGObject obj = newAwareObjects.get(i); //System.out.println(obj.getTemplate()); - if(!updateAwareObjects.contains(obj) && obj != object && !object.getAwareObjects().contains(obj) && obj.getContainer() != object && obj.isInQuadtree()) { + if(!updateAwareObjects.contains(obj) && obj != creature && !creature.getAwareObjects().contains(obj) && obj.getContainer() != creature && obj.isInQuadtree()) { if(obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance2D(newPos) > 200) continue; - //object.makeAware(obj); - - if (object.getOption(Options.MOUNT)){ - CreatureObject owner = (CreatureObject) core.objectService.getObject(object.getOwnerId()); - owner.makeAware(obj); - } - else { - object.makeAware(obj); - } - - if(obj.getClient() != null){ - if (object.getOption(Options.MOUNT)){ - CreatureObject owner = (CreatureObject) core.objectService.getObject(object.getOwnerId()); - obj.makeAware(owner); - } - else { - obj.makeAware(object); - } - } + creature.makeAware(obj); + if(obj.getClient() != null) + obj.makeAware(creature); } } @@ -434,8 +416,7 @@ public class SimulationService implements INetworkDispatch { object.getEventBus().publish(event); } - - + }); objControllerOpcodes.put(ObjControllerOpcodes.DATA_TRANSFORM_WITH_PARENT, new INetworkRemoteEvent() { @@ -485,7 +466,7 @@ public class SimulationService implements INetworkDispatch { if(object.getContainer() != null) object.getContainer()._remove(object); if (object.getClient().isGM() && parent != null && parent instanceof CellObject && parent.getContainer() != null) - object.sendSystemMessage("BuildingId Hex: " + Long.toHexString(parent.getContainer().getObjectID()) + " CellNumber: " + ((CellObject) parent).getCellNumber(), DisplayType.Broadcast); + object.sendSystemMessage("BuildingId - Dec: " + parent.getContainer().getObjectID() + " Hex: " + Long.toHexString(parent.getContainer().getObjectID()) + " CellNumber: " + ((CellObject) parent).getCellNumber(), DisplayType.Broadcast); parent._add(object); } object.setPosition(newPos); @@ -767,6 +748,7 @@ public class SimulationService implements INetworkDispatch { return new Point3D(x, y, z); } + /* * Moved this to ConnectionService which will disconnect them * from the server if they don't send packets for 5 minutes or more