From 0629fa5eb786ba0a992b3a17f39ea6590b72bfe7 Mon Sep 17 00:00:00 2001 From: FateJH Date: Thu, 20 Apr 2017 23:27:14 -0400 Subject: [PATCH] initial work on TargetingImplantRequest packet --- .../psforever/packet/GamePacketOpcode.scala | 2 +- .../packet/game/TargetingImplantRequest.scala | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala diff --git a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala index 055c2235..28ae7a6c 100644 --- a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala +++ b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala @@ -533,7 +533,7 @@ object GamePacketOpcode extends Enumeration { case 0xb2 => game.VoiceHostInfo.decode case 0xb3 => noDecoder(BattleplanMessage) case 0xb4 => game.BattleExperienceMessage.decode - case 0xb5 => noDecoder(TargetingImplantRequest) + case 0xb5 => game.TargetingImplantRequest.decode case 0xb6 => game.ZonePopulationUpdateMessage.decode case 0xb7 => game.DisconnectMessage.decode // 0xb8 diff --git a/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala b/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala new file mode 100644 index 00000000..c93f9928 --- /dev/null +++ b/common/src/main/scala/net/psforever/packet/game/TargetingImplantRequest.scala @@ -0,0 +1,35 @@ +// Copyright (c) 2017 PSForever +package net.psforever.packet.game + +import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket} +import scodec.Codec +import scodec.codecs._ +import shapeless.{::, HNil} + +final case class TargetRequest(target_guid : PlanetSideGUID, + unk : Boolean) + +final case class TargetingImplantRequest(target_list : List[TargetRequest]) + extends PlanetSideGamePacket { + type Packet = TargetingImplantRequest + def opcode = GamePacketOpcode.TargetingImplantRequest + def encode = TargetingImplantRequest.encode(this) +} + +object TargetingImplantRequest extends Marshallable[TargetingImplantRequest] { + private val request_codec : Codec[TargetRequest] = ( + ("target_guid" | PlanetSideGUID.codec) :: + ("unk" | bool) + ).xmap[TargetRequest] ( + { + case a :: b :: HNil => + TargetRequest(a, b) + }, + { + case TargetRequest(a, b) => + a :: b :: HNil + } + ) + + implicit val codec : Codec[TargetingImplantRequest] = ("target_list" | listOfN(intL(6), request_codec)).as[TargetingImplantRequest] +}