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

@ -1,7 +1,7 @@
// Copyright (c) 2017 PSForever
package base
// Copyright (c) 2017 PSForever
import akka.actor.ActorSystem
import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit}
import com.typesafe.config.ConfigFactory
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
@ -48,4 +48,28 @@ object ActorTest {
}
out
}
/**
* A middleman Actor that accepts a `Props` object to instantiate and accepts messages back from it.
* The purpose is to bypass a message receive issue with the `ActorTest` / `TestKit` class
* that does not properly queue messages dispatched to it
* when messages may be sent to it via a `context.parent` call.
* Please do not wrap and parameterize Props objects like this during normal Ops.
* @param actorProps the uninitialized `Actor` that uses `context.parent` to direct communication
* @param sendTo where to send mesages that have originated from an `actorProps` object;
* typically should point back to the test environment constructed by `TestKit`
*/
class SupportActorInterface(actorProps : Props, sendTo : ActorRef) extends Actor {
val test = context.actorOf(actorProps, "support-actor")
def receive : Receive = {
case msg =>
(if(sender == test) {
sendTo
}
else {
test
}) ! msg
}
}
}

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
}
}
}

View file

@ -8,6 +8,7 @@ import net.psforever.objects.equipment._
import net.psforever.objects.inventory.InventoryTile
import net.psforever.objects.serverobject.terminals.Terminal
import net.psforever.objects.serverobject.tube.SpawnTube
import net.psforever.objects.vehicles.UtilityType
import net.psforever.packet.game.PlanetSideGUID
import net.psforever.packet.game.objectcreate._
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, Vector3}
@ -166,6 +167,35 @@ class ConverterTest extends Specification {
}
}
"Telepad" should {
"convert (success)" in {
val obj = new Telepad(GlobalDefinitions.router_telepad)
obj.Router = PlanetSideGUID(1001)
obj.Definition.Packet.ConstructorData(obj) match {
case Success(pkt) =>
pkt mustEqual TelepadData(0, PlanetSideGUID(1001))
case _ =>
ko
}
obj.Definition.Packet.DetailedConstructorData(obj) match {
case Success(pkt) =>
pkt mustEqual DetailedTelepadData(0, PlanetSideGUID(1001))
case _ =>
ko
}
}
"convert (failure; no router)" in {
val obj = new Telepad(GlobalDefinitions.router_telepad)
//obj.Router = PlanetSideGUID(1001)
obj.Definition.Packet.ConstructorData(obj).isFailure mustEqual true
obj.Definition.Packet.DetailedConstructorData(obj).isFailure mustEqual true
}
}
"SmallDeployable" should {
"convert" in {
val obj = new SensorDeployable(GlobalDefinitions.motionalarmsensor)
@ -299,6 +329,79 @@ class ConverterTest extends Specification {
}
}
"TelepadDeployable" should {
"convert (success)" in {
val obj = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
obj.Faction = PlanetSideEmpire.TR
obj.GUID = PlanetSideGUID(90)
obj.Router = PlanetSideGUID(1001)
obj.Owner = PlanetSideGUID(5001)
obj.Health = 1
obj.Definition.Packet.ConstructorData(obj) match {
case Success(pkt) =>
pkt mustEqual TelepadDeployableData(
PlacementData(Vector3.Zero, Vector3.Zero),
PlanetSideEmpire.TR,
bops = false,
destroyed = false,
unk1 = 2, unk2 = true,
router_guid = PlanetSideGUID(1001),
owner_guid = PlanetSideGUID(5001),
unk3 = 87, unk4 = 12
)
case _ =>
ko
}
}
"convert (success; destroyed)" in {
val obj = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
obj.Faction = PlanetSideEmpire.TR
obj.GUID = PlanetSideGUID(90)
obj.Router = PlanetSideGUID(1001)
obj.Owner = PlanetSideGUID(5001)
obj.Health = 0
obj.Definition.Packet.ConstructorData(obj) match {
case Success(pkt) =>
pkt mustEqual TelepadDeployableData(
PlacementData(Vector3.Zero, Vector3.Zero),
PlanetSideEmpire.TR,
bops = false,
destroyed = true,
unk1 = 2, unk2 = true,
router_guid = PlanetSideGUID(1001),
owner_guid = PlanetSideGUID(0),
unk3 = 0, unk4 = 6
)
case _ =>
ko
}
}
"convert (failure; no router)" in {
val obj = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
obj.Faction = PlanetSideEmpire.TR
obj.GUID = PlanetSideGUID(90)
//obj.Router = PlanetSideGUID(1001)
obj.Owner = PlanetSideGUID(5001)
obj.Health = 1
obj.Definition.Packet.ConstructorData(obj).isFailure mustEqual true
obj.Router = PlanetSideGUID(0)
obj.Definition.Packet.ConstructorData(obj).isFailure mustEqual true
}
"convert (failure; detailed)" in {
val obj = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
obj.Faction = PlanetSideEmpire.TR
obj.GUID = PlanetSideGUID(90)
obj.Router = PlanetSideGUID(1001)
obj.Owner = PlanetSideGUID(5001)
obj.Health = 1
obj.Definition.Packet.DetailedConstructorData(obj).isFailure mustEqual true
}
}
"Player" should {
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
val obj : Player = {
@ -525,6 +628,15 @@ class ConverterTest extends Specification {
ams.Definition.Packet.ConstructorData(ams).isSuccess mustEqual true
//did not initialize the utilities, but the converter did not fail
}
"convert to packet (4)" in {
val
router = Vehicle(GlobalDefinitions.router)
router.GUID = PlanetSideGUID(413)
router.Utility(UtilityType.teleportpad_terminal).get.GUID = PlanetSideGUID(1413)
router.Utility(UtilityType.internal_router_telepad_deployable).get.GUID = PlanetSideGUID(2413)
router.Definition.Packet.ConstructorData(router).isSuccess mustEqual true
}
}
"DestroyedVehicle" should {

View file

@ -318,6 +318,38 @@ class TurretControlBetrayalMountTest extends ActorTest {
}
}
class TelepadDeployableTest extends Specification {
"Telepad" should {
"construct" in {
val obj = new Telepad(GlobalDefinitions.router_telepad)
obj.Active mustEqual false
obj.Router mustEqual None
}
"activate and deactivate" in {
val obj = new Telepad(GlobalDefinitions.router_telepad)
obj.Active mustEqual false
obj.Active = true
obj.Active mustEqual true
obj.Active = false
obj.Active mustEqual false
}
"keep track of a Router" in {
val obj = new Telepad(GlobalDefinitions.router_telepad)
obj.Router mustEqual None
obj.Router = PlanetSideGUID(1)
obj.Router mustEqual Some(PlanetSideGUID(1))
obj.Router = None
obj.Router mustEqual None
obj.Router = PlanetSideGUID(1)
obj.Router mustEqual Some(PlanetSideGUID(1))
obj.Router = PlanetSideGUID(0)
obj.Router mustEqual None
}
}
}
object DeployableTest {
class TurretInitializer(obj : TurretDeployable) extends Actor {
def receive : Receive = {

View file

@ -20,10 +20,12 @@ class DeployableToolboxTest extends Specification {
obj.Initialize(Set())
val list = obj.UpdateUI()
list.size mustEqual DeployedItem.values.size - 3 //extra field turrets
list.foreach({case(_,curr,_,max) =>
val (routers, allOthers) = list.partition({ case((_,_,_,max)) => max == 1024 })
allOthers.foreach({case(_,curr,_,max) =>
curr mustEqual 0
max mustEqual 0
})
routers.length mustEqual 1
ok
}
@ -44,7 +46,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"initialization (AssaultEngineering)" in {
@ -64,7 +66,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"initialization (FortificationEngineering)" in {
@ -84,7 +86,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"initialization (AdvancedEngineering)" in {
@ -104,7 +106,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"initialization (AdvancedHacking)" in {
@ -124,7 +126,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"initialization (without CombatEngineering)" in {
@ -144,7 +146,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"initialization (GroundSupport)" in {
@ -164,6 +166,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"can not initialize twice" in {
@ -183,7 +186,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.Initialize(Set(AdvancedEngineering)) mustEqual false
obj.CountDeployable(DeployedItem.boomer)._2 mustEqual 0
@ -200,7 +203,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"uninitialized fields can not accept deployables" in {
@ -240,7 +243,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
CombatEngineering,
@ -260,7 +263,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
FortificationEngineering,
@ -280,7 +283,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
AssaultEngineering,
@ -300,7 +303,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
AssaultEngineering,
@ -320,7 +323,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
AdvancedHacking,
@ -340,7 +343,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"change accessible fields by adding by certification type (GroundSupport)" in {
@ -360,7 +363,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
GroundSupport,
@ -400,7 +403,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.AddToDeployableQuantities(
AdvancedEngineering,
@ -420,7 +423,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"change accessible fields by removing by certification types (all)" in {
@ -440,7 +443,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.RemoveFromDeployableQuantities(
GroundSupport,
@ -460,7 +463,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.RemoveFromDeployableQuantities(
AdvancedHacking,
@ -480,7 +483,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.RemoveFromDeployableQuantities(
FortificationEngineering,
@ -500,7 +503,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.RemoveFromDeployableQuantities(
AssaultEngineering,
@ -520,7 +523,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.RemoveFromDeployableQuantities(
CombatEngineering,
@ -540,7 +543,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"change accessible fields by removing by certification type (AdvancedEngineering)" in {
@ -560,7 +563,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 1
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 1
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 1
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
obj.RemoveFromDeployableQuantities(
AdvancedEngineering,
@ -580,7 +583,7 @@ class DeployableToolboxTest extends Specification {
obj.CountDeployable(DeployedItem.portable_manned_turret_tr)._2 mustEqual 0
obj.CountDeployable(DeployedItem.portable_manned_turret_vs)._2 mustEqual 0
obj.CountDeployable(DeployedItem.deployable_shield_generator)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 0
obj.CountDeployable(DeployedItem.router_telepad_deployable)._2 mustEqual 1024
}
"can not remove deployables from an unpopulated field" in {

View file

@ -5,7 +5,7 @@ import net.psforever.objects._
import net.psforever.objects.equipment._
import net.psforever.objects.inventory.InventoryTile
import net.psforever.objects.GlobalDefinitions._
import net.psforever.objects.ce.DeployedItem
import net.psforever.objects.ce.{DeployedItem, TelepadLike}
import net.psforever.objects.definition._
import net.psforever.packet.game.PlanetSideGUID
import net.psforever.types.CertificationType

View file

@ -3,7 +3,7 @@ package objects
import akka.actor.{Actor, ActorRef, Props}
import base.ActorTest
import net.psforever.objects.{GlobalDefinitions, Vehicle}
import net.psforever.objects._
import net.psforever.objects.serverobject.terminals.Terminal
import net.psforever.objects.vehicles._
import net.psforever.packet.game.PlanetSideGUID
@ -18,7 +18,7 @@ class UtilityTest extends Specification {
obj.UtilType mustEqual UtilityType.order_terminala
obj().isInstanceOf[Terminal] mustEqual true
obj().asInstanceOf[Terminal].Definition.ObjectId mustEqual 613
obj().asInstanceOf[Terminal].Actor == ActorRef.noSender
obj().asInstanceOf[Terminal].Actor mustEqual ActorRef.noSender
}
"create an order_terminalb object" in {
@ -26,7 +26,7 @@ class UtilityTest extends Specification {
obj.UtilType mustEqual UtilityType.order_terminalb
obj().isInstanceOf[Terminal] mustEqual true
obj().asInstanceOf[Terminal].Definition.ObjectId mustEqual 614
obj().asInstanceOf[Terminal].Actor == ActorRef.noSender
obj().asInstanceOf[Terminal].Actor mustEqual ActorRef.noSender
}
"create a matrix_terminalc object" in {
@ -34,7 +34,7 @@ class UtilityTest extends Specification {
obj.UtilType mustEqual UtilityType.matrix_terminalc
obj().isInstanceOf[Terminal] mustEqual true
obj().asInstanceOf[Terminal].Definition.ObjectId mustEqual 519
obj().asInstanceOf[Terminal].Actor == ActorRef.noSender
obj().asInstanceOf[Terminal].Actor mustEqual ActorRef.noSender
}
"create an ams_respawn_tube object" in {
@ -43,7 +43,53 @@ class UtilityTest extends Specification {
obj.UtilType mustEqual UtilityType.ams_respawn_tube
obj().isInstanceOf[SpawnTube] mustEqual true
obj().asInstanceOf[SpawnTube].Definition.ObjectId mustEqual 49
obj().asInstanceOf[SpawnTube].Actor == ActorRef.noSender
obj().asInstanceOf[SpawnTube].Actor mustEqual ActorRef.noSender
}
"create a teleportpad_terminal object" in {
val obj = Utility(UtilityType.teleportpad_terminal, UtilityTest.vehicle)
obj.UtilType mustEqual UtilityType.teleportpad_terminal
obj().isInstanceOf[Terminal] mustEqual true
obj().asInstanceOf[Terminal].Definition.ObjectId mustEqual 853
obj().asInstanceOf[Terminal].Actor mustEqual ActorRef.noSender
}
"teleportpad_terminal produces a telepad object (router_telepad)" in {
import net.psforever.packet.game.ItemTransactionMessage
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, TransactionType}
val veh = Vehicle(GlobalDefinitions.quadstealth)
val obj = Utility(UtilityType.teleportpad_terminal, UtilityTest.vehicle)
veh.GUID = PlanetSideGUID(101)
obj().Owner = veh //hack
obj().GUID = PlanetSideGUID(1)
val msg = obj().asInstanceOf[Terminal].Buy(
Player(Avatar("TestCharacter", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)),
ItemTransactionMessage(PlanetSideGUID(853), TransactionType.Buy, 0, "router_telepad", 0, PlanetSideGUID(0))
)
msg.isInstanceOf[Terminal.BuyEquipment] mustEqual true
msg.asInstanceOf[Terminal.BuyEquipment].item.isInstanceOf[Telepad] mustEqual true
}
"create an internal_router_telepad_deployable object" in {
val obj = Utility(UtilityType.internal_router_telepad_deployable, UtilityTest.vehicle)
obj.UtilType mustEqual UtilityType.internal_router_telepad_deployable
obj().isInstanceOf[Utility.InternalTelepad] mustEqual true
obj().asInstanceOf[Utility.InternalTelepad].Definition.ObjectId mustEqual 744
obj().asInstanceOf[Utility.InternalTelepad].Actor mustEqual ActorRef.noSender
}
"internal_router_telepad_deployable can keep track of an object's GUID (presumedly, it's a Telepad)" in {
val obj = Utility(UtilityType.internal_router_telepad_deployable, UtilityTest.vehicle)
val inpad = obj().asInstanceOf[Utility.InternalTelepad]
inpad.Telepad mustEqual None
inpad.Telepad = PlanetSideGUID(5)
inpad.Telepad mustEqual Some(PlanetSideGUID(5))
inpad.Telepad = PlanetSideGUID(6)
inpad.Telepad mustEqual Some(PlanetSideGUID(6))
inpad.Telepad = None
inpad.Telepad mustEqual None
}
"be located with their owner (terminal)" in {
@ -71,10 +117,25 @@ class UtilityTest extends Specification {
obj().Position mustEqual veh.Position
obj().Orientation mustEqual veh.Orientation
}
"be located with their owner (internal telepad)" in {
val veh = Vehicle(GlobalDefinitions.quadstealth)
val obj = Utility(UtilityType.internal_router_telepad_deployable, veh)
obj().Position mustEqual veh.Position
obj().Orientation mustEqual veh.Orientation
import net.psforever.types.Vector3
veh.Position = Vector3(1, 2, 3)
veh.Orientation = Vector3(4, 5, 6)
veh.GUID = PlanetSideGUID(101)
obj().Position mustEqual veh.Position
obj().Orientation mustEqual veh.Orientation
obj().asInstanceOf[Utility.InternalTelepad].Router mustEqual Some(veh.GUID)
}
}
}
class Utility1Test extends ActorTest {
class UtilityTerminalATest extends ActorTest {
"Utility" should {
"wire an order_terminala Actor" in {
val obj = Utility(UtilityType.order_terminala, UtilityTest.vehicle)
@ -88,7 +149,7 @@ class Utility1Test extends ActorTest {
}
}
class Utility2Test extends ActorTest {
class UtilityTerminalBTest extends ActorTest {
"Utility" should {
"wire an order_terminalb Actor" in {
val obj = Utility(UtilityType.order_terminalb, UtilityTest.vehicle)
@ -102,7 +163,7 @@ class Utility2Test extends ActorTest {
}
}
class Utility3Test extends ActorTest {
class UtilityTerminalCTest extends ActorTest {
"Utility" should {
"wire a matrix_terminalc Actor" in {
val obj = Utility(UtilityType.matrix_terminalc, UtilityTest.vehicle)
@ -116,7 +177,7 @@ class Utility3Test extends ActorTest {
}
}
class Utility4Test extends ActorTest {
class UtilityRespawnTubeTest extends ActorTest {
"Utility" should {
"wire an ams_respawn_tube Actor" in {
val obj = Utility(UtilityType.ams_respawn_tube, UtilityTest.vehicle)
@ -130,6 +191,38 @@ class Utility4Test extends ActorTest {
}
}
class UtilityTelepadTerminalTest extends ActorTest {
"Utility" should {
"wire a teleportpad_terminal Actor" in {
val obj = Utility(UtilityType.teleportpad_terminal, UtilityTest.vehicle)
obj().GUID = PlanetSideGUID(1)
assert(obj().Actor == ActorRef.noSender)
system.actorOf(Props(classOf[UtilityTest.SetupControl], obj), "test") ! ""
receiveOne(Duration.create(100, "ms")) //consume and discard
assert(obj().Actor != ActorRef.noSender)
}
}
}
class UtilityInternalTelepadTest extends ActorTest {
"Utility" should {
"wire a teleportpad_terminal Actor" in {
val veh = Vehicle(GlobalDefinitions.quadstealth)
veh.GUID = PlanetSideGUID(101)
val obj = Utility(UtilityType.internal_router_telepad_deployable, veh)
obj().GUID = PlanetSideGUID(1)
assert(obj().Actor == ActorRef.noSender)
assert(obj().asInstanceOf[Utility.InternalTelepad].Router.contains(veh.GUID))
system.actorOf(Props(classOf[UtilityTest.SetupControl], obj), "test") ! ""
receiveOne(Duration.create(100, "ms")) //consume and discard
assert(obj().Actor == ActorRef.noSender)
assert(obj().asInstanceOf[Utility.InternalTelepad].Router.contains(veh.GUID))
}
}
}
object UtilityTest {
val vehicle = Vehicle(GlobalDefinitions.quadstealth)

View file

@ -3,7 +3,7 @@ package service
import akka.actor.Props
import base.ActorTest
import net.psforever.objects.{GlobalDefinitions, SensorDeployable}
import net.psforever.objects.{GlobalDefinitions, SensorDeployable, Vehicle}
import net.psforever.objects.serverobject.PlanetSideServerObject
import net.psforever.packet.game._
import net.psforever.types.{PlanetSideEmpire, Vector3}
@ -154,6 +154,19 @@ class ProximityTerminalEffectTest extends ActorTest {
}
}
class RouterTelepadTransportTest extends ActorTest {
ServiceManager.boot(system)
"LocalService" should {
"pass RouterTelepadTransport" in {
val service = system.actorOf(Props[LocalService], "l_service")
service ! Service.Join("test")
service ! LocalServiceMessage("test", LocalAction.RouterTelepadTransport(PlanetSideGUID(10), PlanetSideGUID(11), PlanetSideGUID(12), PlanetSideGUID(13)))
expectMsg(LocalServiceResponse("/test/Local", PlanetSideGUID(10), LocalResponse.RouterTelepadTransport(PlanetSideGUID(11), PlanetSideGUID(12), PlanetSideGUID(13))))
}
}
}
class SetEmpireTest extends ActorTest {
ServiceManager.boot(system)
val obj = new SensorDeployable(GlobalDefinitions.motionalarmsensor)
@ -168,6 +181,20 @@ class SetEmpireTest extends ActorTest {
}
}
class ToggleTeleportSystemTest extends ActorTest {
ServiceManager.boot(system)
"LocalService" should {
"pass ToggleTeleportSystem" in {
val router = Vehicle(GlobalDefinitions.router)
val service = system.actorOf(Props[LocalService], "l_service")
service ! Service.Join("test")
service ! LocalServiceMessage("test", LocalAction.ToggleTeleportSystem(PlanetSideGUID(10), router, None))
expectMsg(LocalServiceResponse("/test/Local", PlanetSideGUID(10), LocalResponse.ToggleTeleportSystem(router, None)))
}
}
}
class TriggerEffectTest extends ActorTest {
ServiceManager.boot(system)

View file

@ -5,7 +5,7 @@ import akka.actor.{ActorRef, Props}
import akka.routing.RandomPool
import akka.testkit.TestProbe
import base.ActorTest
import net.psforever.objects.PlanetSideGameObject
import net.psforever.objects.{GlobalDefinitions, PlanetSideGameObject, Tool}
import net.psforever.objects.definition.{EquipmentDefinition, ObjectDefinition}
import net.psforever.objects.equipment.Equipment
import net.psforever.objects.guid.TaskResolver
@ -21,24 +21,26 @@ import scala.concurrent.duration._
// "RemoverActor" should {
// "handle a simple task" in {
// expectNoMsg(500 milliseconds)
// val probe = TestProbe()
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
// val remover = system.actorOf(
// Props(classOf[ActorTest.SupportActorInterface], Props[RemoverActorTest.TestRemover], self),
// "test-remover"
// )
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere)
//
// val reply1 = probe.receiveOne(200 milliseconds)
// val reply1 = receiveOne(500 milliseconds)
// assert(reply1.isInstanceOf[RemoverActorTest.InclusionTestAlert])
// val reply2 = probe.receiveOne(200 milliseconds)
// val reply2 = receiveOne(500 milliseconds)
// assert(reply2.isInstanceOf[RemoverActorTest.InitialJobAlert])
// probe.expectNoMsg(1 seconds) //delay
// val reply3 = probe.receiveOne(300 milliseconds)
// expectNoMsg(1 seconds) //delay
// val reply3 = receiveOne(500 milliseconds)
// assert(reply3.isInstanceOf[RemoverActorTest.FirstJobAlert])
// val reply4 = probe.receiveOne(300 milliseconds)
// val reply4 = receiveOne(500 milliseconds)
// assert(reply4.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
// val reply5 = probe.receiveOne(300 milliseconds)
// val reply5 = receiveOne(500 milliseconds)
// assert(reply5.isInstanceOf[RemoverActorTest.SecondJobAlert])
// val reply6 = probe.receiveOne(500 milliseconds)
// val reply6 = receiveOne(500 milliseconds)
// assert(reply6.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
// val reply7 = probe.receiveOne(500 milliseconds)
// val reply7 = receiveOne(500 milliseconds)
// assert(reply7.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
// }
// }
@ -50,29 +52,31 @@ import scala.concurrent.duration._
// "RemoverActor" should {
// "handle a simple task (timed)" in {
// expectNoMsg(500 milliseconds)
// val probe = TestProbe()
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
// val remover = system.actorOf(
// Props(classOf[ActorTest.SupportActorInterface], Props[RemoverActorTest.TestRemover], self),
// "test-remover"
// )
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(100 milliseconds))
//
// val reply1 = probe.receiveOne(200 milliseconds)
// val reply1 = receiveOne(500 milliseconds)
// assert(reply1.isInstanceOf[RemoverActorTest.InclusionTestAlert])
// val reply2 = probe.receiveOne(200 milliseconds)
// val reply2 = receiveOne(500 milliseconds)
// assert(reply2.isInstanceOf[RemoverActorTest.InitialJobAlert])
// //no delay
// val reply3 = probe.receiveOne(300 milliseconds)
// val reply3 = receiveOne(500 milliseconds)
// assert(reply3.isInstanceOf[RemoverActorTest.FirstJobAlert])
// val reply4 = probe.receiveOne(300 milliseconds)
// val reply4 = receiveOne(500 milliseconds)
// assert(reply4.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
// val reply5 = probe.receiveOne(300 milliseconds)
// val reply5 = receiveOne(500 milliseconds)
// assert(reply5.isInstanceOf[RemoverActorTest.SecondJobAlert])
// val reply6 = probe.receiveOne(300 milliseconds)
// val reply6 = receiveOne(500 milliseconds)
// assert(reply6.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
// val reply7 = probe.receiveOne(300 milliseconds)
// val reply7 = receiveOne(500 milliseconds)
// assert(reply7.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
// }
// }
//}
//
//class ExcludedRemoverActorTest extends ActorTest {
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
// val AlternateTestObject = new PlanetSideGameObject() { def Definition = new ObjectDefinition(0) { } }
@ -81,7 +85,10 @@ import scala.concurrent.duration._
// "allow only specific objects" in {
// expectNoMsg(500 milliseconds)
// val probe = TestProbe()
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
// val remover = system.actorOf(
// Props(classOf[ActorTest.SupportActorInterface], Props[RemoverActorTest.TestRemover], self),
// "test-remover"
// )
// remover ! RemoverActor.AddTask(AlternateTestObject, Zone.Nowhere)
//
// val reply1 = probe.receiveOne(200 milliseconds)
@ -91,7 +98,7 @@ import scala.concurrent.duration._
// }
// }
//}
//
//class MultipleRemoverActorTest extends ActorTest {
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
@ -494,44 +501,44 @@ object RemoverActorTest {
final case class DeletionTaskRunAlert()
class TestRemover(probe : TestProbe) extends RemoverActor {
class TestRemover extends RemoverActor {
import net.psforever.objects.guid.{Task, TaskResolver}
val FirstStandardDuration = 1 seconds
val SecondStandardDuration = 100 milliseconds
def InclusionTest(entry : RemoverActor.Entry) : Boolean = {
probe.ref ! InclusionTestAlert()
entry.obj.isInstanceOf[Equipment]
context.parent ! InclusionTestAlert()
true
}
def InitialJob(entry : RemoverActor.Entry) : Unit = {
probe.ref ! InitialJobAlert()
context.parent ! InitialJobAlert()
}
def FirstJob(entry : RemoverActor.Entry) : Unit = {
probe.ref ! FirstJobAlert()
context.parent ! FirstJobAlert()
}
override def SecondJob(entry : RemoverActor.Entry) : Unit = {
probe.ref ! SecondJobAlert()
context.parent ! SecondJobAlert()
super.SecondJob(entry)
}
def ClearanceTest(entry : RemoverActor.Entry) : Boolean = {
probe.ref ! ClearanceTestAlert()
context.parent ! ClearanceTestAlert()
true
}
def DeletionTask(entry : RemoverActor.Entry) : TaskResolver.GiveTask = {
probe.ref ! DeletionTaskAlert()
context.parent ! DeletionTaskAlert()
TaskResolver.GiveTask(new Task() {
private val localProbe = probe
private val localProbe = context.parent
override def isComplete = Task.Resolution.Success
def Execute(resolver : ActorRef) : Unit = {
localProbe.ref ! DeletionTaskRunAlert()
context.parent ! DeletionTaskRunAlert()
resolver ! scala.util.Success(this)
}
})

View file

@ -0,0 +1,171 @@
// Copyright (c) 2017 PSForever
package service
import akka.actor.Props
import base.ActorTest
import net.psforever.objects._
import net.psforever.objects.zones.Zone
import net.psforever.packet.game.PlanetSideGUID
import services.local.support.RouterTelepadActivation
import services.support.SupportActor
import scala.concurrent.duration._
class RouterTelepadActivationTest extends ActorTest {
"RouterTelepadActivation" should {
"construct" in {
system.actorOf(Props[RouterTelepadActivation], "activation-test-actor")
}
}
}
class RouterTelepadActivationSimpleTest extends ActorTest {
"RouterTelepadActivation" should {
"handle a task" in {
val telepad = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad.GUID = PlanetSideGUID(1)
val obj = system.actorOf(
Props(classOf[ActorTest.SupportActorInterface], Props[RouterTelepadActivation], self),
"activation-test-actor"
)
obj ! RouterTelepadActivation.AddTask(telepad, Zone.Nowhere, Some(2 seconds))
expectMsg(3 seconds, RouterTelepadActivation.ActivateTeleportSystem(telepad, Zone.Nowhere))
}
}
}
class RouterTelepadActivationComplexTest extends ActorTest {
"RouterTelepadActivation" should {
"handle multiple tasks" in {
val telepad1 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad1.GUID = PlanetSideGUID(1)
val telepad2 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad2.GUID = PlanetSideGUID(2)
val telepad3 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad3.GUID = PlanetSideGUID(3)
val obj = system.actorOf(
Props(classOf[ActorTest.SupportActorInterface], Props[RouterTelepadActivation], self),
"activation-test-actor"
)
obj ! RouterTelepadActivation.AddTask(telepad1, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad2, Zone.Nowhere, Some(3 seconds))
obj ! RouterTelepadActivation.AddTask(telepad3, Zone.Nowhere, Some(1 seconds))
val msgs = receiveN(3, 5 seconds) //organized by duration
assert(msgs.head.isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs.head.asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad3)
assert(msgs(1).isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs(1).asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad1)
assert(msgs(2).isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs(2).asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad2)
}
}
}
class RouterTelepadActivationHurryTest extends ActorTest {
"RouterTelepadActivation" should {
"hurry specific tasks" in {
val telepad1 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad1.GUID = PlanetSideGUID(1)
val telepad2 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad2.GUID = PlanetSideGUID(2)
val telepad3 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad3.GUID = PlanetSideGUID(3)
val obj = system.actorOf(
Props(classOf[ActorTest.SupportActorInterface], Props[RouterTelepadActivation], self),
"activation-test-actor"
)
obj ! RouterTelepadActivation.AddTask(telepad1, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad2, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad3, Zone.Nowhere, Some(2 seconds))
obj ! SupportActor.HurrySpecific(List(telepad1, telepad2), Zone.Nowhere)
val msgs = receiveN(2, 1 seconds)
assert(msgs.head.isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs.head.asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad1)
assert(msgs(1).isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs(1).asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad2)
val last = receiveOne(3 seconds)
assert(last.isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(last.asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad3)
}
}
}
class RouterTelepadActivationHurryAllTest extends ActorTest {
"RouterTelepadActivation" should {
"hurry all tasks" in {
val telepad1 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad1.GUID = PlanetSideGUID(1)
val telepad2 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad2.GUID = PlanetSideGUID(2)
val telepad3 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad3.GUID = PlanetSideGUID(3)
val obj = system.actorOf(
Props(classOf[ActorTest.SupportActorInterface], Props[RouterTelepadActivation], self),
"activation-test-actor"
)
obj ! RouterTelepadActivation.AddTask(telepad1, Zone.Nowhere, Some(7 seconds))
obj ! RouterTelepadActivation.AddTask(telepad2, Zone.Nowhere, Some(5 seconds))
obj ! RouterTelepadActivation.AddTask(telepad3, Zone.Nowhere, Some(6 seconds))
obj ! SupportActor.HurryAll()
val msgs = receiveN(3, 4 seconds) //organized by duration; note: all messages received before the earliest task should be performed
assert(msgs.head.isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs.head.asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad2)
assert(msgs(1).isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs(1).asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad3)
assert(msgs(2).isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs(2).asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad1)
}
}
}
class RouterTelepadActivationClearTest extends ActorTest {
"RouterTelepadActivation" should {
"clear specific tasks" in {
val telepad1 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad1.GUID = PlanetSideGUID(1)
val telepad2 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad2.GUID = PlanetSideGUID(2)
val telepad3 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad3.GUID = PlanetSideGUID(3)
val obj = system.actorOf(
Props(classOf[ActorTest.SupportActorInterface], Props[RouterTelepadActivation], self),
"activation-test-actor"
)
obj ! RouterTelepadActivation.AddTask(telepad1, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad2, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad3, Zone.Nowhere, Some(2 seconds))
obj ! SupportActor.ClearSpecific(List(telepad1, telepad2), Zone.Nowhere)
val msgs = receiveN(1, 3 seconds) //should only receive telepad3
assert(msgs.head.isInstanceOf[RouterTelepadActivation.ActivateTeleportSystem])
assert(msgs.head.asInstanceOf[RouterTelepadActivation.ActivateTeleportSystem].telepad == telepad3)
}
}
}
class RouterTelepadActivationClearAllTest extends ActorTest {
"RouterTelepadActivation" should {
"clear all tasks" in {
val telepad1 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad1.GUID = PlanetSideGUID(1)
val telepad2 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad2.GUID = PlanetSideGUID(2)
val telepad3 = new TelepadDeployable(GlobalDefinitions.router_telepad_deployable)
telepad3.GUID = PlanetSideGUID(3)
val obj = system.actorOf(
Props(classOf[ActorTest.SupportActorInterface], Props[RouterTelepadActivation], self),
"activation-test-actor"
)
obj ! RouterTelepadActivation.AddTask(telepad1, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad2, Zone.Nowhere, Some(2 seconds))
obj ! RouterTelepadActivation.AddTask(telepad3, Zone.Nowhere, Some(2 seconds))
obj ! SupportActor.ClearAll()
expectNoMsg(4 seconds)
}
}
}