mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-15 16:34:39 +00:00
clarifying the unknwon fields and adding an enumeration for one of them
This commit is contained in:
parent
261cea9269
commit
25864c87c1
2 changed files with 40 additions and 23 deletions
|
|
@ -7,29 +7,47 @@ import scodec.codecs._
|
||||||
import shapeless.{::, HNil}
|
import shapeless.{::, HNil}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatched by the server when placing deployables to generate a message in the events chat.<br>
|
* An `Enumeration` for the forms of the event chat message produced by this packet.
|
||||||
|
*/
|
||||||
|
object DeploymentOutcome extends Enumeration(1) {
|
||||||
|
type Type = Value
|
||||||
|
|
||||||
|
val Failure = Value(2)
|
||||||
|
//3 produces a Success message, but 4 is common
|
||||||
|
val Success = Value(4)
|
||||||
|
|
||||||
|
val codec = PacketHelpers.createLongEnumerationCodec(this, uint32L)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatched by the server to generate a message in the events chat when placing deployables.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* This packet does not actually modify anything in regards to deployables.
|
* This packet does not actually modify anything in regards to deployables.
|
||||||
* It merely generates the message:<br>
|
* The most common form of the generated message is:<br>
|
||||||
* `"You have placed x of a possible y thing."`<br>
|
* `"You have placed x of a possible y thing s."`<br>
|
||||||
* ... where `x` is the current count of objects of this type that have been deployed;
|
* ... where `x` is the current count of objects of this type that have been deployed;
|
||||||
* `y` is the (reported) maximum amount of objects of this type that can be deployed;
|
* `y` is the (reported) maximum amount of objects of this type that can be deployed;
|
||||||
* and, `thing` is the label for objects of this type.
|
* and, `thing` is the token for objects of this type.
|
||||||
* This text is not directly placed into the message's field but, rather, is a token for language-appropriate descriptive text.<br>
|
* If the `thing` is a valid string token, it will be replaced by language-appropriate descriptive text in the message.
|
||||||
* "boomer," for example, is replaced by "Heavy Explosive Mines" in the message for English language.
|
* Otherwise, that text is placed directly into the message, with an obvious space between the text and the "s".
|
||||||
* @param guid na;
|
* "boomer," for example, is replaced by "Boomer Heavy Explosives" in the message for English language.
|
||||||
|
* "bullet_9mm_AP," however, is just "bullet_9mm_AP s."<br>
|
||||||
|
* <br>
|
||||||
|
* When the `action` is `Success`, the message in the chat will be shown as above.
|
||||||
|
* When the `action` is `Failure`, the message will be:<br>
|
||||||
|
* `"thing failed to deploy and was destroyed."`<br>
|
||||||
|
* ... where, again, `thing` is a valid string token.
|
||||||
|
* @param unk na;
|
||||||
* usually 0?
|
* usually 0?
|
||||||
* @param desc descriptive text of what kind of object is being deployed;
|
* @param desc descriptive text of what kind of object is being deployed;
|
||||||
* matches the `String` description of the object class
|
* string token of the object, at best
|
||||||
* @param unk na;
|
* @param action the form the message will take
|
||||||
* usually 4
|
|
||||||
* @param count the current number of this type of object deployed
|
* @param count the current number of this type of object deployed
|
||||||
* @param max the maximum number of this type of object that can be deployed
|
* @param max the maximum number of this type of object that can be deployed
|
||||||
* @see `ObjectClass`
|
|
||||||
*/
|
*/
|
||||||
final case class ObjectDeployedMessage(guid : PlanetSideGUID,
|
final case class ObjectDeployedMessage(unk : Int,
|
||||||
desc : String,
|
desc : String,
|
||||||
unk : Long,
|
action : DeploymentOutcome.Value,
|
||||||
count : Long,
|
count : Long,
|
||||||
max : Long)
|
max : Long)
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
|
|
@ -42,18 +60,18 @@ object ObjectDeployedMessage extends Marshallable[ObjectDeployedMessage] {
|
||||||
/**
|
/**
|
||||||
* Overloaded constructor for when the guid is not required.
|
* Overloaded constructor for when the guid is not required.
|
||||||
* @param desc descriptive text of what kind of object is being deployed
|
* @param desc descriptive text of what kind of object is being deployed
|
||||||
* @param unk na
|
* @param action na
|
||||||
* @param count the number of this type of object deployed
|
* @param count the number of this type of object deployed
|
||||||
* @param max the maximum number of this type of object that can be deployed
|
* @param max the maximum number of this type of object that can be deployed
|
||||||
* @return an `ObjectDeployedMessage` object
|
* @return an `ObjectDeployedMessage` object
|
||||||
*/
|
*/
|
||||||
def apply(desc : String, unk : Long, count : Long, max : Long) : ObjectDeployedMessage =
|
def apply(desc : String, action : DeploymentOutcome.Value, count : Long, max : Long) : ObjectDeployedMessage =
|
||||||
new ObjectDeployedMessage(PlanetSideGUID(0), desc, unk, count, max)
|
new ObjectDeployedMessage(0, desc, action, count, max)
|
||||||
|
|
||||||
implicit val codec : Codec[ObjectDeployedMessage] = (
|
implicit val codec : Codec[ObjectDeployedMessage] = (
|
||||||
("object_guid" | PlanetSideGUID.codec) ::
|
("unk" | uint16L) ::
|
||||||
("desc" | PacketHelpers.encodedString) ::
|
("desc" | PacketHelpers.encodedString) ::
|
||||||
("unk" | uint32L) ::
|
("action" | DeploymentOutcome.codec) ::
|
||||||
("count" | uint32L) ::
|
("count" | uint32L) ::
|
||||||
("max" | uint32L)
|
("max" | uint32L)
|
||||||
).xmap[ObjectDeployedMessage] (
|
).xmap[ObjectDeployedMessage] (
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ package game
|
||||||
import org.specs2.mutable._
|
import org.specs2.mutable._
|
||||||
import net.psforever.packet._
|
import net.psforever.packet._
|
||||||
import net.psforever.packet.game._
|
import net.psforever.packet.game._
|
||||||
import net.psforever.types.Vector3
|
|
||||||
import scodec.bits._
|
import scodec.bits._
|
||||||
|
|
||||||
class ObjectDeployedMessageTest extends Specification {
|
class ObjectDeployedMessageTest extends Specification {
|
||||||
|
|
@ -12,10 +11,10 @@ class ObjectDeployedMessageTest extends Specification {
|
||||||
|
|
||||||
"decode" in {
|
"decode" in {
|
||||||
PacketCoding.DecodePacket(string_boomer).require match {
|
PacketCoding.DecodePacket(string_boomer).require match {
|
||||||
case ObjectDeployedMessage(guid : PlanetSideGUID, desc : String, unk : Long, count : Long, max : Long) =>
|
case ObjectDeployedMessage(unk : Int, desc : String, act : DeploymentOutcome.Value, count : Long, max : Long) =>
|
||||||
guid mustEqual PlanetSideGUID(0)
|
unk mustEqual 0
|
||||||
desc mustEqual "boomer"
|
desc mustEqual "boomer"
|
||||||
unk mustEqual 4
|
act mustEqual DeploymentOutcome.Success
|
||||||
count mustEqual 1
|
count mustEqual 1
|
||||||
max mustEqual 25
|
max mustEqual 25
|
||||||
case _ =>
|
case _ =>
|
||||||
|
|
@ -24,7 +23,7 @@ class ObjectDeployedMessageTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"encode" in {
|
||||||
val msg = ObjectDeployedMessage("boomer", 4, 1, 25)
|
val msg = ObjectDeployedMessage("boomer", DeploymentOutcome.Success, 1, 25)
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string_boomer
|
pkt mustEqual string_boomer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue