mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-12 19:31:04 +00:00
initial work and dummy tests for SquadDetailDefinitionUpdateMessage packet; 46-bit certification encoding; indicating four previously unhandled SquadAction types; the squad leader is allowed to move around his squad
This commit is contained in:
parent
ceb145d94f
commit
5c433204cf
10 changed files with 582 additions and 129 deletions
|
|
@ -5,11 +5,15 @@ import org.specs2.mutable._
|
|||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.SquadAction._
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.types.CertificationType
|
||||
import scodec.bits._
|
||||
|
||||
class SquadDefinitionActionMessageTest extends Specification {
|
||||
//local test data; note that the second field - unk1 - is always blank for now, but that probably changes
|
||||
val string_00 = hex"e7 00 0c0000" //guid: 3
|
||||
val string_03 = hex"E7 0c 0000c0" //index: 3
|
||||
val string_04 = hex"E7 10 0000c0" //index: 3
|
||||
val string_07 = hex"e7 1c 0000e68043006f0070007300200061006e00640020004d0069006c006900740061007200790020004f006600660069006300650072007300"
|
||||
val string_08 = hex"E7 20 000000"
|
||||
val string_10 = hex"E7 28 000004" //index: 1
|
||||
val string_19 = hex"E7 4c 0000218041002d005400650061006d00" //"A-Team"
|
||||
|
|
@ -34,6 +38,17 @@ class SquadDefinitionActionMessageTest extends Specification {
|
|||
val string_43 = hex"e7 ac 000000"
|
||||
val string_failure = hex"E7 ff"
|
||||
|
||||
"decode (00)" in {
|
||||
PacketCoding.DecodePacket(string_00).require match {
|
||||
case SquadDefinitionActionMessage(unk1, unk2, action) =>
|
||||
unk1 mustEqual 3
|
||||
unk2 mustEqual 0
|
||||
action mustEqual DisplaySquad()
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (03)" in {
|
||||
PacketCoding.DecodePacket(string_03).require match {
|
||||
case SquadDefinitionActionMessage(unk1, unk2, action) =>
|
||||
|
|
@ -45,6 +60,28 @@ class SquadDefinitionActionMessageTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"decode (03)" in {
|
||||
PacketCoding.DecodePacket(string_04).require match {
|
||||
case SquadDefinitionActionMessage(unk1, unk2, action) =>
|
||||
unk1 mustEqual 0
|
||||
unk2 mustEqual 3
|
||||
action mustEqual LoadSquadDefinition()
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (07)" in {
|
||||
PacketCoding.DecodePacket(string_07).require match {
|
||||
case SquadDefinitionActionMessage(unk1, unk2, action) =>
|
||||
unk1 mustEqual 0
|
||||
unk2 mustEqual 3
|
||||
action mustEqual ListSquadDefinition("Cops and Military Officers")
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (08)" in {
|
||||
PacketCoding.DecodePacket(string_08).require match {
|
||||
case SquadDefinitionActionMessage(unk1, unk2, action) =>
|
||||
|
|
@ -138,7 +175,10 @@ class SquadDefinitionActionMessageTest extends Specification {
|
|||
case SquadDefinitionActionMessage(unk1, unk2, action) =>
|
||||
unk1 mustEqual 0
|
||||
unk2 mustEqual 0
|
||||
action mustEqual ChangeSquadMemberRequirementsWeapons(1, 536870928L)
|
||||
action mustEqual ChangeSquadMemberRequirementsCertifications(
|
||||
1,
|
||||
Set(CertificationType.AntiVehicular, CertificationType.InfiltrationSuit)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -280,6 +320,13 @@ class SquadDefinitionActionMessageTest extends Specification {
|
|||
PacketCoding.DecodePacket(string_failure).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"encode (00)" in {
|
||||
val msg = SquadDefinitionActionMessage(3, 0, DisplaySquad())
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_00
|
||||
}
|
||||
|
||||
"encode (03)" in {
|
||||
val msg = SquadDefinitionActionMessage(0, 3, SaveSquadDefinition())
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -287,6 +334,20 @@ class SquadDefinitionActionMessageTest extends Specification {
|
|||
pkt mustEqual string_03
|
||||
}
|
||||
|
||||
"encode (03)" in {
|
||||
val msg = SquadDefinitionActionMessage(0, 3, LoadSquadDefinition())
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_04
|
||||
}
|
||||
|
||||
"encode (07)" in {
|
||||
val msg = SquadDefinitionActionMessage(0, 3, ListSquadDefinition("Cops and Military Officers"))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_07
|
||||
}
|
||||
|
||||
"encode (08)" in {
|
||||
val msg = SquadDefinitionActionMessage(0, 0, ListSquad())
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -344,7 +405,10 @@ class SquadDefinitionActionMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"encode (25)" in {
|
||||
val msg = SquadDefinitionActionMessage(0, 0, ChangeSquadMemberRequirementsWeapons(1, 536870928L))
|
||||
val msg = SquadDefinitionActionMessage(0, 0, ChangeSquadMemberRequirementsCertifications(
|
||||
1,
|
||||
Set(CertificationType.AntiVehicular, CertificationType.InfiltrationSuit)
|
||||
))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_25
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2019 PSForever
|
||||
package game
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class SquadDetailDefinitionUpdateMessageTest extends Specification {
|
||||
val string = hex"e80300848180038021514601288a8400420048006f0066004400bf5c0023006600660064006300300030002a002a002a005c0023003900360034003000660066003d004b004f004b002b005300500043002b0046004c0059003d005c0023006600660064006300300030002a002a002a005c002300460046003400300034003000200041006c006c002000570065006c0063006f006d006500070000009814010650005c00230066006600300030003000300020007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c008000000000800100000c00020c8c5c00230066006600640063003000300020002000200043008000000000800100000c00020c8c5c002300660066006400630030003000200020002000480080eab58a02854f0070006f006c0045000100000c00020c8d5c002300660066006400630030003000200020002000200049008072d47a028b42006f006200610046003300740074003900300037000100000c00020c8c5c0023006600660064006300300030002000200020004e008000000000800100000c00020c8c5c00230066006600640063003000300020002000200041008000000000800100000c00020ca05c00230066006600300030003000300020007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c007c008000000000800100000c00020c8c5c0023003900360034003000660066002000200020004b008000000000800100000c00020c8c5c0023003900360034003000660066002000200020004f008042a28c028448006f00660044000100000c00020c8c5c0023003900360034003000660066002000200020004b008000000000800100000c0000"
|
||||
|
||||
"SquadDetailDefinitionUpdateMessage" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case SquadDetailDefinitionUpdateMessage(guid, unk, leader, task, zone, member_info) =>
|
||||
ok
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = SquadDetailDefinitionUpdateMessage(
|
||||
PlanetSideGUID(3),
|
||||
"HofD",
|
||||
"\\#ffdc00***\\#9640ff=KOK+SPC+FLY=\\#ffdc00***\\#FF4040 All Welcome",
|
||||
PlanetSideZoneID(7),
|
||||
List(
|
||||
SquadPositionDetail("\\#ff0000 |||||||||||||||||||||||", ""),
|
||||
SquadPositionDetail("\\#ffdc00 C", ""),
|
||||
SquadPositionDetail("\\#ffdc00 H", "", "OpoIE"),
|
||||
SquadPositionDetail("\\#ffdc00 I", "", "BobaF3tt907"),
|
||||
SquadPositionDetail("\\#ffdc00 N", ""),
|
||||
SquadPositionDetail("\\#ffdc00 A", ""),
|
||||
SquadPositionDetail("\\#ff0000 |||||||||||||||||||||||", ""),
|
||||
SquadPositionDetail("\\#9640ff K", ""),
|
||||
SquadPositionDetail("\\#9640ff O", "", "HofD"),
|
||||
SquadPositionDetail("\\#9640ff K", "")
|
||||
)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
ok
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue