mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-04-29 16:25:30 +00:00
Revised decoding/encoding for CaptureFlagData
This commit is contained in:
parent
805847793f
commit
5d8d4609a8
2 changed files with 19 additions and 29 deletions
|
|
@ -16,19 +16,18 @@ import shapeless.{::, HNil}
|
||||||
* Whenever an applicable player is nearby, that client will rapidly fire off `ItemUseMessage` packets to the server.
|
* Whenever an applicable player is nearby, that client will rapidly fire off `ItemUseMessage` packets to the server.
|
||||||
* The capture flag will be picked-up by the player and stored in a special slot that is not part of their inventory.
|
* The capture flag will be picked-up by the player and stored in a special slot that is not part of their inventory.
|
||||||
* A special dropping keybind has been prepared to relinquish the capture flag back to the game world.
|
* A special dropping keybind has been prepared to relinquish the capture flag back to the game world.
|
||||||
|
* @param pos the position + orientation + velocity of the LLU where it is dropped/spawned
|
||||||
* @param faction the empire whose players may interact with this capture flag
|
* @param faction the empire whose players may interact with this capture flag
|
||||||
* @param unk1 na
|
* @param owningBaseGuid The GUID of the base that this LLU belongs to
|
||||||
* @param unk2 na
|
* @param targetBaseGuid The GUID of the base that this LLU must be taken to
|
||||||
* @param unk3 na
|
* @param milliseconds_remaining The number of milliseconds left on the timer for this LLU - should match the CC timer
|
||||||
* @param unk4 na
|
|
||||||
*/
|
*/
|
||||||
final case class CaptureFlagData(
|
final case class CaptureFlagData(
|
||||||
pos: PlacementData,
|
pos: PlacementData,
|
||||||
faction: PlanetSideEmpire.Value,
|
faction: PlanetSideEmpire.Value,
|
||||||
unk1: Int,
|
owningBaseGuid : Int,
|
||||||
unk2: Int,
|
targetBaseGuid : Int,
|
||||||
unk3: Int,
|
milliseconds_remaining : Long
|
||||||
unk4: Int
|
|
||||||
) extends ConstructorData {
|
) extends ConstructorData {
|
||||||
override def bitsize: Long = 88L + pos.bitsize
|
override def bitsize: Long = 88L + pos.bitsize
|
||||||
}
|
}
|
||||||
|
|
@ -40,24 +39,23 @@ object CaptureFlagData extends Marshallable[CaptureFlagData] {
|
||||||
bool ::
|
bool ::
|
||||||
uint4L ::
|
uint4L ::
|
||||||
uint16L ::
|
uint16L ::
|
||||||
("unk1" | uint8L) ::
|
("owningBaseGuid" | uint8L) ::
|
||||||
uint8L ::
|
uint8L ::
|
||||||
("unk2" | uint8L) ::
|
("targetBaseGuid" | uint8L) ::
|
||||||
uint8L ::
|
uint8L ::
|
||||||
("unk3" | uint16L) :: //probably a PlanetSideGUID
|
("milliseconds_remaining" | uint32L) ::
|
||||||
("unk4" | uint8L) ::
|
uint(1)
|
||||||
uint(9)
|
|
||||||
).exmap[CaptureFlagData](
|
).exmap[CaptureFlagData](
|
||||||
{
|
{
|
||||||
case pos :: fac :: false :: 4 :: 0 :: unk1 :: 0 :: unk2 :: 0 :: unk3 :: unk4 :: 0 :: HNil =>
|
case pos :: faction :: false :: 4 :: 0 :: owningBaseGuid :: 0 :: targetBaseGuid :: 0 :: milliseconds_remaining :: 0 :: HNil =>
|
||||||
Attempt.Successful(CaptureFlagData(pos, fac, unk1, unk2, unk3, unk4))
|
Attempt.Successful(CaptureFlagData(pos, faction, owningBaseGuid, targetBaseGuid, milliseconds_remaining))
|
||||||
|
|
||||||
case data =>
|
case data =>
|
||||||
Attempt.failure(Err(s"invalid capture flag data format - $data"))
|
Attempt.failure(Err(s"invalid capture flag data format - $data"))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
case CaptureFlagData(pos, fac, unk1, unk2, unk3, unk4) =>
|
case CaptureFlagData(pos, faction, owningBaseGuid, targetBaseGuid, milliseconds_remaining) =>
|
||||||
Attempt.successful(pos :: fac :: false :: 4 :: 0 :: unk1 :: 0 :: unk2 :: 0 :: unk3 :: unk4 :: 0 :: HNil)
|
Attempt.successful(pos :: faction :: false :: 4 :: 0 :: owningBaseGuid :: 0 :: targetBaseGuid :: 0 :: milliseconds_remaining :: 0 :: HNil)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,24 +29,16 @@ class CaptureFlagDataTest extends Specification {
|
||||||
flag.pos.orient.y mustEqual 0f
|
flag.pos.orient.y mustEqual 0f
|
||||||
flag.pos.orient.z mustEqual 47.8125f
|
flag.pos.orient.z mustEqual 47.8125f
|
||||||
flag.faction mustEqual PlanetSideEmpire.NC
|
flag.faction mustEqual PlanetSideEmpire.NC
|
||||||
flag.unk1 mustEqual 21
|
flag.owningBaseGuid mustEqual 21
|
||||||
flag.unk2 mustEqual 4
|
flag.targetBaseGuid mustEqual 4
|
||||||
flag.unk3 mustEqual 2838
|
flag.milliseconds_remaining mustEqual 592662
|
||||||
flag.unk4 mustEqual 9
|
|
||||||
case _ =>
|
case _ =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode" in {
|
"encode" in {
|
||||||
val obj = CaptureFlagData(
|
val obj = CaptureFlagData(PlacementData(3912.0312f, 5169.4375f, 59.96875f, 0f, 0f, 47.8125f), PlanetSideEmpire.NC, 21, 4, 2838)
|
||||||
PlacementData(3912.0312f, 5169.4375f, 59.96875f, 0f, 0f, 47.8125f),
|
|
||||||
PlanetSideEmpire.NC,
|
|
||||||
21,
|
|
||||||
4,
|
|
||||||
2838,
|
|
||||||
9
|
|
||||||
)
|
|
||||||
val msg = ObjectCreateMessage(ObjectClass.capture_flag, PlanetSideGUID(4330), obj)
|
val msg = ObjectCreateMessage(ObjectClass.capture_flag, PlanetSideGUID(4330), obj)
|
||||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||||
pkt mustEqual string_captureflag
|
pkt mustEqual string_captureflag
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue