mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
Test fix (#332)
* fix AvatarService tests * updated README section in regards to PSCrypto * better wording, imho * modifying the construction of Building entities so to properly register them with the zone GUID system * fixed tests
This commit is contained in:
parent
80af2e84a9
commit
e8fd09aad8
|
|
@ -54,10 +54,9 @@ This will clone the repository and SBT will compile and run the login server ([m
|
|||
With a SBT console you can run tests (and you should) using `sbt test`.
|
||||
|
||||
### Downloading PSCrypto
|
||||
**The server requires binary builds of PSCrypto in order to run.** [Download the latest release](https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip) and extract the the approprate dll for your operating system to the top level of your source directory (the root directory, not /pslogin/src/main/scala). SBT, IDEA, and Java will automatically find the required libraries when running the server.
|
||||
If you are not comfortable with compiled binaries, you can [build the libraries yourself](https://github.com/psforever/PSCrypto).
|
||||
**The server requires binary builds of PSCrypto in order to run.** [Download the latest release](https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip) and extract the the approprate dll for your operating system. If you are not comfortable with compiled binaries, you can [build the libraries yourself](https://github.com/psforever/PSCrypto).
|
||||
|
||||
If you have any issues with PSCrypto being detected when trying to run the server try adding `-Djava.library.path=` (no path necessary) to your preferred IDE's build configuration, for example with IDEA: Run -> Edit Configuration -> VM Options
|
||||
SBT, IDEA, and Java will automatically find the required libraries when running the server. The build expects to find the library in a subdirectory of the root directory called /pscrypto-lib/. Historically, we have recommended placing it directly into the root directory and that has worked as well. If you still have issues with PSCrypto being detected, try adding `-Djava.library.path=` (no path necessary) to your preferred IDE's build configuration with the library in the root directory. For example, with IDEA: Run -> Edit Configuration -> (select the configuration) -> Uncheck "Use SBT shell" -> VM Parameters
|
||||
|
||||
## Setting up the Database
|
||||
The Login and World servers require PostgreSQL for persistence.
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@ import net.psforever.objects.serverobject.terminals.CaptureTerminal
|
|||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.types.{PlanetSideEmpire, PlanetSideGUID, Vector3}
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import scalax.collection.{Graph, GraphEdge}
|
||||
import services.Service
|
||||
import services.local.{LocalAction, LocalServiceMessage}
|
||||
|
||||
class Building(private val name: String,
|
||||
private val building_guid : Int,
|
||||
private val map_id : Int,
|
||||
private val zone : Zone,
|
||||
private val buildingType : StructureType.Value,
|
||||
|
|
@ -34,7 +33,12 @@ class Building(private val name: String,
|
|||
private var forceDomeActive : Boolean = false
|
||||
super.Zone_=(zone)
|
||||
|
||||
GUID = PlanetSideGUID(building_guid)
|
||||
/**
|
||||
* An overloaded constructor used for phasing out the need to define the building_guid parameter
|
||||
*/
|
||||
def this(name: String, building_guid : Int, map_id : Int, zone : Zone, buildingType : StructureType.Value, buildingDefinition : ObjectDefinition) = {
|
||||
this(name, map_id, zone, buildingType, buildingDefinition)
|
||||
}
|
||||
|
||||
override def toString = name
|
||||
|
||||
|
|
@ -45,7 +49,7 @@ class Building(private val name: String,
|
|||
def IsCapitol : Boolean = capitols.contains(name)
|
||||
def IsSubCapitol : Boolean = {
|
||||
Neighbours match {
|
||||
case Some(buildings: Set[Building]) => !buildings.filter(x => capitols.contains(x.name)).isEmpty
|
||||
case Some(buildings: Set[Building]) => buildings.exists(x => capitols.contains(x.name))
|
||||
case None => false
|
||||
}
|
||||
}
|
||||
|
|
@ -270,18 +274,19 @@ class Building(private val name: String,
|
|||
}
|
||||
|
||||
object Building {
|
||||
final val NoBuilding : Building = new Building(name = "", building_guid = 0, map_id = 0, Zone.Nowhere, StructureType.Platform, GlobalDefinitions.building) {
|
||||
final val NoBuilding : Building = new Building(name = "", map_id = 0, Zone.Nowhere, StructureType.Platform, GlobalDefinitions.building) {
|
||||
override def Faction_=(faction : PlanetSideEmpire.Value) : PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
||||
override def Amenities_=(obj : Amenity) : List[Amenity] = Nil
|
||||
GUID = net.psforever.types.PlanetSideGUID(0)
|
||||
}
|
||||
|
||||
def apply(name : String, guid : Int, map_id : Int, zone : Zone, buildingType : StructureType.Value) : Building = {
|
||||
new Building(name, guid, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
new Building(name, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
}
|
||||
|
||||
def Structure(buildingType : StructureType.Value, location : Vector3, definition: ObjectDefinition)(name : String, guid : Int, map_id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
val obj = new Building(name, guid, map_id, zone, buildingType, definition)
|
||||
val obj = new Building(name, map_id, zone, buildingType, definition)
|
||||
obj.Position = location
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$map_id-$buildingType-building")
|
||||
obj
|
||||
|
|
@ -290,7 +295,7 @@ object Building {
|
|||
def Structure(buildingType : StructureType.Value, location : Vector3)(name : String, guid : Int, map_id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
|
||||
val obj = new Building(name, guid, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
val obj = new Building(name, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
obj.Position = location
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$map_id-$buildingType-building")
|
||||
obj
|
||||
|
|
@ -298,14 +303,14 @@ object Building {
|
|||
|
||||
def Structure(buildingType : StructureType.Value)(name : String, guid: Int, map_id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
val obj = new Building(name, guid, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
val obj = new Building(name, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$map_id-$buildingType-building")
|
||||
obj
|
||||
}
|
||||
|
||||
def Structure(buildingType : StructureType.Value, buildingDefinition : ObjectDefinition, location : Vector3)(name: String, guid: Int, id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
val obj = new Building(name, guid, id, zone, buildingType, buildingDefinition)
|
||||
val obj = new Building(name, id, zone, buildingType, buildingDefinition)
|
||||
obj.Position = location
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$id-$buildingType-building")
|
||||
obj
|
||||
|
|
|
|||
|
|
@ -399,7 +399,12 @@ class Zone(private val zoneId : String, zoneMap : ZoneMap, zoneNumber : Int) {
|
|||
|
||||
private def MakeBuildings(implicit context : ActorContext) : PairMap[Int, Building] = {
|
||||
val buildingList = Map.LocalBuildings
|
||||
buildings = buildingList.map({case((name, building_guid, map_id), constructor) => building_guid -> constructor.Build(name, building_guid, map_id, this) })
|
||||
buildings = buildingList.map({
|
||||
case((name, building_guid, map_id), constructor) =>
|
||||
val building = constructor.Build(name, building_guid, map_id, this)
|
||||
guid.register(building, building_guid)
|
||||
building_guid -> building
|
||||
})
|
||||
buildings
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ class ResourceSiloControlNtuWarningTest extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
obj.Owner = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
obj.Owner.GUID = PlanetSideGUID(6)
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
|
||||
"Resource silo" should {
|
||||
|
|
@ -139,6 +140,7 @@ class ResourceSiloControlUpdate1Test extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
bldg.GUID = PlanetSideGUID(6)
|
||||
obj.Owner = bldg
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
val buildingEvents = TestProbe("building-events")
|
||||
|
|
@ -204,6 +206,7 @@ class ResourceSiloControlUpdate2Test extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
bldg.GUID = PlanetSideGUID(6)
|
||||
obj.Owner = bldg
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
val buildingEvents = TestProbe("building-events")
|
||||
|
|
@ -261,6 +264,7 @@ class ResourceSiloControlNoUpdateTest extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
bldg.GUID = PlanetSideGUID(6)
|
||||
obj.Owner = bldg
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
val buildingEvents = TestProbe("building-events")
|
||||
|
|
|
|||
|
|
@ -339,8 +339,8 @@ class WorldSessionActor extends Actor
|
|||
case out @ Some(obj) if obj.HasGUID =>
|
||||
out
|
||||
case None if id.nonEmpty =>
|
||||
//delete stale entity reference from client
|
||||
sendResponse(ObjectDeleteMessage(id.get, 0))
|
||||
//delete stale entity reference from client (deferred until later)
|
||||
//sendResponse(ObjectDeleteMessage(id.get, 0))
|
||||
None
|
||||
case _ =>
|
||||
None
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import akka.actor.Props
|
|||
import akka.routing.RandomPool
|
||||
import actor.base.ActorTest
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.ballistics.ResolvedProjectile
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import net.psforever.objects.zones.{Zone, ZoneActor, ZoneMap}
|
||||
import net.psforever.packet.game.objectcreate.{DroppedItemData, ObjectClass, ObjectCreateMessageParent, PlacementData}
|
||||
|
|
@ -370,33 +369,6 @@ class ChangeFireStateStopTest extends ActorTest {
|
|||
}
|
||||
}
|
||||
|
||||
class DamageTest extends ActorTest {
|
||||
val test_func_ref : Any=>ResolvedProjectile = {
|
||||
def test_func(o : Any) : ResolvedProjectile = { null }
|
||||
test_func
|
||||
}
|
||||
val player = Player(Avatar("TestCharacter", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
|
||||
"AvatarService" should {
|
||||
"pass Damage" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props(classOf[AvatarService], Zone.Nowhere), AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.Damage(PlanetSideGUID(10), player, test_func_ref))
|
||||
val msg = receiveOne(1 seconds)
|
||||
assert(msg.isInstanceOf[AvatarServiceResponse])
|
||||
assert(msg.asInstanceOf[AvatarServiceResponse].toChannel == "/test/Avatar")
|
||||
assert(msg.asInstanceOf[AvatarServiceResponse].avatar_guid == PlanetSideGUID(10))
|
||||
assert(msg.asInstanceOf[AvatarServiceResponse].replyMessage
|
||||
.isInstanceOf[AvatarResponse.DamageResolution])
|
||||
assert(msg.asInstanceOf[AvatarServiceResponse].replyMessage
|
||||
.asInstanceOf[AvatarResponse.DamageResolution].target == player)
|
||||
assert(msg.asInstanceOf[AvatarServiceResponse].replyMessage
|
||||
.asInstanceOf[AvatarResponse.DamageResolution].resolution_function == test_func_ref)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WeaponDryFireTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass WeaponDryFire" in {
|
||||
|
|
|
|||
Loading…
Reference in a new issue