Merge pull request #98 from Fate-JH/character-data-update

Proliferation of PlanetSideEmpire
This commit is contained in:
Fate-JH 2017-03-02 07:30:29 -05:00 committed by GitHub
commit d0636b2f93
12 changed files with 83 additions and 48 deletions

View file

@ -2,6 +2,7 @@
package net.psforever.packet.game package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket} import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import net.psforever.types.PlanetSideEmpire
import scodec.{Attempt, Codec, Err} import scodec.{Attempt, Codec, Err}
import scodec.codecs._ import scodec.codecs._
import shapeless.{::, HNil} import shapeless.{::, HNil}

View file

@ -2,8 +2,10 @@
package net.psforever.packet.game package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket} import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import scodec.Codec import net.psforever.types.PlanetSideEmpire
import scodec.{Attempt, Codec, Err}
import scodec.codecs._ import scodec.codecs._
import shapeless.{::, HNil}
object CharacterGender extends Enumeration(1) { object CharacterGender extends Enumeration(1) {
type Type = Value type Type = Value
@ -34,5 +36,17 @@ object CharacterCreateRequestMessage extends Marshallable[CharacterCreateRequest
("voiceId" | uint8L) :: ("voiceId" | uint8L) ::
("gender" | CharacterGender.codec) :: ("gender" | CharacterGender.codec) ::
("empire" | PlanetSideEmpire.codec) ("empire" | PlanetSideEmpire.codec)
).as[CharacterCreateRequestMessage] ).exmap[CharacterCreateRequestMessage] (
{
case name :: headId :: voiceId :: gender :: empire :: HNil =>
Attempt.successful(CharacterCreateRequestMessage(name, headId, voiceId, gender, empire))
},
{
case CharacterCreateRequestMessage(name, _, _, _, PlanetSideEmpire.NEUTRAL) =>
Attempt.failure(Err(s"character $name's faction can not declare as neutral"))
case CharacterCreateRequestMessage(name, headId, voiceId, gender, empire) =>
Attempt.successful(name :: headId :: voiceId :: gender :: empire :: HNil)
}
)
} }

View file

