mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-12 02:13:42 -04:00
Merged projectswg/holocore/development into master
This commit is contained in:
@@ -6,5 +6,8 @@
|
||||
<classpathentry kind="lib" path="lib/jdbc-postgresql.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jython-standalone-2.5.4-rc1.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-1.7.12/slf4j-api-1.7.12.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-1.7.12/slf4j-simple-1.7.12.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jgit-4.0.0.201506020755-rc3.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
import sys
|
||||
from resources.player.PlayerFlags import AFK
|
||||
|
||||
def execute(objManager, player, target, args):
|
||||
player.getPlayerObject().toggleFlag(PlayerFlags.AFK)
|
||||
return
|
||||
@@ -11,12 +11,12 @@ def execute(galacticManager, player, target, args):
|
||||
return
|
||||
|
||||
if target.getParent() == actor:
|
||||
result = target.moveToContainer(actor, inventory)
|
||||
actor.removeEquipment(target)
|
||||
target.moveToContainer(actor, inventory)
|
||||
return
|
||||
else:
|
||||
target.moveToContainer(actor, actor)
|
||||
# actor.addEquipment(target) # This seems to crash the client, look to
|
||||
result = target.moveToContainer(actor, actor)
|
||||
actor.addEquipment(target)
|
||||
return
|
||||
|
||||
return
|
||||
@@ -58,8 +58,7 @@ public class UpdateContainmentMessage extends SWGPacket {
|
||||
}
|
||||
|
||||
public ByteBuffer encode() {
|
||||
int length = 26;
|
||||
ByteBuffer data = ByteBuffer.allocate(length);
|
||||
ByteBuffer data = ByteBuffer.allocate(26);
|
||||
addShort(data, 4);
|
||||
addInt( data, CRC);
|
||||
addLong( data, objectId);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class DeltasMessage extends SWGPacket {
|
||||
addByte(data, num);
|
||||
addInt(data, deltaData.length + 4);
|
||||
addShort(data, 1); // TODO: How many updates there is (1 always for now until a queue system is built
|
||||
addShort(data, update); // TODO: This should be part of the data, for now we'll keep it here until the queue system is in
|
||||
addShort(data, update);
|
||||
data.put(deltaData);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ import resources.client_info.visitors.SlotDescriptorData;
|
||||
import utilities.ByteUtilities;
|
||||
|
||||
public class ClientFactory {
|
||||
|
||||
private static ClientFactory instance;
|
||||
|
||||
private Map <String, ClientData> dataMap = new HashMap<String, ClientData>();
|
||||
private Map <String, String> typeMap = new HashMap<String, String>();
|
||||
|
||||
@@ -81,11 +82,17 @@ public class ClientFactory {
|
||||
* A null instance of {@link ClientData} means that parsing for the type of file is not done, or a file was entered that doesn't exist on the
|
||||
* file system.
|
||||
*/
|
||||
public synchronized ClientData getInfoFromFile(String file, boolean saveInfo) {
|
||||
ClientData data = dataMap.get(file);
|
||||
public synchronized static ClientData getInfoFromFile(String file, boolean saveInfo) {
|
||||
ClientFactory factory = ClientFactory.instance;
|
||||
if (factory == null) {
|
||||
ClientFactory.instance = new ClientFactory();
|
||||
factory = ClientFactory.instance;
|
||||
}
|
||||
|
||||
ClientData data = factory.dataMap.get(file);
|
||||
|
||||
if (data == null) {
|
||||
data = readFile(file);
|
||||
data = factory.readFile(file);
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -100,7 +107,7 @@ public class ClientFactory {
|
||||
return data;
|
||||
}
|
||||
|
||||
public synchronized ClientData getInfoFromFile(String file) {
|
||||
public synchronized static ClientData getInfoFromFile(String file) {
|
||||
return getInfoFromFile(file, true);
|
||||
}
|
||||
|
||||
@@ -184,7 +191,7 @@ public class ClientFactory {
|
||||
switch (c) {
|
||||
case "CrcStringTableData": return new CrcStringTableData();
|
||||
case "DatatableData": return new DatatableData();
|
||||
case "ObjectData": return new ObjectData(this);
|
||||
case "ObjectData": return new ObjectData();
|
||||
case "ProfTemplateData": return new ProfTemplateData();
|
||||
case "SlotDescriptorData": return new SlotDescriptorData();
|
||||
case "SlotDefinitionData": return new SlotDefinitionData();
|
||||
|
||||
@@ -39,7 +39,6 @@ import utilities.ByteUtilities;
|
||||
public class ObjectData extends ClientData {
|
||||
|
||||
private Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
private ClientFactory factory;
|
||||
private List<String> parsedFiles = new ArrayList<String>();
|
||||
|
||||
public static final String APPEARANCE_FILE = "appearanceFilename";
|
||||
@@ -50,9 +49,7 @@ public class ObjectData extends ClientData {
|
||||
public static final String PORTAL_LAYOUT = "portalLayoutFilename";
|
||||
public static final String SLOT_DESCRIPTOR = "slotDescriptorFilename";
|
||||
|
||||
public ObjectData(ClientFactory factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
public ObjectData() {}
|
||||
|
||||
@Override
|
||||
public void handleData(String node, ByteBuffer data, int size) {
|
||||
@@ -64,7 +61,7 @@ public class ObjectData extends ClientData {
|
||||
if (parsedFiles.contains(file)) // some DERVXXX were repeated and we do not want to replace any attributes unless they're overriden by a more specific obj
|
||||
break;
|
||||
|
||||
ClientData attrData = factory.getInfoFromFile(file);
|
||||
ClientData attrData = ClientFactory.getInfoFromFile(file);
|
||||
if (attrData == null || !(attrData instanceof ObjectData)) {
|
||||
System.out.println("Could not load attribute data from file " + file + "!");
|
||||
return; // break out of whole method as we should only continue if we have all the extended attributes
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*******************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
|
||||
package resources.client_info.visitors;
|
||||
|
||||
import resources.Location;
|
||||
import utilities.ByteUtilities;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldSnapshotData extends ClientData {
|
||||
private Map<Integer, String> objectTemplateNames = new HashMap<>();
|
||||
private List<Chunk> chunks = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void handleData(String node, ByteBuffer data, int size) {
|
||||
switch (node) {
|
||||
case "OTNL":
|
||||
// Object Template Name Table
|
||||
int n = data.getInt();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
String template = ByteUtilities.nextString(data);
|
||||
objectTemplateNames.put(i, template);
|
||||
}
|
||||
break;
|
||||
case "0000DATA":
|
||||
Chunk chunk = new Chunk();
|
||||
chunk.setId(data.getInt());
|
||||
chunk.setContainerId(data.getInt());
|
||||
chunk.setObjectTemplateNameIndex(data.getInt());
|
||||
chunk.setCellIndex(data.getInt());
|
||||
Location location = new Location();
|
||||
location.setOrientationW(data.getFloat());
|
||||
location.setOrientationX(data.getFloat());
|
||||
location.setOrientationY(data.getFloat());
|
||||
location.setOrientationZ(data.getFloat());
|
||||
location.setX(data.getFloat());
|
||||
location.setY(data.getFloat());
|
||||
location.setZ(data.getFloat());
|
||||
chunk.setLocation(location);
|
||||
chunk.setRadius(data.getFloat());
|
||||
chunk.setPortalLayoutCrc(data.getInt());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, String> getObjectTemplateNames() {
|
||||
return objectTemplateNames;
|
||||
}
|
||||
|
||||
public List<Chunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
public class Chunk {
|
||||
private int id;
|
||||
private int containerId;
|
||||
private int objectTemplateNameIndex;
|
||||
private int cellIndex;
|
||||
private Location location;
|
||||
private float radius;
|
||||
private int portalLayoutCrc;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getContainerId() {
|
||||
return containerId;
|
||||
}
|
||||
|
||||
public void setContainerId(int containerId) {
|
||||
this.containerId = containerId;
|
||||
}
|
||||
|
||||
public int getObjectTemplateNameIndex() {
|
||||
return objectTemplateNameIndex;
|
||||
}
|
||||
|
||||
public void setObjectTemplateNameIndex(int objectTemplateNameIndex) {
|
||||
this.objectTemplateNameIndex = objectTemplateNameIndex;
|
||||
}
|
||||
|
||||
public int getCellIndex() {
|
||||
return cellIndex;
|
||||
}
|
||||
|
||||
public void setCellIndex(int cellIndex) {
|
||||
this.cellIndex = cellIndex;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public int getPortalLayoutCrc() {
|
||||
return portalLayoutCrc;
|
||||
}
|
||||
|
||||
public void setPortalLayoutCrc(int portalLayoutCrc) {
|
||||
this.portalLayoutCrc = portalLayoutCrc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,16 +30,13 @@ package resources.collections;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.AbstractList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import network.packets.swg.zone.baselines.Baseline.BaselineType;
|
||||
import network.packets.swg.zone.deltas.DeltasMessage;
|
||||
import resources.network.BaselineBuilder.Encodable;
|
||||
import resources.network.DeltaBuilder;
|
||||
import resources.objects.SWGObject;
|
||||
@@ -65,7 +62,7 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
private transient int updateCount;
|
||||
private int dataSize;
|
||||
|
||||
private boolean indexed = false;
|
||||
private boolean indexed = true;
|
||||
private boolean noUpdates = false;
|
||||
private StringType strType = StringType.UNSPECIFIED;
|
||||
|
||||
@@ -108,7 +105,7 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
boolean added = list.add(e);
|
||||
|
||||
if (added) {
|
||||
addData(list.lastIndexOf(e), e);
|
||||
addObjectData(list.lastIndexOf(e), e);
|
||||
}
|
||||
|
||||
return added;
|
||||
@@ -119,23 +116,32 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
updateCount++;
|
||||
list.add(index, e);
|
||||
|
||||
addData(index, e);
|
||||
addObjectData(index, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
// Sends a "change" delta
|
||||
updateCount++;
|
||||
E previous = list.set(index, element);
|
||||
if (previous != null)
|
||||
if (previous != null) {
|
||||
removeDataSize(index);
|
||||
addData(index, element, (byte) 2);
|
||||
removeData(index);
|
||||
}
|
||||
addObjectData(index, element, (byte) 2);
|
||||
return previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
// TODO: Remove elements in list
|
||||
throw new UnsupportedOperationException();
|
||||
// Method is also called for remove(E element), just replaced by the index
|
||||
updateCount++;
|
||||
E element = list.remove(index);
|
||||
|
||||
if (element != null)
|
||||
removeObjectData(index, element, (byte) 0);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,9 +169,9 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
|
||||
if (size != data.size()) {
|
||||
// Data got out of sync with the list, so lets clean that up!
|
||||
data.clear();
|
||||
clearAllData();
|
||||
for (int i = 0; i < size; i++) {
|
||||
addData(i, list.get(i), (byte) 0);
|
||||
addObjectData(i, list.get(i), (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +188,7 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
}
|
||||
|
||||
public void sendDeltaMessage(SWGObject target) {
|
||||
if (!(deltas.size() > 0))
|
||||
if (deltas.size() == 0)
|
||||
return;
|
||||
|
||||
if (target.getOwner() == null || target.getOwner().getPlayerState() != PlayerState.ZONED_IN) {
|
||||
@@ -192,13 +198,21 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
|
||||
DeltaBuilder builder = new DeltaBuilder(target, baseline, view, updateType, (noUpdates ? encode() : getDeltaData()));
|
||||
builder.send();
|
||||
// Clear the queue since the delta has been sent to observers through the builder
|
||||
clearDeltaQueue();
|
||||
}
|
||||
|
||||
public void clearDeltaQueue() {
|
||||
deltas.clear();
|
||||
deltaSize = 0;
|
||||
}
|
||||
|
||||
|
||||
private void clearAllData() {
|
||||
data.clear();
|
||||
dataSize = 0;
|
||||
clearDeltaQueue();
|
||||
}
|
||||
|
||||
public void setUpdateCount(int count) {
|
||||
this.updateCount = count;
|
||||
}
|
||||
@@ -225,7 +239,7 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addData(int index, Object obj, byte update) {
|
||||
private void addObjectData(int index, Object obj, byte update) {
|
||||
byte[] encodedData = Encoder.encode(obj, strType);
|
||||
|
||||
data.put(index, encodedData);
|
||||
@@ -244,21 +258,38 @@ public class SWGList<E> extends AbstractList<E> implements Encodable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addData(int index, Object obj) {
|
||||
addData(index, obj, (byte) 1);
|
||||
private void addObjectData(int index, Object obj) {
|
||||
addObjectData(index, obj, (byte) 1);
|
||||
}
|
||||
|
||||
// Removes obj size of data and removes it from the data map
|
||||
private void removeData(Object obj) {
|
||||
dataSize -= data.remove(indexOf(obj)).length;
|
||||
|
||||
private void removeObjectData(int index, Object object, byte update) {
|
||||
if (data.get(index) != null) {
|
||||
dataSize -= data.remove(index).length;
|
||||
}
|
||||
|
||||
if (indexed && !noUpdates) {
|
||||
// Only the index is sent for removing data
|
||||
ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putShort((short) index);
|
||||
createDeltaData(buffer.array(), update);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Removes obj size of data without removing it from the data map
|
||||
private void removeDataSize(int index) {
|
||||
dataSize -= data.get(index).length;
|
||||
}
|
||||
|
||||
|
||||
private void removeData(int index) {
|
||||
data.remove(index);
|
||||
}
|
||||
|
||||
public BaselineType getBaseline() { return baseline; }
|
||||
public int getViewType() { return view; }
|
||||
public int getUpdateType() { return updateType; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SWGList[" + baseline + "0" + view + ":" + updateType + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class SWGMap<K, V> extends AbstractMap<K, V> implements Encodable {
|
||||
|
||||
if (data.size() != size) {
|
||||
// Data got out of sync with the map, so lets clean that up!
|
||||
data.clear();
|
||||
clearAllData();
|
||||
for (Entry<K, V> entry : map.entrySet()) {
|
||||
addData(entry.getKey(), entry.getValue(), (byte) 0);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class SWGMap<K, V> extends AbstractMap<K, V> implements Encodable {
|
||||
|
||||
DeltaBuilder builder = new DeltaBuilder(target, baseline, view, updateType, getDeltaData());
|
||||
builder.send();
|
||||
|
||||
// Clear the queue since the delta has been sent to observers through the builder
|
||||
clearDeltaQueue();
|
||||
}
|
||||
|
||||
@@ -222,7 +222,14 @@ public class SWGMap<K, V> extends AbstractMap<K, V> implements Encodable {
|
||||
deltas.put(key, combindedUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void clearAllData() {
|
||||
dataSize = 0;
|
||||
data.clear();
|
||||
|
||||
clearDeltaQueue();
|
||||
}
|
||||
|
||||
private void addData(Object key, Object value, byte update) {
|
||||
byte[] encodedKey = Encoder.encode(key, strType);
|
||||
byte[] encodedValue = Encoder.encode(value, strType);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/***********************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***********************************************************************************/
|
||||
package resources.commands.callbacks;
|
||||
|
||||
import resources.commands.ICmdCallback;
|
||||
import resources.objects.SWGObject;
|
||||
import resources.player.Player;
|
||||
import resources.player.PlayerFlags;
|
||||
import services.galaxy.GalacticManager;
|
||||
|
||||
public class AfkCmdCallback implements ICmdCallback {
|
||||
|
||||
@Override
|
||||
public void execute(GalacticManager galacticManager, Player player,
|
||||
SWGObject target, String args) {
|
||||
player.getPlayerObject().toggleFlag(PlayerFlags.AFK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,14 +38,32 @@ public class RequestWaypointCmdCallback implements ICmdCallback {
|
||||
|
||||
@Override
|
||||
public void execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
|
||||
// First parameter can be name of the planet or an int for the color
|
||||
// Args: (^-,=+_)color_1(,+-=_^)=1 planet x 0.0 z
|
||||
PlayerObject ghost = player.getPlayerObject();
|
||||
if (ghost == null)
|
||||
return;
|
||||
|
||||
String[] cmd = args.split(" ", 5);
|
||||
|
||||
String[] cmd = args.split(" ", 6);
|
||||
WaypointObject.WaypointColor color = WaypointObject.WaypointColor.BLUE;
|
||||
|
||||
/* if (cmd[0].contains("color_")) {
|
||||
// Command is in color planet x y z name format
|
||||
String colorId = cmd[0].substring(14, cmd[0].length() - 10);
|
||||
color = WaypointObject.WaypointColor.values()[Integer.valueOf(colorId) - 1];
|
||||
}*/
|
||||
|
||||
double x = (color != null ? Double.valueOf(cmd[2]) : Double.valueOf(cmd[1]));
|
||||
double y = (color != null ? Double.valueOf(cmd[3]) : Double.valueOf(cmd[2]));
|
||||
double z = (color != null ? Double.valueOf(cmd[4]) : Double.valueOf(cmd[3]));
|
||||
|
||||
String name = (cmd.length == 6 ? cmd[5] : "New Waypoint");
|
||||
|
||||
WaypointObject waypoint = (WaypointObject) galacticManager.getObjectManager().createObject("object/waypoint/shared_waypoint.iff", player.getCreatureObject().getLocation());
|
||||
waypoint.setLocation(Double.valueOf(cmd[2]), 0, Double.valueOf(cmd[4]));
|
||||
waypoint.setLocation(x, y, z);
|
||||
waypoint.setName(name);
|
||||
if (color != null)
|
||||
waypoint.setColor(color);
|
||||
ghost.addWaypoint(waypoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
***********************************************************************************/
|
||||
package resources.commands.callbacks;
|
||||
|
||||
import network.packets.swg.zone.chat.ChatSystemMessage;
|
||||
import resources.Location;
|
||||
import resources.Terrain;
|
||||
import resources.commands.ICmdCallback;
|
||||
@@ -87,11 +86,8 @@ public class WaypointCmdCallback implements ICmdCallback {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (ghost.getWaypoints().size() < 250) {
|
||||
WaypointObject waypoint = createWaypoint(galacticManager.getObjectManager(), terrain, color, name, x, y, player.getCreatureObject().getLocation());
|
||||
ghost.addWaypoint(waypoint);
|
||||
} else
|
||||
ghost.sendSelf(new ChatSystemMessage(ChatSystemMessage.SystemChatType.SCREEN_AND_CHAT, "@base_player:too_many_waypoints"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
import resources.common.CRC;
|
||||
import resources.network.BaselineBuilder.Encodable;
|
||||
import resources.objects.SWGObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
public class Equipment implements Encodable {
|
||||
@@ -41,16 +42,15 @@ public class Equipment implements Encodable {
|
||||
private byte[] customizationString;
|
||||
private int arrangementId = 4;
|
||||
private long objectId;
|
||||
private int templateCRC;
|
||||
private String template;
|
||||
|
||||
public Equipment(long objectId, String template) {
|
||||
this.objectId = objectId;
|
||||
this.templateCRC = CRC.getCrc(template);
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public Equipment(WeaponObject weapon) {
|
||||
this.objectId = weapon.getObjectId();
|
||||
this.templateCRC = weapon.getCrc();
|
||||
this(weapon.getObjectId(), weapon.getTemplate());
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Equipment implements Encodable {
|
||||
|
||||
buffer.putInt(arrangementId);
|
||||
buffer.putLong(objectId);
|
||||
buffer.putInt(templateCRC);
|
||||
buffer.putInt(CRC.getCrc(template));
|
||||
|
||||
if (weapon != null) {
|
||||
buffer.put((byte) 0x01);
|
||||
@@ -93,6 +93,19 @@ public class Equipment implements Encodable {
|
||||
public long getObjectId() { return objectId; }
|
||||
public void setObjectId(long objectId) { this.objectId = objectId; }
|
||||
|
||||
public int getTemplateCRC() { return templateCRC; }
|
||||
public void setTemplateCRC(int templateCRC) { this.templateCRC = templateCRC; }
|
||||
public String getTemplate() { return template; }
|
||||
public void setTemplate(String template) { this.template = template; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Equipment: " + template;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof SWGObject))
|
||||
return super.equals(o);
|
||||
|
||||
return ((SWGObject) o).getObjectId() == objectId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
int arrangementId = container.getArrangementId(this);
|
||||
if (arrangementId == -1) {
|
||||
// Item is going to go into the container, so check to see if it'll fit
|
||||
if (container.getMaxContainerSize() >= container.getContainedObjects().size()) {
|
||||
if (container.getMaxContainerSize() <= container.getContainedObjects().size()) {
|
||||
return ContainerResult.CONTAINER_FULL;
|
||||
}
|
||||
}
|
||||
@@ -176,15 +176,19 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
List<SWGObject> oldObservers = getChildrenAwareness();
|
||||
|
||||
// Remove this object from the old parent if one exists
|
||||
SWGObject oldParent = null;
|
||||
if (parent != null) {
|
||||
oldParent = parent;
|
||||
parent.removeObject(this);
|
||||
}
|
||||
|
||||
container.addObject(this);
|
||||
if (!container.addObject(this))
|
||||
System.err.println("Failed adding " + this + " to " + container);
|
||||
|
||||
// Observer notification
|
||||
sendUpdatedContainment(oldObservers, new ArrayList<>(container.getChildrenAwareness()));
|
||||
|
||||
Log.i("Container", "Moved %s from %s to %s", this, oldParent, container);
|
||||
return ContainerResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -424,7 +428,7 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
* @return Arrangement ID for the object
|
||||
*/
|
||||
public int getArrangementId(SWGObject object) {
|
||||
if (object.getArrangement() == null)
|
||||
if (slots.size() == 0 || object.getArrangement() == null)
|
||||
return -1;
|
||||
|
||||
int arrangementId = 4;
|
||||
@@ -437,8 +441,7 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
if (!hasSlot(slot)) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
if (slots.get(slot) != null) {
|
||||
} else if (slots.get(slot) != null) {
|
||||
passesCompletely = false;
|
||||
}
|
||||
}
|
||||
@@ -449,7 +452,7 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
|
||||
arrangementId++;
|
||||
}
|
||||
return (filledId != -1) ? arrangementId : 4;
|
||||
return (filledId != -1) ? filledId : -1;
|
||||
}
|
||||
|
||||
protected final void sendSceneCreateObject(Player target) {
|
||||
@@ -576,6 +579,8 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
}
|
||||
|
||||
private void sendUpdatedContainment(List<SWGObject> oldObservers, List<SWGObject> newObservers) {
|
||||
if (parent == null)
|
||||
return;
|
||||
List<SWGObject> same = new ArrayList<>(oldObservers);
|
||||
same.retainAll(newObservers);
|
||||
|
||||
@@ -657,29 +662,61 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
}
|
||||
|
||||
protected void createChildrenObjects(Player target) {
|
||||
if (slots.size() == 0 && containedObjects.size() == 0)
|
||||
return;
|
||||
|
||||
if (!hasPermission(target.getCreatureObject(), ContainerPermissions.Permission.OPEN)) {
|
||||
Log.w("SWGObject", target.getCreatureObject() + " doesn't have permission to view " + this + " -- skipping packet sending");
|
||||
Log.i("SWGObject", target.getCreatureObject() + " doesn't have permission to view " + this + " -- skipping packet sending");
|
||||
return;
|
||||
}
|
||||
|
||||
List<SWGObject> sentObjects = new ArrayList<>();
|
||||
|
||||
// First create the objects in the slots
|
||||
for (SWGObject slotObject : slots.values()) {
|
||||
if (slotObject != null) {
|
||||
//Log.d("Sending slotObj " + slotObject + " to " + target);
|
||||
if (slotObject != null && !sentObjects.contains(slotObject)) {
|
||||
//Log.i("ChildrenObjects", "Sending slotObj " + slotObject + " to " + target);
|
||||
slotObject.createObject(target);
|
||||
sentObjects.add(slotObject);
|
||||
}
|
||||
}
|
||||
|
||||
// Now create the contained objects
|
||||
for (SWGObject containedObject : containedObjects.values()) {
|
||||
if (containedObject != null) {
|
||||
//Log.d("SWGObject", "Sending containedObj " + containedObject + " to " + target);
|
||||
if (containedObject != null && sentObjects.contains(containedObject)) {
|
||||
//Log.i("ChildrenObjects", "Sending containedObj " + containedObject + " to " + target);
|
||||
//Log.d("SWGObject", "Sending to location " + containedObject.getLocation());
|
||||
containedObject.createObject(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void debug_printSlotInfo(int tabs) {
|
||||
String s = "";
|
||||
for (int i = 0; i < tabs; i++) {
|
||||
s += "\t";
|
||||
}
|
||||
System.out.println(s + "=== debug_printSlotInfo ===: " + this);
|
||||
if (slots.size() == 0 && containedObjects.size() == 0) {
|
||||
System.out.println(s + "NO CHILDREN");
|
||||
return;
|
||||
}
|
||||
|
||||
if (slots.size() > 0) System.out.println(s + "= Slots =");
|
||||
for (Map.Entry<String, SWGObject> entry : slots.entrySet()) {
|
||||
System.out.println(s + "Slot: " + entry.getKey() + " Value: " + entry.getValue() + (entry.getValue() != null ? " arrangement: " + entry.getValue().slotArrangement : ""));
|
||||
if (entry.getValue() != null) entry.getValue().debug_printSlotInfo(tabs + 1);
|
||||
}
|
||||
|
||||
if (containedObjects.size() > 0) System.out.println(s + "= ContainerObjects =");
|
||||
for (SWGObject object : containedObjects.values()) {
|
||||
System.out.println(s + "ContainedObject: " + object + " arrangementId: " + object.slotArrangement);
|
||||
object.debug_printSlotInfo(tabs + 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SWGObject[ID=" + objectId + " NAME=" + objectName + " TEMPLATE=" + template + "]";
|
||||
|
||||
@@ -39,9 +39,7 @@ import resources.objects.SWGObject;
|
||||
import resources.server_info.Log;
|
||||
|
||||
public class BuildoutLoader {
|
||||
|
||||
private static final ClientFactory clientFactory = new ClientFactory();
|
||||
private static final CrcStringTableData crcTable = (CrcStringTableData) clientFactory.getInfoFromFile("misc/object_template_crc_string_table.iff");
|
||||
private static final CrcStringTableData crcTable = (CrcStringTableData) ClientFactory.getInfoFromFile("misc/object_template_crc_string_table.iff");
|
||||
|
||||
public static List <SWGObject> loadAllBuildouts() {
|
||||
List <SWGObject> objects = new LinkedList<SWGObject>();
|
||||
@@ -51,10 +49,10 @@ public class BuildoutLoader {
|
||||
}
|
||||
|
||||
public static List <SWGObject> loadBuildoutsForTerrain(Terrain terrain) {
|
||||
DatatableData table = (DatatableData) clientFactory.getInfoFromFile("datatables/buildout/buildout_scenes.iff");
|
||||
DatatableData table = (DatatableData) ClientFactory.getInfoFromFile("datatables/buildout/buildout_scenes.iff");
|
||||
for (int row = 0; row < table.getRowCount(); row++) {
|
||||
if (table.getCell(row, 0).equals(terrain.name().toLowerCase(Locale.ENGLISH))) {
|
||||
TerrainBuildoutLoader loader = new TerrainBuildoutLoader(clientFactory, crcTable, terrain);
|
||||
TerrainBuildoutLoader loader = new TerrainBuildoutLoader(crcTable, terrain);
|
||||
loader.load(row);
|
||||
return loader.getObjects();
|
||||
}
|
||||
@@ -65,7 +63,7 @@ public class BuildoutLoader {
|
||||
}
|
||||
|
||||
private static List <Terrain> getTerrainsToLoad() {
|
||||
DatatableData table = (DatatableData) clientFactory.getInfoFromFile("datatables/buildout/buildout_scenes.iff");
|
||||
DatatableData table = (DatatableData) ClientFactory.getInfoFromFile("datatables/buildout/buildout_scenes.iff");
|
||||
List <Terrain> terrains = new LinkedList<Terrain>();
|
||||
for (int row = 0; row < table.getRowCount(); row++) {
|
||||
Terrain t = Terrain.getTerrainFromName((String) table.getCell(row, 0));
|
||||
|
||||
@@ -45,15 +45,13 @@ import services.objects.ObjectCreator;
|
||||
class TerrainBuildoutLoader {
|
||||
|
||||
private static final String BASE_PATH = "datatables/buildout/";
|
||||
|
||||
private final ClientFactory clientFactory;
|
||||
|
||||
private final CrcStringTableData crcTable;
|
||||
private final Terrain terrain;
|
||||
private final Map <Long, SWGObject> objectTable;
|
||||
private final List <SWGObject> objects;
|
||||
|
||||
public TerrainBuildoutLoader(ClientFactory clientFactory, CrcStringTableData crcTable, Terrain terrain) {
|
||||
this.clientFactory = clientFactory;
|
||||
public TerrainBuildoutLoader(CrcStringTableData crcTable, Terrain terrain) {
|
||||
this.crcTable = crcTable;
|
||||
this.terrain = terrain;
|
||||
this.objectTable = new Hashtable<Long, SWGObject>(12*1024);
|
||||
@@ -72,7 +70,7 @@ class TerrainBuildoutLoader {
|
||||
private void loadAreas(int sceneNumber) {
|
||||
objects.clear();
|
||||
String file = BASE_PATH+"areas_"+terrain.getName()+".iff";
|
||||
DatatableData areaTable = (DatatableData) clientFactory.getInfoFromFile(file);
|
||||
DatatableData areaTable = (DatatableData) ClientFactory.getInfoFromFile(file);
|
||||
for (int row = 0; row < areaTable.getRowCount(); row++) {
|
||||
BuildoutArea area = new BuildoutArea();
|
||||
area.load(areaTable.getRow(row), sceneNumber, row);
|
||||
@@ -84,7 +82,7 @@ class TerrainBuildoutLoader {
|
||||
|
||||
private void loadArea(BuildoutArea area) {
|
||||
String file = BASE_PATH+terrain.getName()+"/"+area.getName().replace("server", "client")+".iff";
|
||||
DatatableData areaTable = (DatatableData) clientFactory.getInfoFromFile(file);
|
||||
DatatableData areaTable = (DatatableData) ClientFactory.getInfoFromFile(file);
|
||||
BuildoutRow buildoutRow = new BuildoutRow(area);
|
||||
for (int row = 0; row < areaTable.getRowCount(); row++) {
|
||||
buildoutRow.load(areaTable.getRow(row), crcTable);
|
||||
|
||||
@@ -112,8 +112,13 @@ public class CreatureObject extends TangibleObject {
|
||||
|
||||
public void removeEquipment(SWGObject obj) {
|
||||
synchronized (equipmentList) {
|
||||
if (equipmentList.remove(obj))
|
||||
equipmentList.sendDeltaMessage(this);
|
||||
for (Equipment equipment : equipmentList) {
|
||||
if (equipment.getObjectId() == obj.getObjectId()) {
|
||||
equipmentList.remove(equipment);
|
||||
equipmentList.sendDeltaMessage(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +141,12 @@ public class CreatureObject extends TangibleObject {
|
||||
|
||||
public void removeAppearanceItem(SWGObject obj) {
|
||||
synchronized (appearanceList) {
|
||||
if (appearanceList.remove(obj))
|
||||
appearanceList.sendDeltaMessage(this);
|
||||
for (Equipment equipment : appearanceList) {
|
||||
if (equipment.getObjectId() == obj.getObjectId()) {
|
||||
appearanceList.remove(equipment);
|
||||
appearanceList.sendDeltaMessage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ package resources.objects.player;
|
||||
|
||||
import network.packets.swg.zone.UpdatePostureMessage;
|
||||
import network.packets.swg.zone.baselines.Baseline.BaselineType;
|
||||
import network.packets.swg.zone.chat.ChatSystemMessage;
|
||||
import resources.collections.SWGList;
|
||||
import resources.collections.SWGMap;
|
||||
import resources.network.BaselineBuilder;
|
||||
@@ -102,8 +103,13 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
public void addWaypoint(WaypointObject waypoint) {
|
||||
synchronized(waypoints) {
|
||||
if (waypoints.size() < 250) {
|
||||
waypoints.put(waypoint.getObjectId(), waypoint);
|
||||
waypoints.sendDeltaMessage(this);
|
||||
}
|
||||
else {
|
||||
sendSelf(new ChatSystemMessage(ChatSystemMessage.SystemChatType.SCREEN_AND_CHAT, "@base_player:too_many_waypoints"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,17 +128,16 @@ public class CommandService extends Service {
|
||||
}
|
||||
|
||||
private void loadBaseCommands() {
|
||||
final ClientFactory factory = new ClientFactory();
|
||||
final String [] commandTables = new String [] {"command_table", "client_command_table", "command_table_ground"};
|
||||
|
||||
clearCommands();
|
||||
for (String table : commandTables) {
|
||||
loadBaseCommands(factory, table);
|
||||
loadBaseCommands(table);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBaseCommands(ClientFactory factory, String table) {
|
||||
DatatableData baseCommands = (DatatableData) factory.getInfoFromFile("datatables/command/"+table+".iff");
|
||||
private void loadBaseCommands(String table) {
|
||||
DatatableData baseCommands = (DatatableData) ClientFactory.getInfoFromFile("datatables/command/"+table+".iff");
|
||||
|
||||
for (int row = 0; row < baseCommands.getRowCount(); row++) {
|
||||
Object [] cmdRow = baseCommands.getRow(row);
|
||||
@@ -171,7 +170,6 @@ public class CommandService extends Service {
|
||||
registerCallback("teleport", new AdminTeleportCallback());
|
||||
registerCallback("prone", new ProneCmdCallback());
|
||||
registerCallback("kneel", new KneelCmdCallback());
|
||||
registerCallback("toggleAwayFromKeyBoard", new AfkCmdCallback());
|
||||
registerCallback("jumpServer", new JumpCmdCallback());
|
||||
registerCallback("serverDestroyObject", new ServerDestroyObjectCmdCallback());
|
||||
}
|
||||
|
||||
@@ -69,9 +69,8 @@ public class MapService extends Service {
|
||||
dynamicMapLocations = new ConcurrentHashMap<>();
|
||||
persistentMapLocations = new ConcurrentHashMap<>();
|
||||
|
||||
ClientFactory clientFactory = new ClientFactory();
|
||||
loadMapCategories(clientFactory);
|
||||
loadMappingTemplates(clientFactory);
|
||||
loadMapCategories();
|
||||
loadMappingTemplates();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,8 +128,8 @@ public class MapService extends Service {
|
||||
player.sendPacket(responseMessage);
|
||||
}
|
||||
|
||||
private void loadMapCategories(ClientFactory clientFactory) {
|
||||
DatatableData table = (DatatableData) clientFactory.getInfoFromFile("datatables/player/planet_map_cat.iff");
|
||||
private void loadMapCategories() {
|
||||
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());
|
||||
@@ -144,8 +143,8 @@ public class MapService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMappingTemplates(ClientFactory clientFactory) {
|
||||
DatatableData table = (DatatableData) clientFactory.getInfoFromFile("map_locations.iff");
|
||||
private void loadMappingTemplates() {
|
||||
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()));
|
||||
@@ -159,7 +158,6 @@ public class MapService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addMapLocation(SWGObject object, MapType type) {
|
||||
if (!mappingTemplates.containsKey(object.getTemplate()))
|
||||
return;
|
||||
@@ -191,7 +189,7 @@ public class MapService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void addStaticMapLocation(String planet, MapLocation location) {
|
||||
public void addStaticMapLocation(String planet, MapLocation location) {
|
||||
if (staticMapLocations.containsKey(planet)) {
|
||||
location.setId(staticMapLocations.get(planet).size() + 1);
|
||||
staticMapLocations.get(planet).add(location);
|
||||
@@ -202,7 +200,7 @@ public class MapService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void addDynamicMapLocation(String planet, MapLocation location) {
|
||||
public void addDynamicMapLocation(String planet, MapLocation location) {
|
||||
if (dynamicMapLocations.containsKey(planet)) {
|
||||
location.setId(dynamicMapLocations.get(planet).size() + 1);
|
||||
dynamicMapLocations.get(planet).add(location);
|
||||
@@ -213,7 +211,7 @@ public class MapService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void addPersistentMapLocation(String planet, MapLocation location) {
|
||||
public void addPersistentMapLocation(String planet, MapLocation location) {
|
||||
if (persistentMapLocations.containsKey(planet)) {
|
||||
location.setId(persistentMapLocations.get(planet).size() + 1);
|
||||
persistentMapLocations.get(planet).add(location);
|
||||
|
||||
@@ -50,9 +50,7 @@ import resources.objects.waypoint.WaypointObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
public final class ObjectCreator {
|
||||
|
||||
private static final ClientFactory clientFac = new ClientFactory();
|
||||
|
||||
|
||||
public static final SWGObject createObjectFromTemplate(long objectId, String template) {
|
||||
if (!template.startsWith("object/"))
|
||||
return null;
|
||||
@@ -93,7 +91,7 @@ public final class ObjectCreator {
|
||||
}
|
||||
|
||||
private static void addObjectAttributes(SWGObject obj, String template) {
|
||||
ObjectData attributes = (ObjectData) clientFac.getInfoFromFile(ClientFactory.formatToSharedFile(template));
|
||||
ObjectData attributes = (ObjectData) ClientFactory.getInfoFromFile(ClientFactory.formatToSharedFile(template));
|
||||
|
||||
String stf = (String) attributes.getAttribute(ObjectData.OBJ_STF);
|
||||
String detailStf = (String) attributes.getAttribute(ObjectData.DETAIL_STF);
|
||||
@@ -122,7 +120,7 @@ public final class ObjectCreator {
|
||||
private static void createObjectSlots(SWGObject object) {
|
||||
if (object.getTemplateAttribute(ObjectData.SLOT_DESCRIPTOR) != null) {
|
||||
// These are the slots that the object *HAS*
|
||||
SlotDescriptorData descriptor = (SlotDescriptorData) clientFac.getInfoFromFile((String) object.getTemplateAttribute(ObjectData.SLOT_DESCRIPTOR));
|
||||
SlotDescriptorData descriptor = (SlotDescriptorData) ClientFactory.getInfoFromFile((String) object.getTemplateAttribute(ObjectData.SLOT_DESCRIPTOR));
|
||||
|
||||
for (String slotName : descriptor.getSlots()) {
|
||||
object.getSlots().put(slotName, null);
|
||||
@@ -131,7 +129,7 @@ public final class ObjectCreator {
|
||||
|
||||
if (object.getTemplateAttribute(ObjectData.ARRANGEMENT_FILE) != null) {
|
||||
// This is what slots the created object is able to go into/use
|
||||
SlotArrangementData arrangementData = (SlotArrangementData) clientFac.getInfoFromFile((String) object.getTemplateAttribute(ObjectData.ARRANGEMENT_FILE));
|
||||
SlotArrangementData arrangementData = (SlotArrangementData) ClientFactory.getInfoFromFile((String) object.getTemplateAttribute(ObjectData.ARRANGEMENT_FILE));
|
||||
object.setArrangement(arrangementData.getArrangement());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ public class ObjectManager extends Manager {
|
||||
SWGObject obj = objects.remove(objId);
|
||||
if (obj == null)
|
||||
return null;
|
||||
obj.clearAware();
|
||||
objectAwareness.remove(obj);
|
||||
Log.i("ObjectManager", "Deleted object %d [%s]", obj.getObjectId(), obj.getTemplate());
|
||||
return obj;
|
||||
@@ -287,7 +288,15 @@ public class ObjectManager extends Manager {
|
||||
return createObject(template, null);
|
||||
}
|
||||
|
||||
public SWGObject createObject(String template, boolean addToAwareness) {
|
||||
return createObject(template, null, addToAwareness);
|
||||
}
|
||||
|
||||
public SWGObject createObject(String template, Location l) {
|
||||
return createObject(template, l, true);
|
||||
}
|
||||
|
||||
public SWGObject createObject(String template, Location l, boolean addToAwareness) {
|
||||
synchronized (objects) {
|
||||
long objectId = getNextObjectId();
|
||||
SWGObject obj = ObjectCreator.createObjectFromTemplate(objectId, template);
|
||||
@@ -296,7 +305,9 @@ public class ObjectManager extends Manager {
|
||||
return null;
|
||||
}
|
||||
obj.setLocation(l);
|
||||
objectAwareness.add(obj);
|
||||
if (addToAwareness) {
|
||||
objectAwareness.add(obj);
|
||||
}
|
||||
objects.put(objectId, obj);
|
||||
Log.i("ObjectManager", "Created object %d [%s]", obj.getObjectId(), obj.getTemplate());
|
||||
return obj;
|
||||
|
||||
@@ -31,6 +31,8 @@ import intents.GalacticIntent;
|
||||
import intents.PlayerEventIntent;
|
||||
import intents.ZoneInIntent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -41,6 +43,11 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import main.ProjectSWG;
|
||||
import network.packets.Packet;
|
||||
import network.packets.soe.SessionRequest;
|
||||
@@ -68,6 +75,7 @@ import network.packets.swg.zone.ShowBackpack;
|
||||
import network.packets.swg.zone.ShowHelmet;
|
||||
import network.packets.swg.zone.UpdatePvpStatusMessage;
|
||||
import network.packets.swg.zone.chat.ChatOnConnectAvatar;
|
||||
import network.packets.swg.zone.chat.ChatSystemMessage;
|
||||
import network.packets.swg.zone.chat.VoiceChatStatus;
|
||||
import network.packets.swg.zone.insertion.ChatServerStatus;
|
||||
import network.packets.swg.zone.insertion.CmdStartScene;
|
||||
@@ -102,7 +110,6 @@ public class ZoneService extends Service {
|
||||
|
||||
private final Map <String, Player> lockedNames;
|
||||
private final Map <String, ProfTemplateData> profTemplates;
|
||||
private final ClientFactory clientFac;
|
||||
private final NameFilter nameFilter;
|
||||
private final SWGNameGenerator nameGenerator;
|
||||
private final CharacterCreationRestriction creationRestriction;
|
||||
@@ -110,14 +117,15 @@ public class ZoneService extends Service {
|
||||
private PreparedStatement createCharacter;
|
||||
private PreparedStatement getCharacter;
|
||||
private PreparedStatement getLikeCharacterName;
|
||||
private String commitHistory;
|
||||
|
||||
public ZoneService() {
|
||||
lockedNames = new HashMap<String, Player>();
|
||||
profTemplates = new ConcurrentHashMap<String, ProfTemplateData>();
|
||||
clientFac = new ClientFactory();
|
||||
nameFilter = new NameFilter("namegen/bad_word_list.txt", "namegen/reserved_words.txt", "namegen/fiction_reserved.txt");
|
||||
nameGenerator = new SWGNameGenerator(nameFilter);
|
||||
creationRestriction = new CharacterCreationRestriction(2);
|
||||
commitHistory = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,6 +136,7 @@ public class ZoneService extends Service {
|
||||
getLikeCharacterName = getLocalDatabase().prepareStatement("SELECT name FROM characters WHERE name ilike ?"); //NOTE: ilike is not SQL standard. It is an extension for postgres only.
|
||||
nameGenerator.loadAllRules();
|
||||
loadProfTemplates();
|
||||
loadCommitHistory();
|
||||
if (!nameFilter.load())
|
||||
System.err.println("Failed to load name filter!");
|
||||
registerForIntent(ZoneInIntent.TYPE);
|
||||
@@ -182,9 +191,48 @@ public class ZoneService extends Service {
|
||||
creature.createObject(player);
|
||||
System.out.printf("[%s] %s is zoning in%n", player.getUsername(), player.getCharacterName());
|
||||
Log.i("ObjectManager", "Zoning in %s with character %s", player.getUsername(), player.getCharacterName());
|
||||
sendCommitHistory(player);
|
||||
new PlayerEventIntent(player, galaxy, PlayerEvent.PE_ZONE_IN).broadcast();
|
||||
}
|
||||
|
||||
private void loadCommitHistory() {
|
||||
File repoDir = new File("./" + Constants.DOT_GIT); // Ziggy: Get the git directory
|
||||
Git git = null;
|
||||
Repository repo = null;
|
||||
int commitCount = 3;
|
||||
int iterations = 0;
|
||||
|
||||
try {
|
||||
git = Git.open(repoDir);
|
||||
repo = git.getRepository();
|
||||
|
||||
try {
|
||||
commitHistory = "The " + commitCount + " most recent commits in branch '" + repo.getBranch() + "':\n";
|
||||
|
||||
for(RevCommit commit : git.log().setMaxCount(commitCount).call()) {
|
||||
commitHistory += commit.getName().substring(0, 7) + " " + commit.getShortMessage();
|
||||
|
||||
if(commitCount > iterations++)
|
||||
commitHistory += "\n";
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
// Ziggy: An exception is thrown if bash isn't installed
|
||||
// It works fine anyways.
|
||||
// https://www.eclipse.org/forums/index.php/t/1031740/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void sendCommitHistory(Player player) {
|
||||
player.sendPacket(new ChatSystemMessage(ChatSystemMessage.SystemChatType.CHAT, commitHistory));
|
||||
}
|
||||
|
||||
private void sendZonePackets(Player player, CreatureObject creature) {
|
||||
long objId = creature.getObjectId();
|
||||
Race race = creature.getRace();
|
||||
@@ -488,13 +536,13 @@ public class ZoneService extends Service {
|
||||
}
|
||||
|
||||
private void loadProfTemplates() {
|
||||
profTemplates.put("crafting_artisan", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_combat_brawler.iff"));
|
||||
profTemplates.put("combat_brawler", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_combat_brawler.iff"));
|
||||
profTemplates.put("social_entertainer", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_social_entertainer.iff"));
|
||||
profTemplates.put("combat_marksman", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_combat_marksman.iff"));
|
||||
profTemplates.put("science_medic", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_science_medic.iff"));
|
||||
profTemplates.put("outdoors_scout", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_outdoors_scout.iff"));
|
||||
profTemplates.put("jedi", (ProfTemplateData) clientFac.getInfoFromFile("creation/profession_defaults_jedi.iff"));
|
||||
profTemplates.put("crafting_artisan", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_combat_brawler.iff"));
|
||||
profTemplates.put("combat_brawler", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_combat_brawler.iff"));
|
||||
profTemplates.put("social_entertainer", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_social_entertainer.iff"));
|
||||
profTemplates.put("combat_marksman", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_combat_marksman.iff"));
|
||||
profTemplates.put("science_medic", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_science_medic.iff"));
|
||||
profTemplates.put("outdoors_scout", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_outdoors_scout.iff"));
|
||||
profTemplates.put("jedi", (ProfTemplateData) ClientFactory.getInfoFromFile("creation/profession_defaults_jedi.iff"));
|
||||
}
|
||||
|
||||
private boolean lockName(String name, Player player) {
|
||||
|
||||
Reference in New Issue
Block a user