From 6aa96f006af7bf26acf42a744880f650489639b7 Mon Sep 17 00:00:00 2001 From: AconiteX <63141077+AconiteX@users.noreply.github.com> Date: Thu, 3 Jun 2021 23:22:52 -0400 Subject: [PATCH] Block Container Transfer out of Buyback Container if the item hasn't actually been bought back --- .../game/script/library/smuggler.java | 2 ++ .../game/script/object/autostack.java | 13 +++++++++- .../compiled/game/script/object/buyback.java | 25 +++++++++++++++++++ .../game/script/player/base/base_player.java | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sku.0/sys.server/compiled/game/script/object/buyback.java diff --git a/sku.0/sys.server/compiled/game/script/library/smuggler.java b/sku.0/sys.server/compiled/game/script/library/smuggler.java index 150e8b9c2a..0064487276 100755 --- a/sku.0/sys.server/compiled/game/script/library/smuggler.java +++ b/sku.0/sys.server/compiled/game/script/library/smuggler.java @@ -1088,6 +1088,7 @@ public static boolean moveBuyBackObjectIntoInventory(obj_id player, obj_id objec return false; } // This should be a vendor... and if so, we don't care if it's full because the vendor does NOT try to move. + detachScript(object, "object.buyback"); if (putInOverloaded(object, objContainer)) { removeObjVar(object, BUYBACK_OBJ_TIMESTAMP); @@ -1095,6 +1096,7 @@ public static boolean moveBuyBackObjectIntoInventory(obj_id player, obj_id objec removeObjVar(object, BUYBACK_OBJ_SOLD); return true; } + attachScript(object, "object.buyback"); CustomerServiceLog("Junk_Dealer: ", "smuggler.moveBuyBackObjectIntoInventory() - Player (OID: " + player + ") could not put object: " + object + " in buy back container."); return false; } diff --git a/sku.0/sys.server/compiled/game/script/object/autostack.java b/sku.0/sys.server/compiled/game/script/object/autostack.java index 2d7c00d127..67574a4dd8 100755 --- a/sku.0/sys.server/compiled/game/script/object/autostack.java +++ b/sku.0/sys.server/compiled/game/script/object/autostack.java @@ -119,6 +119,9 @@ public boolean canRestack(obj_id self) throws InterruptedException } public void restackIt(obj_id self) throws InterruptedException { + if(isPendingJunkDeal(self)) { + return; + } blog("restackIt init"); if (!isIdValid(self) || !exists(self)) { @@ -149,7 +152,7 @@ public void restackIt(obj_id self) throws InterruptedException obj_id item = loot.findItemToStack(self); if (isIdValid(item) && !isInSecureTrade(item)) { - if (utils.hasScriptVar(self, "unstacking") || utils.hasScriptVar(item, "unstacking")) + if (utils.hasScriptVar(self, "unstacking") || utils.hasScriptVar(item, "unstacking") || isPendingJunkDeal(item)) { return; } @@ -165,6 +168,9 @@ public void restackIt(obj_id self) throws InterruptedException } public void unstackIt(obj_id self, obj_id player) throws InterruptedException { + if(isPendingJunkDeal(self)) { + return; + } if (!isInSecureTrade(self)) { if (getCount(self) == 2) @@ -296,4 +302,9 @@ else if (msg == null || msg.equals("")) LOG(BLOGGING_CATEGORY, msg); return true; } + // Used to block stack/split if item should be in Junk Dealer Buy Back Container + public boolean isPendingJunkDeal(obj_id item) { + return hasObjVar(item, smuggler.BUYBACK_OBJ_SOLD); + } + } diff --git a/sku.0/sys.server/compiled/game/script/object/buyback.java b/sku.0/sys.server/compiled/game/script/object/buyback.java new file mode 100644 index 0000000000..c9816d1513 --- /dev/null +++ b/sku.0/sys.server/compiled/game/script/object/buyback.java @@ -0,0 +1,25 @@ +package script.object; + +import script.library.smuggler; +import script.obj_id; + +public class buyback extends script.base_script { + + /** + * Triggered when this item is about to be transferred from the buyback container + * potentially into another container (like player inventory), in which case we will + * first validate that the item has actually been bought back. + */ + public int OnAboutToBeTransferred(obj_id self, obj_id destContainer, obj_id transferer) throws InterruptedException { + + if(hasObjVar(self, smuggler.BUYBACK_OBJ_SOLD)) { + if(getTemplateName(destContainer).equalsIgnoreCase(smuggler.BUY_BACK_CONTROL_DEVICE_TEMPLATE)) { + return SCRIPT_CONTINUE; + } else { + return SCRIPT_OVERRIDE; + } + } + return SCRIPT_CONTINUE; + } + +} \ No newline at end of file diff --git a/sku.0/sys.server/compiled/game/script/player/base/base_player.java b/sku.0/sys.server/compiled/game/script/player/base/base_player.java index 3b0bda20d4..17c211a84e 100755 --- a/sku.0/sys.server/compiled/game/script/player/base/base_player.java +++ b/sku.0/sys.server/compiled/game/script/player/base/base_player.java @@ -10918,6 +10918,7 @@ public int handleSoldJunk(obj_id self, dictionary params) throws InterruptedExce sendSystemMessageProse(player, ppSoldJunk); setObjVar(item, smuggler.BUYBACK_OBJ_SOLD, getGameTime()); smuggler.moveBuyBackObjectIntoContainer(player, item, price); + attachScript(item, "object.buyback"); CustomerServiceLog("Junk_Dealer: ", "junk_dealer.handleSoldJunk() - Player: " + self + " has sold item: " + item + " and the item has been marked sold. The item is about to be moved to the buy back container."); boolean reshowSui = params.getBoolean("reshowSui"); if (reshowSui && fence)