fix item swap

This commit is contained in:
ScrawnyRonnie 2023-11-24 06:42:28 -05:00
parent 60989f488a
commit aa0ae5f731
3 changed files with 17 additions and 2 deletions

View file

@ -102,7 +102,7 @@ class SessionTerminalHandlers(
lastTerminalOrderFulfillment = true
case Terminal.BuyVehicle(vehicle, _, _)
if tplayer.avatar.purchaseCooldown(vehicle.Definition).nonEmpty =>
if tplayer.avatar.purchaseCooldown(vehicle.Definition).nonEmpty || tplayer.spectator =>
sendResponse(ItemTransactionResultMessage(msg.terminal_guid, TransactionType.Buy, success = false))
lastTerminalOrderFulfillment = true

View file

@ -323,7 +323,7 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
player.Name,
AvatarAction.ObjectHeld(player.GUID, before, -1)
)
} else if (!resistance && before != slot && (player.DrawnSlot = slot) != before) {
} else if ((!resistance && before != slot && (player.DrawnSlot = slot) != before) && ItemSwapSlot != before) {
val mySlot = if (updateMyHolsterArm) slot else -1 //use as a short-circuit
events ! AvatarServiceMessage(
player.Continent,
@ -352,6 +352,9 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
log.info(s"${player.Name} lowers ${player.Sex.possessive} hand")
}
}
UpdateItemSwapSlot
} else if (ItemSwapSlot == before) {
UpdateItemSwapSlot
}
case Terminal.TerminalMessage(_, msg, order) =>

View file

@ -42,6 +42,7 @@ trait ContainableBehavior {
* The destination is set back to normal - flag to `0` - when both of the attempts short-circuit due to timeout.
*/
private var waitOnMoveItemOps: Int = 0
private var itemSwapSlot: Int = 10 // Just a number higher than any inventory item slots
final val containerBehavior: Receive = {
/* messages that modify delivery order */
@ -136,6 +137,15 @@ trait ContainableBehavior {
}
/* Functions (item transfer) */
// For issue 1108
def UpdateItemSwapSlot: Int = {
itemSwapSlot = 10
itemSwapSlot
}
// For issue 1108
def ItemSwapSlot: Int = {
itemSwapSlot
}
protected def ContainableMoveItem(
destination: PlanetSideServerObject with Container,
@ -154,6 +164,7 @@ trait ContainableBehavior {
LocalPutItemInSlot(item, dest) match {
case Containable.ItemPutInSlot(_, _, _, None) => ; //success
case Containable.ItemPutInSlot(_, _, _, Some(swapItem)) => //success, but with swap item
itemSwapSlot = dest
LocalPutItemInSlotOnlyOrAway(swapItem, slot) match {
case Containable.ItemPutInSlot(_, _, _, None) => ;
case _ =>
@ -174,6 +185,7 @@ trait ContainableBehavior {
case Success(Containable.ItemPutInSlot(_, _, _, None)) => ; //successful
case Success(Containable.ItemPutInSlot(_, _, _, Some(swapItem))) => //successful, but with swap item
itemSwapSlot = dest
PutItBackOrDropIt(source, swapItem, slot, destination.Actor)
case Success(_: Containable.CanNotPutItemInSlot) => //failure case ; try restore original item placement