mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-04 12:40:20 +00:00
Add BailType enumeration and update parameters for vehicle dismounting with correct naming and type
This commit is contained in:
parent
cfe2dffa44
commit
6f65603942
8 changed files with 52 additions and 33 deletions
|
|
@ -4,16 +4,17 @@ package net.psforever.packet.game
|
|||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
import net.psforever.types.BailType
|
||||
|
||||
/**
|
||||
* Dispatched by the client when the player wishes to get out of a vehicle.
|
||||
* @param player_guid the player
|
||||
* @param unk1 na
|
||||
* @param bailType The dismount action e.g. normal dismount, kicked by owner, bailed
|
||||
* @param unk2 na
|
||||
*/
|
||||
final case class DismountVehicleMsg(player_guid : PlanetSideGUID,
|
||||
unk1 : Int, //maybe, seat number?
|
||||
unk2 : Boolean) //maybe, bailing?
|
||||
bailType : BailType.Value,
|
||||
wasKickedByDriver : Boolean) // Seems to be true if a passenger was manually kicked by the vehicle owner
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = DismountVehicleMsg
|
||||
def opcode = GamePacketOpcode.DismountVehicleMsg
|
||||
|
|
@ -23,7 +24,7 @@ final case class DismountVehicleMsg(player_guid : PlanetSideGUID,
|
|||
object DismountVehicleMsg extends Marshallable[DismountVehicleMsg] {
|
||||
implicit val codec : Codec[DismountVehicleMsg] = (
|
||||
("player_guid" | PlanetSideGUID.codec) ::
|
||||
("unk1" | uint4L) ::
|
||||
("unk2" | bool)
|
||||
("bailType" | BailType.codec) ::
|
||||
("wasKickedByDriver" | bool)
|
||||
).as[DismountVehicleMsg]
|
||||
}
|
||||
|
|
|
|||
15
common/src/main/scala/net/psforever/types/BailType.scala
Normal file
15
common/src/main/scala/net/psforever/types/BailType.scala
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.types
|
||||
|
||||
import net.psforever.packet.PacketHelpers
|
||||
import scodec.codecs._
|
||||
|
||||
object BailType extends Enumeration {
|
||||
type Type = Value
|
||||
|
||||
val Normal = Value(0)
|
||||
val Kicked = Value(4) // User was kicked out by vehicle owner or locked from vehicle
|
||||
val Bailed = Value(8) // User bailed out
|
||||
|
||||
implicit val codec = PacketHelpers.createEnumerationCodec(this, uint4L)
|
||||
}
|
||||
|
|
@ -5,23 +5,24 @@ import org.specs2.mutable._
|
|||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
import net.psforever.types.BailType
|
||||
|
||||
class DismountVehicleMsgTest extends Specification {
|
||||
val string = hex"0F C609 00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DismountVehicleMsg(player_guid, unk1, unk2) =>
|
||||
case DismountVehicleMsg(player_guid, bailType, wasKickedByDriver) =>
|
||||
player_guid mustEqual PlanetSideGUID(2502)
|
||||
unk1 mustEqual 0
|
||||
unk2 mustEqual false
|
||||
bailType mustEqual 0
|
||||
wasKickedByDriver mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DismountVehicleMsg(PlanetSideGUID(2502), 0, false)
|
||||
val msg = DismountVehicleMsg(PlanetSideGUID(2502), BailType.Normal, false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue