diff --git a/ngengine_public.jar b/ngengine_public.jar index c1ff368c..6da80c04 100644 Binary files a/ngengine_public.jar and b/ngengine_public.jar differ diff --git a/scripts/object/building/general/shuttleport_general.py b/scripts/object/building/general/shuttleport_general.py index ccad8904..9d1219e5 100644 --- a/scripts/object/building/general/shuttleport_general.py +++ b/scripts/object/building/general/shuttleport_general.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + objSvc = core.objectService + objSvc.createChildObject(object, 'object/tangible/terminal/shared_terminal_travel.iff', -13, 0.6, -10, -0.707107, 0.707107) + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_shuttle.iff', 0, 0.6, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', -13, 0.6, 10, -0.707107, 0.707107) return \ No newline at end of file diff --git a/scripts/object/building/naboo/hangar_naboo_theed.py b/scripts/object/building/naboo/hangar_naboo_theed.py index ccad8904..f3d215ec 100644 --- a/scripts/object/building/naboo/hangar_naboo_theed.py +++ b/scripts/object/building/naboo/hangar_naboo_theed.py @@ -1,4 +1,19 @@ import sys def setup(core, object): + stcSvc = core.staticService + cell = object.getCellByCellNumber(3) + cell2 = object.getCellByCellNumber(4) + cell3 = object.getCellByCellNumber(5) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-26.94), float(0.749), float(-67.14), float(1), float(0)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell2.getObjectID(), float(26.94), float(0.749), float(-67.14), float(1), float(0)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell3.getObjectID(), float(-9.49), float(7.979), float(-45.2359), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell3.getObjectID(), float(9.49), float(7.979), float(-45.2359), float(0), float(1)) + stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', object.getPlanet().getName(), cell3.getObjectID(), float(-10), float(7.979), float(10), float(-0.707107), float(0.707107)) + stcSvc.spawnObject('object/creature/npc/theme_park/shared_player_transport_theed_hangar.iff', object.getPlanet().getName(), cell3.getObjectID(), float(0), float(7.979), float(0), float(1), float(1)) + + core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) + return \ No newline at end of file diff --git a/scripts/object/building/naboo/rori_restuss_shuttleport.py b/scripts/object/building/naboo/rori_restuss_shuttleport.py index ccad8904..9d1219e5 100644 --- a/scripts/object/building/naboo/rori_restuss_shuttleport.py +++ b/scripts/object/building/naboo/rori_restuss_shuttleport.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + objSvc = core.objectService + objSvc.createChildObject(object, 'object/tangible/terminal/shared_terminal_travel.iff', -13, 0.6, -10, -0.707107, 0.707107) + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_shuttle.iff', 0, 0.6, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', -13, 0.6, 10, -0.707107, 0.707107) return \ No newline at end of file diff --git a/scripts/object/building/naboo/rori_restuss_starport.py b/scripts/object/building/naboo/rori_restuss_starport.py index ccad8904..c48218dd 100644 --- a/scripts/object/building/naboo/rori_restuss_starport.py +++ b/scripts/object/building/naboo/rori_restuss_starport.py @@ -1,4 +1,14 @@ import sys def setup(core, object): + stcSvc = core.staticService + objSvc = core.objectService + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_transport.iff', 0, 7, 0, 0.707107, 0.707107) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 1, 0, -10, 0, 1) + + cell = object.getCellByCellNumber(1) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-3.12), float(0.14659503), float(-17.57), float(0.707107), float(-0.707107)) + return \ No newline at end of file diff --git a/scripts/object/building/restuss/restuss_shuttleport.py b/scripts/object/building/restuss/restuss_shuttleport.py index ccad8904..a3ddedaa 100644 --- a/scripts/object/building/restuss/restuss_shuttleport.py +++ b/scripts/object/building/restuss/restuss_shuttleport.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + return \ No newline at end of file diff --git a/scripts/object/building/restuss/restuss_starport.py b/scripts/object/building/restuss/restuss_starport.py index ccad8904..b686025c 100644 --- a/scripts/object/building/restuss/restuss_starport.py +++ b/scripts/object/building/restuss/restuss_starport.py @@ -1,4 +1,16 @@ import sys def setup(core, object): + + stcSvc = core.staticService + objSvc = core.objectService + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_transport.iff', 0, 7, 0, 0.707107, 0.707107) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 1, 0, -10, 0, 1) + + cell = object.getCellByCellNumber(1) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-3.12), float(0.14659503), float(-17.57), float(0.707107), float(-0.707107)) + + return \ No newline at end of file diff --git a/scripts/object/creature/npc/theme_park/player_transport_theed_hangar.py b/scripts/object/creature/npc/theme_park/player_transport_theed_hangar.py index ccad8904..57a5dcc3 100644 --- a/scripts/object/creature/npc/theme_park/player_transport_theed_hangar.py +++ b/scripts/object/creature/npc/theme_park/player_transport_theed_hangar.py @@ -1,4 +1,11 @@ import sys def setup(core, object): + object.setPosture(0) # land = 0 : away = 2 + object.setOptionsBitmask(256) + tp = core.travelService.getNearestTravelPoint(object) + if tp: + tp.setShuttle(object) + tp.setShuttleAvailable(True) + tp.setShuttleLanding(False) return \ No newline at end of file diff --git a/scripts/static_spawns/rori.py b/scripts/static_spawns/rori.py index ae6e37f3..e097f64b 100644 --- a/scripts/static_spawns/rori.py +++ b/scripts/static_spawns/rori.py @@ -369,15 +369,15 @@ def addPlanetSpawns(core, planet): stcSvc.spawnObject('object/static/worldbuilding/structures/shared_mun_nboo_building_chunk_destoyed_10.iff', 'rori', long(0), float(5165.2), float(80), float(5550.01), float(0.24), float(0.971)) stcSvc.spawnObject('object/static/worldbuilding/decal/shared_mun_decal_blast_lg.iff', 'rori', long(0), float(5139.4), float(160), float(5599.26), float(0.349), float(0.937)) stcSvc.spawnObject('object/static/worldbuilding/structures/shared_mun_nboo_building_chunk_destoyed_13.iff', 'rori', long(0), float(5124.02), float(80), float(5682.59), float(0.057), float(0.998)) - stcSvc.spawnObject('object/building/military/shared_outpost_cloning_facility.iff', 'rori', long(0), float(5232.54), float(79.914), float(6176.29), float(0.703), float(0.711)) - stcSvc.spawnObject('object/building/naboo/shared_rori_restuss_starport.iff', 'rori', long(0), float(5281.13), float(80), float(6171.442), float(1), float(-0.001)) - stcSvc.spawnObject('object/building/military/shared_military_base_shed_imperial_style_cantina_s01.iff', 'rori', long(0), float(5284.15), float(80), float(6236.408), float(1), float(-0.001)) - stcSvc.spawnObject('object/building/military/shared_military_base_shed_imperial_style_hospital_01.iff', 'rori', long(0), float(5327.94), float(80), float(6204.451), float(0.877), float(-0.48)) - stcSvc.spawnObject('object/building/military/shared_military_rebel_tactical_center.iff', 'rori', long(0), float(4719.25), float(80), float(5870.46), float(0.707), float(0.707)) - stcSvc.spawnObject('object/building/restuss/shared_restuss_faction_cantina.iff', 'rori', long(0), float(4827.85), float(80), float(5874.45), float(0.703), float(0.711)) - stcSvc.spawnObject('object/building/military/shared_military_rebel_tactical_center.iff', 'rori', long(0), float(4778.08), float(80), float(5905.97), float(1), float(0)) - stcSvc.spawnObject('object/building/military/shared_military_base_shed_rebel_style_01.iff', 'rori', long(0), float(4831.285), float(80), float(5810.192), float(-0.41), float(0.912)) - stcSvc.spawnObject('object/building/military/shared_military_rebel_detachment_hq.iff', 'rori', long(0), float(4777.64), float(80), float(5776.2), float(0), float(1)) + #stcSvc.spawnObject('object/building/military/shared_outpost_cloning_facility.iff', 'rori', long(0), float(5232.54), float(79.914), float(6176.29), float(0.703), float(0.711)) + #stcSvc.spawnObject('object/building/naboo/shared_rori_restuss_starport.iff', 'rori', long(0), float(5281.13), float(80), float(6171.442), float(1), float(-0.001)) + #stcSvc.spawnObject('object/building/military/shared_military_base_shed_imperial_style_cantina_s01.iff', 'rori', long(0), float(5284.15), float(80), float(6236.408), float(1), float(-0.001)) + #stcSvc.spawnObject('object/building/military/shared_military_base_shed_imperial_style_hospital_01.iff', 'rori', long(0), float(5327.94), float(80), float(6204.451), float(0.877), float(-0.48)) + #stcSvc.spawnObject('object/building/military/shared_military_rebel_tactical_center.iff', 'rori', long(0), float(4719.25), float(80), float(5870.46), float(0.707), float(0.707)) + #stcSvc.spawnObject('object/building/restuss/shared_restuss_faction_cantina.iff', 'rori', long(0), float(4827.85), float(80), float(5874.45), float(0.703), float(0.711)) + #stcSvc.spawnObject('object/building/military/shared_military_rebel_tactical_center.iff', 'rori', long(0), float(4778.08), float(80), float(5905.97), float(1), float(0)) + #stcSvc.spawnObject('object/building/military/shared_military_base_shed_rebel_style_01.iff', 'rori', long(0), float(4831.285), float(80), float(5810.192), float(-0.41), float(0.912)) + #stcSvc.spawnObject('object/building/military/shared_military_rebel_detachment_hq.iff', 'rori', long(0), float(4777.64), float(80), float(5776.2), float(0), float(1)) stcSvc.spawnObject('object/static/worldbuilding/decal/shared_mun_decal_blast_lg.iff', 'rori', long(0), float(5254.85), float(160), float(5553.39), float(-0.551), float(0.834)) stcSvc.spawnObject('object/static/worldbuilding/decal/shared_mun_decal_blast_lg.iff', 'rori', long(0), float(5365.02), float(160), float(5577.16), float(-0.574), float(0.819)) stcSvc.spawnObject('object/static/worldbuilding/decal/shared_mun_decal_blast_lg.iff', 'rori', long(0), float(5143.04), float(160), float(5552.77), float(-0.259), float(0.966)) diff --git a/scripts/static_travel_points.py b/scripts/static_travel_points.py index 49a20aa2..50461dcb 100644 --- a/scripts/static_travel_points.py +++ b/scripts/static_travel_points.py @@ -86,6 +86,7 @@ def nabooPoints(core, planet): trvSvc.addTravelPoint(planet, "Theed Shuttle A", -5856, 19, 4172) trvSvc.addTravelPoint(planet, "Theed Shuttle B", -5005, 19, 4072) trvSvc.addTravelPoint(planet, "Theed Shuttle C", -5411, 19, 4332) + trvSvc.addTravelPoint(planet, "Theed Spaceport", -4858, 5, 4164) return diff --git a/src/main/NGECore.java b/src/main/NGECore.java index ba630888..50667a51 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -286,7 +286,7 @@ public class NGECore { didServerCrash = false; System.out.println("Started Server."); setGalaxyStatus(2); - + } diff --git a/src/protocol/swg/UpdateCellPermissionMessage.java b/src/protocol/swg/UpdateCellPermissionMessage.java index fe35f240..943eb532 100644 --- a/src/protocol/swg/UpdateCellPermissionMessage.java +++ b/src/protocol/swg/UpdateCellPermissionMessage.java @@ -42,13 +42,13 @@ public class UpdateCellPermissionMessage extends SWGMessage { } public IoBuffer serialize() { - IoBuffer result = IoBuffer.allocate(128).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer result = IoBuffer.allocate(15).order(ByteOrder.LITTLE_ENDIAN); result.putShort((short)3); result.putInt(0xF612499C); result.put(permission); result.putLong(cellId); - return result; + return result.flip(); } } diff --git a/src/resources/objects/building/BuildingMessageBuilder.java b/src/resources/objects/building/BuildingMessageBuilder.java index 224e0a8d..606f5f78 100644 --- a/src/resources/objects/building/BuildingMessageBuilder.java +++ b/src/resources/objects/building/BuildingMessageBuilder.java @@ -21,6 +21,93 @@ ******************************************************************************/ package resources.objects.building; -public class BuildingMessageBuilder { +import java.nio.ByteOrder; +import org.apache.mina.core.buffer.IoBuffer; +import resources.objects.ObjectMessageBuilder; + +public class BuildingMessageBuilder extends ObjectMessageBuilder { + + public BuildingMessageBuilder(BuildingObject buildingObject) { + setObject(buildingObject); + } + + public IoBuffer buildBaseline3() { + + BuildingObject building = (BuildingObject) object; + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 0x0D); + buffer.putFloat(building.getComplexity()); + buffer.put(getAsciiString(building.getStfFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(building.getStfName())); + buffer.putInt(0); + buffer.putInt(255); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(1).order(ByteOrder.BIG_ENDIAN); + buffer.putInt(0); + buffer.putInt(0); + buffer.putShort((short) 0); + buffer.putInt(0x201C); + buffer.put((byte) 1); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("BUIO", (byte) 3, buffer, size); + + return buffer; + + } + + public IoBuffer buildBaseline6() { + + BuildingObject building = (BuildingObject) object; + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 8); + buffer.putInt(0x43); + + buffer.put(getAsciiString(building.getDetailFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(building.getDetailName())); + buffer.putInt(0); + buffer.put((byte) 0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("BUIO", (byte) 6, buffer, size); + + return buffer; + + } + + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + + @Override + public void sendBaselines() { + + } } diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index a1267703..482e9cb2 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -21,14 +21,10 @@ ******************************************************************************/ package resources.objects.building; - - import java.util.concurrent.atomic.AtomicReference; - import resources.objects.cell.CellObject; - import com.sleepycat.persist.model.Entity; - +import com.sleepycat.persist.model.NotPersistent; import engine.clients.Client; import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; @@ -39,18 +35,17 @@ import engine.resources.scene.Quaternion; @Entity public class BuildingObject extends SWGObject { + @NotPersistent + private BuildingMessageBuilder messageBuilder; + public BuildingObject() { super(); + messageBuilder = new BuildingMessageBuilder(this); } public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { super(objectID, planet, position, orientation, Template); - } - - @Override - public void sendBaselines(Client client) { - // TODO Auto-generated method stub - + messageBuilder = new BuildingMessageBuilder(this); } public CellObject getCellByCellNumber(final int cellNumber) { @@ -73,5 +68,17 @@ public class BuildingObject extends SWGObject { } - + @Override + public void sendBaselines(Client destination) { + + if(destination == null || destination.getSession() == null) { + System.out.println("NULL session"); + return; + } + + destination.getSession().write(messageBuilder.buildBaseline3()); + destination.getSession().write(messageBuilder.buildBaseline6()); + + } + } diff --git a/src/resources/objects/cell/CellMessageBuilder.java b/src/resources/objects/cell/CellMessageBuilder.java index 63f5592b..dd627e06 100644 --- a/src/resources/objects/cell/CellMessageBuilder.java +++ b/src/resources/objects/cell/CellMessageBuilder.java @@ -21,6 +21,78 @@ ******************************************************************************/ package resources.objects.cell; -public class CellMessageBuilder { +import java.nio.ByteOrder; +import org.apache.mina.core.buffer.IoBuffer; + +import resources.objects.ObjectMessageBuilder; +import resources.objects.building.BuildingObject; + +public class CellMessageBuilder extends ObjectMessageBuilder { + + public CellMessageBuilder(CellObject cellObject) { + setObject(cellObject); + } + + public IoBuffer buildBaseline3() { + + CellObject cell = (CellObject) object; + IoBuffer buffer = bufferPool.allocate(27, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 6); + buffer.putFloat(0); + buffer.putShort((short) 0); + + buffer.putInt(0); + buffer.putShort((short) 0); + + buffer.putInt(0); + buffer.putInt(0); + buffer.put((byte) 1); + buffer.putInt(cell.getCellNumber()); + + int size = buffer.position(); + + buffer.flip(); + buffer = createBaseline("SCLT", (byte) 3, buffer, size); + + return buffer; + + } + + public IoBuffer buildBaseline6() { + + IoBuffer buffer = bufferPool.allocate(30, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 4); + buffer.putInt(0x43); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + + int size = buffer.position(); + + buffer.flip(); + buffer = createBaseline("SCLT", (byte) 6, buffer, size); + + return buffer; + + } + + + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + + @Override + public void sendBaselines() { + // TODO Auto-generated method stub + + } } diff --git a/src/resources/objects/cell/CellObject.java b/src/resources/objects/cell/CellObject.java index a32e33b1..bf8670b8 100644 --- a/src/resources/objects/cell/CellObject.java +++ b/src/resources/objects/cell/CellObject.java @@ -21,10 +21,10 @@ ******************************************************************************/ package resources.objects.cell; +import protocol.swg.UpdateCellPermissionMessage; - +import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; - import engine.clients.Client; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; @@ -35,18 +35,23 @@ import engine.resources.scene.Quaternion; public class CellObject extends SWGObject { private int cellNumber = 0; + @NotPersistent + private CellMessageBuilder messageBuilder; public CellObject() { super(); + messageBuilder = new CellMessageBuilder(this); } public CellObject(long objectID, Planet planet, int cellNumber) { - super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/cell/shared_cell.iff"); + super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/cell/shared_cell.iff"); setCellNumber(cellNumber); + messageBuilder = new CellMessageBuilder(this); } public CellObject(long objectID, Planet planet) { - super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/cell/shared_cell.iff"); + super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/cell/shared_cell.iff"); + messageBuilder = new CellMessageBuilder(this); } public int getCellNumber() { @@ -62,8 +67,17 @@ public class CellObject extends SWGObject { } @Override - public void sendBaselines(Client client) { - // TODO Auto-generated method stub + public void sendBaselines(Client destination) { + + if(destination == null || destination.getSession() == null) { + System.out.println("NULL session"); + return; + } + + destination.getSession().write(messageBuilder.buildBaseline3()); + destination.getSession().write(messageBuilder.buildBaseline6()); + destination.getSession().write(new UpdateCellPermissionMessage((byte) 1, getObjectID()).serialize()); + } diff --git a/src/resources/objects/staticobject/StaticMessageBuilder.java b/src/resources/objects/staticobject/StaticMessageBuilder.java index 696954f3..41aaa4ba 100644 --- a/src/resources/objects/staticobject/StaticMessageBuilder.java +++ b/src/resources/objects/staticobject/StaticMessageBuilder.java @@ -41,9 +41,11 @@ public class StaticMessageBuilder extends ObjectMessageBuilder { buffer.putShort((short) 4); buffer.putInt(0); + //buffer.putShort((short) 0); buffer.put(getAsciiString(object.getStfFilename())); buffer.putInt(0); + //buffer.putShort((short) 0); buffer.put(getAsciiString(object.getStfName())); buffer.putInt(0); buffer.putInt(0xFF); @@ -63,9 +65,11 @@ public class StaticMessageBuilder extends ObjectMessageBuilder { buffer.setAutoExpand(true); buffer.putShort((short) 2); buffer.putInt(0x92); + //buffer.putShort((short) 0); buffer.put(getAsciiString(object.getDetailFilename())); buffer.putInt(0); buffer.put(getAsciiString(object.getDetailName())); + // buffer.putShort((short) 0); int size = buffer.position(); buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); diff --git a/src/resources/objects/staticobject/StaticObject.java b/src/resources/objects/staticobject/StaticObject.java index 1bb2380c..28b9d797 100644 --- a/src/resources/objects/staticobject/StaticObject.java +++ b/src/resources/objects/staticobject/StaticObject.java @@ -55,8 +55,8 @@ public class StaticObject extends SWGObject { return; } - destination.getSession().write(messageBuilder.buildBaseline3()); - destination.getSession().write(messageBuilder.buildBaseline6()); + //destination.getSession().write(messageBuilder.buildBaseline3()); + //destination.getSession().write(messageBuilder.buildBaseline6()); } diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 443d57cb..48197155 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -248,7 +248,7 @@ public class SimulationService implements INetworkDispatch { // + " 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, 200); + List newAwareObjects = get(object.getPlanet(), newPos.x, newPos.z, 512); ArrayList oldAwareObjects = new ArrayList(object.getAwareObjects()); Collection updateAwareObjects = CollectionUtils.intersection(oldAwareObjects, newAwareObjects); object.notifyObservers(utm, false); @@ -256,6 +256,8 @@ public class SimulationService implements INetworkDispatch { 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(obj.getAttachment("bigSpawnRange") != null && obj.getWorldPosition().getDistance2D(newPos) < 512) + continue; object.makeUnaware(obj); if(obj.getClient() != null) obj.makeUnaware(object); @@ -263,7 +265,10 @@ public class SimulationService implements INetworkDispatch { } for(int i = 0; i < newAwareObjects.size(); i++) { SWGObject obj = newAwareObjects.get(i); - if(!updateAwareObjects.contains(obj) && obj != object && !object.getAwareObjects().contains(obj) && obj.getWorldPosition().getDistance2D(newPos) <= 200 && obj.getContainer() != object && obj.isInQuadtree()) { + //System.out.println(obj.getTemplate()); + if(!updateAwareObjects.contains(obj) && obj != object && !object.getAwareObjects().contains(obj) && obj.getContainer() != object && obj.isInQuadtree()) { + if(obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance2D(newPos) > 200) + continue; object.makeAware(obj); if(obj.getClient() != null) obj.makeAware(object); @@ -515,9 +520,11 @@ public class SimulationService implements INetworkDispatch { Point3D pos = object.getWorldPosition(); - Collection newAwareObjects = get(object.getPlanet(), pos.x, pos.z, 200); + Collection newAwareObjects = get(object.getPlanet(), pos.x, pos.z, 512); for(Iterator it = newAwareObjects.iterator(); it.hasNext();) { SWGObject obj = it.next(); + if(obj.getAttachment("bigSpawnRange") == null & obj.getWorldPosition().getDistance(pos) > 200) + continue; object.makeAware(obj); if(obj.getClient() != null) obj.makeAware(object); diff --git a/src/services/TerrainService.java b/src/services/TerrainService.java index d6c80695..789f54f9 100644 --- a/src/services/TerrainService.java +++ b/src/services/TerrainService.java @@ -130,7 +130,12 @@ public class TerrainService { config.setFilePath("options.cfg"); if (config.loadConfigFile() && config.getInt("LOAD.SNAPSHOT_OBJECTS") > 0) { - core.objectService.loadSnapshotObjects(planet); + try { + core.objectService.loadSnapshotObjects(planet); + core.objectService.loadBuildoutObjects(planet); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } } } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index f7595124..014c66b3 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -57,6 +57,7 @@ import protocol.swg.ServerTimeMessage; import protocol.swg.UnkByteFlag; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.CrcStringTableVisitor; +import engine.clientdata.visitors.DatatableVisitor; import engine.clientdata.visitors.WorldSnapshotVisitor; import engine.clientdata.visitors.WorldSnapshotVisitor.SnapshotChunk; import engine.clients.Client; @@ -144,8 +145,11 @@ public class ObjectService implements INetworkDispatch { } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } + boolean isSnapshot = false; if(objectID == 0) objectID = generateObjectID(); + else + isSnapshot = true; if(Template.startsWith("object/creature")) { @@ -163,9 +167,17 @@ public class ObjectService implements INetworkDispatch { object = new WeaponObject(objectID, planet, Template, position, orientation); - } else if(Template.startsWith("object/building")){ + } else if(Template.startsWith("object/building") || Template.startsWith("object/static/worldbuilding/structures")){ object = new BuildingObject(objectID, planet, position, orientation, Template); + if(!isSnapshot && object.getPortalVisitor() != null) { + int cellCount = object.getPortalVisitor().cells.size() - 1; // -1 for index 0 cell which is outside the building and used for ai pathfinding + for (int i = 0; i < cellCount; i++) { + CellObject cell = (CellObject) createObject("object/cell/shared_cell.iff", planet); + cell.setCellNumber(i+1); + object.add(cell); + } + } } else if(Template.startsWith("object/cell")) { @@ -198,7 +210,7 @@ public class ObjectService implements INetworkDispatch { } object.setPlanetId(planet.getID()); - + object.setisInSnapshot(isSnapshot); //loadServerTemplate(object); objectList.put(objectID, object); @@ -596,6 +608,106 @@ public class ObjectService implements INetworkDispatch { public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) { createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0)); } + + public void loadBuildoutObjects(Planet planet) throws InstantiationException, IllegalAccessException { + + DatatableVisitor buildoutTable = ClientFileManager.loadFile("datatables/buildout/areas_" + planet.getName() + ".iff", DatatableVisitor.class); + + for (int i = 0; i < buildoutTable.getRowCount(); i++) { + + String areaName = (String) buildoutTable.getObject(i, 0); + float x1 = (Float) buildoutTable.getObject(i, 1); + float z1 = (Float) buildoutTable.getObject(i, 2); + + readBuildoutDatatable(ClientFileManager.loadFile("datatables/buildout/" + planet.getName() + "/" + areaName + ".iff", DatatableVisitor.class), planet, x1, z1); + + } + } + + public void readBuildoutDatatable(DatatableVisitor buildoutTable, Planet planet, float x1, float z1) throws InstantiationException, IllegalAccessException { + + CrcStringTableVisitor crcTable = ClientFileManager.loadFile("misc/object_template_crc_string_table.iff", CrcStringTableVisitor.class); + + for (int i = 0; i < buildoutTable.getRowCount(); i++) { + + String template; + + if(buildoutTable.getColumnCount() <= 11) + template = crcTable.getTemplateString((Integer) buildoutTable.getObject(i, 0)); + else + template = crcTable.getTemplateString((Integer) buildoutTable.getObject(i, 3)); + + if(template != null) { + + float px, py, pz, qw, qx, qy, qz, radius; + long objectId = 0, containerId = 0; + int type = 0, cellIndex = 0, portalCRC; + + if(buildoutTable.getColumnCount() <= 11) { + + cellIndex = (Integer) buildoutTable.getObject(i, 1); + px = (Float) buildoutTable.getObject(i, 2); + py = (Float) buildoutTable.getObject(i, 3); + pz = (Float) buildoutTable.getObject(i, 4); + qw = (Float) buildoutTable.getObject(i, 5); + qx = (Float) buildoutTable.getObject(i, 6); + qy = (Float) buildoutTable.getObject(i, 7); + qz = (Float) buildoutTable.getObject(i, 8); + radius = (Float) buildoutTable.getObject(i, 9); + portalCRC = (Integer) buildoutTable.getObject(i, 10); + + } else { + + objectId = (Integer) buildoutTable.getObject(i, 0); + containerId = (Integer) buildoutTable.getObject(i, 1); + type = (Integer) buildoutTable.getObject(i, 2); + cellIndex = (Integer) buildoutTable.getObject(i, 4); + + px = (Float) buildoutTable.getObject(i, 5); + py = (Float) buildoutTable.getObject(i, 6); + pz = (Float) buildoutTable.getObject(i, 7); + qw = (Float) buildoutTable.getObject(i, 8); + qx = (Float) buildoutTable.getObject(i, 9); + qy = (Float) buildoutTable.getObject(i, 10); + qz = (Float) buildoutTable.getObject(i, 11); + radius = (Float) buildoutTable.getObject(i, 12); + portalCRC = (Integer) buildoutTable.getObject(i, 13); + + } + + SWGObject object; + + if(objectId != 0 && containerId == 0) { + if(portalCRC != 0) + objectId = 0; + object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz)); + if(object == null) + continue; + if(radius > 256) + object.setAttachment("bigSpawnRange", new Boolean(true)); + core.simulationService.add(object, object.getPosition().x, object.getPosition().z); + } else if(objectId != 0 && containerId != 0 && cellIndex != 0) { + object = createObject(template, objectId, planet, new Point3D(px, py, pz), new Quaternion(qw, qx, qy, qz)); + if(object instanceof CellObject) + ((CellObject) object).setCellNumber(cellIndex); + SWGObject parent = getObject(containerId); + + if(parent != null && object != null) + parent.add(object); + } else { + object = createObject(template, 0, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz)); + core.simulationService.add(object, object.getPosition().x, object.getPosition().z); + } + + //System.out.println("Spawning: " + template + " at: X:" + object.getPosition().x + " Y: " + object.getPosition().y + " Z: " + object.getPosition().z); + + } + + + } + + + } } diff --git a/src/services/travel/TravelPoint.java b/src/services/travel/TravelPoint.java index ce67d8f1..1f1771bd 100644 --- a/src/services/travel/TravelPoint.java +++ b/src/services/travel/TravelPoint.java @@ -143,7 +143,7 @@ public class TravelPoint { public boolean isStarport() { if(getShuttle() != null) { - return getShuttle().getTemplate().equals("object/creature/npc/theme_park/shared_player_transport.iff"); + return (getShuttle().getTemplate().equals("object/creature/npc/theme_park/shared_player_transport.iff") || getShuttle().getTemplate().equals("object/creature/npc/theme_park/shared_player_transport_theed_hangar.iff")); } else { System.out.println("null shuttle at: " + getName()); return false; diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index 81e11383..df05a4c6 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -244,7 +244,7 @@ public class TravelService implements INetworkDispatch { synchronized(travelMap) { for (TravelPoint tp : planetTp) { //System.out.println("Distance for point " + tp.getName() + " is " + tp.getLocation().getDistance2D(obj.getWorldPosition())); - if (tp.getLocation().getDistance2D(obj.getWorldPosition()) <= 70) { + if (tp.getLocation().getDistance2D(obj.getWorldPosition()) <= 125) { returnedPoint = tp; } }