From 231c8974f5a7af6de0c47b32a55c8d5525633663 Mon Sep 17 00:00:00 2001 From: FateJH Date: Mon, 17 Oct 2016 08:15:54 -0400 Subject: [PATCH] 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 5a1d2b16..20ba5b38 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 2f7e8a11..168f5bf2 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"