clarifying the unknwon fields and adding an enumeration for one of them

This commit is contained in:
FateJH 2017-04-23 02:09:24 -04:00
parent 261cea9269
commit 25864c87c1
2 changed files with 40 additions and 23 deletions

View file

@ -7,29 +7,47 @@ import scodec.codecs._
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>
* This packet does not actually modify anything in regards to deployables.
* It merely generates the message:<br>
* `"You have placed x of a possible y thing."`<br>
* The most common form of the generated message is:<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;
* `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.
* This text is not directly placed into the message's field but, rather, is a token for language-appropriate descriptive text.<br>
* "boomer," for example, is replaced by "Heavy Explosive Mines" in the message for English language.
* @param guid na;
* and, `thing` is the token for objects of this type.
* If the `thing` is a valid string token, it will be replaced by language-appropriate descriptive text in the message.
* Otherwise, that text is placed directly into the message, with an obvious space between the text and the "s".
* "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?
* @param desc descriptive text of what kind of object is being deployed;
* matches the `String` description of the object class
* @param unk na;
* usually 4
* string token of the object, at best
* @param action the form the message will take
* @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
* @see `ObjectClass`
*/
final case class ObjectDeployedMessage(guid : PlanetSideGUID,
final case class ObjectDeployedMessage(unk : Int,
desc : String,
unk : Long,
action : DeploymentOutcome.Value,
count : Long,
max : Long)
extends PlanetSideGamePacket {
@ -42,18 +60,18 @@ object ObjectDeployedMessage extends Marshallable[ObjectDeployedMessage] {
/**
* Overloaded constructor for when the guid is not required.
* @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 max the maximum number of this type of object that can be deployed
* @return an `ObjectDeployedMessage` object
*/
def apply(desc : String, unk : Long, count : Long, max : Long) : ObjectDeployedMessage =
new ObjectDeployedMessage(PlanetSideGUID(0), desc, unk, count, max)
def apply(desc : String, action : DeploymentOutcome.Value, count : Long, max : Long) : ObjectDeployedMessage =
new ObjectDeployedMessage(0, desc, action, count, max)
implicit val codec : Codec[ObjectDeployedMessage] = (
("object_guid" | PlanetSideGUID.codec) ::
("unk" | uint16L) ::
("desc" | PacketHelpers.encodedString) ::
("unk" | uint32L) ::
("action" | DeploymentOutcome.codec) ::
("count" | uint32L) ::
("max" | uint32L)
).xmap[ObjectDeployedMessage] (

View file

@ -4,7 +4,6 @@ package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.Vector3
import scodec.bits._
class ObjectDeployedMessageTest extends Specification {
@ -12,10 +11,10 @@ class ObjectDeployedMessageTest extends Specification {
"decode" in {
PacketCoding.DecodePacket(string_boomer).require match {
case ObjectDeployedMessage(guid : PlanetSideGUID, desc : String, unk : Long, count : Long, max : Long) =>
guid mustEqual PlanetSideGUID(0)
case ObjectDeployedMessage(unk : Int, desc : String, act : DeploymentOutcome.Value, count : Long, max : Long) =>
unk mustEqual 0
desc mustEqual "boomer"
unk mustEqual 4
act mustEqual DeploymentOutcome.Success
count mustEqual 1
max mustEqual 25
case _ =>
@ -24,7 +23,7 @@ class ObjectDeployedMessageTest extends Specification {
}
"encode" in {
val msg = ObjectDeployedMessage("boomer", 4, 1, 25)
val msg = ObjectDeployedMessage("boomer", DeploymentOutcome.Success, 1, 25)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string_boomer