From 37778229dc05f9cac131e6a4628cbe76c4aa4ca7 Mon Sep 17 00:00:00 2001 From: FateJH Date: Thu, 22 Sep 2016 21:34:00 -0400 Subject: [PATCH 1/4] added TrainingZoneMessage packet; rudimentary comments, but no tests --- .../psforever/packet/GamePacketOpcode.scala | 2 +- .../packet/game/TrainingZoneMessage.scala | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala diff --git a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala index 6e9984e5d..911bc1103 100644 --- a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala +++ b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala @@ -457,7 +457,7 @@ object GamePacketOpcode extends Enumeration { case 0x72 => noDecoder(FriendsRequest) case 0x73 => noDecoder(FriendsResponse) case 0x74 => noDecoder(TriggerEnvironmentalDamageMessage) - case 0x75 => noDecoder(TrainingZoneMessage) + case 0x75 => game.TrainingZoneMessage.decode case 0x76 => noDecoder(DeployableObjectsInfoMessage) case 0x77 => noDecoder(SquadState) // 0x78 diff --git a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala new file mode 100644 index 000000000..5a1d2b168 --- /dev/null +++ b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala @@ -0,0 +1,38 @@ +// Copyright (c) 2016 PSForever.net to present +package net.psforever.packet.game + +import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket} +import scodec.Codec +import scodec.codecs._ + +/** + * The client is telling the server that the player wants to go to the training zones.
+ *
+ * This message is dispatched when a player enters the VR hallway / VR teleport and accepts the "Shooting Range" or the "Vehicle Training Area" options on the prompt. + * The packet sends indication to the server (as if it didn't know?) in regards to which training grounds the player should be sent. + * Players are sent to their respective empire's area by default.
+ * @param unk1 na; + * 19 (`13`) when shooting range; + * 22 (`16`) when ground vehicle range + * @param unk2 na; always zero? + * @param unk3 na; always zero? + * @param unk4 na; always zero? + */ +final case class TrainingZoneMessage(unk1 : Int, + unk2 : Int, + unk3 : Int, + unk4 : Int) + extends PlanetSideGamePacket { + type Packet = TrainingZoneMessage + def opcode = GamePacketOpcode.TrainingZoneMessage + def encode = TrainingZoneMessage.encode(this) +} + +object TrainingZoneMessage extends Marshallable[TrainingZoneMessage] { + implicit val codec : Codec[TrainingZoneMessage] = ( + ("unk1" | uint8L) :: + ("unk2" | uint8L) :: + ("unk3" | uint8L) :: + ("unk4" | uint8L) + ).as[TrainingZoneMessage] +} From 231c8974f5a7af6de0c47b32a55c8d5525633663 Mon Sep 17 00:00:00 2001 From: FateJH Date: Mon, 17 Oct 2016 08:15:54 -0400 Subject: [PATCH 2/4] add comments about zone modifiers to main file and tests to test file --- .../packet/game/TrainingZoneMessage.scala | 41 ++++++++++++------- common/src/test/scala/GamePacketTest.scala | 23 +++++++++++ 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala index 5a1d2b168..20ba5b380 100644 --- a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala @@ -6,22 +6,35 @@ import scodec.Codec import scodec.codecs._ /** - * The client is telling the server that the player wants to go to the training zones.
+ * Dispatched when the player wants to go to the training zones. + * When a player enters the virtual reality hallways behind sanctuary spawn rooms and walks to the base of the ramp, he is presented with a prompt. + * From the prompt, the player accepts either "Shooting Range" or "Vehicle Training Area."
*
- * This message is dispatched when a player enters the VR hallway / VR teleport and accepts the "Shooting Range" or the "Vehicle Training Area" options on the prompt. - * The packet sends indication to the server (as if it didn't know?) in regards to which training grounds the player should be sent. - * Players are sent to their respective empire's area by default.
- * @param unk1 na; - * 19 (`13`) when shooting range; - * 22 (`16`) when ground vehicle range + * Both sets of training zones utilize the same map for their type - `map14` for shooting and `map15` for vehicles. + * The factions are kept separate so there are actually six separated zones - two each - to accommodate the three factions. + * There is no global map notation, i.e., `map##`, for going to a faction-instance training zone map. + * The zone modifier is used in conjunction with the `LoadMapMessage` packet to determine the faction-instance of the training map.
+ *
+ * Players are sent to their respective empire's area by default. + * A TR player utilizing the virtual reality hallway in the NC sanctuary and will still only be offered the TR virtual reality areas. + * Black OPs do not have normal access to virtual reality areas.
+ *
+ * Zone:
+ * 17 - `11` - TR Shooting Range
+ * 18 - `12` - NC Shooting Range
+ * 19 - `13` - VS Shooting Range
+ * 20 - `14` - TR Vehicle Training Area
+ * 21 - `15` - NC Vehicle Training Area
+ * 22 - `16` - VS Vehicle Training Area + * @param zone the virtual reality zone to send the player + * @param unk1 na; always zero? * @param unk2 na; always zero? * @param unk3 na; always zero? - * @param unk4 na; always zero? */ -final case class TrainingZoneMessage(unk1 : Int, +final case class TrainingZoneMessage(zone : Int, + unk1 : Int, unk2 : Int, - unk3 : Int, - unk4 : Int) + unk3 : Int) extends PlanetSideGamePacket { type Packet = TrainingZoneMessage def opcode = GamePacketOpcode.TrainingZoneMessage @@ -30,9 +43,9 @@ final case class TrainingZoneMessage(unk1 : Int, object TrainingZoneMessage extends Marshallable[TrainingZoneMessage] { implicit val codec : Codec[TrainingZoneMessage] = ( - ("unk1" | uint8L) :: + ("zone" | uint8L) :: + ("unk1" | uint8L) :: ("unk2" | uint8L) :: - ("unk3" | uint8L) :: - ("unk4" | uint8L) + ("unk3" | uint8L) ).as[TrainingZoneMessage] } diff --git a/common/src/test/scala/GamePacketTest.scala b/common/src/test/scala/GamePacketTest.scala index 2f7e8a11d..168f5bf23 100644 --- a/common/src/test/scala/GamePacketTest.scala +++ b/common/src/test/scala/GamePacketTest.scala @@ -830,6 +830,29 @@ class GamePacketTest extends Specification { } } + "TrainingZoneMessage" should { + val string = hex"75 13 000000" + + "decode" in { + PacketCoding.DecodePacket(string).require match { + case TrainingZoneMessage(zone, unk1, unk2, unk3) => + zone mustEqual 19 + unk1 mustEqual 0 + unk2 mustEqual 0 + unk3 mustEqual 0 + case default => + ko + } + } + + "encode" in { + val msg = TrainingZoneMessage(19, 0, 0, 0) + val pkt = PacketCoding.EncodePacket(msg).require.toByteVector + + pkt mustEqual string + } + } + "WeaponDryFireMessage" should { val string = hex"52 4C00" From de590cd4e205ce1e71f4d9989ecdf4f4623df23d Mon Sep 17 00:00:00 2001 From: FateJH Date: Mon, 17 Oct 2016 08:49:20 -0400 Subject: [PATCH 3/4] fixing a mistaken parameter --- .../psforever/packet/game/TrainingZoneMessage.scala | 13 ++----------- common/src/test/scala/GamePacketTest.scala | 7 ++----- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala index 20ba5b380..21885a175 100644 --- a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala @@ -27,14 +27,8 @@ import scodec.codecs._ * 21 - `15` - NC Vehicle Training Area
* 22 - `16` - VS Vehicle Training Area * @param zone the virtual reality zone to send the player - * @param unk1 na; always zero? - * @param unk2 na; always zero? - * @param unk3 na; always zero? */ -final case class TrainingZoneMessage(zone : Int, - unk1 : Int, - unk2 : Int, - unk3 : Int) +final case class TrainingZoneMessage(zone : Long) extends PlanetSideGamePacket { type Packet = TrainingZoneMessage def opcode = GamePacketOpcode.TrainingZoneMessage @@ -43,9 +37,6 @@ final case class TrainingZoneMessage(zone : Int, object TrainingZoneMessage extends Marshallable[TrainingZoneMessage] { implicit val codec : Codec[TrainingZoneMessage] = ( - ("zone" | uint8L) :: - ("unk1" | uint8L) :: - ("unk2" | uint8L) :: - ("unk3" | uint8L) + "zone" | uint32L ).as[TrainingZoneMessage] } diff --git a/common/src/test/scala/GamePacketTest.scala b/common/src/test/scala/GamePacketTest.scala index 168f5bf23..3aab6ca3d 100644 --- a/common/src/test/scala/GamePacketTest.scala +++ b/common/src/test/scala/GamePacketTest.scala @@ -835,18 +835,15 @@ class GamePacketTest extends Specification { "decode" in { PacketCoding.DecodePacket(string).require match { - case TrainingZoneMessage(zone, unk1, unk2, unk3) => + case TrainingZoneMessage(zone) => zone mustEqual 19 - unk1 mustEqual 0 - unk2 mustEqual 0 - unk3 mustEqual 0 case default => ko } } "encode" in { - val msg = TrainingZoneMessage(19, 0, 0, 0) + val msg = TrainingZoneMessage(19) val pkt = PacketCoding.EncodePacket(msg).require.toByteVector pkt mustEqual string From 13e0f55f39d1f26e9ef758585b6a3602c46c0001 Mon Sep 17 00:00:00 2001 From: FateJH Date: Wed, 11 Jan 2017 22:27:08 -0500 Subject: [PATCH 4/4] adding a field to TrainingZone for divided byte-length --- .../net/psforever/packet/game/TrainingZoneMessage.scala | 7 +++++-- common/src/test/scala/GamePacketTest.scala | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala index 21885a175..59367263b 100644 --- a/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/TrainingZoneMessage.scala @@ -27,8 +27,10 @@ import scodec.codecs._ * 21 - `15` - NC Vehicle Training Area
* 22 - `16` - VS Vehicle Training Area * @param zone the virtual reality zone to send the player + * @param unk na; always 0? */ -final case class TrainingZoneMessage(zone : Long) +final case class TrainingZoneMessage(zone : PlanetSideGUID, + unk : Int = 0) extends PlanetSideGamePacket { type Packet = TrainingZoneMessage def opcode = GamePacketOpcode.TrainingZoneMessage @@ -37,6 +39,7 @@ final case class TrainingZoneMessage(zone : Long) object TrainingZoneMessage extends Marshallable[TrainingZoneMessage] { implicit val codec : Codec[TrainingZoneMessage] = ( - "zone" | uint32L + ("zone" | PlanetSideGUID.codec) :: + ("unk" | uint16L) ).as[TrainingZoneMessage] } diff --git a/common/src/test/scala/GamePacketTest.scala b/common/src/test/scala/GamePacketTest.scala index 3aab6ca3d..04787b752 100644 --- a/common/src/test/scala/GamePacketTest.scala +++ b/common/src/test/scala/GamePacketTest.scala @@ -835,15 +835,15 @@ class GamePacketTest extends Specification { "decode" in { PacketCoding.DecodePacket(string).require match { - case TrainingZoneMessage(zone) => - zone mustEqual 19 + case TrainingZoneMessage(zone, unk) => + zone mustEqual PlanetSideGUID(19) case default => ko } } "encode" in { - val msg = TrainingZoneMessage(19) + val msg = TrainingZoneMessage(PlanetSideGUID(19)) val pkt = PacketCoding.EncodePacket(msg).require.toByteVector pkt mustEqual string