From 5ceded71c1c3f0b6b880546d054edcd3a316679d Mon Sep 17 00:00:00 2001 From: FateJH Date: Tue, 2 May 2017 00:51:54 -0400 Subject: [PATCH] comments in class; added a match case in WSA; short test, to at least show a full working sample --- .../packet/game/TargetingImplantRequest.scala | 11 +++++++ .../game/TargetingImplantRequestTest.scala | 33 ++++++++++++++++--- .../src/main/scala/WorldSessionActor.scala | 3 ++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala b/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala index 7566c523..63cceeb6 100644 --- a/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala +++ b/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala @@ -5,9 +5,20 @@ import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacke import scodec.Codec import scodec.codecs._ +/** + * An entry regarding a specific target. + * @param target_guid the target + * @param unk na + */ final case class TargetRequest(target_guid : PlanetSideGUID, unk : Boolean) +/** + * Dispatched by the client when the advanced targeting implant activates to collect status information from the server.
+ *
+ * This packet is answered by a `TargetingInfoMessage` with `List` entries of thed corresponding UIDs. + * @param target_list a `List` of targets + */ final case class TargetingImplantRequest(target_list : List[TargetRequest]) extends PlanetSideGamePacket { type Packet = TargetingImplantRequest diff --git a/common/src/test/scala/game/TargetingImplantRequestTest.scala b/common/src/test/scala/game/TargetingImplantRequestTest.scala index 52d177c1..0a2112c1 100644 --- a/common/src/test/scala/game/TargetingImplantRequestTest.scala +++ b/common/src/test/scala/game/TargetingImplantRequestTest.scala @@ -7,10 +7,23 @@ import net.psforever.packet.game._ import scodec.bits._ class TargetingImplantRequestTest extends Specification { - val string = hex"b5 41edeb12d4409f0144053f8010541ba91d03df376831b1e26000611041e1107c0209c0"//0510085013d9ffb6720d5b132900003770? + val string_single = hex"b5 061016" + val string_long = hex"b5 41edeb12d4409f0144053f8010541ba91d03df376831b1e26000611041e1107c0209c0"//0510085013d9ffb6720d5b132900003770? - "decode" in { - PacketCoding.DecodePacket(string).require match { + "decode (single)" in { + PacketCoding.DecodePacket(string_single).require match { + case TargetingImplantRequest(target_list) => + target_list.length mustEqual 1 + //0 + target_list.head.target_guid mustEqual PlanetSideGUID(1412) + target_list.head.unk mustEqual true + case _ => + ko + } + } + + "decode (long)" in { + PacketCoding.DecodePacket(string_long).require match { case TargetingImplantRequest(target_list) => target_list.length mustEqual 16 //0 @@ -66,7 +79,17 @@ class TargetingImplantRequestTest extends Specification { } } - "encode" in { + "encode (single)" in { + val msg = TargetingImplantRequest( + TargetRequest(PlanetSideGUID(1412), true) :: + Nil + ) + val pkt = PacketCoding.EncodePacket(msg).require.toByteVector + + pkt mustEqual string_single + } + + "encode (long)" in { val msg = TargetingImplantRequest( TargetRequest(PlanetSideGUID(31355), true) :: TargetRequest(PlanetSideGUID(27273), false) :: @@ -88,6 +111,6 @@ class TargetingImplantRequestTest extends Specification { ) val pkt = PacketCoding.EncodePacket(msg).require.toByteVector - pkt mustEqual string + pkt mustEqual string_long } } diff --git a/pslogin/src/main/scala/WorldSessionActor.scala b/pslogin/src/main/scala/WorldSessionActor.scala index 091a5035..503433c6 100644 --- a/pslogin/src/main/scala/WorldSessionActor.scala +++ b/pslogin/src/main/scala/WorldSessionActor.scala @@ -425,6 +425,9 @@ class WorldSessionActor extends Actor with MDCContextAware { case msg @ WeaponDryFireMessage(weapon) => log.info("WeaponDryFireMessage: "+msg) + case msg @ TargetingImplantRequest(list) => + log.info("TargetingImplantRequest: "+msg) + case default => log.error(s"Unhandled GamePacket ${pkt}") }