mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-20 02:24:45 +00:00
Packet: QuantityUpdateMessage
This commit is contained in:
parent
93fe7d6be8
commit
0bed8ce5b8
|
|
@ -392,7 +392,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
|
||||
// OPCODE 60
|
||||
case GenericCollisionMsg => noDecoder(opcode)
|
||||
case QuantityUpdateMessage => noDecoder(opcode)
|
||||
case QuantityUpdateMessage => game.QuantityUpdateMessage.decode
|
||||
case ArmorChangedMessage => noDecoder(opcode)
|
||||
case ProjectileStateMessage => noDecoder(opcode)
|
||||
case MountVehicleCargoMsg => noDecoder(opcode)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2016 PSForever.net to present
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
|
||||
/**
|
||||
* Instructs client to update the quantity of an item when sent server to client.
|
||||
*
|
||||
* See also [[QuantityDeltaUpdateMessage]]
|
||||
*
|
||||
* @param item_guid the item to update
|
||||
* @param quantity the quantity to update the item to
|
||||
*/
|
||||
final case class QuantityUpdateMessage(item_guid : PlanetSideGUID,
|
||||
quantity : Int)
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = QuantityUpdateMessage
|
||||
def opcode = GamePacketOpcode.QuantityUpdateMessage
|
||||
def encode = QuantityUpdateMessage.encode(this)
|
||||
}
|
||||
|
||||
object QuantityUpdateMessage extends Marshallable[QuantityUpdateMessage] {
|
||||
implicit val codec : Codec[QuantityUpdateMessage] = (
|
||||
("item_guid" | PlanetSideGUID.codec) ::
|
||||
("quantity" | int32L)
|
||||
).as[QuantityUpdateMessage]
|
||||
}
|
||||
|
|
@ -837,6 +837,27 @@ class GamePacketTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"QuantityUpdateMessage" should {
|
||||
val string = hex"3D 5300 7B000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case QuantityUpdateMessage(item_guid, quantity) =>
|
||||
item_guid mustEqual PlanetSideGUID(83)
|
||||
quantity mustEqual 123
|
||||
case default =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = QuantityUpdateMessage(PlanetSideGUID(83), 123)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
||||
"PingMsg" should {
|
||||
val packet = hex"1a 00000000 b0360000"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue