mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
added (failing) tests for unhandled situation; unworking code that leads towards handling that situation
This commit is contained in:
parent
758eab167b
commit
ce165aa9a5
|
|
@ -29,12 +29,12 @@ import scodec.codecs._
|
|||
* @param effect1 for macros, a three letter acronym displayed in the hotbar
|
||||
* @param effect2 for macros, the chat message content
|
||||
*/
|
||||
//TODO Failed to parse game packet 0x28: purpose: cannot acquire 15 bits from a vector that contains 4 bits -- encountered when attempting to move shortcuts -- look into this
|
||||
//TODO must handle case 0x28 xxxx 01 00 00 for moving shortcuts
|
||||
final case class CreateShortcutMessage(player_guid : PlanetSideGUID,
|
||||
slot : Int,
|
||||
unk1 : Int,
|
||||
unk2 : Int,
|
||||
purpose : String,
|
||||
purpose : String = "",
|
||||
effect1 : String = "",
|
||||
effect2 : String = "")
|
||||
extends PlanetSideGamePacket {
|
||||
|
|
@ -42,7 +42,7 @@ final case class CreateShortcutMessage(player_guid : PlanetSideGUID,
|
|||
def opcode = GamePacketOpcode.CreateShortcutMessage
|
||||
def encode = CreateShortcutMessage.encode(this)
|
||||
}
|
||||
|
||||
//*
|
||||
object CreateShortcutMessage extends Marshallable[CreateShortcutMessage] {
|
||||
implicit val codec : Codec[CreateShortcutMessage] = (
|
||||
("player_guid" | PlanetSideGUID.codec) ::
|
||||
|
|
@ -54,3 +54,18 @@ object CreateShortcutMessage extends Marshallable[CreateShortcutMessage] {
|
|||
("effect2" | PacketHelpers.encodedWideString)
|
||||
).as[CreateShortcutMessage]
|
||||
}
|
||||
// */
|
||||
/*
|
||||
object CreateShortcutMessage extends Marshallable[CreateShortcutMessage] {
|
||||
implicit val codec : Codec[CreateShortcutMessage] = (
|
||||
("player_guid" | PlanetSideGUID.codec) ::
|
||||
("slot" | uint8L) ::
|
||||
("unk1" | uint8L) ::
|
||||
("unk2" | uintL(3)) >>:~ ( value =>
|
||||
conditional(value.last > 0, "purpose" | PacketHelpers.encodedStringAligned(5)) ::
|
||||
conditional(value.last > 0, "effect1" | PacketHelpers.encodedWideString) ::
|
||||
conditional(value.last > 0, "effect2" | PacketHelpers.encodedWideString)
|
||||
)
|
||||
).as[CreateShortcutMessage]
|
||||
}
|
||||
// */
|
||||
|
|
|
|||
|
|
@ -303,6 +303,7 @@ class GamePacketTest extends Specification {
|
|||
val stringMedkit = hex"28 7210 01 00 90 C0 6D65646B6974 80 80"
|
||||
val stringImplant = hex"28 7210 04 00 D0 A0 7375726765 80 80"
|
||||
val stringMacro = hex"28 4C05 08 00 B1 C0 73686F72746375745F6D6163726F 83 4E00 5400 5500 9B 2F00 7000 6C00 6100 7400 6F00 6F00 6E00 2000 4900 6E00 6300 6F00 6D00 6900 6E00 6700 2000 4E00 5400 5500 2000 7300 7000 6100 6D00 2100"
|
||||
val stringRemove = hex"28 4C05 01 00 00"
|
||||
|
||||
"decode (medkit)" in {
|
||||
PacketCoding.DecodePacket(stringMedkit).require match {
|
||||
|
|
@ -349,6 +350,21 @@ class GamePacketTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"decode (remove)" in {
|
||||
PacketCoding.DecodePacket(stringRemove).require match {
|
||||
case CreateShortcutMessage(player_guid, slot, unk1, unk2, purpose, effect1, effect2) =>
|
||||
player_guid mustEqual PlanetSideGUID(1356)
|
||||
slot mustEqual 1
|
||||
unk1 mustEqual 0
|
||||
unk2 mustEqual 0
|
||||
purpose mustEqual ""
|
||||
effect1 mustEqual ""
|
||||
effect2 mustEqual ""
|
||||
case default =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (medkit)" in {
|
||||
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 1, 0, 4, "medkit")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -369,6 +385,13 @@ class GamePacketTest extends Specification {
|
|||
|
||||
pkt mustEqual stringMacro
|
||||
}
|
||||
|
||||
"encode (remove)" in {
|
||||
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 1, 0, 0, "")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringRemove
|
||||
}
|
||||
}
|
||||
|
||||
"DropItemMessage" should {
|
||||
|
|
|
|||
Loading…
Reference in a new issue