diff --git a/src/intents/object/ContainerTransferIntent.java b/src/intents/object/ContainerTransferIntent.java
new file mode 100644
index 000000000..7372a5d76
--- /dev/null
+++ b/src/intents/object/ContainerTransferIntent.java
@@ -0,0 +1,66 @@
+/************************************************************************************
+ * 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 intents.object;
+
+import resources.control.Intent;
+import resources.objects.SWGObject;
+
+public class ContainerTransferIntent extends Intent {
+
+ public static final String TYPE = "ContainerTransferIntent";
+
+ private SWGObject obj;
+ private SWGObject container;
+
+ public ContainerTransferIntent() {
+ this(null, null);
+ }
+
+ public ContainerTransferIntent(SWGObject obj, SWGObject container) {
+ super(TYPE);
+ setObject(obj);
+ setContainer(container);
+ }
+
+ public SWGObject getObject() {
+ return obj;
+ }
+
+ public void setObject(SWGObject obj) {
+ this.obj = obj;
+ }
+
+ public SWGObject getContainer() {
+ return container;
+ }
+
+ public void setContainer(SWGObject container) {
+ this.container = container;
+ }
+
+}
diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java
index 0184de697..e3636cfdd 100644
--- a/src/resources/objects/SWGObject.java
+++ b/src/resources/objects/SWGObject.java
@@ -55,6 +55,7 @@ import resources.server_info.Log;
import services.CoreManager;
import services.objects.ObjectCreator;
import utilities.AwarenessUtilities;
+import intents.object.ContainerTransferIntent;
import java.util.ArrayList;
import java.util.Collection;
@@ -186,6 +187,7 @@ public abstract class SWGObject extends BaselineObject implements Comparable observer.sendPacket(update));
AwarenessUtilities.callForNewObserver(oldObservers, newObservers, (observer) -> createObject(observer, false));
AwarenessUtilities.callForOldObserver(oldObservers, newObservers, (observer) -> destroyObject(observer));
+ new ContainerTransferIntent(this, container).broadcast();
return ContainerResult.SUCCESS;
}
diff --git a/src/resources/objects/awareness/AwarenessHandler.java b/src/resources/objects/awareness/AwarenessHandler.java
index 7a51926c2..4d9086438 100644
--- a/src/resources/objects/awareness/AwarenessHandler.java
+++ b/src/resources/objects/awareness/AwarenessHandler.java
@@ -29,16 +29,12 @@ package resources.objects.awareness;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
-
import resources.Location;
import resources.Terrain;
import resources.buildout.BuildoutArea;
import resources.objects.SWGObject;
import resources.objects.awareness.TerrainMap.TerrainMapCallback;
-import resources.player.Player;
import resources.server_info.Log;
-import utilities.AwarenessUtilities;
public class AwarenessHandler {
@@ -100,8 +96,6 @@ public class AwarenessHandler {
}
public void moveObject(SWGObject obj, SWGObject parent, Location requestedLocation) {
- Set oldAware = obj.getObjectsAware();
- Set oldObservers = obj.getObservers();
if (obj.getParent() != parent)
obj.moveToContainer(parent);
// Remove from previous awareness
@@ -111,13 +105,7 @@ public class AwarenessHandler {
// Update location
obj.setLocation(requestedLocation);
// Update awareness
- TerrainMap map = getTerrainMap(parent);
- if (map != null) {
- map.moveToParent(obj, parent);
- AwarenessUtilities.handleUpdateAwarenessManual(obj, oldAware, oldObservers, obj.getObjectsAware(), obj.getObservers());
- } else if (!requestedLocation.equals(GONE_LOCATION)) {
- Log.e(this, "Unknown terrain: %s", requestedLocation.getTerrain());
- }
+ obj.resetAwareness();
}
public void disappearObject(SWGObject obj, boolean disappearObjects, boolean disappearCustom) {
diff --git a/src/resources/objects/awareness/TerrainMap.java b/src/resources/objects/awareness/TerrainMap.java
index 31f09f903..f00330ed9 100644
--- a/src/resources/objects/awareness/TerrainMap.java
+++ b/src/resources/objects/awareness/TerrainMap.java
@@ -93,21 +93,13 @@ public class TerrainMap {
}
}
- public void moveToParent(SWGObject obj, SWGObject parent) {
- obj.resetAwareness();
- }
-
public void removeWithoutUpdate(SWGObject obj) {
- if (isInAwareness(obj)) {
- remove(obj);
- }
+ remove(obj);
}
public void removeFromMap(SWGObject obj) {
- if (isInAwareness(obj)) {
- remove(obj);
- update(obj);
- }
+ remove(obj);
+ update(obj);
}
private void move(SWGObject obj) {
diff --git a/src/services/objects/ObjectAwareness.java b/src/services/objects/ObjectAwareness.java
index 5007720e5..2c6141d08 100644
--- a/src/services/objects/ObjectAwareness.java
+++ b/src/services/objects/ObjectAwareness.java
@@ -30,6 +30,7 @@ package services.objects;
import intents.PlayerEventIntent;
import intents.RequestZoneInIntent;
import intents.network.GalacticPacketIntent;
+import intents.object.ContainerTransferIntent;
import intents.object.DestroyObjectIntent;
import intents.object.MoveObjectIntent;
import intents.object.ObjectCreatedIntent;
@@ -73,6 +74,7 @@ public class ObjectAwareness extends Service implements TerrainMapCallback {
registerForIntent(GalacticPacketIntent.TYPE);
registerForIntent(MoveObjectIntent.TYPE);
registerForIntent(ConfigChangedIntent.TYPE);
+ registerForIntent(ContainerTransferIntent.TYPE);
}
@Override
@@ -111,6 +113,11 @@ public class ObjectAwareness extends Service implements TerrainMapCallback {
case ConfigChangedIntent.TYPE:
if (i instanceof ConfigChangedIntent)
processConfigChangedIntent((ConfigChangedIntent) i);
+ break;
+ case ContainerTransferIntent.TYPE:
+ if (i instanceof ContainerTransferIntent)
+ processContainerTransferIntent((ContainerTransferIntent) i);
+ break;
default:
break;
}
@@ -217,6 +224,13 @@ public class ObjectAwareness extends Service implements TerrainMapCallback {
dataTransformHandler.setSpeedCheck(Boolean.parseBoolean(i.getNewValue()));
}
+ private void processContainerTransferIntent(ContainerTransferIntent i) {
+ if (i.getContainer() == null)
+ awarenessHandler.moveObject(i.getObject(), i.getObject().getLocation());
+ else
+ awarenessHandler.moveObject(i.getObject(), i.getContainer(), i.getObject().getLocation());
+ }
+
private void startScene(CreatureObject creature) {
Location loc = creature.getWorldLocation();
long time = ProjectSWG.getGalacticTime();
@@ -225,7 +239,7 @@ public class ObjectAwareness extends Service implements TerrainMapCallback {
Player owner = creature.getOwner();
creature.resetAwareness();
owner.sendPacket(new CmdStartScene(ignoreSnapshots, creature.getObjectId(), race, loc, time, (int)(System.currentTimeMillis()/1E3)));
- recursiveCreateObject(creature, owner);
+ recursiveCreateObject(creature, creature.getOwner());
if (creature.getParent() != null) {
for (SWGObject obj : creature.getSuperParent().getObjectsAware()) {
obj.createObject(creature);