From 7cd9b8f5f14bb279c3c40829f800b491213eb9b9 Mon Sep 17 00:00:00 2001 From: FateJH Date: Fri, 2 Dec 2016 18:44:40 -0500 Subject: [PATCH] ignoring the inventory, character stream decoding is functional --- .../packet/game/ObjectCreateMessage.scala | 104 +++++++++--------- common/src/test/scala/GamePacketTest.scala | 29 ++++- 2 files changed, 77 insertions(+), 56 deletions(-) diff --git a/common/src/main/scala/net/psforever/packet/game/ObjectCreateMessage.scala b/common/src/main/scala/net/psforever/packet/game/ObjectCreateMessage.scala index dd211a764..05e159266 100644 --- a/common/src/main/scala/net/psforever/packet/game/ObjectCreateMessage.scala +++ b/common/src/main/scala/net/psforever/packet/game/ObjectCreateMessage.scala @@ -91,28 +91,28 @@ case class CharacterData(pos : Vector3, unk3 : Int, //2 viewPitch : Int, viewYaw : Int, - upperMerit : Int, //0xFFFF means no merit (for all ...) - middleMerit : Int, - lowerMerit : Int, - termOfServiceMerit : Int, -// healthMax : Int, -// health : Int, -// armor : Int, -// unk4 : Int, //1 -// unk5 : Int, //7 -// unk6 : Int, //7 -// staminaMax : Int, -// stamina : Int, -// unk7 : Int, // 192 -// unk8 : Int, //66 -// unk9 : Int, //197 -// unk10 : Int, //70 -// unk11 : Int, //134 -// unk12 : Int, //199 -// firstTimeEvent_length : Long, -// firstEntry : Option[String], -// firstTimeEvent_list : List[String], -// tutorial_list : List[String], + upperMerit : Long, //0xFFFFFFFF means no merit (for all ...) + middleMerit : Long, + lowerMerit : Long, + termOfServiceMerit : Long, + healthMax : Int, + health : Int, + armor : Int, + unk4 : Int, //1 + unk5 : Int, //7 + unk6 : Int, //7 + staminaMax : Int, + stamina : Int, + unk7 : Int, // 28 + unk8 : Int, //4 + unk9 : Int, //44 + unk10 : Int, //84 + unk11 : Int, //104 + unk12 : Int, //1900 + firstTimeEvent_length : Long, + firstEntry : Option[String], + firstTimeEvent_list : List[String], + tutorial_list : List[String], inventory : BitVector ) extends ConstructorData @@ -149,37 +149,37 @@ object CharacterData extends Marshallable[CharacterData] { ("viewPitch" | uint8L) :: ("viewYaw" | uint8L) :: ignore(10) :: - ("upperMerit" | uint16L) :: - ("middleMerit" | uint16L) :: - ("lowerMerit" | uint16L) :: - ("termOfServiceMerit" | uint16L) :: -// ignore(160) :: -// ("healthMax" | uint16L) :: -// ("health" | uint16L) :: -// ignore(1) :: -// ("armor" | uint16L) :: -// ignore(9) :: -// ("unk4" | uint8L) :: -// ignore(8) :: -// ("unk5" | uint4L) :: -// ("unk6" | uintL(3)) :: -// ("staminaMax" | uint16L) :: -// ("stamina" | uint16L) :: -// ignore(152) :: -// ("unk7" | uint16L) :: -// ("unk8" | uint8L) :: -// ("unk9" | uint8L) :: -// ("unk10" | uint8L) :: -// ("unk11" | uint8L) :: -// ("unk12" | uintL(12)) :: -// ignore(3) :: -// (("firstTimeEvent_length" | uint32L) >>:~ { len => -// conditional(len > 0, "firstEntry" | PacketHelpers.encodedStringAligned(5)) :: -// ("firstTimeEvent_list" | PacketHelpers.listOfNSized(len - 1, PacketHelpers.encodedString)) :: -// ("tutorial_list" | PacketHelpers.listOfNAligned(uint32L, 0, PacketHelpers.encodedString)) :: -// ignore(207) :: + ("upperMerit" | uint32L) :: + ("middleMerit" | uint32L) :: + ("lowerMerit" | uint32L) :: + ("termOfServiceMerit" | uint32L) :: + ignore(160) :: + ("healthMax" | uint16L) :: + ("health" | uint16L) :: + ignore(1) :: + ("armor" | uint16L) :: + ignore(9) :: + ("unk4" | uint8L) :: + ignore(8) :: + ("unk5" | uint4L) :: + ("unk6" | uintL(3)) :: + ("staminaMax" | uint16L) :: + ("stamina" | uint16L) :: + ignore(149) :: + ("unk7" | uint16L) :: + ("unk8" | uint8L) :: + ("unk9" | uint8L) :: + ("unk10" | uint8L) :: + ("unk11" | uint8L) :: + ("unk12" | uintL(12)) :: + ignore(19) :: + (("firstTimeEvent_length" | uint32L) >>:~ { len => + conditional(len > 0, "firstEntry" | PacketHelpers.encodedStringAligned(5)) :: + ("firstTimeEvent_list" | PacketHelpers.listOfNSized(len - 1, PacketHelpers.encodedString)) :: + ("tutorial_list" | PacketHelpers.listOfNAligned(uint32L, 0, PacketHelpers.encodedString)) :: + ignore(207) :: ("inventory" | bits) -// }) + }) ).as[CharacterData] } diff --git a/common/src/test/scala/GamePacketTest.scala b/common/src/test/scala/GamePacketTest.scala index 0dce99160..5355a4953 100644 --- a/common/src/test/scala/GamePacketTest.scala +++ b/common/src/test/scala/GamePacketTest.scala @@ -193,10 +193,31 @@ class GamePacketTest extends Specification { char.unk3 mustEqual 2 char.viewPitch mustEqual 0xFF char.viewYaw mustEqual 0x6A - char.upperMerit mustEqual 0xFFFF //none - char.middleMerit mustEqual 0xFFFF //none - char.lowerMerit mustEqual 0xFFFF //none - char.termOfServiceMerit mustEqual 0xFFFF //none + char.upperMerit mustEqual 0xFFFFFFFFL //none + char.middleMerit mustEqual 0xFFFFFFFFL //none + char.lowerMerit mustEqual 0xFFFFFFFFL //none + char.termOfServiceMerit mustEqual 0xFFFFFFFFL //none + char.healthMax mustEqual 100 + char.health mustEqual 100 + char.armor mustEqual 50 //standard exosuit value + char.unk4 mustEqual 1 + char.unk5 mustEqual 7 + char.unk6 mustEqual 7 + char.staminaMax mustEqual 100 + char.stamina mustEqual 100 + char.unk7 mustEqual 28 + char.unk8 mustEqual 4 + char.unk9 mustEqual 44 + char.unk10 mustEqual 84 + char.unk11 mustEqual 104 + char.unk12 mustEqual 1900 + char.firstTimeEvent_length mustEqual 4 + char.firstEntry mustEqual Some("xpe_sanctuary_help") + char.firstTimeEvent_list.size mustEqual 3 + char.firstTimeEvent_list.head mustEqual "xpe_th_firemodes" + char.firstTimeEvent_list(1) mustEqual "used_beamer" + char.firstTimeEvent_list(2) mustEqual "map13" + char.tutorial_list.size mustEqual 0 case default => ko }