Merge pull request #124 from SouNourS/AvatarDeadStateMessage

Packet: AvatarDeadStateMessage
This commit is contained in:
Fate-JH 2017-04-20 18:20:06 -04:00 committed by GitHub
commit 6ae2cd6bcf
3 changed files with 73 additions and 1 deletions

View file

@ -523,7 +523,7 @@ object GamePacketOpcode extends Enumeration {
case 0xaa => noDecoder(UnknownMessage170)
case 0xab => noDecoder(UnknownMessage171)
case 0xac => noDecoder(ReleaseAvatarRequestMessage)
case 0xad => noDecoder(AvatarDeadStateMessage)
case 0xad => game.AvatarDeadStateMessage.decode
case 0xae => noDecoder(CSAssistMessage)
case 0xaf => noDecoder(CSAssistCommentMessage)

View file

@ -0,0 +1,39 @@
// Copyright (c) 2017 PSForever
package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
import net.psforever.types.Vector3
import scodec.Codec
import scodec.codecs._
/**
* na
* @param unk1 0 = nothing, 1 = waiting for a rez, 2 = auto map to select spawn, 3 = respawn time
* @param unk2 na
* @param unk3 spawn penality
* @param pos last victim's position
* @param unk4 na
* @param unk5 na
*/
final case class AvatarDeadStateMessage(unk1 : Int,
unk2 : Long,
unk3 : Long,
pos : Vector3,
unk4 : Long,
unk5 : Boolean)
extends PlanetSideGamePacket {
type Packet = AvatarDeadStateMessage
def opcode = GamePacketOpcode.AvatarDeadStateMessage
def encode = AvatarDeadStateMessage.encode(this)
}
object AvatarDeadStateMessage extends Marshallable[AvatarDeadStateMessage] {
implicit val codec : Codec[AvatarDeadStateMessage] = (
("unk1" | uintL(3)) ::
("unk2" | uint32L) ::
("unk3" | uint32L) ::
("pos" | Vector3.codec_pos) ::
("unk4" | uint32L) ::
("unk5" | bool)
).as[AvatarDeadStateMessage]
}

View file

@ -0,0 +1,33 @@
// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.Vector3
import scodec.bits._
class AvatarDeadStateMessageTest extends Specification {
val string = hex"ad3c1260801c12608009f99861fb0741e040000010"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case AvatarDeadStateMessage(unk1,unk2,unk3,pos,unk4,unk5) =>
unk1 mustEqual 1
unk2 mustEqual 300000
unk3 mustEqual 300000
pos mustEqual Vector3(6552.617f,4602.375f,60.90625f)
unk4 mustEqual 2
unk5 mustEqual true
case _ =>
ko
}
}
"encode" in {
val msg = AvatarDeadStateMessage(1, 300000, 300000, Vector3(6552.617f,4602.375f,60.90625f), 2, true)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}