mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 15:34:42 +00:00
Packet: PlayerStateMessageUpstream (#34)
* Fill out PlayerStateMessageUpstream packet * Add PlayerStateMessageUpstream test
This commit is contained in:
parent
c03b29b2bd
commit
3fca8b1a95
3 changed files with 69 additions and 5 deletions
|
|
@ -2,15 +2,45 @@
|
||||||
package net.psforever.packet.game
|
package net.psforever.packet.game
|
||||||
|
|
||||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||||
|
import net.psforever.types.Vector3
|
||||||
import scodec.Codec
|
import scodec.Codec
|
||||||
import scodec.codecs._
|
import scodec.codecs._
|
||||||
|
|
||||||
final case class PlayerStateMessageUpstream(some_field : Int) extends PlanetSideGamePacket {
|
final case class PlayerStateMessageUpstream(avatar_guid : PlanetSideGUID,
|
||||||
|
pos : Vector3,
|
||||||
|
vel : Option[Vector3],
|
||||||
|
unk1 : Int,
|
||||||
|
aim_pitch : Int,
|
||||||
|
unk2 : Int,
|
||||||
|
unk3 : Int,
|
||||||
|
unk4 : Int,
|
||||||
|
is_crouching : Boolean,
|
||||||
|
unk5 : Boolean,
|
||||||
|
unk6 : Boolean,
|
||||||
|
unk7 : Boolean,
|
||||||
|
unk8 : Int,
|
||||||
|
unk9 : Int)
|
||||||
|
extends PlanetSideGamePacket {
|
||||||
type Packet = PlayerStateMessageUpstream
|
type Packet = PlayerStateMessageUpstream
|
||||||
def opcode = GamePacketOpcode.PlayerStateMessageUpstream
|
def opcode = GamePacketOpcode.PlayerStateMessageUpstream
|
||||||
def encode = PlayerStateMessageUpstream.encode(this)
|
def encode = PlayerStateMessageUpstream.encode(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
object PlayerStateMessageUpstream extends Marshallable[PlayerStateMessageUpstream] {
|
object PlayerStateMessageUpstream extends Marshallable[PlayerStateMessageUpstream] {
|
||||||
implicit val codec : Codec[PlayerStateMessageUpstream] = ("some_field" | uint8L).as[PlayerStateMessageUpstream]
|
implicit val codec : Codec[PlayerStateMessageUpstream] = (
|
||||||
}
|
("avatar_guid" | PlanetSideGUID.codec) ::
|
||||||
|
("pos" | Vector3.codec_pos) ::
|
||||||
|
("vel" | optional(bool, Vector3.codec_vel)) ::
|
||||||
|
("unk1" | uint8L) ::
|
||||||
|
("aim_pitch" | uint8L) ::
|
||||||
|
("unk2" | uint8L) ::
|
||||||
|
("unk3" | uintL(10)) ::
|
||||||
|
("unk4" | uintL(3)) ::
|
||||||
|
("is_crouching" | bool) ::
|
||||||
|
("unk5" | bool) ::
|
||||||
|
("unk6" | bool) ::
|
||||||
|
("unk7" | bool) ::
|
||||||
|
("unk8" | uint8L) ::
|
||||||
|
("unk9" | uint16L)
|
||||||
|
).as[PlayerStateMessageUpstream]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -435,5 +435,38 @@ class GamePacketTest extends Specification {
|
||||||
pkt mustEqual string
|
pkt mustEqual string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"PlayerStateMessageUpstream" should {
|
||||||
|
val string = hex"BD 4B000 E377BA575B616C640A70004014060110007000000"
|
||||||
|
|
||||||
|
"decode" in {
|
||||||
|
PacketCoding.DecodePacket(string).require match {
|
||||||
|
case PlayerStateMessageUpstream(avatar_guid, pos, vel, unk1, aim_pitch, unk2, unk3, unk4, is_crouching, unk5, unk6, unk7, unk8, unk9) =>
|
||||||
|
avatar_guid mustEqual PlanetSideGUID(75)
|
||||||
|
pos mustEqual Vector3(3694.1094f, 2735.4531f, 90.84375f)
|
||||||
|
vel mustEqual Some(Vector3(4.375f, 2.59375f, 0.0f))
|
||||||
|
unk1 mustEqual 10
|
||||||
|
aim_pitch mustEqual 3
|
||||||
|
unk2 mustEqual 0
|
||||||
|
unk3 mustEqual 136
|
||||||
|
unk4 mustEqual 0
|
||||||
|
is_crouching mustEqual false
|
||||||
|
unk5 mustEqual false
|
||||||
|
unk6 mustEqual false
|
||||||
|
unk7 mustEqual false
|
||||||
|
unk8 mustEqual 112
|
||||||
|
unk9 mustEqual 0
|
||||||
|
case default =>
|
||||||
|
ko
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"encode" in {
|
||||||
|
val msg = PlayerStateMessageUpstream(PlanetSideGUID(75), Vector3(3694.1094f, 2735.4531f, 90.84375f), Some(Vector3(4.375f, 2.59375f, 0.0f)), 10, 3, 0, 136, 0, false, false, false, false, 112, 0)
|
||||||
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
|
pkt mustEqual string
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
case KeepAliveMessage(code) =>
|
case KeepAliveMessage(code) =>
|
||||||
sendResponse(PacketCoding.CreateGamePacket(0, KeepAliveMessage(0)))
|
sendResponse(PacketCoding.CreateGamePacket(0, KeepAliveMessage(0)))
|
||||||
|
|
||||||
case PlayerStateMessageUpstream(_) =>
|
case msg @ PlayerStateMessageUpstream(avatar_guid, pos, vel, unk1, aim_pitch, unk2, unk3, unk4, is_crouching, unk5, unk6, unk7, unk8, unk9) =>
|
||||||
|
//log.info("PlayerState: " + msg)
|
||||||
|
|
||||||
case msg @ ChatMsg(messagetype, unk1, recipient, contents) =>
|
case msg @ ChatMsg(messagetype, unk1, recipient, contents) =>
|
||||||
log.info("Chat: " + msg)
|
log.info("Chat: " + msg)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue