From 827c379952f50f7ba40299bd55bc75bbc5d296c1 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 6 Jun 2015 11:45:10 -0400 Subject: [PATCH] Disabled transferItemMisc script until blue ghost bug is fixed, Items that were in multiple slots are no longer sent individually for each slot --- scripts/commands/generic/transferItemMisc.py | 2 + .../encodables/player/Equipment.java | 27 ++++++++--- src/resources/objects/SWGObject.java | 46 +++++++++++++++++-- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/scripts/commands/generic/transferItemMisc.py b/scripts/commands/generic/transferItemMisc.py index 230d55ce4..97f6996cf 100644 --- a/scripts/commands/generic/transferItemMisc.py +++ b/scripts/commands/generic/transferItemMisc.py @@ -1,6 +1,8 @@ import sys def execute(galacticManager, player, target, args): + return + actor = player.getCreatureObject() if actor is None or target is None: return diff --git a/src/resources/encodables/player/Equipment.java b/src/resources/encodables/player/Equipment.java index e5afae432..6fd7f17d6 100644 --- a/src/resources/encodables/player/Equipment.java +++ b/src/resources/encodables/player/Equipment.java @@ -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; + } } diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java index b69914739..5bd909f5b 100644 --- a/src/resources/objects/SWGObject.java +++ b/src/resources/objects/SWGObject.java @@ -176,7 +176,9 @@ public abstract class SWGObject implements Serializable, Comparable { List oldObservers = getChildrenAwareness(); // Remove this object from the old parent if one exists + SWGObject oldParent = null; if (parent != null) { + oldParent = parent; parent.removeObject(this); } @@ -186,6 +188,7 @@ public abstract class SWGObject implements Serializable, Comparable { // Observer notification sendUpdatedContainment(oldObservers, new ArrayList<>(container.getChildrenAwareness())); + Log.i("Container", "Moved %s from %s to %s", this, oldParent, container); return ContainerResult.SUCCESS; } @@ -662,29 +665,62 @@ public abstract class SWGObject implements Serializable, Comparable { } 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"); return; } + List 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); + sentObjects.add(containedObject); } } } - + + 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 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 + "]";