diff --git a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala index b7f84e264..6a3b2b51c 100644 --- a/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala +++ b/common/src/main/scala/net/psforever/packet/GamePacketOpcode.scala @@ -465,7 +465,7 @@ object GamePacketOpcode extends Enumeration { case 0x79 => noDecoder(TradeMessage) case 0x7a => noDecoder(UnknownMessage122) case 0x7b => noDecoder(DamageFeedbackMessage) - case 0x7c => noDecoder(DismountBuildingMsg) + case 0x7c => game.DismountBuildingMsg.decode case 0x7d => noDecoder(UnknownMessage125) case 0x7e => noDecoder(UnknownMessage126) case 0x7f => noDecoder(AvatarStatisticsMessage) diff --git a/common/src/main/scala/net/psforever/packet/game/DismountBuildingMsg.scala b/common/src/main/scala/net/psforever/packet/game/DismountBuildingMsg.scala new file mode 100644 index 000000000..e8f224cc6 --- /dev/null +++ b/common/src/main/scala/net/psforever/packet/game/DismountBuildingMsg.scala @@ -0,0 +1,28 @@ +// 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._ + +/** + * Alert that the player is "dismounting" a building.
+ *
+ * Paragraph in which "'dismounting' a building" is explained. + * @param player_guid the player + * @param building_guid the building + */ +final case class DismountBuildingMsg(player_guid : PlanetSideGUID, + building_guid : PlanetSideGUID) + extends PlanetSideGamePacket { + type Packet = DismountBuildingMsg + def opcode = GamePacketOpcode.DismountBuildingMsg + def encode = DismountBuildingMsg.encode(this) +} + +object DismountBuildingMsg extends Marshallable[DismountBuildingMsg] { + implicit val codec : Codec[DismountBuildingMsg] = ( + ("player_guid" | PlanetSideGUID.codec) :: + ("building_guid" | PlanetSideGUID.codec) + ).as[DismountBuildingMsg] +} diff --git a/common/src/test/scala/GamePacketTest.scala b/common/src/test/scala/GamePacketTest.scala index 2f45b923f..01c663f02 100644 --- a/common/src/test/scala/GamePacketTest.scala +++ b/common/src/test/scala/GamePacketTest.scala @@ -1 +1,2 @@ // Copyright (c) 2016 PSForever.net to present + diff --git a/common/src/test/scala/game/DismountBuildingMsgTest.scala b/common/src/test/scala/game/DismountBuildingMsgTest.scala new file mode 100644 index 000000000..0fac4d850 --- /dev/null +++ b/common/src/test/scala/game/DismountBuildingMsgTest.scala @@ -0,0 +1,28 @@ +// Copyright (c) 2016 PSForever.net to present +package game + +import org.specs2.mutable._ +import net.psforever.packet._ +import net.psforever.packet.game._ +import scodec.bits._ + +class DismountBuildingMsgTest extends Specification { + val string = hex"7C 4B00 2E00" + + "decode" in { + PacketCoding.DecodePacket(string).require match { + case DismountBuildingMsg(player_guid, building_guid) => + player_guid mustEqual PlanetSideGUID(75) + building_guid mustEqual PlanetSideGUID(46) + case _ => + ko + } + } + + "encode" in { + val msg = DismountBuildingMsg(PlanetSideGUID(75), PlanetSideGUID(46)) + val pkt = PacketCoding.EncodePacket(msg).require.toByteVector + + pkt mustEqual string + } +}