@ -2,21 +2,21 @@
package net.psforever.packet.game package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket} import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import net.psforever.types.PlanetSideEmpire
import scodec.Codec import scodec.Codec
import scodec.codecs._ import scodec.codecs._
/** /**
* Create a dispatched game packet that instructs the client to update the user about continents that are conquered. * Create a dispatched game packet that instructs the client to update the user about continents that are conquered.<br>
* * <br>
* This generates the event message "The [empire] have captured [continent]." * This generates the event message "The [empire] have captured [continent]."
* If the continent_guid is not a valid zone, no message is displayed. * If the continent_guid is not a valid zone, no message is displayed.
* If empire is not a valid empire, no message is displayed. * If empire is not a valid empire, or refers to the neutral or Black Ops forces, no message is displayed.
*
* @param continent_guid identifies the zone (continent) * @param continent_guid identifies the zone (continent)
* @param empire identifies the empire; this value is matchable against PlanetSideEmpire * @param empire identifies the empire
*/ */
final case class ContinentalLockUpdateMessage(continent_guid : PlanetSideGUID, final case class ContinentalLockUpdateMessage(continent_guid : PlanetSideGUID,
empire : PlanetSideEmpire.Value) // 00 for TR, 40 for NC, 80 for VS; C0 generates no message empire : PlanetSideEmpire.Value)
extends PlanetSideGamePacket { extends PlanetSideGamePacket {
type Packet = ContinentalLockUpdateMessage type Packet = ContinentalLockUpdateMessage
def opcode = GamePacketOpcode.ContinentalLockUpdateMessage def opcode = GamePacketOpcode.ContinentalLockUpdateMessage

View file

@ -2,6 +2,7 @@
package net.psforever.packet.game package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket} import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import net.psforever.types.PlanetSideEmpire
import scodec.Codec import scodec.Codec
import scodec.codecs._ import scodec.codecs._
@ -24,8 +25,8 @@ import scodec.codecs._
* In the case of absentee kills, for example, where there is no killer listed, this field has been zero'd (`00000000`).<br> * In the case of absentee kills, for example, where there is no killer listed, this field has been zero'd (`00000000`).<br>
* <br> * <br>
* The faction affiliation is different from the normal way `PlanetSideEmpire` values are recorded. * The faction affiliation is different from the normal way `PlanetSideEmpire` values are recorded.
* The higher nibble will reflect the first part of the `PlanetSideEmpire` value - `0` for TR, `4` for NC `8` for TR, `C` for Neutral/BOPs. * The higher nibble will reflect the first part of the `PlanetSideEmpire` value.
* An extra `20` will be added if the player is in a vehicle or turret at the time - `2` for TR, `6` for NC, `A` for VS, `E` for Neutral/BOPs. * An extra `20` will be added if the player is in a vehicle or turret at the time.
* When marked as being in a vehicle or turret, the player's name will be enclosed within square brackets. * When marked as being in a vehicle or turret, the player's name will be enclosed within square brackets.
* The length of the player's name found at the start of the wide character string does not reflect whether or not there will be square brackets (fortunately).<br> * The length of the player's name found at the start of the wide character string does not reflect whether or not there will be square brackets (fortunately).<br>
* <br> * <br>
@ -36,26 +37,24 @@ import scodec.codecs._
* It is also unknown what the two bytes preceding `method` specify, as changing them does nothing to the displayed message. * It is also unknown what the two bytes preceding `method` specify, as changing them does nothing to the displayed message.
* @param killer the name of the player who did the killing * @param killer the name of the player who did the killing
* @param killer_unk See above * @param killer_unk See above
* @param killer_empire the empire affiliation of the killer: * @param killer_empire the empire affiliation of the killer
* 0 - TR, 1 - NC, 2 - VS, 3 - Neutral/BOPs
* @param killer_inVehicle true, if the killer was in a vehicle at the time of the kill; false, otherwise * @param killer_inVehicle true, if the killer was in a vehicle at the time of the kill; false, otherwise
* @param unk na; but does not like being set to 0 * @param unk na; but does not like being set to 0
* @param method modifies the icon in the message, related to the way the victim was killed * @param method modifies the icon in the message, related to the way the victim was killed
* @param victim the name of the player who was killed * @param victim the name of the player who was killed
* @param victim_unk See above * @param victim_unk See above
* @param victim_empire the empire affiliation of the victim: * @param victim_empire the empire affiliation of the victim
* 0 - TR, 1 - NC, 2 - VS, 3 - Neutral/BOPs
* @param victim_inVehicle true, if the victim was in a vehicle when he was killed; false, otherwise * @param victim_inVehicle true, if the victim was in a vehicle when he was killed; false, otherwise
*/ */
final case class DestroyDisplayMessage(killer : String, final case class DestroyDisplayMessage(killer : String,
killer_unk : Long, killer_unk : Long,
killer_empire : Int, killer_empire : PlanetSideEmpire.Value,
killer_inVehicle : Boolean, killer_inVehicle : Boolean,
unk : PlanetSideGUID, unk : Int,
method : PlanetSideGUID, method : Int,
victim : String, victim : String,
victim_unk : Long, victim_unk : Long,
victim_empire : Int, victim_empire : PlanetSideEmpire.Value,
victim_inVehicle : Boolean victim_inVehicle : Boolean
) )
extends PlanetSideGamePacket { extends PlanetSideGamePacket {
@ -68,13 +67,13 @@ object DestroyDisplayMessage extends Marshallable[DestroyDisplayMessage] {
implicit val codec : Codec[DestroyDisplayMessage] = ( implicit val codec : Codec[DestroyDisplayMessage] = (
("killer" | PacketHelpers.encodedWideString) :: ("killer" | PacketHelpers.encodedWideString) ::
("killer_unk" | ulongL(32)) :: ("killer_unk" | ulongL(32)) ::
("killer_empire" | uintL(2)) :: ("killer_empire" | PlanetSideEmpire.codec) ::
("killer_inVehicle" | bool) :: ("killer_inVehicle" | bool) ::
("unk" | PlanetSideGUID.codec) :: ("unk" | uint16L) ::
("method" | PlanetSideGUID.codec) :: ("method" | uint16L) ::
("victim" | PacketHelpers.encodedWideStringAligned(5)) :: ("victim" | PacketHelpers.encodedWideStringAligned(5)) ::
("victim_unk" | ulongL(32)) :: ("victim_unk" | ulongL(32)) ::
("victim_empire" | uintL(2)) :: ("victim_empire" | PlanetSideEmpire.codec) ::
("victim_inVehicle" | bool) ("victim_inVehicle" | bool)
).as[DestroyDisplayMessage] ).as[DestroyDisplayMessage]
} }

View file

@ -2,6 +2,7 @@
package net.psforever.packet.game package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket} import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import net.psforever.types.PlanetSideEmpire
import scodec.Codec import scodec.Codec
import scodec.codecs._ import scodec.codecs._

View file

@ -4,6 +4,7 @@ package net.psforever.packet.game
import java.net.{InetAddress, InetSocketAddress} import java.net.{InetAddress, InetSocketAddress}
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket} import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import net.psforever.types.PlanetSideEmpire
import scodec._ import scodec._
import scodec.bits._ import scodec.bits._
import scodec.codecs._ import scodec.codecs._
@ -22,13 +23,6 @@ object ServerType extends Enumeration(1) {
implicit val codec = PacketHelpers.createEnumerationCodec(this, uint8L) implicit val codec = PacketHelpers.createEnumerationCodec(this, uint8L)
} }
object PlanetSideEmpire extends Enumeration {
type Type = Value
val TR, NC, VS, NEUTRAL = Value
implicit val codec = PacketHelpers.createEnumerationCodec(this, uint2L)
}
final case class WorldConnectionInfo(address : InetSocketAddress) final case class WorldConnectionInfo(address : InetSocketAddress)
final case class WorldInformation(name : String, status : WorldStatus.Value, final case class WorldInformation(name : String, status : WorldStatus.Value,

View file

@ -2,7 +2,7 @@
package net.psforever.packet.game.objectcreate package net.psforever.packet.game.objectcreate
import net.psforever.packet.{Marshallable, PacketHelpers} import net.psforever.packet.{Marshallable, PacketHelpers}
import net.psforever.types.Vector3 import net.psforever.types.{PlanetSideEmpire, Vector3}
import scodec.{Attempt, Codec, Err} import scodec.{Attempt, Codec, Err}
import scodec.codecs._ import scodec.codecs._
import shapeless.{::, HNil} import shapeless.{::, HNil}
@ -18,11 +18,6 @@ import shapeless.{::, HNil}
* This base length of this stream is __430__ known bits, excluding the length of the name and the padding on that name. * This base length of this stream is __430__ known bits, excluding the length of the name and the padding on that name.
* Of that, __203__ bits are perfectly unknown in significance. * Of that, __203__ bits are perfectly unknown in significance.
* <br> * <br>
* Faction:<br>
* `0 - Terran Republic`<br>
* `1 - New Conglomerate`<br>
* `2 - Vanu Sovereignty`<br>
* <br>
* Exo-suit:<br> * Exo-suit:<br>
* `0 - Agile`<br> * `0 - Agile`<br>
* `1 - Refinforced`<br> * `1 - Refinforced`<br>
@ -91,7 +86,7 @@ import shapeless.{::, HNil}
*/ */
final case class CharacterAppearanceData(pos : Vector3, final case class CharacterAppearanceData(pos : Vector3,
objYaw : Int, objYaw : Int,
faction : Int, faction : PlanetSideEmpire.Value,
bops : Boolean, bops : Boolean,
unk1 : Int, unk1 : Int,
name : String, name : String,
@ -138,7 +133,7 @@ object CharacterAppearanceData extends Marshallable[CharacterAppearanceData] {
ignore(16) :: ignore(16) ::
("objYaw" | uint8L) :: ("objYaw" | uint8L) ::
ignore(1) :: ignore(1) ::
("faction" | uint2L) :: ("faction" | PlanetSideEmpire.codec) ::
("bops" | bool) :: ("bops" | bool) ::
("unk1" | uint4L) :: ("unk1" | uint4L) ::
ignore(16) :: ignore(16) ::
@ -164,7 +159,23 @@ object CharacterAppearanceData extends Marshallable[CharacterAppearanceData] {
("unk8" | uint4L) :: ("unk8" | uint4L) ::
ignore(6) :: ignore(6) ::
("ribbons" | RibbonBars.codec) ("ribbons" | RibbonBars.codec)
).as[CharacterAppearanceData] ).exmap[CharacterAppearanceData] (
{
case a :: _ :: b :: _ :: c :: d :: e :: _ :: f :: g :: _ :: h :: i :: j :: k :: l :: _ :: m :: n :: o :: _ :: p :: _ :: q :: _ :: r :: s :: t :: _ :: u :: HNil =>
Attempt.successful(
CharacterAppearanceData(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)
)
},
{
case CharacterAppearanceData(_, _, PlanetSideEmpire.NEUTRAL, _, _, name, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
Attempt.failure(Err(s"character $name's faction can not declare as neutral"))
case CharacterAppearanceData(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) =>
Attempt.successful(
a :: () :: b :: () :: c :: d :: e :: () :: f :: g :: () :: h :: i :: j :: k :: l :: () :: m :: n :: o :: () :: p :: () :: q :: () :: r :: s :: t :: () :: u :: HNil
)
}
)
} }
/** /**

View file

@ -421,7 +421,6 @@ object ObjectClass {
case ObjectClass.battlewagon_weapon_systemb => WeaponData.genericCodec case ObjectClass.battlewagon_weapon_systemb => WeaponData.genericCodec
case ObjectClass.battlewagon_weapon_systemc => WeaponData.genericCodec case ObjectClass.battlewagon_weapon_systemc => WeaponData.genericCodec
case ObjectClass.battlewagon_weapon_systemd => WeaponData.genericCodec case ObjectClass.battlewagon_weapon_systemd => WeaponData.genericCodec
case ObjectClass.beamer => WeaponData.genericCodec
case ObjectClass.bolt_driver => WeaponData.genericCodec case ObjectClass.bolt_driver => WeaponData.genericCodec
case ObjectClass.chainblade => WeaponData.genericCodec case ObjectClass.chainblade => WeaponData.genericCodec
case ObjectClass.chaingun_p => WeaponData.genericCodec case ObjectClass.chaingun_p => WeaponData.genericCodec

View file

@ -0,0 +1,15 @@
// Copyright (c) 2016 PSForever.net to present
package net.psforever.types
import net.psforever.packet.PacketHelpers
import scodec.codecs.uint2L
/**
* Values for the three empires and the neutral/Black Ops group.
*/
object PlanetSideEmpire extends Enumeration {
type Type = Value
val TR, NC, VS, NEUTRAL = Value
implicit val codec = PacketHelpers.createEnumerationCodec(this, uint2L)
}

View file

@ -374,7 +374,7 @@ class GamePacketTest extends Specification {
char.appearance.pos.y mustEqual 2726.789f char.appearance.pos.y mustEqual 2726.789f
char.appearance.pos.z mustEqual 91.15625f char.appearance.pos.z mustEqual 91.15625f
char.appearance.objYaw mustEqual 19 char.appearance.objYaw mustEqual 19
char.appearance.faction mustEqual 2 //vs char.appearance.faction mustEqual PlanetSideEmpire.VS
char.appearance.bops mustEqual false char.appearance.bops mustEqual false
char.appearance.unk1 mustEqual 4 char.appearance.unk1 mustEqual 4
char.appearance.name mustEqual "IlllIIIlllIlIllIlllIllI" char.appearance.name mustEqual "IlllIIIlllIlIllIlllIllI"
@ -529,7 +529,7 @@ class GamePacketTest extends Specification {
val app = CharacterAppearanceData( val app = CharacterAppearanceData(
Vector3(3674.8438f, 2726.789f, 91.15625f), Vector3(3674.8438f, 2726.789f, 91.15625f),
19, 19,
2, PlanetSideEmpire.VS,
false, false,
4, 4,
"IlllIIIlllIlIllIlllIllI", "IlllIIIlllIlIllIlllIllI",
@ -1332,13 +1332,13 @@ class GamePacketTest extends Specification {
case DestroyDisplayMessage(killer, killer_unk, killer_empire, killer_inVehicle, unk, method, victim, victim_unk, victim_empire, victim_inVehicle) => case DestroyDisplayMessage(killer, killer_unk, killer_empire, killer_inVehicle, unk, method, victim, victim_unk, victim_empire, victim_inVehicle) =>
killer mustEqual "Angello" killer mustEqual "Angello"
killer_unk mustEqual 30981173 killer_unk mustEqual 30981173
killer_empire mustEqual 2 killer_empire mustEqual PlanetSideEmpire.VS
killer_inVehicle mustEqual false killer_inVehicle mustEqual false
unk mustEqual PlanetSideGUID(121) unk mustEqual 121
method mustEqual PlanetSideGUID(969) method mustEqual 969
victim mustEqual "HMFIC" victim mustEqual "HMFIC"
victim_unk mustEqual 31035057 victim_unk mustEqual 31035057
victim_empire mustEqual 0 victim_empire mustEqual PlanetSideEmpire.TR
victim_inVehicle mustEqual false victim_inVehicle mustEqual false
case default => case default =>
ko ko
@ -1346,7 +1346,7 @@ class GamePacketTest extends Specification {
} }
"encode" in { "encode" in {
val msg = DestroyDisplayMessage("Angello", 30981173, 2, false, PlanetSideGUID(121), PlanetSideGUID(969), "HMFIC", 31035057, 0, false) val msg = DestroyDisplayMessage("Angello", 30981173, PlanetSideEmpire.VS, false, 121, 969, "HMFIC", 31035057, PlanetSideEmpire.TR, false)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string pkt mustEqual string
} }

View file

@ -9,6 +9,7 @@ import org.log4s.MDC
import scodec.Attempt.{Failure, Successful} import scodec.Attempt.{Failure, Successful}
import scodec.bits._ import scodec.bits._
import MDCContextAware.Implicits._ import MDCContextAware.Implicits._
import net.psforever.types.PlanetSideEmpire
import scala.concurrent.duration._ import scala.concurrent.duration._
import scala.util.Random import scala.util.Random

View file

@ -10,7 +10,7 @@ import scodec.bits._
import org.log4s.MDC import org.log4s.MDC
import MDCContextAware.Implicits._ import MDCContextAware.Implicits._
import net.psforever.packet.game.objectcreate._ import net.psforever.packet.game.objectcreate._
import net.psforever.types.{ChatMessageType, Vector3} import net.psforever.types.{ChatMessageType, PlanetSideEmpire, Vector3}
class WorldSessionActor extends Actor with MDCContextAware { class WorldSessionActor extends Actor with MDCContextAware {
private[this] val log = org.log4s.getLogger private[this] val log = org.log4s.getLogger
@ -113,7 +113,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
val app = CharacterAppearanceData( val app = CharacterAppearanceData(
Vector3(3674.8438f, 2726.789f, 91.15625f), Vector3(3674.8438f, 2726.789f, 91.15625f),
19, 19,
2, PlanetSideEmpire.VS,
false, false,
4, 4,
"IlllIIIlllIlIllIlllIllI", "IlllIIIlllIlIllIlllIllI",