mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-07-16 08:55:18 +00:00
recalcalating name offsets for later; primary test is this player-driven AMS (see PSMU for details)
This commit is contained in:
parent
70c4393e9b
commit
9607648e6a
9 changed files with 59 additions and 36 deletions
|
|
@ -217,9 +217,12 @@ class SessionData(
|
|||
}
|
||||
}
|
||||
fallHeightTracker(pos.z)
|
||||
// if (isCrouching && !player.Crouching) {
|
||||
// //dev stuff goes here
|
||||
// }
|
||||
if (isCrouching && !player.Crouching) {
|
||||
import scodec.bits._
|
||||
// 17 B8010000 970 3D10 002D765535CA16000000 402285BB0037E 4100749E1D03000000620D83A0A00000195798741C00000332E40D84800000
|
||||
middlewareActor ! MiddlewareActor.Raw(hex"17 ec060000 970 fe0f 6C2D765535CA16000013 f9c1f2f80c000 1e18ff0000 105 1e4078640000000 8c50004c0041006d0069006e00670079007500650054005200 7c00000304217c859e8080000000000000002503420022c02a002a002a002a0050004c0041002a002a002a002a00010027e300940000016c0400023c040002285a086c2f00c80000000000300210288740800000004046f17423018000002c4d6190400000001010704a86406000002bc770842000000004041c5f21d01800000e075821902000000623e84208000001950588c1800000332ea0f840000000")
|
||||
//dev stuff goes here
|
||||
}
|
||||
player.Position = pos
|
||||
player.Velocity = vel
|
||||
player.Orientation = Vector3(player.Orientation.x, pitch, yaw)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import net.psforever.objects.Vehicle
|
|||
import net.psforever.packet.game.objectcreate.{UtilityVehicleData, VehicleFormat}
|
||||
|
||||
class UtilityVehicleConverter extends VehicleConverter {
|
||||
override protected def SpecificFormatModifier: VehicleFormat.Value = VehicleFormat.Utility
|
||||
override protected def SpecificFormatModifier: VehicleFormat = VehicleFormat.Utility
|
||||
|
||||
override protected def SpecificFormatData(obj: Vehicle) = Some(UtilityVehicleData(0))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import net.psforever.objects.Vehicle
|
|||
import net.psforever.packet.game.objectcreate.{VariantVehicleData, VehicleFormat}
|
||||
|
||||
class VariantVehicleConverter extends VehicleConverter {
|
||||
override protected def SpecificFormatModifier: VehicleFormat.Value = VehicleFormat.Variant
|
||||
override protected def SpecificFormatModifier: VehicleFormat = VehicleFormat.Variant
|
||||
|
||||
override protected def SpecificFormatData(obj: Vehicle) = {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class VehicleConverter extends ObjectCreateConverter[Vehicle]() {
|
|||
}
|
||||
}
|
||||
|
||||
protected def SpecificFormatModifier: VehicleFormat.Value = VehicleFormat.Normal
|
||||
protected def SpecificFormatModifier: VehicleFormat = VehicleFormat.Normal
|
||||
|
||||
protected def SpecificFormatData(obj: Vehicle): Option[SpecificVehicleData] = None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ object CharacterAppearanceData extends Marshallable[CharacterAppearanceData] {
|
|||
def a_codec(name_padding: Int): Codec[CharacterAppearanceA] =
|
||||
(
|
||||
("data" | CommonFieldData.codec) >>:~ { data =>
|
||||
("name" | PacketHelpers.encodedWideStringAligned(namePadding(name_padding, data.v2))) ::
|
||||
("name" | PacketHelpers.encodedWideStringAligned(namePadding(name_padding, data.v2))) >>:~ { name =>
|
||||
("exosuit" | ExoSuitType.codec) ::
|
||||
("unk5" | uint2) :: //unknown
|
||||
("sex" | CharacterSex.codec) ::
|
||||
|
|
@ -312,7 +312,7 @@ object CharacterAppearanceData extends Marshallable[CharacterAppearanceData] {
|
|||
("unk8" | uint16L) ::
|
||||
("unk9" | uint16L) ::
|
||||
("unkA" | uint16L) //usually either 0 or 65535
|
||||
}
|
||||
}}
|
||||
).exmap[CharacterAppearanceA](
|
||||
{
|
||||
case data :: name :: suit :: u5 :: sex :: head :: v1 :: u6 :: u7 :: u8 :: u9 :: uA :: HNil =>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ object MountableInventory {
|
|||
* @param format the subtype for this vehicle
|
||||
* @return a `Codec` that translates `InventoryData`
|
||||
*/
|
||||
def custom_inventory_codec(hasVelocity: Boolean, format: VehicleFormat.Type): Codec[InventoryData] =
|
||||
def custom_inventory_codec(hasVelocity: Boolean, format: VehicleFormat): Codec[InventoryData] =
|
||||
custom_inventory_codec(InitialStreamLengthToSeatEntries(hasVelocity, format))
|
||||
|
||||
/**
|
||||
|
|
@ -136,16 +136,8 @@ object MountableInventory {
|
|||
* @param format the subtype for this vehicle
|
||||
* @return the length of the bitstream
|
||||
*/
|
||||
def InitialStreamLengthToSeatEntries(hasVelocity: Boolean, format: VehicleFormat.Type): Long = {
|
||||
198 +
|
||||
(if (hasVelocity) 42 else 0) +
|
||||
(format match {
|
||||
case VehicleFormat.Utility => 6
|
||||
case VehicleFormat.Variant => 8
|
||||
case VehicleFormat.Battleframe => 1
|
||||
case VehicleFormat.BattleframeFlight => 2
|
||||
case _ => 0
|
||||
})
|
||||
def InitialStreamLengthToSeatEntries(hasVelocity: Boolean, format: VehicleFormat): Long = {
|
||||
198 + (if (hasVelocity) 42 else 0) + format.value
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,20 +7,29 @@ import scodec.{Attempt, Codec, Err}
|
|||
import shapeless.HNil
|
||||
import scodec.codecs._
|
||||
import net.psforever.types.DriveState
|
||||
import enumeratum.values.{IntEnum, IntEnumEntry}
|
||||
|
||||
/**
|
||||
* An `Enumeration` of the various formats that known structures that the stream of bits for `VehicleData` can assume.
|
||||
* An enumeration of the various formats that known structures that the stream of bits for `VehicleData` can assume.
|
||||
*/
|
||||
object VehicleFormat extends Enumeration {
|
||||
type Type = Value
|
||||
sealed abstract class VehicleFormat(val value: Int) extends IntEnumEntry
|
||||
|
||||
val Battleframe, BattleframeFlight, Normal, Utility, Variant = Value
|
||||
object VehicleFormat extends IntEnum[VehicleFormat] {
|
||||
val values = findValues
|
||||
|
||||
case object Normal extends VehicleFormat(value = 0)
|
||||
case object Battleframe extends VehicleFormat(value = 1)
|
||||
case object BattleframeFlight extends VehicleFormat(value = 2)
|
||||
case object Utility extends VehicleFormat(value = 6)
|
||||
case object Variant extends VehicleFormat(value = 8)
|
||||
|
||||
//val Battleframe, BattleframeFlight, Normal, Utility, Variant = Value
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic `Trait` connecting all of the vehicle data formats (excepting `Normal`/`None`).
|
||||
*/
|
||||
sealed abstract class SpecificVehicleData(val format: VehicleFormat.Value) extends StreamBitSize
|
||||
sealed abstract class SpecificVehicleData(val format: VehicleFormat) extends StreamBitSize
|
||||
|
||||
/**
|
||||
* The format of vehicle data for the type of vehicles that are considered "utility."
|
||||
|
|
@ -84,7 +93,7 @@ final case class VehicleData(
|
|||
cloak: Boolean,
|
||||
vehicle_format_data: Option[SpecificVehicleData],
|
||||
inventory: Option[InventoryData] = None
|
||||
)(val vehicle_type: VehicleFormat.Value = VehicleFormat.Normal)
|
||||
)(val vehicle_type: VehicleFormat = VehicleFormat.Normal)
|
||||
extends ConstructorData {
|
||||
override def bitsize: Long = {
|
||||
//factor guard bool values into the base size, not its corresponding optional field
|
||||
|
|
@ -174,7 +183,7 @@ object VehicleData extends Marshallable[VehicleData] {
|
|||
*/
|
||||
private val utility_data_codec: Codec[SpecificVehicleData] = {
|
||||
import shapeless.::
|
||||
uintL(6).hlist.exmap[SpecificVehicleData](
|
||||
uintL(VehicleFormat.Utility.value).hlist.exmap[SpecificVehicleData](
|
||||
{
|
||||
case n :: HNil =>
|
||||
Successful(UtilityVehicleData(n).asInstanceOf[SpecificVehicleData])
|
||||
|
|
@ -193,7 +202,7 @@ object VehicleData extends Marshallable[VehicleData] {
|
|||
*/
|
||||
private val variant_data_codec: Codec[SpecificVehicleData] = {
|
||||
import shapeless.::
|
||||
uint8L.hlist.exmap[SpecificVehicleData](
|
||||
uintL(VehicleFormat.Variant.value).hlist.exmap[SpecificVehicleData](
|
||||
{
|
||||
case n :: HNil =>
|
||||
Successful(VariantVehicleData(n).asInstanceOf[SpecificVehicleData])
|
||||
|
|
@ -212,7 +221,7 @@ object VehicleData extends Marshallable[VehicleData] {
|
|||
* @param vehicleFormat the requested format
|
||||
* @return the appropriate `Codec` for parsing that format
|
||||
*/
|
||||
private def selectFormatReader(vehicleFormat: VehicleFormat.Value): Codec[SpecificVehicleData] =
|
||||
private def selectFormatReader(vehicleFormat: VehicleFormat): Codec[SpecificVehicleData] =
|
||||
vehicleFormat match {
|
||||
case VehicleFormat.Utility =>
|
||||
utility_data_codec
|
||||
|
|
@ -223,7 +232,7 @@ object VehicleData extends Marshallable[VehicleData] {
|
|||
.asInstanceOf[Codec[SpecificVehicleData]]
|
||||
}
|
||||
|
||||
def codec(vehicle_type: VehicleFormat.Value): Codec[VehicleData] = {
|
||||
def codec(vehicle_type: VehicleFormat): Codec[VehicleData] = {
|
||||
import shapeless.::
|
||||
(
|
||||
("pos" | PlacementData.codec) >>:~ { pos =>
|
||||
|
|
@ -237,7 +246,7 @@ object VehicleData extends Marshallable[VehicleData] {
|
|||
("unk6" | bool) ::
|
||||
("cloak" | bool) :: //cloak as wraith, phantasm
|
||||
conditional(vehicle_type != VehicleFormat.Normal,"vehicle_format_data" | selectFormatReader(vehicle_type)) ::
|
||||
optional(bool, target = "inventory" | MountableInventory.custom_inventory_codec(pos.vel.isDefined, VehicleFormat.Normal))
|
||||
optional(bool, target = "inventory" | MountableInventory.custom_inventory_codec(pos.vel.isDefined, vehicle_type))
|
||||
}
|
||||
).exmap[VehicleData](
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import scodec.codecs._
|
|||
/**
|
||||
* An `Enumeration` of the kinds of states applicable to the grenade animation.
|
||||
*/
|
||||
object GrenadeState extends Enumeration(1) {
|
||||
object GrenadeState extends Enumeration {
|
||||
type Type = Value
|
||||
|
||||
val Primed, //avatars and other depicted player characters
|
||||
Thrown, //avatars only
|
||||
None //non-actionable state of rest
|
||||
val
|
||||
Non, //non-actionable state of rest
|
||||
Primed, //avatars and other depicted player characters
|
||||
Thrown, //avatars only
|
||||
None //non-actionable state of rest
|
||||
= Value
|
||||
|
||||
implicit val codec = PacketHelpers.createEnumerationCodec(this, uint8L)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class UtilityVehiclesTest extends Specification {
|
|||
val string_ant = hex"17 C2000000 9E0 7C01 6C2D7 65535 CA16 00 00 00 4400003FC000000"
|
||||
val string_ams =
|
||||
hex"17 B8010000 970 3D10 002D765535CA16000000 402285BB0037E4100749E1D03000000620D83A0A00000195798741C00000332E40D84800000"
|
||||
// val string_ams_seated =
|
||||
// hex"17ec060000970fe0f030898abda28127f007ff9c1f2f80c0001e18ff00001051e40786400000008c50004c0041006d0069006e006700790075006500540052007c00000304217c859e8080000000000000002503420022c02a002a002a002a0050004c0041002a002a002a002a00010027e300940000016c0400023c040002285a086c2f00c80000000000300210288740800000004046f17423018000002c4d6190400000001010704a86406000002bc770842000000004041c5f21d01800000e075821902000000623e84208000001950588c1800000332ea0f840000000"
|
||||
val string_ams_seated =
|
||||
hex"17ec060000970fe0f030898abda28127f007ff9c1f2f80c0001e18ff00001051e40786400000008c50004c0041006d0069006e006700790075006500540052007c00000304217c859e8080000000000000002503420022c02a002a002a002a0050004c0041002a002a002a002a00010027e300940000016c0400023c040002285a086c2f00c80000000000300210288740800000004046f17423018000002c4d6190400000001010704a86406000002bc770842000000004041c5f21d01800000e075821902000000623e84208000001950588c1800000332ea0f840000000"
|
||||
|
||||
"Utility vehicles" should {
|
||||
"decode (ant)" in {
|
||||
|
|
@ -95,6 +95,23 @@ class UtilityVehiclesTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"decode (ams, seated)" in {
|
||||
PacketCoding.decodePacket(string_ams_seated).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, None, data) =>
|
||||
len mustEqual 440L
|
||||
cls mustEqual ObjectClass.ams
|
||||
guid mustEqual PlanetSideGUID(4157)
|
||||
data match {
|
||||
case ams: VehicleData =>
|
||||
ok
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (ant)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(3674.8438f, 2726.789f, 91.15625f, 0f, 0f, 90.0f),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue