From 49880ce4762cd36c5b37b9c42e872d4f0fa2682f Mon Sep 17 00:00:00 2001 From: FateJH Date: Thu, 9 Mar 2017 22:57:15 -0500 Subject: [PATCH 1/4] initial ChildObjectStateMessage packet and tests --- .../psforever/packet/GamePacketOpcode.scala | 2 +- .../packet/game/ChildObjectStateMessage.scala | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala diff --git a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala index 9da9c70c..63b1bac1 100644 --- a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala +++ b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala @@ -353,7 +353,7 @@ object GamePacketOpcode extends Enumeration { case 0x1b => noDecoder(VehicleStateMessage) case 0x1c => noDecoder(FrameVehicleStateMessage) case 0x1d => game.GenericObjectStateMsg.decode - case 0x1e => noDecoder(ChildObjectStateMessage) + case 0x1e => game.ChildObjectStateMessage.decode case 0x1f => game.ActionResultMessage.decode // OPCODES 0x20-2f diff --git a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala new file mode 100644 index 00000000..efbb27cd --- /dev/null +++ b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala @@ -0,0 +1,23 @@ +// Copyright (c) 2017 PSForever +package net.psforever.packet.game + +import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket} +import scodec.Codec +import scodec.codecs._ + +final case class ChildObjectStateMessage(unk1 : Int, + unk2 : Int, + unk3 : Int) + extends PlanetSideGamePacket { + type Packet = ChildObjectStateMessage + def opcode = GamePacketOpcode.ChildObjectStateMessage + def encode = ChildObjectStateMessage.encode(this) +} + +object ChildObjectStateMessage extends Marshallable[ChildObjectStateMessage] { + implicit val codec : Codec[ChildObjectStateMessage] = ( + ("unk1" | uint16L) :: + ("unk2" | uint8L) :: + ("unk3" | uint8L) + ).as[ChildObjectStateMessage] +} From 749d2d2c50b6ab4c80d7f095567612f017ca564f Mon Sep 17 00:00:00 2001 From: FateJH Date: Thu, 20 Apr 2017 08:37:51 -0400 Subject: [PATCH 2/4] fleshed out field details of COSM --- .../packet/game/ChildObjectStateMessage.scala | 24 ++++++++++++++----- .../src/main/scala/WorldSessionActor.scala | 3 +++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala index efbb27cd..34e964c7 100644 --- a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala @@ -5,9 +5,21 @@ import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacke import scodec.Codec import scodec.codecs._ -final case class ChildObjectStateMessage(unk1 : Int, - unk2 : Int, - unk3 : Int) +/** + * na + * @param object_guid the object being manipulated (controlled) + * @param pitch the angle with respect to the sky and the ground towards which the object is directed; + * an 8-bit unsigned value; + * 0 is perfectly level and forward-facing, wrapping around at 255; + * positive rotation is occurs by rotating downwards from forward-facing + * @param yaw the angle with respect to the horizon towards which the object is directed; + * an 8-bit unsigned value; + * 0 is forward-facing, wrapping around at 255; + * positive rotation is clockwise of forward-facing + */ +final case class ChildObjectStateMessage(object_guid : PlanetSideGUID, + pitch : Int, + yaw : Int) extends PlanetSideGamePacket { type Packet = ChildObjectStateMessage def opcode = GamePacketOpcode.ChildObjectStateMessage @@ -16,8 +28,8 @@ final case class ChildObjectStateMessage(unk1 : Int, object ChildObjectStateMessage extends Marshallable[ChildObjectStateMessage] { implicit val codec : Codec[ChildObjectStateMessage] = ( - ("unk1" | uint16L) :: - ("unk2" | uint8L) :: - ("unk3" | uint8L) + ("object_guid" | PlanetSideGUID.codec) :: + ("pitch" | uint8L) :: + ("yaw" | uint8L) ).as[ChildObjectStateMessage] } diff --git a/pslogin/src/main/scala/WorldSessionActor.scala b/pslogin/src/main/scala/WorldSessionActor.scala index 5dc6479e..9ba1b9a8 100644 --- a/pslogin/src/main/scala/WorldSessionActor.scala +++ b/pslogin/src/main/scala/WorldSessionActor.scala @@ -238,6 +238,9 @@ class WorldSessionActor extends Actor with MDCContextAware { case msg @ PlayerStateMessageUpstream(avatar_guid, pos, vel, unk1, aim_pitch, unk2, seq_time, unk3, is_crouching, is_jumping, unk4, is_cloaking, unk5, unk6) => //log.info("PlayerState: " + msg) + case msg @ ChildObjectStateMessage(object_guid : PlanetSideGUID, pitch : Int, yaw : Int) => + //log.info("ChildObjectState: " + msg) + case msg @ ChatMsg(messagetype, has_wide_contents, recipient, contents, note_contents) => // TODO: Prevents log spam, but should be handled correctly if (messagetype != ChatMessageType.CMT_TOGGLE_GM) { From 941b1f01bb7e4714d94a12318c1c4e89ade1fa58 Mon Sep 17 00:00:00 2001 From: FateJH Date: Thu, 20 Apr 2017 19:02:54 -0400 Subject: [PATCH 3/4] comments in the main packet file and working tests --- .../packet/game/ChildObjectStateMessage.scala | 22 ++++++++++---- .../game/ChildObjectStateMessageTest.scala | 29 +++++++++++++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 common/src/test/scala/game/ChildObjectStateMessageTest.scala diff --git a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala index 34e964c7..7e28c442 100644 --- a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala @@ -6,16 +6,26 @@ import scodec.Codec import scodec.codecs._ /** - * na + * Dispatched from a client when its user is controlling a secondary object whose state must be updated.
+ *
+ * When `ChildObjectStateMessage` is being sent to the server, it replaces `PlayerStateMessage`. + * The packet frequently gets hidden in a `MultiPacket`, though it is not functionally essential to do that.
+ *
+ * Note the lack of position data. + * The secondary object in question is updated in position through another means or is stationary. + * The only concern is the direction the object is facing. + * The angles are relative to the object's normal forward-facing and typically begin tracking at 0, 0 (forward-facing). * @param object_guid the object being manipulated (controlled) * @param pitch the angle with respect to the sky and the ground towards which the object is directed; * an 8-bit unsigned value; - * 0 is perfectly level and forward-facing, wrapping around at 255; - * positive rotation is occurs by rotating downwards from forward-facing + * 0 is perfectly level and forward-facing and mapped to 255; + * positive rotation is downwards from forward-facing; + * between 7 (down) and 231 (up), for 32 angles * @param yaw the angle with respect to the horizon towards which the object is directed; - * an 8-bit unsigned value; - * 0 is forward-facing, wrapping around at 255; - * positive rotation is clockwise of forward-facing + * an 8-bit unsigned value; + * 0 is forward-facing, wrapping around at 127; + * positive rotation is counter-clockwise of forward-facing; + * full rotation */ final case class ChildObjectStateMessage(object_guid : PlanetSideGUID, pitch : Int, diff --git a/common/src/test/scala/game/ChildObjectStateMessageTest.scala b/common/src/test/scala/game/ChildObjectStateMessageTest.scala new file mode 100644 index 00000000..00cba45d --- /dev/null +++ b/common/src/test/scala/game/ChildObjectStateMessageTest.scala @@ -0,0 +1,29 @@ +// Copyright (c) 2017 PSForever +package game + +import org.specs2.mutable._ +import net.psforever.packet._ +import net.psforever.packet.game._ +import scodec.bits._ + +class ChildObjectStateMessageTest extends Specification { + val string = hex"1E 640B 06 47" + + "decode" in { + PacketCoding.DecodePacket(string).require match { + case ChildObjectStateMessage(object_guid, pitch, yaw) => + object_guid mustEqual PlanetSideGUID(2916) + pitch mustEqual 6 + yaw mustEqual 71 + case _ => + ko + } + } + + "encode" in { + val msg = ChildObjectStateMessage(PlanetSideGUID(2916), 6, 71) + val pkt = PacketCoding.EncodePacket(msg).require.toByteVector + + pkt mustEqual string + } +} From ba0111601314de6de12de153c4fc142c8e86543c Mon Sep 17 00:00:00 2001 From: Fate-JH Date: Fri, 21 Apr 2017 07:16:25 -0400 Subject: [PATCH 4/4] Update ChildObjectStateMessage.scala scrubbed accidental information specific to the handling of the test platfiorm (Orion) from general comments about COSM --- .../net/psforever/packet/game/ChildObjectStateMessage.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala index 7e28c442..4b2a3058 100644 --- a/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/ChildObjectStateMessage.scala @@ -19,13 +19,11 @@ import scodec.codecs._ * @param pitch the angle with respect to the sky and the ground towards which the object is directed; * an 8-bit unsigned value; * 0 is perfectly level and forward-facing and mapped to 255; - * positive rotation is downwards from forward-facing; - * between 7 (down) and 231 (up), for 32 angles + * positive rotation is downwards from forward-facing * @param yaw the angle with respect to the horizon towards which the object is directed; * an 8-bit unsigned value; * 0 is forward-facing, wrapping around at 127; - * positive rotation is counter-clockwise of forward-facing; - * full rotation + * positive rotation is counter-clockwise of forward-facing */ final case class ChildObjectStateMessage(object_guid : PlanetSideGUID, pitch : Int,