mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-04-29 16:25:30 +00:00
correct packet fields to support and added tests for 'no entry' packet; added commentary
This commit is contained in:
parent
3e84e999fb
commit
7050027235
3 changed files with 81 additions and 22 deletions
|
|
@ -833,6 +833,7 @@ class GamePacketTest extends Specification {
|
|||
"FriendsResponse" should {
|
||||
val stringOneFriend = hex"73 61 8C 60 4B007500720074004800650063007400690063002D004700 00"
|
||||
val stringManyFriends = hex"73 01 AC 48 4100 6E00 6700 6500 6C00 6C00 6F00 2D00 5700 47 00 7400 6800 6500 7000 6800 6100 7400 7400 7000 6800 7200 6F00 6700 6700 46 80 4B00 6900 6D00 7000 6F00 7300 7300 6900 6200 6C00 6500 3100 3200 45 00 5A00 6500 6100 7200 7400 6800 6C00 6900 6E00 6700 46 00 4B00 7500 7200 7400 4800 6500 6300 7400 6900 6300 2D00 4700 00"
|
||||
val stringShort = hex"73 81 80"
|
||||
|
||||
"decode (one friend)" in {
|
||||
PacketCoding.DecodePacket(stringOneFriend).require match {
|
||||
|
|
@ -842,8 +843,9 @@ class GamePacketTest extends Specification {
|
|||
unk3 mustEqual true
|
||||
unk4 mustEqual true
|
||||
number_of_friends mustEqual 1
|
||||
friend.name mustEqual "KurtHectic-G"
|
||||
friend.online mustEqual false
|
||||
friend.isDefined mustEqual true
|
||||
friend.get.name mustEqual "KurtHectic-G"
|
||||
friend.get.online mustEqual false
|
||||
list.size mustEqual 0
|
||||
case default =>
|
||||
ko
|
||||
|
|
@ -858,8 +860,9 @@ class GamePacketTest extends Specification {
|
|||
unk3 mustEqual true
|
||||
unk4 mustEqual true
|
||||
number_of_friends mustEqual 5
|
||||
friend.name mustEqual "Angello-W"
|
||||
friend.online mustEqual false
|
||||
friend.isDefined mustEqual true
|
||||
friend.get.name mustEqual "Angello-W"
|
||||
friend.get.online mustEqual false
|
||||
list.size mustEqual 4
|
||||
list.head.name mustEqual "thephattphrogg"
|
||||
list.head.online mustEqual false
|
||||
|
|
@ -874,22 +877,44 @@ class GamePacketTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"decode (short)" in {
|
||||
PacketCoding.DecodePacket(stringShort).require match {
|
||||
case FriendsResponse(unk1, unk2, unk3, unk4, number_of_friends, friend, list) =>
|
||||
unk1 mustEqual 4
|
||||
unk2 mustEqual 0
|
||||
unk3 mustEqual true
|
||||
unk4 mustEqual true
|
||||
number_of_friends mustEqual 0
|
||||
friend.isDefined mustEqual false
|
||||
list.size mustEqual 0
|
||||
case default =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (one friend)" in {
|
||||
val msg = FriendsResponse(3, 0, true, true, 1, Friend("KurtHectic-G", false))
|
||||
val msg = FriendsResponse(3, 0, true, true, 1, Option(Friend("KurtHectic-G", false)))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringOneFriend
|
||||
}
|
||||
|
||||
"encode (multiple friends)" in {
|
||||
val msg = FriendsResponse(0, 0, true, true, 5, Friend("Angello-W", false), Friend("thephattphrogg", false) ::
|
||||
Friend("Kimpossible12", false) ::
|
||||
Friend("Zearthling", false) ::
|
||||
Friend("KurtHectic-G", false) :: Nil)
|
||||
val msg = FriendsResponse(0, 0, true, true, 5, Option(Friend("Angello-W", false)), Friend("thephattphrogg", false) ::
|
||||
Friend("Kimpossible12", false) ::
|
||||
Friend("Zearthling", false) ::
|
||||
Friend("KurtHectic-G", false) :: Nil)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringManyFriends
|
||||
}
|
||||
|
||||
"encode (short)" in {
|
||||
val msg = FriendsResponse(4, 0, true, true, 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringShort
|
||||
}
|
||||
}
|
||||
|
||||
"WeaponDryFireMessage" should {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue