Skip to content

Commit

Permalink
Block Container Transfer out of Buyback Container if the item hasn't …
Browse files Browse the repository at this point in the history
…actually been bought back
  • Loading branch information
AconiteX committed Jun 4, 2021
1 parent dccc8a9 commit 6aa96f0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sku.0/sys.server/compiled/game/script/library/smuggler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,15 @@ 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);
removeObjVar(object, BUYBACK_OBJ_CREDITS);
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;
}
Expand Down
13 changes: 12 additions & 1 deletion sku.0/sys.server/compiled/game/script/object/autostack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}

}
25 changes: 25 additions & 0 deletions sku.0/sys.server/compiled/game/script/object/buyback.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6aa96f0

Please sign in to comment.