Packet: PickupItemMessage and create tests (#117)

This commit is contained in:
Fate-JH 2017-03-10 21:39:39 -05:00 committed by pschord
parent f4fa24f344
commit 06004b0af0
4 changed files with 73 additions and 1 deletions

View file

@ -382,7 +382,7 @@ object GamePacketOpcode extends Enumeration {
case 0x33 => game.ObjectHeldMessage.decode
case 0x34 => game.WeaponFireMessage.decode
case 0x35 => game.AvatarJumpMessage.decode
case 0x36 => noDecoder(PickupItemMessage)
case 0x36 => game.PickupItemMessage.decode
case 0x37 => game.DropItemMessage.decode
// 0x38
case 0x38 => noDecoder(InventoryStateMessage)

View file

@ -0,0 +1,39 @@
// Copyright (c) 2017 PSForever
package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
import scodec.Codec
import scodec.codecs._
/**
* Dispatched by the client when the player's intent is to collect an item from the ground.<br>
* <br>
* When a player faces a freed item on the ground in the game world, a prompt appears that invites him to pick it up.
* Doing so generates this packet.
* The server determines the exact inventory position where the item will get placed.
* If the inventory has insufficient space to accommodate the item, it gets put into the player's hand (on the cursor).<br>
* <br>
* This packet is complemented by an `ObjectAttachMessage` packet from the server that performs the actual "picking up."
* @param item_guid na
* @param player_guid na
* @param unk1 na
* @param unk2 na
*/
final case class PickupItemMessage(item_guid : PlanetSideGUID,
player_guid : PlanetSideGUID,
unk1 : Int,
unk2 : Int)
extends PlanetSideGamePacket {
type Packet = PickupItemMessage
def opcode = GamePacketOpcode.PickupItemMessage
def encode = PickupItemMessage.encode(this)
}
object PickupItemMessage extends Marshallable[PickupItemMessage] {
implicit val codec : Codec[PickupItemMessage] = (
("item_guid" | PlanetSideGUID.codec) ::
("player_guid" | PlanetSideGUID.codec) ::
("unk1" | uint8L) ::
("unk2" | uint16L)
).as[PickupItemMessage]
}