From ab4f9243fc06a49eaf6ebb3a2e3d0bf20c42a330 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Fri, 5 Jun 2015 16:42:58 -0400 Subject: [PATCH] Fixed container and slot volume size logic checks and moved AFK to a script --- .../generic/toggleAwayFromKeyBoard.py | 6 +++ .../commands/callbacks/AfkCmdCallback.java | 44 ------------------- src/resources/objects/SWGObject.java | 12 ++--- src/services/commands/CommandService.java | 1 - 4 files changed, 12 insertions(+), 51 deletions(-) create mode 100644 scripts/commands/generic/toggleAwayFromKeyBoard.py delete mode 100644 src/resources/commands/callbacks/AfkCmdCallback.java diff --git a/scripts/commands/generic/toggleAwayFromKeyBoard.py b/scripts/commands/generic/toggleAwayFromKeyBoard.py new file mode 100644 index 000000000..7b47f0707 --- /dev/null +++ b/scripts/commands/generic/toggleAwayFromKeyBoard.py @@ -0,0 +1,6 @@ +import sys +from resources.player.PlayerFlags import AFK + +def execute(objManager, player, target, args): + player.getPlayerObject().toggleFlag(PlayerFlags.AFK) + return \ No newline at end of file diff --git a/src/resources/commands/callbacks/AfkCmdCallback.java b/src/resources/commands/callbacks/AfkCmdCallback.java deleted file mode 100644 index b5929f081..000000000 --- a/src/resources/commands/callbacks/AfkCmdCallback.java +++ /dev/null @@ -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 . * -* * -***********************************************************************************/ -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); - } - -} diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java index 5dc0245f2..919831af7 100644 --- a/src/resources/objects/SWGObject.java +++ b/src/resources/objects/SWGObject.java @@ -165,7 +165,7 @@ public abstract class SWGObject implements Serializable, Comparable { 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; } } @@ -180,7 +180,8 @@ public abstract class SWGObject implements Serializable, Comparable { 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())); @@ -424,7 +425,7 @@ public abstract class SWGObject implements Serializable, Comparable { * @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 +438,7 @@ public abstract class SWGObject implements Serializable, Comparable { if (!hasSlot(slot)) { isValid = false; break; - } - if (slots.get(slot) != null) { + } else if (slots.get(slot) != null) { passesCompletely = false; } } @@ -449,7 +449,7 @@ public abstract class SWGObject implements Serializable, Comparable { arrangementId++; } - return (filledId != -1) ? arrangementId : 4; + return (filledId != -1) ? filledId : -1; } protected final void sendSceneCreateObject(Player target) { diff --git a/src/services/commands/CommandService.java b/src/services/commands/CommandService.java index 96f6d0dee..c6980cb8c 100644 --- a/src/services/commands/CommandService.java +++ b/src/services/commands/CommandService.java @@ -170,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()); }