Router and Telepad (#232)

* added short and detailed codecs for Telepad, and converter for switching between Telepad and packets; modified Utility to construct a formal TeleportPadTerminal that associates the Telepad with a Router; can now pull telepad Equipment from Router terminal utilities

* this code supports operation of the deployable-side telepad

* basic teleportation between the Router and the remote telepad is functional; an ever-present internal telepad utility was added to the Router to facilitate this teleportation

* breakdown of Router teleportation code for the purposes of client synchronization; supports Router being set up first or Telepad being set up first, either order; background timer for eventual activation of Router

* refactored the router telepad system to remove unecessary function diversions; telepads now are properly linked where appropriate and links are properly broken in appropriate situations; message passing has been simplified

* fixed inventory size of the telepad; transferred router telepad activation systems from VehicleService to LocalService, and from the Ruoter to the TelepadDeployable; cleaned up code that handled the TelepadDeployable the Router relationship in WSA

* tests, mostly; no-router conditions for certain telepad-related converters

* adjusted (made constant) quantities for owned telepads

* resolved issue with router and telepad crashes; properly handles deployment states of AMS and Router upon zone entry; changed ownership/decon requirements to ownerless only
This commit is contained in:
Fate-JH 2018-10-17 12:36:43 -04:00 committed by GitHub
parent 3270ec87b8
commit 9340777c00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 2057 additions and 251 deletions

View file

@ -0,0 +1,38 @@
// Copyright (c) 2017 PSForever
package game.objectcreate
import net.psforever.packet.PacketCoding
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
import net.psforever.packet.game.objectcreate._
import org.specs2.mutable._
import scodec.bits._
class ContainedTelepadDeployableDataTest extends Specification {
val string = hex"178f0000004080f42b00182cb0202000100000"
"ContainedTelepadDeployableData" should {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 143
cls mustEqual 744
guid mustEqual PlanetSideGUID(432)
parent.isDefined mustEqual true
parent.get.guid mustEqual PlanetSideGUID(385)
parent.get.slot mustEqual 2
data.isDefined mustEqual true
data.get.isInstanceOf[ContainedTelepadDeployableData] mustEqual true
data.get.asInstanceOf[ContainedTelepadDeployableData].unk mustEqual 101
data.get.asInstanceOf[ContainedTelepadDeployableData].router_guid mustEqual PlanetSideGUID(385)
case _ =>
ko
}
}
"encode" in {
val obj = ContainedTelepadDeployableData(101, PlanetSideGUID(385))
val msg = ObjectCreateMessage(744, PlanetSideGUID(432), ObjectCreateMessageParent(PlanetSideGUID(385), 2), obj)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
}

View file

@ -0,0 +1,40 @@
// Copyright (c) 2017 PSForever
package game.objectcreate
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.packet.game.objectcreate._
import org.specs2.mutable._
import scodec.bits._
class TelepadDataTest extends Specification {
val string = hex"17 86000000 5700 f3a a201 80 0302020000000"
//TODO validate the unknown fields before router_guid for testing
"TelepadData" should {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 134
cls mustEqual ObjectClass.router_telepad
guid mustEqual PlanetSideGUID(418)
parent.isDefined mustEqual true
parent.get.guid mustEqual PlanetSideGUID(430)
parent.get.slot mustEqual 0
data.isDefined mustEqual true
data.get.isInstanceOf[TelepadData] mustEqual true
data.get.asInstanceOf[TelepadData].router_guid mustEqual Some(PlanetSideGUID(385))
case _ =>
ko
}
}
"encode" in {
val obj = TelepadData(0, PlanetSideGUID(385))
val msg = ObjectCreateMessage(ObjectClass.router_telepad, PlanetSideGUID(418), ObjectCreateMessageParent(PlanetSideGUID(430), 0), obj)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
}

View file

@ -0,0 +1,61 @@
// Copyright (c) 2017 PSForever
package game.objectcreate
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.packet.game.objectcreate._
import net.psforever.types.{PlanetSideEmpire, Vector3}
import org.specs2.mutable._
import scodec.bits._
class TelepadDeployableDataTest extends Specification {
val string = hex"17 c8000000 f42 6101 fbcfc 0fd43 6903 00 00 79 05 8101 ae01 5700c"
//TODO validate the unknown fields before router_guid for testing
"TelepadData" should {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 200
cls mustEqual ObjectClass.router_telepad_deployable
guid mustEqual PlanetSideGUID(353)
parent.isDefined mustEqual false
data.isDefined mustEqual true
data.get.isInstanceOf[TelepadDeployableData] mustEqual true
val teledata = data.get.asInstanceOf[TelepadDeployableData]
teledata.pos.coord mustEqual Vector3(6559.961f, 1960.1172f, 13.640625f)
teledata.pos.orient mustEqual Vector3.z(109.6875f)
teledata.pos.vel.isDefined mustEqual false
teledata.faction mustEqual PlanetSideEmpire.TR
teledata.bops mustEqual false
teledata.destroyed mustEqual false
teledata.unk1 mustEqual 2
teledata.unk2 mustEqual true
teledata.router_guid mustEqual PlanetSideGUID(385)
teledata.owner_guid mustEqual PlanetSideGUID(430)
teledata.unk3 mustEqual 87
teledata.unk4 mustEqual 12
case _ =>
ko
}
}
"encode" in {
val obj = TelepadDeployableData(
PlacementData(
Vector3(6559.961f, 1960.1172f, 13.640625f),
Vector3.z(109.6875f)
),
PlanetSideEmpire.TR,
false, false, 2, true,
PlanetSideGUID(385),
PlanetSideGUID(430),
87, 12
)
val msg = ObjectCreateMessage(ObjectClass.router_telepad_deployable, PlanetSideGUID(353), obj)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
}

View file

@ -0,0 +1,66 @@
// Copyright (c) 2017 PSForever
package game.objectcreatedetailed
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.packet.game.objectcreate._
import org.specs2.mutable._
import scodec.bits._
class DetailedTelepadDataTest extends Specification {
val string = hex"18 97000000 4f00 f3a e301 80 4a680400000200008"
val string_short = hex"18 87000000 2a00 f3a 5d01 89 8000000200008"
//TODO validate the unknown fields before router_guid for testing
"DetailedTelepadData" should {
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 151
cls mustEqual ObjectClass.router_telepad
guid mustEqual PlanetSideGUID(483)
parent.isDefined mustEqual true
parent.get.guid mustEqual PlanetSideGUID(414)
parent.get.slot mustEqual 0
data.isDefined mustEqual true
data.get.isInstanceOf[DetailedTelepadData] mustEqual true
data.get.asInstanceOf[DetailedTelepadData].router_guid mustEqual Some(PlanetSideGUID(564))
case _ =>
ko
}
}
"decode (short)" in {
PacketCoding.DecodePacket(string_short).require match {
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
len mustEqual 135
cls mustEqual ObjectClass.router_telepad
guid mustEqual PlanetSideGUID(349)
parent.isDefined mustEqual true
parent.get.guid mustEqual PlanetSideGUID(340)
parent.get.slot mustEqual 9
data.isDefined mustEqual true
data.get.isInstanceOf[DetailedTelepadData] mustEqual true
data.get.asInstanceOf[DetailedTelepadData].router_guid mustEqual None
case _ =>
ko
}
}
"encode" in {
val obj = DetailedTelepadData(18, PlanetSideGUID(564))
val msg = ObjectCreateDetailedMessage(ObjectClass.router_telepad, PlanetSideGUID(483), ObjectCreateMessageParent(PlanetSideGUID(414), 0), obj)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
"encode (short)" in {
val obj = DetailedTelepadData(32)
val msg = ObjectCreateDetailedMessage(ObjectClass.router_telepad, PlanetSideGUID(349), ObjectCreateMessageParent(PlanetSideGUID(340), 9), obj)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string_short
}
}
}