add initial SetChatFilterMessage packet and tests; gave FriendsResponse a valid action enumeration; changed continent id and building id in DensityUpdateLevel to use simple data type rather than PlanetSideGUID; worked these packet changes into WSA initialization workflow

This commit is contained in:
FateJH 2018-03-07 22:32:27 -05:00
parent 2526f15406
commit 0578d291a5
7 changed files with 224 additions and 24 deletions

View file

@ -49,4 +49,4 @@ class DensityLevelUpdateMessageTest extends Specification {
val msg1 = DensityLevelUpdateMessage(1, 19999, List(0,0, 0,0, 0,-1, 0,0))
PacketCoding.EncodePacket(msg1).isSuccessful mustEqual false
}
}
}

View file

@ -14,7 +14,7 @@ class FriendsResponseTest extends Specification {
"decode (one friend)" in {
PacketCoding.DecodePacket(stringOneFriend).require match {
case FriendsResponse(action, unk2, unk3, unk4, list) =>
action mustEqual 3
action mustEqual FriendAction.UpdateFriend
unk2 mustEqual 0
unk3 mustEqual true
unk4 mustEqual true
@ -29,7 +29,7 @@ class FriendsResponseTest extends Specification {
"decode (multiple friends)" in {
PacketCoding.DecodePacket(stringManyFriends).require match {
case FriendsResponse(action, unk2, unk3, unk4, list) =>
action mustEqual 0
action mustEqual FriendAction.InitializeFriendList
unk2 mustEqual 0
unk3 mustEqual true
unk4 mustEqual true
@ -52,7 +52,7 @@ class FriendsResponseTest extends Specification {
"decode (short)" in {
PacketCoding.DecodePacket(stringShort).require match {
case FriendsResponse(action, unk2, unk3, unk4, list) =>
action mustEqual 4
action mustEqual FriendAction.InitializeIgnoreList
unk2 mustEqual 0
unk3 mustEqual true
unk4 mustEqual true
@ -63,7 +63,7 @@ class FriendsResponseTest extends Specification {
}
"encode (one friend)" in {
val msg = FriendsResponse(3, 0, true, true,
val msg = FriendsResponse(FriendAction.UpdateFriend, 0, true, true,
Friend("KurtHectic-G", false) ::
Nil)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
@ -72,7 +72,7 @@ class FriendsResponseTest extends Specification {
}
"encode (multiple friends)" in {
val msg = FriendsResponse(0, 0, true, true,
val msg = FriendsResponse(FriendAction.InitializeFriendList, 0, true, true,
Friend("Angello-W", false) ::
Friend("thephattphrogg", false) ::
Friend("Kimpossible12", false) ::
@ -85,7 +85,7 @@ class FriendsResponseTest extends Specification {
}
"encode (short)" in {
val msg = FriendsResponse(4, 0, true, true)
val msg = FriendsResponse(FriendAction.InitializeIgnoreList, 0, true, true)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual stringShort

View file

@ -0,0 +1,75 @@
// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import scodec.bits._
class SetChatFilterMessageTest extends Specification {
val string = hex"63 05FF80"
val string_custom = hex"63 05C180"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case SetChatFilterMessage(send, origin, filters) =>
send mustEqual ChatChannel.Local
origin mustEqual true
filters.length mustEqual 9
filters.head mustEqual ChatChannel.Unknown
filters(1) mustEqual ChatChannel.Tells
filters(2) mustEqual ChatChannel.Local
filters(3) mustEqual ChatChannel.Squad
filters(4) mustEqual ChatChannel.Outfit
filters(5) mustEqual ChatChannel.Command
filters(6) mustEqual ChatChannel.Platoon
filters(7) mustEqual ChatChannel.Broadcast
filters(8) mustEqual ChatChannel.SquadLeader
case _ =>
ko
}
}
"decode (custom)" in {
PacketCoding.DecodePacket(string_custom).require match {
case SetChatFilterMessage(send, origin, filters) =>
send mustEqual ChatChannel.Local
origin mustEqual true
filters.length mustEqual 4
filters.head mustEqual ChatChannel.Unknown
filters(1) mustEqual ChatChannel.Tells
filters(2) mustEqual ChatChannel.Broadcast
filters(3) mustEqual ChatChannel.SquadLeader
case _ =>
ko
}
}
"encode" in {
val msg = SetChatFilterMessage(ChatChannel.Local, true, List(ChatChannel.Unknown, ChatChannel.Tells, ChatChannel.Local, ChatChannel.Squad, ChatChannel.Outfit, ChatChannel.Command, ChatChannel.Platoon, ChatChannel.Broadcast, ChatChannel.SquadLeader))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (success; same channel listed multiple times)" in {
val msg = SetChatFilterMessage(ChatChannel.Local, true, List(ChatChannel.Unknown, ChatChannel.Unknown, ChatChannel.Tells, ChatChannel.Tells, ChatChannel.Local, ChatChannel.Squad, ChatChannel.Outfit, ChatChannel.Command, ChatChannel.Platoon, ChatChannel.Broadcast, ChatChannel.SquadLeader))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (success; out of order)" in {
val msg = SetChatFilterMessage(ChatChannel.Local, true, List(ChatChannel.Squad, ChatChannel.Outfit, ChatChannel.SquadLeader, ChatChannel.Unknown, ChatChannel.Command, ChatChannel.Platoon, ChatChannel.Broadcast, ChatChannel.Tells, ChatChannel.Local))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (success; custom)" in {
val msg = SetChatFilterMessage(ChatChannel.Local, true, List(ChatChannel.Unknown, ChatChannel.Tells, ChatChannel.Broadcast, ChatChannel.SquadLeader))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string_custom
}
}