From 622291d6dcc039f7d1d8a95d377625a55a9e23f0 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Tue, 2 Jun 2015 16:21:21 -0400 Subject: [PATCH] Added MapService along with temporary locations for tatooine cities --- .../zone/spatial/GetMapLocationsMessage.java | 60 ++--- .../GetMapLocationsResponseMessage.java | 108 +++++++- src/services/map/MapCategory.java | 96 +++++++ src/services/map/MapLocation.java | 133 ++++++++++ src/services/map/MapService.java | 250 ++++++++++++++++++ src/services/map/MappingTemplate.java | 90 +++++++ src/services/objects/ObjectManager.java | 9 +- src/services/player/ZoneService.java | 7 - 8 files changed, 701 insertions(+), 52 deletions(-) create mode 100644 src/services/map/MapCategory.java create mode 100644 src/services/map/MapLocation.java create mode 100644 src/services/map/MapService.java create mode 100644 src/services/map/MappingTemplate.java diff --git a/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java b/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java index 62bfccfac..54ea72bb4 100644 --- a/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java +++ b/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java @@ -35,38 +35,20 @@ public class GetMapLocationsMessage extends SWGPacket { public static final int CRC = 0x1A7AB839; private String planet; - private float x; - private float y; - private boolean category; - private boolean subcategory; - private boolean icon; - + private int versionStatic; + private int versionDynamic; + private int versionPersist; + public GetMapLocationsMessage() { - this("", 0, 0, false, false, false); } - - public GetMapLocationsMessage(String planet, float x, float y, boolean category, boolean subcategory, boolean icon) { - this.planet = planet; - this.x = x; - this.y = y; - this.category = category; - this.subcategory = subcategory; - this.icon = icon; - } - - public GetMapLocationsMessage(ByteBuffer data) { - decode(data); - } - + public void decode(ByteBuffer data) { if (!super.decode(data, CRC)) return; planet = getAscii(data); - x = getFloat(data); - y = getFloat(data); - category = getByte(data) != 0; - subcategory = getByte(data) != 0; - icon = getByte(data) != 0; + versionStatic = getInt(data); + versionDynamic = getInt(data); + versionPersist = getInt(data); } public ByteBuffer encode() { @@ -74,14 +56,30 @@ public class GetMapLocationsMessage extends SWGPacket { addShort(data, 28); addInt (data, CRC); addAscii(data, planet); - addFloat(data, x); - addFloat(data, y); - addByte (data, category ? 1 : 0); - addByte (data, subcategory ? 1 : 0); - addByte (data, icon ? 1 : 0); + addInt(data, versionStatic); + addInt(data, versionDynamic); + addInt(data, versionPersist); return data; } public String getPlanet() { return planet; } + + public int getVersionDynamic() { + return versionDynamic; + } + + public int getVersionStatic() { + return versionStatic; + } + + public int getVersionPersist() { + return versionPersist; + } + + @Override + public String toString() { + return String.format("[GetMapLocationsMessage] planet=%s static=%d dynamic=%d persist=%d", + planet, versionStatic, versionDynamic, versionPersist); + } } diff --git a/src/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java b/src/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java index 7d5756ee6..2b0ef9fed 100644 --- a/src/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java +++ b/src/network/packets/swg/zone/spatial/GetMapLocationsResponseMessage.java @@ -28,32 +28,114 @@ package network.packets.swg.zone.spatial; import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.List; import network.packets.swg.SWGPacket; +import services.map.MapLocation; +import utilities.ByteUtilities; public class GetMapLocationsResponseMessage extends SWGPacket { public static final int CRC = 0x9F80464C; private String planet; + private List updatedStaticLocations; + private List updatedDynamicLocations; + private List updatedPersistLocations; + private int staticLocVersion; + private int dynamicLocVersion; + private int persistentLocVersion; - public GetMapLocationsResponseMessage(String planet) { + public GetMapLocationsResponseMessage(String planet, + List staticLocs, List dynamicLocs, List persistLocs, + int staticLocVersion, int dynamicLocVersion, int persistLocVersion) { this.planet = planet; + this.updatedStaticLocations = staticLocs; + this.updatedDynamicLocations = dynamicLocs; + this.updatedPersistLocations = persistLocs; + this.staticLocVersion = staticLocVersion; + this.dynamicLocVersion = dynamicLocVersion; + this.persistentLocVersion = persistLocVersion; } - - public ByteBuffer encode() { - ByteBuffer data = ByteBuffer.allocate(32 + planet.length()); + public ByteBuffer encode() { + int size = planet.length() + 34; + + // Encode the map locations to byte arrays and retrieve sizes for buffer allocation + List encodedStatic = null; + List encodedDynamic = null; + List encodedPersist = null; + + if (updatedStaticLocations != null) { + encodedStatic = new ArrayList<>(); + for (MapLocation location : updatedStaticLocations) { + byte[] data = location.encode(); + encodedStatic.add(data); + size += data.length; + } + } + + if (updatedDynamicLocations != null) { + encodedDynamic = new ArrayList<>(); + for (MapLocation location : updatedDynamicLocations) { + byte[] data = location.encode(); + encodedDynamic.add(data); + size += data.length; + } + } + + if (updatedPersistLocations != null) { + encodedPersist = new ArrayList<>(); + for (MapLocation location : updatedPersistLocations) { + byte[] data = location.encode(); + encodedPersist.add(data); + size += data.length; + } + } + + // Create the packet + ByteBuffer data = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN); addShort(data, 8); addInt(data, CRC); + addAscii(data, planet); - addInt(data, 0); // map locations size - - // Unknowns - addInt(data, 0); - addInt(data, 0); - addInt(data, 0x480); - addInt(data, 0x48D); - addInt(data, 1); + + if (encodedStatic != null) { + addInt(data, encodedStatic.size()); + for (byte[] bytes : encodedStatic) { + data.put(bytes); + } + } else { + addInt(data, 0); + } + + if(encodedDynamic != null) { + addInt(data, encodedDynamic.size()); + for (byte[] bytes : encodedDynamic) { + data.put(bytes); + } + } else { + addInt(data, 0); + } + + if (encodedPersist != null) { + addInt(data, encodedPersist.size()); + for (byte[] bytes : encodedPersist) { + data.put(bytes); + } + } else { + addInt(data, 0); + } + + addInt(data, staticLocVersion); + addInt(data, dynamicLocVersion); + addInt(data, persistentLocVersion); return data; } - + + @Override + public String toString() { + return "[GetMapLocationsResponseMessage] " + + "staticVersion=" + staticLocVersion + "dynamicVersion=" + dynamicLocVersion + "persistVersion=" + persistentLocVersion; + } } diff --git a/src/services/map/MapCategory.java b/src/services/map/MapCategory.java new file mode 100644 index 000000000..e11231a6f --- /dev/null +++ b/src/services/map/MapCategory.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package services.map; + +public class MapCategory { + private String name; + private int index; + private boolean isCategory; + private boolean isSubCategory; + private boolean canBeActive; + private String faction; + private boolean factionVisibleOnly; + + public MapCategory() {} + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public boolean isCategory() { + return isCategory; + } + + public void setIsCategory(boolean isCategory) { + this.isCategory = isCategory; + } + + public boolean isSubCategory() { + return isSubCategory; + } + + public void setIsSubCategory(boolean isSubCategory) { + this.isSubCategory = isSubCategory; + } + + public boolean isCanBeActive() { + return canBeActive; + } + + public void setCanBeActive(boolean canBeActive) { + this.canBeActive = canBeActive; + } + + public String getFaction() { + return faction; + } + + public void setFaction(String faction) { + this.faction = faction; + } + + public boolean isFactionVisibleOnly() { + return factionVisibleOnly; + } + + public void setFactionVisibleOnly(boolean factionVisibleOnly) { + this.factionVisibleOnly = factionVisibleOnly; + } +} diff --git a/src/services/map/MapLocation.java b/src/services/map/MapLocation.java new file mode 100644 index 000000000..afef251a6 --- /dev/null +++ b/src/services/map/MapLocation.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package services.map; + +import resources.network.BaselineBuilder; +import utilities.ByteUtilities; +import utilities.Encoder; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class MapLocation implements BaselineBuilder.Encodable{ + private long id; + private String name; + private float x; + private float y; + private byte category; + private byte subcategory; + private boolean isActive; + + private byte[] data; + + public MapLocation() { + } + + public MapLocation(long id, String name, float x, float y, byte category, byte subcategory, boolean isActive) { + this.id = id; + this.name = name; + this.x = x; + this.y = y; + this.category = category; + this.subcategory = subcategory; + this.isActive = isActive; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public float getX() { + return x; + } + + public void setX(float x) { + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + this.y = y; + } + + public byte getCategory() { + return category; + } + + public void setCategory(byte category) { + this.category = category; + } + + public byte getSubcategory() { + return subcategory; + } + + public void setSubcategory(byte subcategory) { + this.subcategory = subcategory; + } + + public boolean isActive() { + return isActive; + } + + public void setIsActive(boolean isActive) { + this.isActive = isActive; + } + + @Override + public byte[] encode() { + if (data != null) + return data; + + ByteBuffer bb = ByteBuffer.allocate((name.length() * 2) + 23).order(ByteOrder.LITTLE_ENDIAN); + bb.putLong(id); + bb.put(Encoder.encodeUnicode(name)); + bb.putFloat(x); + bb.putFloat(y); + bb.put(category); + bb.put(subcategory); + bb.put((byte) (isActive ? 1 : 0)); + data = bb.array(); + return data; + } +} diff --git a/src/services/map/MapService.java b/src/services/map/MapService.java new file mode 100644 index 000000000..863b75406 --- /dev/null +++ b/src/services/map/MapService.java @@ -0,0 +1,250 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + *

+ * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + *

+ * This file is part of Holocore. + *

+ * -------------------------------------------------------------------------------- + *

+ * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + *

+ * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + *

+ * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package services.map; + +import intents.network.GalacticPacketIntent; +import network.packets.Packet; +import network.packets.swg.SWGPacket; +import network.packets.swg.zone.spatial.GetMapLocationsMessage; +import network.packets.swg.zone.spatial.GetMapLocationsResponseMessage; +import resources.client_info.ClientFactory; +import resources.client_info.visitors.DatatableData; +import resources.control.Intent; +import resources.control.Service; +import resources.objects.SWGObject; +import resources.player.Player; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; + +public class MapService extends Service { + private final Map mapCategories; + private final Map mappingTemplates; + + private final Map> staticMapLocations; // ex: NPC cities and buildings + private final Map> dynamicMapLocations; // ex: camps, faction presences (grids) + private final Map> persistentMapLocations; // ex: Player structures, vendors + + // Version is used to determine when the client needs to be updated. 0 sent by client if no map requested yet. + // AtomicInteger used for synchronization + private final AtomicInteger staticMapVersion = new AtomicInteger(1); + private final AtomicInteger dynamicMapVersion = new AtomicInteger(1); + private final AtomicInteger persistMapVersion = new AtomicInteger(1); + + + public MapService() { + mapCategories = new HashMap<>(); + mappingTemplates = new HashMap<>(); + + staticMapLocations = new ConcurrentHashMap<>(); + dynamicMapLocations = new ConcurrentHashMap<>(); + persistentMapLocations = new ConcurrentHashMap<>(); + + ClientFactory clientFactory = new ClientFactory(); + loadMapCategories(clientFactory); + loadMappingTemplates(clientFactory); + } + + @Override + public boolean initialize() { + registerForIntent(GalacticPacketIntent.TYPE); + debug_addMapLocations(); + return super.initialize(); + } + + @Override + public void onIntentReceived(Intent i) { + switch (i.getType()) { + case GalacticPacketIntent.TYPE: + processPacket((GalacticPacketIntent) i); + break; + default: + break; + } + } + + private void processPacket(GalacticPacketIntent intent) { + Player player = intent.getPlayerManager().getPlayerFromNetworkId(intent.getNetworkId()); + if (player == null) + return; + Packet p = intent.getPacket(); + if (p instanceof SWGPacket) + processSwgPacket(player, (SWGPacket) p); + } + + private void processSwgPacket(Player player, SWGPacket p) { + switch (p.getPacketType()) { + case GET_MAP_LOCATIONS_MESSAGE: + handleMapLocationsRequest(player, (GetMapLocationsMessage) p); + break; + default: + break; + } + } + + private void handleMapLocationsRequest(Player player, GetMapLocationsMessage p) { + String planet = p.getPlanet(); + + int staticVer = staticMapVersion.get(); + int dynamicVer = dynamicMapVersion.get(); + int persistVer = persistMapVersion.get(); + + // Only send list if the current map version isn't the same as the clients. + List staticLocs = (p.getVersionStatic() != staticVer ? staticMapLocations.get(planet) : null); + List dynamicLocs = (p.getVersionDynamic() != dynamicVer ? dynamicMapLocations.get(planet) : null); + List persistLocs = (p.getVersionPersist() != persistVer ? persistentMapLocations.get(planet) : null); + + GetMapLocationsResponseMessage responseMessage = new GetMapLocationsResponseMessage(planet, + staticLocs, dynamicLocs, persistLocs, staticVer, dynamicVer, persistVer); + + player.sendPacket(responseMessage); + } + + private void loadMapCategories(ClientFactory clientFactory) { + DatatableData table = (DatatableData) clientFactory.getInfoFromFile("datatables/player/planet_map_cat.iff"); + for (int row = 0; row < table.getRowCount(); row++) { + MapCategory category = new MapCategory(); + category.setName(table.getCell(row, 0).toString()); + category.setIndex(Integer.valueOf(table.getCell(row, 1).toString())); + category.setIsCategory(Boolean.valueOf(table.getCell(row, 2).toString())); + category.setIsSubCategory(Boolean.valueOf(table.getCell(row, 3).toString())); + category.setCanBeActive(Boolean.valueOf(table.getCell(row, 4).toString())); + category.setFaction(table.getCell(row, 5).toString()); + category.setFactionVisibleOnly(Boolean.valueOf(table.getCell(row, 6).toString())); + mapCategories.put(category.getName(), category); + } + } + + private void loadMappingTemplates(ClientFactory clientFactory) { + DatatableData table = (DatatableData) clientFactory.getInfoFromFile("map_locations.iff"); + for (int row = 0; row < table.getRowCount(); row++) { + MappingTemplate template = new MappingTemplate(); + template.setTemplate(ClientFactory.formatToSharedFile(table.getCell(row, 0).toString())); + template.setName(table.getCell(row, 1).toString()); + template.setCategory(table.getCell(row, 2).toString()); + template.setSubcategory(table.getCell(row, 3).toString()); + template.setType(Integer.valueOf(table.getCell(row, 4).toString())); + template.setFlag(Integer.valueOf(table.getCell(row, 5).toString())); + + mappingTemplates.put(template.getTemplate(), template); + } + } + + + public void addMapLocation(SWGObject object, MapType type) { + if (!mappingTemplates.containsKey(object.getTemplate())) + return; + + MappingTemplate mappingTemplate = mappingTemplates.get(object.getTemplate()); + + MapLocation mapLocation = new MapLocation(); + mapLocation.setName(mappingTemplate.getName()); + mapLocation.setCategory((byte) mapCategories.get(mappingTemplate.getCategory()).getIndex()); + if (mappingTemplate.getSubcategory() != null && !mappingTemplate.getSubcategory().isEmpty()) + mapLocation.setSubcategory((byte) mapCategories.get(mappingTemplate.getSubcategory()).getIndex()); + else + mapLocation.setSubcategory((byte) 0); + mapLocation.setX((float) object.getLocation().getX()); + mapLocation.setY((float) object.getLocation().getZ()); + + String planet = object.getLocation().getTerrain().getName(); + + switch (type) { + case STATIC: + addStaticMapLocation(planet, mapLocation); + break; + case DYNAMIC: + addDynamicMapLocation(planet, mapLocation); + break; + case PERSISTENT: + addPersistentMapLocation(planet, mapLocation); + break; + } + } + + private void addStaticMapLocation(String planet, MapLocation location) { + if (staticMapLocations.containsKey(planet)) { + location.setId(staticMapLocations.get(planet).size() + 1); + staticMapLocations.get(planet).add(location); + } else { + location.setId(1); + staticMapLocations.put(planet, new ArrayList()); + staticMapLocations.get(planet).add(location); + } + } + + private void addDynamicMapLocation(String planet, MapLocation location) { + if (dynamicMapLocations.containsKey(planet)) { + location.setId(dynamicMapLocations.get(planet).size() + 1); + dynamicMapLocations.get(planet).add(location); + } else { + location.setId(1); + dynamicMapLocations.put(planet, new ArrayList()); + dynamicMapLocations.get(planet).add(location); + } + } + + private void addPersistentMapLocation(String planet, MapLocation location) { + if (persistentMapLocations.containsKey(planet)) { + location.setId(persistentMapLocations.get(planet).size() + 1); + persistentMapLocations.get(planet).add(location); + } else { + location.setId(1); + persistentMapLocations.put(planet, new ArrayList()); + persistentMapLocations.get(planet).add(location); + } + } + + private void debug_addMapLocations() { + // TODO: Remove this when world snapshot loading is implemented, as the map locations will be added automatically + // -- by using the capitol.iff template building + ArrayList tatooineLocs = staticMapLocations.get("tatooine"); + if (tatooineLocs == null) + tatooineLocs = new ArrayList<>(); + + byte city = (byte) mapCategories.get("city").getIndex(); + tatooineLocs.add(new MapLocation(tatooineLocs.size() + 1, "Mos Eisley", 3528, -4804, city, (byte) 0, false)); + tatooineLocs.add(new MapLocation(tatooineLocs.size() + 1, "Bestine", -1290, -3590, city, (byte) 0, false)); + tatooineLocs.add(new MapLocation(tatooineLocs.size() + 1, "Mos Espa", -2902, 2130, city, (byte) 0, false)); + tatooineLocs.add(new MapLocation(tatooineLocs.size() + 1, "Mos Entha", 1291, 3138, city, (byte) 0, false)); + tatooineLocs.add(new MapLocation(tatooineLocs.size() + 1, "Wayfar", -5124, -6530, city, (byte) 0, false)); + tatooineLocs.add(new MapLocation(tatooineLocs.size() + 1, "Anchorhead", 40, -5348, city, (byte) 0, false)); + + staticMapLocations.put("tatooine", tatooineLocs); + } + + public enum MapType { + STATIC, + DYNAMIC, + PERSISTENT + } +} diff --git a/src/services/map/MappingTemplate.java b/src/services/map/MappingTemplate.java new file mode 100644 index 000000000..487df8d63 --- /dev/null +++ b/src/services/map/MappingTemplate.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package services.map; + +/** + * Created by Waverunner on 6/1/2015 + */ +public class MappingTemplate { + private String template; + private String name; + private String category; + private String subcategory; + private int type; + private int flag; + + public MappingTemplate() {} + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubcategory() { + return subcategory; + } + + public void setSubcategory(String subcategory) { + this.subcategory = subcategory; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public int getFlag() { + return flag; + } + + public void setFlag(int flag) { + this.flag = flag; + } +} diff --git a/src/services/objects/ObjectManager.java b/src/services/objects/ObjectManager.java index aa8e8bdec..c644952b3 100644 --- a/src/services/objects/ObjectManager.java +++ b/src/services/objects/ObjectManager.java @@ -58,16 +58,20 @@ import resources.server_info.Config; import resources.server_info.Log; import resources.server_info.ObjectDatabase; import resources.server_info.ObjectDatabase.Traverser; +import services.map.MapService; import services.player.PlayerManager; public class ObjectManager extends Manager { - + + private final MapService mapService; + private final Map > buildoutObjects; private final ObjectDatabase objects; private final ObjectAwareness objectAwareness; private long maxObjectId; public ObjectManager() { + mapService = new MapService(); buildoutObjects = new HashMap>(); objects = new CachedObjectDatabase("odb/objects.db"); objectAwareness = new ObjectAwareness(); @@ -76,6 +80,7 @@ public class ObjectManager extends Manager { @Override public boolean initialize() { + addChildService(mapService); registerForIntent(GalacticPacketIntent.TYPE); registerForIntent(PlayerEventIntent.TYPE); registerForIntent(ObjectTeleportIntent.TYPE); @@ -151,6 +156,8 @@ public class ObjectManager extends Manager { objectAwareness.add(obj); } } + + mapService.addMapLocation(obj, MapService.MapType.STATIC); } private void loadObject(SWGObject obj) { diff --git a/src/services/player/ZoneService.java b/src/services/player/ZoneService.java index e43b5032c..91d3e1392 100644 --- a/src/services/player/ZoneService.java +++ b/src/services/player/ZoneService.java @@ -161,8 +161,6 @@ public class ZoneService extends Service { handleCmdSceneReady(player, (CmdSceneReady) p); if (p instanceof SetWaypointColor) handleSetWaypointColor(player, (SetWaypointColor) p); - if (p instanceof GetMapLocationsMessage) - handleMapLocationsResponse(player, (GetMapLocationsMessage) p); if(p instanceof ShowBackpack) handleShowBackpack(player, (ShowBackpack) p); if(p instanceof ShowHelmet) @@ -211,11 +209,6 @@ public class ZoneService extends Service { private void handleShowHelmet(Player player, ShowHelmet p) { player.getPlayerObject().setShowHelmet(p.showingHelmet()); } - - private void handleMapLocationsResponse(Player player, GetMapLocationsMessage p) { - // TODO Implement actual handling in GU2, this is to avoid constant map location requests from the client - player.sendPacket(new GetMapLocationsResponseMessage(p.getPlanet())); - } private void handleSetWaypointColor(Player player, SetWaypointColor p) { // TODO Should move this to a different service, maybe make a service for other packets similar to this (ie misc.)