mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-14 07:55:07 +00:00
handling Infantry packets, which have an extra field; added tests and comments
This commit is contained in:
parent
3789bc2ae5
commit
bc2a231d45
2 changed files with 54 additions and 20 deletions
|
|
@ -6,20 +6,58 @@ import scodec.Codec
|
||||||
import scodec.codecs._
|
import scodec.codecs._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* na
|
* Load the designator for an entry in the player's favorites list.<br>
|
||||||
* @param list na
|
* <br>
|
||||||
|
* This entry defines a loadout but does not directly associate itself with the configurations and contents of the loadout.
|
||||||
|
* It is just the user-defined name that appears on a "Favorites" tab list and can be selected.
|
||||||
|
* A subsequent server request - `ItemTransactionMessage` - must be made to retrieve the said configuration and content for loading.
|
||||||
|
* Multiple separated favorites lists are present in the game.
|
||||||
|
* All entries are prepended with their destination list, which determines what kind of terminal or menu allows them to be viewable.<br>
|
||||||
|
* <br>
|
||||||
|
* Infantry equipment favorites are appended with a code for the type of exo-suit that they will load on a player.
|
||||||
|
* This does not match the same two field numbering system as in `ArmorChangedMessage` packets.
|
||||||
|
* Subtypes are not considered separately.<br>
|
||||||
|
* <br>
|
||||||
|
* Lists:<br>
|
||||||
|
* `
|
||||||
|
* 0 - Equipment Terminal (infantry)<br>
|
||||||
|
* 1 - Repair/Rearm (standard vehicles)<br>
|
||||||
|
* `
|
||||||
|
* <br>
|
||||||
|
* Armors:<br>
|
||||||
|
* `
|
||||||
|
* 1 - Agile<br>
|
||||||
|
* 2 - Reinforced<br>
|
||||||
|
* 4 - AA MAX<br>
|
||||||
|
* 5 - AI MAX<br>
|
||||||
|
* 6 - AV MAX<br>
|
||||||
|
* `
|
||||||
|
* <br>
|
||||||
|
* Exploration 1:<br>
|
||||||
|
* The identifier for the list is two bits so four separated lists of Favorites are supportable.
|
||||||
|
* Two of the lists are common enough and we can assume one of the others is related to Battleframe Robotics.
|
||||||
|
* What, if anything, is the fourth indexed list?<br>
|
||||||
|
* <br>
|
||||||
|
* Exploration 2:<br>
|
||||||
|
* There are three unaccounted exo-suit indices - '0', '3', and '7' - and two specific kinds of exo-suit that are not defined - Infiltration and Standard.
|
||||||
|
* It is possible that one of the indices also defines the generic MAX (see `ArmorChangedMessage`).
|
||||||
|
* Which exo-suit is associated with which index?<br>
|
||||||
|
* <br>
|
||||||
|
* Exploration 3:<br>
|
||||||
|
* The `armor` parameter coincides with the type of exo-suit maintained by the loadout.
|
||||||
|
* Does this value help the client judge when a favorite can be selected by checking against certifications for exo-suit permission?
|
||||||
|
* (If so, why isn't it working?)
|
||||||
|
* @param list the destination list
|
||||||
* @param player_guid the player
|
* @param player_guid the player
|
||||||
* @param line na
|
* @param line the zero-indexed line number of this entry in its list
|
||||||
* @param subject na
|
* @param label the identifier for this entry
|
||||||
* @param armor the type of exo-suit
|
* @param armor the type of exo-suit, if an Infantry loadout
|
||||||
* @param subtype the exo-suit subtype, if any
|
|
||||||
*/
|
*/
|
||||||
final case class FavoritesMessage(list : Int,
|
final case class FavoritesMessage(list : Int,
|
||||||
player_guid : PlanetSideGUID,
|
player_guid : PlanetSideGUID,
|
||||||
line : Int,
|
line : Int,
|
||||||
subject : String,
|
label : String,
|
||||||
armor : Option[Int] = None,
|
armor : Option[Int] = None)
|
||||||
subtype : Option[Int] = None)
|
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
type Packet = FavoritesMessage
|
type Packet = FavoritesMessage
|
||||||
def opcode = GamePacketOpcode.FavoritesMessage
|
def opcode = GamePacketOpcode.FavoritesMessage
|
||||||
|
|
@ -31,8 +69,7 @@ object FavoritesMessage extends Marshallable[FavoritesMessage] {
|
||||||
("list" | uintL(2)) >>:~ { value =>
|
("list" | uintL(2)) >>:~ { value =>
|
||||||
("player_guid" | PlanetSideGUID.codec) ::
|
("player_guid" | PlanetSideGUID.codec) ::
|
||||||
("line" | uintL(4)) ::
|
("line" | uintL(4)) ::
|
||||||
("subject" | PacketHelpers.encodedWideStringAligned(2)) ::
|
("label" | PacketHelpers.encodedWideStringAligned(2)) ::
|
||||||
conditional(value == 0, "armor" | uintL(3)) ::
|
conditional(value == 0, "armor" | uintL(3))
|
||||||
conditional(value == 0, "subtype" | uintL(3))
|
|
||||||
}).as[FavoritesMessage]
|
}).as[FavoritesMessage]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -856,22 +856,20 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"decode (for infantry)" in {
|
"decode (for infantry)" in {
|
||||||
PacketCoding.DecodePacket(stringInfantry).require match {
|
PacketCoding.DecodePacket(stringInfantry).require match {
|
||||||
case FavoritesMessage(list, player_guid, line, subject, armor, subtype) =>
|
case FavoritesMessage(list, player_guid, line, label, armor) =>
|
||||||
list mustEqual 0
|
list mustEqual 0
|
||||||
player_guid mustEqual PlanetSideGUID(3760)
|
player_guid mustEqual PlanetSideGUID(3760)
|
||||||
line mustEqual 0
|
line mustEqual 0
|
||||||
subject mustEqual "Agile (basic)"
|
label mustEqual "Agile (basic)"
|
||||||
armor.isDefined mustEqual true
|
armor.isDefined mustEqual true
|
||||||
armor.get mustEqual 1
|
armor.get mustEqual 1
|
||||||
subtype.isDefined mustEqual true
|
|
||||||
subtype.get mustEqual 0
|
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (for infantry)" in {
|
"encode (for infantry)" in {
|
||||||
val msg = FavoritesMessage(0, PlanetSideGUID(3760), 0, "Agile (basic)", Option(1), Option(0))
|
val msg = FavoritesMessage(0, PlanetSideGUID(3760), 0, "Agile (basic)", Option(1))
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringInfantry
|
pkt mustEqual stringInfantry
|
||||||
|
|
@ -879,13 +877,12 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"decode (for vehicles)" in {
|
"decode (for vehicles)" in {
|
||||||
PacketCoding.DecodePacket(stringVehicles).require match {
|
PacketCoding.DecodePacket(stringVehicles).require match {
|
||||||
case FavoritesMessage(list, player_guid, line, subject, armor, subtype) =>
|
case FavoritesMessage(list, player_guid, line, label, armor) =>
|
||||||
list mustEqual 1
|
list mustEqual 1
|
||||||
player_guid mustEqual PlanetSideGUID(4210)
|
player_guid mustEqual PlanetSideGUID(4210)
|
||||||
line mustEqual 0
|
line mustEqual 0
|
||||||
subject mustEqual "Skyguard"
|
label mustEqual "Skyguard"
|
||||||
armor.isDefined mustEqual false
|
armor.isDefined mustEqual false
|
||||||
subtype.isDefined mustEqual false
|
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue