diff --git a/src/main/scala/net/psforever/packet/game/OutfitEvent.scala b/src/main/scala/net/psforever/packet/game/OutfitEvent.scala index 8b2780745..be267fce7 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitEvent.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitEvent.scala @@ -9,8 +9,7 @@ import scodec.codecs._ import shapeless.{::, HNil} final case class OutfitEvent( - request_type: OutfitEvent.RequestType.Type, - outfit_guid: Long, + outfit_id: Long, action: OutfitEventAction ) extends PlanetSideGamePacket { type Packet = OutfitEvent @@ -84,13 +83,13 @@ object OutfitEventAction { private val OutfitRankNamesCodec: Codec[OutfitRankNames] = ( PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString :: - PacketHelpers.encodedWideString + PacketHelpers.encodedWideString :: + PacketHelpers.encodedWideString :: + PacketHelpers.encodedWideString :: + PacketHelpers.encodedWideString :: + PacketHelpers.encodedWideString :: + PacketHelpers.encodedWideString :: + PacketHelpers.encodedWideString ).xmap[OutfitRankNames]( { case u0 :: u1 :: u2 :: u3 :: u4 :: u5 :: u6 :: u7 :: HNil => @@ -103,20 +102,20 @@ object OutfitEventAction { ) private val InfoCodec: Codec[OutfitInfo] = ( - ("outfit_name" | PacketHelpers.encodedWideStringAligned(5)) :: - ("outfit_points1" | uint32L) :: - ("outfit_points2" | uint32L) :: - ("member_count" | uint32L) :: - ("outfit_rank_names" | OutfitRankNamesCodec) :: - ("motd" | PacketHelpers.encodedWideString) :: - ("" | uint8L) :: - ("" | bool) :: - ("" | uint32L) :: - ("created_timestamp" | uint32L) :: - ("" | uint32L) :: - ("" | uint32L) :: - ("" | uint32L) - ).xmap[OutfitInfo]( + ("outfit_name" | PacketHelpers.encodedWideStringAligned(5)) :: + ("outfit_points1" | uint32L) :: + ("outfit_points2" | uint32L) :: + ("member_count" | uint32L) :: + ("outfit_rank_names" | OutfitRankNamesCodec) :: + ("motd" | PacketHelpers.encodedWideString) :: + ("" | uint8L) :: + ("" | bool) :: + ("" | uint32L) :: + ("created_timestamp" | uint32L) :: + ("" | uint32L) :: + ("" | uint32L) :: + ("" | uint32L) + ).xmap[OutfitInfo]( { case outfit_name :: outfit_points1 :: outfit_points2 :: member_count :: outfit_rank_names :: motd :: u10 :: u11 :: u12 :: created_timestamp :: u23 :: u24 :: u25 :: HNil => OutfitInfo(outfit_name, outfit_points1, outfit_points2, member_count, outfit_rank_names, motd, u10, u11, u12, created_timestamp, u23, u24, u25) @@ -213,17 +212,17 @@ object OutfitEventAction { object OutfitEvent extends Marshallable[OutfitEvent] { - object RequestType extends Enumeration { + object PacketType extends Enumeration { type Type = Value - val Unk0: RequestType.Value = Value(0) // start listing of members - val Unk1: RequestType.Value = Value(1) // end listing of members - val Unk2: RequestType.Value = Value(2) // send after creating an outfit // normal info, same as Unk0 - val Unk3: RequestType.Value = Value(3) // below - val UpdateOutfitId: RequestType.Value = Value(4) - val Unk5: RequestType.Value = Value(5) - val Unk6: RequestType.Value = Value(6) - val Unk7: RequestType.Value = Value(7) + val Unk0: PacketType.Value = Value(0) // start listing of members + val Unk1: PacketType.Value = Value(1) // end listing of members + val Unk2: PacketType.Value = Value(2) // send after creating an outfit // normal info, same as Unk0 + val Unk3: PacketType.Value = Value(3) // below + val UpdateOutfitId: PacketType.Value = Value(4) + val Unk5: PacketType.Value = Value(5) + val Unk6: PacketType.Value = Value(6) + val Unk7: PacketType.Value = Value(7) implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(3)) } @@ -247,18 +246,18 @@ object OutfitEvent extends Marshallable[OutfitEvent] { } implicit val codec: Codec[OutfitEvent] = ( - ("request_type" | RequestType.codec) >>:~ { request_type => + ("packet_type" | PacketType.codec) >>:~ { packet_type => ("outfit_guid" | uint32L) :: - ("action" | selectFromType(request_type.id)) + ("action" | selectFromType(packet_type.id)) } - ).xmap[OutfitEvent]( + ).xmap[OutfitEvent]( { - case request_type :: outfit_guid :: action :: HNil => - OutfitEvent(request_type, outfit_guid, action) + case _ :: outfit_guid :: action :: HNil => + OutfitEvent(outfit_guid, action) }, { - case OutfitEvent(request_type, outfit_guid, action) => - request_type :: outfit_guid :: action :: HNil + case OutfitEvent(outfit_guid, action) => + OutfitEvent.PacketType(action.code) :: outfit_guid :: action :: HNil } ) } diff --git a/src/main/scala/net/psforever/packet/game/OutfitListEvent.scala b/src/main/scala/net/psforever/packet/game/OutfitListEvent.scala index 42d7cc29e..acd9ed99c 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitListEvent.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitListEvent.scala @@ -9,7 +9,6 @@ import scodec.codecs._ import shapeless.{::, HNil} final case class OutfitListEvent( - request_type: OutfitListEvent.RequestType.Type, action: OutfitListEventAction ) extends PlanetSideGamePacket { type Packet = OutfitListEvent @@ -50,11 +49,11 @@ object OutfitListEventAction { val ListElementOutfitCodec: Codec[ListElementOutfit] = ( ("unk1" | uint32L) :: - ("points" | uint32L) :: - ("members" | uint32L) :: - ("outfit_name" | PacketHelpers.encodedWideStringAligned(5)) :: - ("outfit_leader" | PacketHelpers.encodedWideString) - ).xmap[ListElementOutfit]( + ("points" | uint32L) :: + ("members" | uint32L) :: + ("outfit_name" | PacketHelpers.encodedWideStringAligned(5)) :: + ("outfit_leader" | PacketHelpers.encodedWideString) + ).xmap[ListElementOutfit]( { case u1 :: points :: members :: outfit_name :: outfit_leader :: HNil => ListElementOutfit(u1, points, members, outfit_name, outfit_leader) @@ -67,7 +66,7 @@ object OutfitListEventAction { val Unk3Codec: Codec[Unk3] = ( ("unk1" | uint32L) - ).xmap[Unk3]( + ).xmap[Unk3]( { case u1 => Unk3(u1) @@ -109,17 +108,17 @@ object OutfitListEventAction { object OutfitListEvent extends Marshallable[OutfitListEvent] { import shapeless.{::, HNil} - object RequestType extends Enumeration { + object PacketType extends Enumeration { type Type = Value - val Unk0: RequestType.Value = Value(0) - val Unk1: RequestType.Value = Value(1) - val ListElementOutfit: RequestType.Value = Value(2) - val Unk3: RequestType.Value = Value(3) - val Unk4: RequestType.Value = Value(4) - val Unk5: RequestType.Value = Value(5) - val unk6: RequestType.Value = Value(6) - val unk7: RequestType.Value = Value(7) + val Unk0: PacketType.Value = Value(0) + val Unk1: PacketType.Value = Value(1) + val ListElementOutfit: PacketType.Value = Value(2) + val Unk3: PacketType.Value = Value(3) + val Unk4: PacketType.Value = Value(4) + val Unk5: PacketType.Value = Value(5) + val unk6: PacketType.Value = Value(6) + val unk7: PacketType.Value = Value(7) implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(3)) } @@ -132,7 +131,7 @@ object OutfitListEvent extends Marshallable[OutfitListEvent] { case 0 => unknownCodec(action = code) case 1 => unknownCodec(action = code) case 2 => ListElementOutfitCodec - case 3 => Unk3Codec // indicated in code + case 3 => Unk3Codec case 4 => unknownCodec(action = code) case 5 => unknownCodec(action = code) case 6 => unknownCodec(action = code) @@ -143,17 +142,17 @@ object OutfitListEvent extends Marshallable[OutfitListEvent] { } implicit val codec: Codec[OutfitListEvent] = ( - ("request_type" | RequestType.codec) >>:~ { request_type => - ("action" | selectFromType(request_type.id)).hlist + ("packet_type" | PacketType.codec) >>:~ { packet_type => + ("action" | selectFromType(packet_type.id)).hlist } - ).xmap[OutfitListEvent]( + ).xmap[OutfitListEvent]( { - case request_type :: action :: HNil => - OutfitListEvent(request_type, action) + case _ :: action :: HNil => + OutfitListEvent(action) }, { - case OutfitListEvent(request_type, action) => - request_type :: action :: HNil + case OutfitListEvent(action) => + OutfitListEvent.PacketType(action.code) :: action :: HNil } ) } diff --git a/src/main/scala/net/psforever/packet/game/OutfitMemberEvent.scala b/src/main/scala/net/psforever/packet/game/OutfitMemberEvent.scala index f40498a41..0ae680853 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitMemberEvent.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitMemberEvent.scala @@ -9,7 +9,6 @@ import scodec.codecs._ import shapeless.{::, HNil} final case class OutfitMemberEvent( - packet_type: OutfitMemberEvent.PacketType.Type, outfit_id: Long, member_id: Long, action: OutfitMemberEventAction @@ -36,13 +35,13 @@ object OutfitMemberEventAction { /* action is unimplemented! if action == 0 unk2 will contain one additional uint32L - unk0_padding contains one byte of padding. may contain 4byte of unknown data depending on action + padding contains one uint4L of padding. may contain uint32L of unknown data depending on action */ final case class Unk0( member_name: String, rank: Int, points: Long, // client divides this by 100 - last_login: Long, // seconds ago from current time, 0 if online + last_online: Long, // seconds ago from current time, 0 if online action: PacketType.Type, // should always be 1, otherwise there will be actual data in padding. not implemented! padding: Int // should always be 0, 4 bits of padding // only contains data if action is 0 ) extends OutfitMemberEventAction(code = 0) @@ -60,13 +59,13 @@ object OutfitMemberEventAction { private val everFailCondition = conditional(included = false, bool) val Unk0Codec: Codec[Unk0] = ( - ("member_name" | PacketHelpers.encodedWideStringAligned(6)) :: // from here is packet_type == 0 only - ("rank" | uint(3)) :: - ("points" | uint32L) :: - ("last_login" | uint32L) :: - ("action" | OutfitMemberEventAction.PacketType.codec) :: - ("padding" | uint4L) - ).xmap[Unk0]( + ("member_name" | PacketHelpers.encodedWideStringAligned(6)) :: // from here is packet_type == 0 only + ("rank" | uint(3)) :: + ("points" | uint32L) :: + ("last_login" | uint32L) :: + ("action" | OutfitMemberEventAction.PacketType.codec) :: + ("padding" | uint4L) + ).xmap[Unk0]( { case member_name :: rank :: points :: last_login :: action :: padding :: HNil => Unk0(member_name, rank, points, last_login, action, padding) @@ -112,6 +111,8 @@ object OutfitMemberEvent extends Marshallable[OutfitMemberEvent] { val Unk0: PacketType.Value = Value(0) val Unk1: PacketType.Value = Value(1) // Info: Player has been invited / response to OutfitMembershipRequest Unk2 for that player + val Unk2: PacketType.Value = Value(2) + val Unk3: PacketType.Value = Value(3) implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(2)) } @@ -123,6 +124,8 @@ object OutfitMemberEvent extends Marshallable[OutfitMemberEvent] { ((code: @switch) match { case 0 => Unk0Codec case 1 => Unk1Codec + case 2 => unknownCodec(code) + case 3 => unknownCodec(code) case _ => failureCodec(code) }).asInstanceOf[Codec[OutfitMemberEventAction]] @@ -134,14 +137,14 @@ object OutfitMemberEvent extends Marshallable[OutfitMemberEvent] { ("member_id" | uint32L) :: ("action" | selectFromType(packet_type.id)).hlist } - ).xmap[OutfitMemberEvent]( + ).xmap[OutfitMemberEvent]( { - case packet_type :: outfit_id :: member_id:: action :: HNil => - OutfitMemberEvent(packet_type, outfit_id, member_id, action) + case _ :: outfit_id :: member_id:: action :: HNil => + OutfitMemberEvent(outfit_id, member_id, action) }, { - case OutfitMemberEvent(packet_type, outfit_id, member_id, action) => - packet_type :: outfit_id :: member_id :: action :: HNil + case OutfitMemberEvent(outfit_id, member_id, action) => + OutfitMemberEvent.PacketType(action.code) :: outfit_id :: member_id :: action :: HNil } ) } diff --git a/src/main/scala/net/psforever/packet/game/OutfitMemberUpdate.scala b/src/main/scala/net/psforever/packet/game/OutfitMemberUpdate.scala index 88cae6328..979d26f9f 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitMemberUpdate.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitMemberUpdate.scala @@ -7,10 +7,10 @@ import scodec.codecs._ import shapeless.{::, HNil} final case class OutfitMemberUpdate( - outfit_guid: Long, - char_id: Long, - rank: Int, // 0-7 - unk1: Int, + outfit_id: Long, + char_id: Long, + rank: Int, // 0-7 + flag: Boolean, ) extends PlanetSideGamePacket { type Packet = OutfitMemberUpdate def opcode = GamePacketOpcode.OutfitMemberUpdate @@ -19,18 +19,18 @@ final case class OutfitMemberUpdate( object OutfitMemberUpdate extends Marshallable[OutfitMemberUpdate] { implicit val codec: Codec[OutfitMemberUpdate] = ( - ("outfit_guid" | uint32L) :: - ("char_id" | uint32L) :: - ("rank" | uint(3)) :: - ("unk1" | uint(5)) - ).xmap[OutfitMemberUpdate]( + ("outfit_id" | uint32L) :: + ("char_id" | uint32L) :: + ("rank" | uint(3)) :: + ("flag" | bool) + ).xmap[OutfitMemberUpdate]( { - case outfit_guid :: char_id :: rank :: u1 :: HNil => - OutfitMemberUpdate(outfit_guid, char_id, rank, u1) + case outfit_id :: char_id :: rank :: flag :: HNil => + OutfitMemberUpdate(outfit_id, char_id, rank, flag) }, { - case OutfitMemberUpdate(outfit_guid, char_id, rank, u1) => - outfit_guid :: char_id :: rank :: u1 :: HNil + case OutfitMemberUpdate(outfit_id, char_id, rank, flag) => + outfit_id :: char_id :: rank :: flag :: HNil } ) } diff --git a/src/main/scala/net/psforever/packet/game/OutfitMembershipRequest.scala b/src/main/scala/net/psforever/packet/game/OutfitMembershipRequest.scala index 5e0c8b9b7..41cb6b176 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitMembershipRequest.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitMembershipRequest.scala @@ -9,7 +9,6 @@ import scodec.codecs._ import shapeless.{::, HNil} final case class OutfitMembershipRequest( - request_type: OutfitMembershipRequest.RequestType.Type, outfit_id: Long, action: OutfitMembershipRequestAction ) extends PlanetSideGamePacket { @@ -61,8 +60,8 @@ object OutfitMembershipRequestAction { ) extends OutfitMembershipRequestAction(code = 6) final case class SetRank( - avatar_id: Long, // 32 - rank: Int, // 3 + avatar_id: Long, + rank: Int, member_name: String, ) extends OutfitMembershipRequestAction(code = 7) @@ -75,120 +74,116 @@ object OutfitMembershipRequestAction { object Codecs { private val everFailCondition = conditional(included = false, bool) - val CreateCodec: Codec[Create] = - ( - PacketHelpers.encodedWideStringAligned(5) :: - PacketHelpers.encodedWideString - ).xmap[Create]( - { - case u1 :: outfit_name :: HNil => - Create(u1, outfit_name) - }, - { - case Create(u1, outfit_name) => - u1 :: outfit_name :: HNil - } - ) + val CreateCodec: Codec[Create] = ( + PacketHelpers.encodedWideStringAligned(5) :: + PacketHelpers.encodedWideString + ).xmap[Create]( + { + case u1 :: outfit_name :: HNil => + Create(u1, outfit_name) + }, + { + case Create(u1, outfit_name) => + u1 :: outfit_name :: HNil + } + ) - val FormCodec: Codec[Form] = - ( - PacketHelpers.encodedWideStringAligned(5) :: - PacketHelpers.encodedWideString - ).xmap[Form]( - { - case u1 :: outfit_name :: HNil => - Form(u1, outfit_name) - }, - { - case Form(u1, outfit_name) => - u1 :: outfit_name :: HNil - } - ) + val FormCodec: Codec[Form] = ( + PacketHelpers.encodedWideStringAligned(5) :: + PacketHelpers.encodedWideString + ).xmap[Form]( + { + case u1 :: outfit_name :: HNil => + Form(u1, outfit_name) + }, + { + case Form(u1, outfit_name) => + u1 :: outfit_name :: HNil + } + ) - val InviteCodec: Codec[Invite] = - ( - uint32L :: - PacketHelpers.encodedWideStringAligned(5) - ).xmap[Invite]( - { - case u1 :: member_name :: HNil => - Invite(u1, member_name) - }, - { - case Invite(u1, member_name) => - u1 :: member_name :: HNil - } - ) + val InviteCodec: Codec[Invite] = ( + uint32L :: + PacketHelpers.encodedWideStringAligned(5) + ).xmap[Invite]( + { + case avatar_id :: member_name :: HNil => + Invite(avatar_id, member_name) + }, + { + case Invite(avatar_id, member_name) => + avatar_id :: member_name :: HNil + } + ) - val AcceptInviteCodec: Codec[AcceptInvite] = - PacketHelpers.encodedWideString.xmap[AcceptInvite]( - { - case u1 => - AcceptInvite(u1) - }, - { - case AcceptInvite(u1) => - u1 - } - ) + val AcceptInviteCodec: Codec[AcceptInvite] = ( + PacketHelpers.encodedWideString + ).xmap[AcceptInvite]( + { + case member_name => + AcceptInvite(member_name) + }, + { + case AcceptInvite(member_name) => + member_name + } + ) - val RejectInviteCodec: Codec[RejectInvite] = - PacketHelpers.encodedWideString.xmap[RejectInvite]( - { - case u1 => - RejectInvite(u1) - }, - { - case RejectInvite(u1) => - u1 - } - ) + val RejectInviteCodec: Codec[RejectInvite] = ( + PacketHelpers.encodedWideString + ).xmap[RejectInvite]( + { + case member_name => + RejectInvite(member_name) + }, + { + case RejectInvite(member_name) => + member_name + } + ) - val CancelInviteCodec: Codec[CancelInvite] = - ( - uint32L :: - PacketHelpers.encodedWideStringAligned(5) - ).xmap[CancelInvite]( - { - case u1 :: outfit_name :: HNil => - CancelInvite(u1, outfit_name) - }, - { - case CancelInvite(u1, outfit_name) => - u1 :: outfit_name :: HNil - } - ) + val CancelInviteCodec: Codec[CancelInvite] = ( + uint32L :: + PacketHelpers.encodedWideStringAligned(5) + ).xmap[CancelInvite]( + { + case avatar_id :: outfit_name :: HNil => + CancelInvite(avatar_id, outfit_name) + }, + { + case CancelInvite(avatar_id, outfit_name) => + avatar_id :: outfit_name :: HNil + } + ) - val KickCodec: Codec[Kick] = - ( - uint32L :: - PacketHelpers.encodedWideStringAligned(5) - ).xmap[Kick]( - { - case u1 :: member_name :: HNil => - Kick(u1, member_name) - }, - { - case Kick(u1, member_name) => - u1 :: member_name :: HNil - } - ) + val KickCodec: Codec[Kick] = ( + uint32L :: + PacketHelpers.encodedWideStringAligned(5) + ).xmap[Kick]( + { + case avatar_id :: member_name :: HNil => + Kick(avatar_id, member_name) + }, + { + case Kick(avatar_id, member_name) => + avatar_id :: member_name :: HNil + } + ) - val SetRankCodec: Codec[SetRank] = - ( - uint32L :: - uintL(3) :: - PacketHelpers.encodedWideStringAligned(2) - ).xmap[SetRank]( - { - case u1 :: rank :: member_name :: HNil => - SetRank(u1, rank, member_name) - }, - { - case SetRank(u1, rank, member_name) => - u1 :: rank :: member_name :: HNil - } - ) + val SetRankCodec: Codec[SetRank] = ( + uint32L :: + uintL(3) :: + PacketHelpers.encodedWideStringAligned(2) + ).xmap[SetRank]( + { + case avatar_id :: rank :: member_name :: HNil => + SetRank(avatar_id, rank, member_name) + }, + { + case SetRank(avatar_id, rank, member_name) => + avatar_id :: rank :: member_name :: HNil + } + ) /** @@ -221,17 +216,17 @@ object OutfitMembershipRequestAction { object OutfitMembershipRequest extends Marshallable[OutfitMembershipRequest] { - object RequestType extends Enumeration { + object PacketType extends Enumeration { type Type = Value - val Create: RequestType.Value = Value(0) - val Form: RequestType.Value = Value(1) - val Invite: RequestType.Value = Value(2) - val Accept: RequestType.Value = Value(3) - val Reject: RequestType.Value = Value(4) - val Cancel: RequestType.Value = Value(5) - val Kick: RequestType.Value = Value(6) - val SetRank: RequestType.Value = Value(7) + val Create: PacketType.Value = Value(0) + val Form: PacketType.Value = Value(1) + val Invite: PacketType.Value = Value(2) + val Accept: PacketType.Value = Value(3) + val Reject: PacketType.Value = Value(4) + val Cancel: PacketType.Value = Value(5) + val Kick: PacketType.Value = Value(6) + val SetRank: PacketType.Value = Value(7) implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(3)) } @@ -255,18 +250,18 @@ object OutfitMembershipRequest extends Marshallable[OutfitMembershipRequest] { } implicit val codec: Codec[OutfitMembershipRequest] = ( - ("request_type" | RequestType.codec) >>:~ { request_type => + ("packet_type" | PacketType.codec) >>:~ { packet_type => ("outfit_id" | uint32L) :: - ("action" | selectFromType(request_type.id)) + ("action" | selectFromType(packet_type.id)) } ).xmap[OutfitMembershipRequest]( { - case request_type :: outfit_id :: action :: HNil => - OutfitMembershipRequest(request_type, outfit_id, action) + case _ :: outfit_id :: action :: HNil => + OutfitMembershipRequest(outfit_id, action) }, { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type :: outfit_id :: action :: HNil + case OutfitMembershipRequest(outfit_id, action) => + OutfitMembershipRequest.PacketType(action.code) :: outfit_id :: action :: HNil } ) } diff --git a/src/main/scala/net/psforever/packet/game/OutfitMembershipResponse.scala b/src/main/scala/net/psforever/packet/game/OutfitMembershipResponse.scala index da9c27b5e..1608cbf97 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitMembershipResponse.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitMembershipResponse.scala @@ -43,22 +43,22 @@ object OutfitMembershipResponse extends Marshallable[OutfitMembershipResponse] { } implicit val codec: Codec[OutfitMembershipResponse] = ( - ("response_type" | PacketType.codec) :: - ("unk0" | uintL(5)) :: - ("unk1" | uintL(3)) :: - ("outfit_id" | uint32L) :: - ("target_id" | uint32L) :: - ("str1" | PacketHelpers.encodedWideStringAligned(5)) :: - ("str2" | PacketHelpers.encodedWideString) :: - ("flag" | bool) - ).xmap[OutfitMembershipResponse]( + ("packet_type" | PacketType.codec) :: + ("unk0" | uintL(5)) :: + ("unk1" | uintL(3)) :: + ("outfit_id" | uint32L) :: + ("target_id" | uint32L) :: + ("str1" | PacketHelpers.encodedWideStringAligned(5)) :: + ("str2" | PacketHelpers.encodedWideString) :: + ("flag" | bool) + ).xmap[OutfitMembershipResponse]( { - case response_type :: u0 :: u1 :: outfit_id :: target_id :: str1 :: str2 :: flag :: HNil => - OutfitMembershipResponse(response_type, u0, u1, outfit_id, target_id, str1, str2, flag) + case packet_type :: u0 :: u1 :: outfit_id :: target_id :: str1 :: str2 :: flag :: HNil => + OutfitMembershipResponse(packet_type, u0, u1, outfit_id, target_id, str1, str2, flag) }, { - case OutfitMembershipResponse(response_type, u0, u1, outfit_id, target_id, str1, str2, flag) => - response_type :: u0 :: u1 :: outfit_id :: target_id :: str1 :: str2 :: flag :: HNil + case OutfitMembershipResponse(packet_type, u0, u1, outfit_id, target_id, str1, str2, flag) => + packet_type :: u0 :: u1 :: outfit_id :: target_id :: str1 :: str2 :: flag :: HNil } ) } diff --git a/src/main/scala/net/psforever/packet/game/OutfitRequest.scala b/src/main/scala/net/psforever/packet/game/OutfitRequest.scala index c62b1fda2..7d6b4cd0c 100644 --- a/src/main/scala/net/psforever/packet/game/OutfitRequest.scala +++ b/src/main/scala/net/psforever/packet/game/OutfitRequest.scala @@ -37,16 +37,19 @@ object OutfitRequestAction { * @param unk na */ final case class Unk2(unk: Int) extends OutfitRequestAction(code = 2) + /** * na * @param unk na */ final case class Unk3(menuOpen: Boolean) extends OutfitRequestAction(code = 3) + /** * na * @param unk na */ final case class Unk4(menuOpen: Boolean) extends OutfitRequestAction(code = 4) + /** * na * @param unk na @@ -142,14 +145,14 @@ object OutfitRequest extends Marshallable[OutfitRequest] { _ => Attempt.Failure(Err(s"can not encode $action-type info - no such thing")) ) - object RequestType extends Enumeration { + object PacketType extends Enumeration { type Type = Value - val Motd: RequestType.Value = Value(0) - val Rank: RequestType.Value = Value(1) - val Unk2: RequestType.Value = Value(2) - val Detail: RequestType.Value = Value(3) - val List: RequestType.Value = Value(4) // sent by client if menu is either open (true) or closed (false) + val Motd: PacketType.Value = Value(0) + val Rank: PacketType.Value = Value(1) + val Unk2: PacketType.Value = Value(2) + val Detail: PacketType.Value = Value(3) + val List: PacketType.Value = Value(4) // sent by client if menu is either open (true) or closed (false) implicit val codec: Codec[Type] = PacketHelpers.createEnumerationCodec(this, uintL(3)) } @@ -169,18 +172,18 @@ object OutfitRequest extends Marshallable[OutfitRequest] { } implicit val codec: Codec[OutfitRequest] = ( - uint(bits = 3) >>:~ { code => + ("packet_type" | PacketType.codec) >>:~ { packet_type => ("id" | uint32L) :: - ("action" | selectFromType(code)) + ("action" | selectFromType(packet_type.id)).hlist } - ).xmap[OutfitRequest]( + ).xmap[OutfitRequest]( { case _ :: id:: action :: HNil => OutfitRequest(id, action) }, { case OutfitRequest(id, action) => - action.code :: id :: action :: HNil + OutfitRequest.PacketType(action.code) :: id :: action :: HNil } ) } diff --git a/src/test/scala/game/OutfitEventTest.scala b/src/test/scala/game/OutfitEventTest.scala index 2b3e2dd8e..27039f043 100644 --- a/src/test/scala/game/OutfitEventTest.scala +++ b/src/test/scala/game/OutfitEventTest.scala @@ -2,13 +2,13 @@ package game import net.psforever.packet._ -import net.psforever.packet.game.OutfitEvent.RequestType +import net.psforever.packet.game.OutfitEvent import net.psforever.packet.game.OutfitEventAction._ -import net.psforever.packet.game._ import org.specs2.mutable._ import scodec.bits._ class OutfitEventTest extends Specification { + val unk0_ABC: ByteVector = ByteVector.fromValidHex( "8f 1 a8c2 0001" + // packet head "2a 0 42006c00610063006b002000410072006d006f0072006500640020005200650061007000650072007300" + // Black Armored Reapers @@ -51,8 +51,7 @@ class OutfitEventTest extends Specification { "decode Unk0 ABC" in { PacketCoding.decodePacket(unk0_ABC).require match { - case OutfitEvent(request_type, outfit_guid, action) => - request_type mustEqual RequestType.Unk0 + case OutfitEvent(outfit_guid, action) => outfit_guid mustEqual 25044 action mustEqual Unk0( OutfitInfo( @@ -78,7 +77,6 @@ class OutfitEventTest extends Specification { "encode Unk0 ABC" in { val msg = OutfitEvent( - RequestType.Unk0, 25044, Unk0( OutfitInfo( @@ -105,8 +103,7 @@ class OutfitEventTest extends Specification { "decode Unk1 ABC" in { PacketCoding.decodePacket(unk1_ABC).require match { - case OutfitEvent(request_type, outfit_guid, action) => - request_type mustEqual RequestType.Unk1 + case OutfitEvent(outfit_guid, action) => outfit_guid mustEqual 529688L action mustEqual Unk1() case _ => @@ -116,7 +113,6 @@ class OutfitEventTest extends Specification { "encode Unk1 ABC" in { val msg = OutfitEvent( - RequestType.Unk1, 529688L, Unk1() ) @@ -127,8 +123,7 @@ class OutfitEventTest extends Specification { "decode Unk2 ABC" in { PacketCoding.decodePacket(unk2_ABC).require match { - case OutfitEvent(request_type, outfit_guid, action) => - request_type mustEqual RequestType.Unk2 + case OutfitEvent(outfit_guid, action) => outfit_guid mustEqual 2147418113L action mustEqual Unk2(OutfitInfo( outfit_name = "PlanetSide_Forever_Vanu", @@ -152,7 +147,6 @@ class OutfitEventTest extends Specification { "encode Unk2 ABC" in { val msg = OutfitEvent( - RequestType.Unk2, 2147418113L, Unk2( OutfitInfo( @@ -179,8 +173,7 @@ class OutfitEventTest extends Specification { "decode Unk3 ABC" in { PacketCoding.decodePacket(unk3_ABC).require match { - case OutfitEvent(request_type, outfit_guid, action) => - request_type mustEqual RequestType.Unk3 + case OutfitEvent(outfit_guid, action) => outfit_guid mustEqual 2147418113L action mustEqual Unk3() case _ => @@ -190,7 +183,6 @@ class OutfitEventTest extends Specification { "encode Unk3 ABC" in { val msg = OutfitEvent( - RequestType.Unk3, 2147418113L, Unk3() ) @@ -201,8 +193,7 @@ class OutfitEventTest extends Specification { "decode Unk4 ABC" in { PacketCoding.decodePacket(unk4_ABC).require match { - case OutfitEvent(request_type, outfit_guid, action) => - request_type mustEqual RequestType.UpdateOutfitId + case OutfitEvent(outfit_guid, action) => outfit_guid mustEqual 2147418113L action mustEqual UpdateOutfitId( new_outfit_id = 529744L, @@ -214,7 +205,6 @@ class OutfitEventTest extends Specification { "encode Unk4 ABC" in { val msg = OutfitEvent( - RequestType.UpdateOutfitId, 2147418113L, UpdateOutfitId( new_outfit_id = 529744L, @@ -227,8 +217,7 @@ class OutfitEventTest extends Specification { "decode Unk5 ABC" in { PacketCoding.decodePacket(unk5_ABC).require match { - case OutfitEvent(request_type, outfit_guid, action) => - request_type mustEqual RequestType.Unk5 + case OutfitEvent(outfit_guid, action) => outfit_guid mustEqual 2147418113L action mustEqual Unk5( unk1 = 2, @@ -240,7 +229,6 @@ class OutfitEventTest extends Specification { "encode Unk5 ABC" in { val msg = OutfitEvent( - RequestType.Unk5, 2147418113L, Unk5( unk1 = 2, diff --git a/src/test/scala/game/OutfitListEventTest.scala b/src/test/scala/game/OutfitListEventTest.scala index c5713a55f..79b5d0377 100644 --- a/src/test/scala/game/OutfitListEventTest.scala +++ b/src/test/scala/game/OutfitListEventTest.scala @@ -3,12 +3,12 @@ package game import net.psforever.packet._ import net.psforever.packet.game.OutfitListEvent -import net.psforever.packet.game.OutfitListEvent.RequestType import net.psforever.packet.game.OutfitListEventAction.ListElementOutfit import org.specs2.mutable._ import scodec.bits.ByteVector class OutfitListEventTest extends Specification { + val unk2_0_ABC: ByteVector = ByteVector.fromValidHex("98 5 e83a0000 000e1800 0800000 11404e0069006700680074004c006f00720064007300 854e005900430061007400") val unk2_0_DEF: ByteVector = ByteVector.fromValidHex("98 4 ec281001 51a62800 3400000 11a0490052004f004e004600490053005400200043006c0061006e00 8654006f006c006a00") val unk2_1_ABC: ByteVector = ByteVector.fromValidHex("98 4 723c0000 2aa81e00 2200000 11006900470061006d00650073002d004500 906900670061006d006500730043005400460057006800610063006b002d004500") @@ -21,8 +21,7 @@ class OutfitListEventTest extends Specification { "decode unk0_ABC" in { PacketCoding.decodePacket(unk2_0_ABC).require match { - case OutfitListEvent(code, ListElementOutfit(unk1, points, members, outfit_name, outfit_leader)) => - code mustEqual OutfitListEvent.RequestType.ListElementOutfit + case OutfitListEvent(ListElementOutfit(unk1, points, members, outfit_name, outfit_leader)) => unk1 mustEqual 7668 points mustEqual 788224 members mustEqual 4 @@ -34,7 +33,15 @@ class OutfitListEventTest extends Specification { } "encode unk0_ABC" in { - val msg = OutfitListEvent(RequestType.ListElementOutfit, ListElementOutfit(7668, 788224, 4, "NightLords", "NYCat")) + val msg = OutfitListEvent( + ListElementOutfit( + 7668, + 788224, + 4, + "NightLords", + "NYCat" + ) + ) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual unk2_0_ABC diff --git a/src/test/scala/game/OutfitMemberEventTest.scala b/src/test/scala/game/OutfitMemberEventTest.scala index 726d0a787..510e7278a 100644 --- a/src/test/scala/game/OutfitMemberEventTest.scala +++ b/src/test/scala/game/OutfitMemberEventTest.scala @@ -22,8 +22,7 @@ class OutfitMemberEventTest extends Specification { "decode Lazer padding" in { PacketCoding.decodePacket(Lazer).require match { - case OutfitMemberEvent(packet_type, outfit_id, member_id, Unk0(member_name, rank, points, last_login, action, padding)) => - packet_type mustEqual OutfitMemberEvent.PacketType.Unk0 + case OutfitMemberEvent(outfit_id, member_id, Unk0(member_name, rank, points, last_login, action, padding)) => outfit_id mustEqual 6418 member_id mustEqual 705344 member_name mustEqual "Lazer1982" @@ -39,14 +38,13 @@ class OutfitMemberEventTest extends Specification { "encode Lazer padding" in { val msg = OutfitMemberEvent( - packet_type = OutfitMemberEvent.PacketType.Unk0, outfit_id = 6418, member_id = 705344, Unk0( member_name = "Lazer1982", rank = 7, points = 3134113, - last_login = 156506, + last_online = 156506, action = OutfitMemberEventAction.PacketType.Padding, padding = 0 ) @@ -58,8 +56,7 @@ class OutfitMemberEventTest extends Specification { "decode OpolE padding" in { PacketCoding.decodePacket(OpolE).require match { - case OutfitMemberEvent(packet_type, outfit_id, member_id, Unk0(member_name, rank, points, last_login, action, unk0_padding)) => - packet_type mustEqual OutfitMemberEvent.PacketType.Unk0 + case OutfitMemberEvent(outfit_id, member_id, Unk0(member_name, rank, points, last_login, action, unk0_padding)) => outfit_id mustEqual 6418 member_id mustEqual 42644970 member_name mustEqual "OpolE" @@ -75,14 +72,13 @@ class OutfitMemberEventTest extends Specification { "encode OpolE padding" in { val msg = OutfitMemberEvent( - packet_type = OutfitMemberEvent.PacketType.Unk0, outfit_id = 6418, member_id = 42644970, Unk0( member_name = "OpolE", rank = 6, points = 461901, - last_login = 137576, + last_online = 137576, action = OutfitMemberEventAction.PacketType.Padding, padding = 0 ) @@ -95,8 +91,7 @@ class OutfitMemberEventTest extends Specification { "decode Unk1" in { PacketCoding.decodePacket(unk1).require match { - case OutfitMemberEvent(packet_type,outfit_id, member_id, Unk1()) => - packet_type mustEqual OutfitMemberEvent.PacketType.Unk1 + case OutfitMemberEvent(outfit_id, member_id, Unk1()) => outfit_id mustEqual 529744 member_id mustEqual 41605263 case _ => @@ -106,7 +101,6 @@ class OutfitMemberEventTest extends Specification { "encode Unk1" in { val msg = OutfitMemberEvent( - packet_type = OutfitMemberEvent.PacketType.Unk1, outfit_id = 529744, member_id = 41605263, Unk1() diff --git a/src/test/scala/game/OutfitMemberUpdateTest.scala b/src/test/scala/game/OutfitMemberUpdateTest.scala new file mode 100644 index 000000000..39e0ca3de --- /dev/null +++ b/src/test/scala/game/OutfitMemberUpdateTest.scala @@ -0,0 +1,51 @@ +// Copyright (c) 2023-2025 PSForever +package game + +import net.psforever.packet._ +import net.psforever.packet.game.OutfitMemberUpdate +import org.specs2.mutable._ +import scodec.bits._ + +class OutfitMemberUpdateTest extends Specification { + + val updateRankToOwnerOfOutfitInFormation = hex"91 0100ff7f15aa7a02f0" + val normalRankChange = hex"91 1219000086d9130090" + + "decode updateOwnerOfOutfitInFormation" in { + PacketCoding.decodePacket(updateRankToOwnerOfOutfitInFormation).require match { + case OutfitMemberUpdate(outfit_id, char_id, rank, flag) => + outfit_id mustEqual 2147418113 + char_id mustEqual 41593365 + rank mustEqual 7 + flag mustEqual true + case _ => + ko + } + } + + "encode updateOwnerOfOutfitInFormation" in { + val msg = OutfitMemberUpdate(outfit_id = 2147418113, char_id = 41593365, rank = 7, flag = true) + val pkt = PacketCoding.encodePacket(msg).require.toByteVector + + pkt mustEqual updateRankToOwnerOfOutfitInFormation + } + + "decode normalRankChange" in { + PacketCoding.decodePacket(normalRankChange).require match { + case OutfitMemberUpdate(outfit_id, char_id, rank, flag) => + outfit_id mustEqual 6418 + char_id mustEqual 1300870 + rank mustEqual 4 + flag mustEqual true + case _ => + ko + } + } + + "encode normalRankChange" in { + val msg = OutfitMemberUpdate(outfit_id = 6418, char_id = 1300870, rank = 4, flag = true) + val pkt = PacketCoding.encodePacket(msg).require.toByteVector + + pkt mustEqual normalRankChange + } +} diff --git a/src/test/scala/game/OutfitMembershipRequestTest.scala b/src/test/scala/game/OutfitMembershipRequestTest.scala index 0e8af6e4c..b733c4d88 100644 --- a/src/test/scala/game/OutfitMembershipRequestTest.scala +++ b/src/test/scala/game/OutfitMembershipRequestTest.scala @@ -2,13 +2,13 @@ package game import net.psforever.packet._ -import net.psforever.packet.game._ -import net.psforever.packet.game.OutfitMembershipRequest.RequestType +import net.psforever.packet.game.OutfitMembershipRequest import net.psforever.packet.game.OutfitMembershipRequestAction._ import org.specs2.mutable._ import scodec.bits._ class OutfitMembershipRequestTest extends Specification { + val create_ABC = hex"8c 0 0200 000 1000 83 410042004300" val create_2222 = hex"8c 0 1000 000 1000 84 3200320032003200" val form_abc = hex"8c 2 0200 000 1000 83 610062006300" @@ -30,8 +30,8 @@ class OutfitMembershipRequestTest extends Specification { "decode CreateOutfit ABC" in { PacketCoding.decodePacket(create_ABC).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Create + case OutfitMembershipRequest(outfit_id, action) => + outfit_id mustEqual 1 action mustEqual Create("", "ABC") case _ => @@ -40,7 +40,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode CreateOutfit ABC" in { - val msg = OutfitMembershipRequest(RequestType.Create, 1, Create("", "ABC")) + val msg = OutfitMembershipRequest(1, Create("", "ABC")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual create_ABC @@ -48,8 +48,7 @@ class OutfitMembershipRequestTest extends Specification { "decode CreateOutfit 2222" in { PacketCoding.decodePacket(create_2222).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Create + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 8 action mustEqual Create("", "2222") case _ => @@ -58,7 +57,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode CreateOutfit 2222" in { - val msg = OutfitMembershipRequest(RequestType.Create, 8, Create("", "2222")) + val msg = OutfitMembershipRequest(8, Create("", "2222")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual create_2222 @@ -66,8 +65,7 @@ class OutfitMembershipRequestTest extends Specification { "decode FormOutfit abc" in { PacketCoding.decodePacket(form_abc).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Form + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 1 action mustEqual Form("", "abc") case _ => @@ -76,7 +74,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode FormOutfit abc" in { - val msg = OutfitMembershipRequest(RequestType.Form, 1, Form("", "abc")) + val msg = OutfitMembershipRequest(1, Form("", "abc")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual form_abc @@ -84,8 +82,7 @@ class OutfitMembershipRequestTest extends Specification { "decode FormOutfit 1" in { PacketCoding.decodePacket(form_1).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Form + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 8 action mustEqual Form("", "1") case _ => @@ -94,7 +91,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode FormOutfit 1" in { - val msg = OutfitMembershipRequest(RequestType.Form, 8, Form("", "1")) + val msg = OutfitMembershipRequest(8, Form("", "1")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual form_1 @@ -102,8 +99,7 @@ class OutfitMembershipRequestTest extends Specification { "decode Invite" in { PacketCoding.decodePacket(invite_old).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Invite + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 30383325L action mustEqual Invite(0, "virusgiver") case _ => @@ -112,7 +108,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode Invite" in { - val msg = OutfitMembershipRequest(RequestType.Invite, 30383325L, Invite(0, "virusgiver")) + val msg = OutfitMembershipRequest(30383325L, Invite(0, "virusgiver")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual invite_old @@ -120,8 +116,7 @@ class OutfitMembershipRequestTest extends Specification { "decode AcceptOutfitInvite 1" in { PacketCoding.decodePacket(accept_1).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Accept + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 1 action mustEqual AcceptInvite("") case _ => @@ -130,7 +125,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode AcceptOutfitInvite 1" in { - val msg = OutfitMembershipRequest(RequestType.Accept, 1, AcceptInvite("")) + val msg = OutfitMembershipRequest(1, AcceptInvite("")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual accept_1 @@ -138,8 +133,7 @@ class OutfitMembershipRequestTest extends Specification { "decode AcceptOutfitInvite 2" in { PacketCoding.decodePacket(accept_2).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Accept + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 2 action mustEqual AcceptInvite("") case _ => @@ -148,7 +142,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode AcceptOutfitInvite 2" in { - val msg = OutfitMembershipRequest(RequestType.Accept, 2, AcceptInvite("")) + val msg = OutfitMembershipRequest(2, AcceptInvite("")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual accept_2 @@ -156,8 +150,7 @@ class OutfitMembershipRequestTest extends Specification { "decode RejectOutfitInvite 1" in { PacketCoding.decodePacket(reject_1).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Reject + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 1 action mustEqual RejectInvite("") case _ => @@ -166,7 +159,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode RejectOutfitInvite 1" in { - val msg = OutfitMembershipRequest(RequestType.Reject, 1, RejectInvite("")) + val msg = OutfitMembershipRequest(1, RejectInvite("")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual reject_1 @@ -174,8 +167,7 @@ class OutfitMembershipRequestTest extends Specification { "decode RejectOutfitInvite 2" in { PacketCoding.decodePacket(reject_2).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Reject + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 2 action mustEqual RejectInvite("") case _ => @@ -184,7 +176,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode RejectOutfitInvite 2" in { - val msg = OutfitMembershipRequest(RequestType.Reject, 2, RejectInvite("")) + val msg = OutfitMembershipRequest(2, RejectInvite("")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual reject_2 @@ -192,8 +184,7 @@ class OutfitMembershipRequestTest extends Specification { "decode CancelOutfitInvite 3" in { PacketCoding.decodePacket(cancel_3).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Cancel + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 3 action mustEqual CancelInvite(0, "") case _ => @@ -202,7 +193,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode CancelOutfitInvite 3" in { - val msg = OutfitMembershipRequest(RequestType.Cancel, 3, CancelInvite(0, "")) + val msg = OutfitMembershipRequest(3, CancelInvite(0, "")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual cancel_3 @@ -210,8 +201,7 @@ class OutfitMembershipRequestTest extends Specification { "decode CancelOutfitInvite 1 abc" in { PacketCoding.decodePacket(cancel_1_abc).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Cancel + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 1 action mustEqual CancelInvite(0, "abc") case _ => @@ -220,7 +210,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode CancelOutfitInvite 1 abc" in { - val msg = OutfitMembershipRequest(RequestType.Cancel, 1, CancelInvite(0, "abc")) + val msg = OutfitMembershipRequest(1, CancelInvite(0, "abc")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual cancel_1_abc @@ -228,8 +218,7 @@ class OutfitMembershipRequestTest extends Specification { "decode CancelOutfitInvite 3 def" in { PacketCoding.decodePacket(cancel_3_def).require match { - case OutfitMembershipRequest(request_type, outfit_id, action) => - request_type mustEqual RequestType.Cancel + case OutfitMembershipRequest(outfit_id, action) => outfit_id mustEqual 3 action mustEqual CancelInvite(0, "def") case _ => @@ -238,7 +227,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode CancelOutfitInvite 3 def" in { - val msg = OutfitMembershipRequest(RequestType.Cancel, 3, CancelInvite(0, "def")) + val msg = OutfitMembershipRequest(3, CancelInvite(0, "def")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual cancel_3_def @@ -248,8 +237,7 @@ class OutfitMembershipRequestTest extends Specification { "decode invite" in { PacketCoding.decodePacket(invite).require match { - case OutfitMembershipRequest(request_type, outfit_id, Invite(unk1, member_name)) => - request_type mustEqual RequestType.Invite + case OutfitMembershipRequest(outfit_id, Invite(unk1, member_name)) => outfit_id mustEqual 1 unk1 mustEqual 0 member_name mustEqual "inviteTest1" @@ -259,7 +247,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode invite" in { - val msg = OutfitMembershipRequest(RequestType.Invite, 1, Invite(0, "inviteTest1")) + val msg = OutfitMembershipRequest(1, Invite(0, "inviteTest1")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual invite @@ -268,8 +256,7 @@ class OutfitMembershipRequestTest extends Specification { "decode kick" in { PacketCoding.decodePacket(kick).require match { - case OutfitMembershipRequest(request_type, outfit_id, Kick(avatar_id, member_name)) => - request_type mustEqual RequestType.Kick + case OutfitMembershipRequest(outfit_id, Kick(avatar_id, member_name)) => outfit_id mustEqual 1 avatar_id mustEqual 41575613 member_name mustEqual "" @@ -279,7 +266,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode kick" in { - val msg = OutfitMembershipRequest(RequestType.Kick, 1, Kick(41575613, "")) + val msg = OutfitMembershipRequest(1, Kick(41575613, "")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual kick @@ -287,8 +274,7 @@ class OutfitMembershipRequestTest extends Specification { "decode setrank" in { PacketCoding.decodePacket(setrank).require match { - case OutfitMembershipRequest(request_type, outfit_id, SetRank(avatar_id, rank, member_name)) => - request_type mustEqual RequestType.SetRank + case OutfitMembershipRequest(outfit_id, SetRank(avatar_id, rank, member_name)) => outfit_id mustEqual 1 avatar_id mustEqual 41575613 rank mustEqual 1 @@ -299,7 +285,7 @@ class OutfitMembershipRequestTest extends Specification { } "encode setrank" in { - val msg = OutfitMembershipRequest(RequestType.SetRank, 1, SetRank(41575613, 1, "")) + val msg = OutfitMembershipRequest(1, SetRank(41575613, 1, "")) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual setrank diff --git a/src/test/scala/game/OutfitMembershipResponseTest.scala b/src/test/scala/game/OutfitMembershipResponseTest.scala index 7646a96e4..bd16286a3 100644 --- a/src/test/scala/game/OutfitMembershipResponseTest.scala +++ b/src/test/scala/game/OutfitMembershipResponseTest.scala @@ -2,8 +2,8 @@ package game import net.psforever.packet._ +import net.psforever.packet.game.OutfitMembershipResponse import net.psforever.packet.game.OutfitMembershipResponse.PacketType -import net.psforever.packet.game._ import org.specs2.mutable._ import scodec.bits._ diff --git a/src/test/scala/game/OutfitRequesTest.scala b/src/test/scala/game/OutfitRequestTest.scala similarity index 92% rename from src/test/scala/game/OutfitRequesTest.scala rename to src/test/scala/game/OutfitRequestTest.scala index 0928b3f55..4c4adcb11 100644 --- a/src/test/scala/game/OutfitRequesTest.scala +++ b/src/test/scala/game/OutfitRequestTest.scala @@ -3,17 +3,18 @@ package game import org.specs2.mutable._ import net.psforever.packet._ -import net.psforever.packet.game._ +import net.psforever.packet.game.{OutfitRequest, OutfitRequestAction} import scodec.bits._ class OutfitRequestTest extends Specification { + val setMotd = hex"8e 02b54f40401780560061006e00750020006f0075007400660069007400200066006f0072002000740068006500200070006c0061006e00650074007300690064006500200066006f00720065007600650072002000700072006f006a006500630074002100200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002d00660069006e00640020006f007500740020006d006f00720065002000610062006f0075007400200074006800650020005000530045004d0055002000700072006f006a0065006300740020006100740020005000530066006f00720065007600650072002e006e0065007400" val setRanks = hex"8e 22b54f405800c000c000c000c000c000c000c000" val string4 = hex"8e 42b54f404aa0" //faked by modifying the previous example val string6 = hex"8e 649e822010" val string8 = hex"8e 81b2cf4050" - "decode 0" in { + "decode Motd" in { PacketCoding.decodePacket(setMotd).require match { case OutfitRequest(id, OutfitRequestAction.Motd(str)) => id mustEqual 41593365L @@ -23,7 +24,7 @@ class OutfitRequestTest extends Specification { } } - "decode 1" in { + "decode Ranks" in { PacketCoding.decodePacket(setRanks).require match { case OutfitRequest(id, OutfitRequestAction.Ranks(list)) => id mustEqual 41593365L @@ -33,7 +34,7 @@ class OutfitRequestTest extends Specification { } } - "decode 2 (fake)" in { + "decode Unk2 (fake)" in { PacketCoding.decodePacket(string4).require match { case OutfitRequest(id, OutfitRequestAction.Unk2(value)) => id mustEqual 41593365L @@ -43,7 +44,7 @@ class OutfitRequestTest extends Specification { } } - "decode 3" in { + "decode Unk3" in { PacketCoding.decodePacket(string6).require match { case OutfitRequest(id, OutfitRequestAction.Unk3(value)) => id mustEqual 1176612L @@ -53,7 +54,7 @@ class OutfitRequestTest extends Specification { } } - "decode 4" in { + "decode Unk4" in { PacketCoding.decodePacket(string8).require match { case OutfitRequest(id, OutfitRequestAction.Unk4(value)) => id mustEqual 41588237L @@ -63,7 +64,7 @@ class OutfitRequestTest extends Specification { } } - "encode 0" in { + "encode Motd" in { val msg = OutfitRequest(41593365L, OutfitRequestAction.Motd( "Vanu outfit for the planetside forever project! -find out more about the PSEMU project at PSforever.net" )) @@ -72,28 +73,28 @@ class OutfitRequestTest extends Specification { pkt mustEqual setMotd } - "encode 1" in { + "encode Ranks" in { val msg = OutfitRequest(41593365L, OutfitRequestAction.Ranks(List(Some(""), Some(""), Some(""), Some(""), Some(""), Some(""), Some(""), Some("")))) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual setRanks } - "encode 2 (fake)" in { + "encode Unk2 (fake)" in { val msg = OutfitRequest(41593365L, OutfitRequestAction.Unk2(85)) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual string4 } - "encode 3" in { + "encode Unk3" in { val msg = OutfitRequest(1176612L, OutfitRequestAction.Unk3(true)) val pkt = PacketCoding.encodePacket(msg).require.toByteVector pkt mustEqual string6 } - "encode 4" in { + "encode Unk4" in { val msg = OutfitRequest(41588237L, OutfitRequestAction.Unk4(true)) val pkt = PacketCoding.encodePacket(msg).require.toByteVector