mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-03-07 22:40:32 +00:00
introduced a 'more elegant' method of adding objects to the Zones via ServerObjectBuilder; pushed information about specifics of Zone into ZoneMap object; shuffled around initialization responsibility to make this agreeable
This commit is contained in:
parent
2076100b50
commit
186c4ccba9
9 changed files with 84 additions and 106 deletions
|
|
@ -6,6 +6,7 @@ import net.psforever.objects.definition.converter.{CommandDetonaterConverter, Lo
|
|||
import net.psforever.objects.equipment.CItem.DeployedItem
|
||||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.inventory.InventoryTile
|
||||
import net.psforever.objects.terminals.OrderTerminalDefinition
|
||||
import net.psforever.packet.game.objectcreate.ObjectClass
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
|
||||
|
|
@ -1169,4 +1170,7 @@ object GlobalDefinitions {
|
|||
fury.Weapons += 1 -> fury_weapon_systema
|
||||
fury.TrunkSize = InventoryTile(11, 11)
|
||||
fury.TrunkOffset = 30
|
||||
|
||||
val
|
||||
orderTerminal = new OrderTerminalDefinition
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class IntergalacticCluster(zones : List[Zone]) extends Actor {
|
|||
case Some(continent) =>
|
||||
sender ! IntergalacticCluster.GiveWorld(zoneId, continent)
|
||||
case None =>
|
||||
sender ! IntergalacticCluster.GiveWorld(zoneId, Zone.Nowhere)
|
||||
log.error(s"Requested zone with id $zoneId could not be found")
|
||||
}
|
||||
|
||||
case IntergalacticCluster.RequestZoneInitialization(tplayer) =>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.continent
|
||||
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.PlanetSideGameObject
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
|
||||
trait ServerObjectBuilder {
|
||||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : PlanetSideGameObject
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.continent
|
||||
|
||||
import net.psforever.objects.terminals.{Terminal, TerminalDefinition}
|
||||
|
||||
class TerminalObjectBuilder(tdef : TerminalDefinition, id : Int) extends ServerObjectBuilder {
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
|
||||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : Terminal = {
|
||||
val obj = Terminal(tdef)
|
||||
guid.register(obj, id)
|
||||
obj.Actor
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
||||
object TerminalObjectBuilder {
|
||||
def apply(tdef : TerminalDefinition, id : Int) : TerminalObjectBuilder = {
|
||||
new TerminalObjectBuilder(tdef, id)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,9 @@ package net.psforever.objects.continent
|
|||
|
||||
import akka.actor.{ActorContext, ActorRef, Props}
|
||||
import net.psforever.objects.{PlanetSideGameObject, Player}
|
||||
import net.psforever.objects.entity.IdentifiableEntity
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
import net.psforever.objects.guid.actor.{NumberPoolAccessorActor, NumberPoolActor, Register}
|
||||
import net.psforever.objects.guid.actor.{NumberPoolAccessorActor, NumberPoolActor}
|
||||
import net.psforever.objects.guid.selector.RandomSelector
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.packet.GamePacket
|
||||
|
|
@ -15,23 +14,24 @@ import net.psforever.types.Vector3
|
|||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
class Zone(id : String, zoneNumber : Int, map : String) {
|
||||
class Zone(id : String, map : ZoneMap, zoneNumber : Int) {
|
||||
private var actor = ActorRef.noSender
|
||||
private var accessor : ActorRef = ActorRef.noSender
|
||||
private var startupUtilities : List[(PlanetSideGameObject, Int)] = List()
|
||||
//private var startupUtilities : List[ServerObjectBuilder] = List()
|
||||
private var guid : NumberPoolHub = new NumberPoolHub(new LimitedNumberSource(65536))
|
||||
|
||||
def Actor : ActorRef = actor
|
||||
|
||||
def Init(implicit context : ActorContext) : Unit = {
|
||||
//TODO wrong initialization
|
||||
implicit val guid = this.guid
|
||||
val pool = guid.AddPool("pool", (200 to 1000).toList)
|
||||
pool.Selector = new RandomSelector
|
||||
val poolActor = context.actorOf(Props(classOf[NumberPoolActor], pool), name = s"$ZoneId-poolActor")
|
||||
accessor = context.actorOf(Props(classOf[NumberPoolAccessorActor], guid, pool, poolActor), s"$ZoneId-accessor")
|
||||
|
||||
StartupUtilities.foreach({case ((obj, uid)) =>
|
||||
guid.register(obj, uid)
|
||||
map.LocalObjects.foreach({builderObject =>
|
||||
builderObject.Build
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
|
||||
def ZoneNumber : Int = zoneNumber
|
||||
|
||||
def Map : String = map
|
||||
def Map : ZoneMap = map
|
||||
|
||||
def GUID : ActorRef = accessor
|
||||
|
||||
|
|
@ -70,15 +70,15 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
|
||||
def EquipmentOnGround : ListBuffer[Equipment] = equipmentOnGround
|
||||
|
||||
def AddUtility(obj : PlanetSideGameObject, id : Int) : Unit = {
|
||||
startupUtilities = startupUtilities :+ (obj, id)
|
||||
}
|
||||
|
||||
def StartupUtilities : List[(IdentifiableEntity, Int)] = {
|
||||
val utilities = startupUtilities
|
||||
startupUtilities = Nil
|
||||
utilities
|
||||
}
|
||||
// def AddUtility(obj : ServerObjectBuilder) : Unit = {
|
||||
// startupUtilities = startupUtilities :+ obj
|
||||
// }
|
||||
//
|
||||
// def StartupUtilities : List[ServerObjectBuilder] = {
|
||||
// val utilities = startupUtilities
|
||||
// startupUtilities = Nil
|
||||
// utilities
|
||||
// }
|
||||
|
||||
def ClientInitialization() : List[GamePacket] = {
|
||||
List.empty[GamePacket]
|
||||
|
|
@ -90,8 +90,6 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
}
|
||||
|
||||
object Zone {
|
||||
final def Nowhere : Zone = { Zone("nowhere", 0, "nowhere") } //TODO needs overrides
|
||||
|
||||
final case class DropItemOnGround(item : Equipment, pos : Vector3, orient : Vector3)
|
||||
|
||||
final case class GetItemOnGround(player : Player, item_guid : PlanetSideGUID)
|
||||
|
|
@ -100,7 +98,7 @@ object Zone {
|
|||
|
||||
final case class ClientInitialization(list : List[GamePacket])
|
||||
|
||||
def apply(zoneId : String, zoneNumber : Int, map : String) : Zone = {
|
||||
new Zone(zoneId, zoneNumber, map)
|
||||
def apply(id : String, map : ZoneMap, number : Int) : Zone = {
|
||||
new Zone(id, map, number)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package net.psforever.objects.continent
|
|||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
import net.psforever.objects.guid.actor.Register
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
|
@ -13,7 +12,6 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
|
||||
override def preStart() : Unit = {
|
||||
super.preStart()
|
||||
log.info(s"Calling ${zone.ZoneId} init ...")
|
||||
zone.Init
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.continent
|
||||
|
||||
class ZoneMap(private val name : String) {
|
||||
private var localObjects : List[ServerObjectBuilder] = List()
|
||||
|
||||
def Name : String = name
|
||||
|
||||
def LocalObject(obj : ServerObjectBuilder) : Unit = {
|
||||
localObjects = localObjects :+ obj
|
||||
}
|
||||
|
||||
def LocalObjects : List[ServerObjectBuilder] = {
|
||||
val utilities = localObjects
|
||||
localObjects = Nil
|
||||
utilities
|
||||
}
|
||||
}
|
||||
|
|
@ -12,9 +12,8 @@ import ch.qos.logback.core.status._
|
|||
import ch.qos.logback.core.util.StatusPrinter
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import net.psforever.crypto.CryptoInterface
|
||||
import net.psforever.objects.continent.{IntergalacticCluster, Zone}
|
||||
import net.psforever.objects.continent.{IntergalacticCluster, TerminalObjectBuilder, Zone, ZoneMap}
|
||||
import net.psforever.objects.guid.TaskResolver
|
||||
import net.psforever.objects.terminals.{OrderTerminalDefinition, Terminal}
|
||||
import org.slf4j
|
||||
import org.fusesource.jansi.Ansi._
|
||||
import org.fusesource.jansi.Ansi.Color._
|
||||
|
|
@ -221,22 +220,13 @@ object PsLogin {
|
|||
}
|
||||
|
||||
def createContinents() : List[Zone] = {
|
||||
val home3 = new Zone("home3",13,"map13") {
|
||||
override def Init(implicit context : ActorContext) : Unit = {
|
||||
val orderTerm = new OrderTerminalDefinition
|
||||
val obj853 = Terminal(orderTerm)
|
||||
val obj855 = Terminal(orderTerm)
|
||||
val obj860 = Terminal(orderTerm)
|
||||
AddUtility(obj853, 853)
|
||||
AddUtility(obj855, 855)
|
||||
AddUtility(obj860, 860)
|
||||
|
||||
super.Init
|
||||
obj853.Actor
|
||||
obj855.Actor
|
||||
obj860.Actor
|
||||
}
|
||||
val map13 = new ZoneMap("map13") {
|
||||
import net.psforever.objects.GlobalDefinitions._
|
||||
LocalObject(TerminalObjectBuilder(orderTerminal, 853))
|
||||
LocalObject(TerminalObjectBuilder(orderTerminal, 855))
|
||||
LocalObject(TerminalObjectBuilder(orderTerminal, 860))
|
||||
}
|
||||
val home3 = Zone("home3", map13, 13)
|
||||
|
||||
home3 ::
|
||||
Nil
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
var avatarService = Actor.noSender
|
||||
var taskResolver = Actor.noSender
|
||||
var galaxy = Actor.noSender
|
||||
var continent : Zone = Zone.Nowhere
|
||||
var continent : Zone = null
|
||||
|
||||
var clientKeepAlive : Cancellable = WorldSessionActor.DefaultCancellable
|
||||
|
||||
|
|
@ -358,7 +358,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.PlanetsideAttribute(tplayer.GUID, 4, tplayer.Armor))
|
||||
//re-draw equipment held in free hand
|
||||
beforeFreeHand match {
|
||||
//TODO was any previous free hand item deleted?
|
||||
case Some(item) =>
|
||||
tplayer.FreeHand.Equipment = beforeFreeHand
|
||||
val definition = item.Definition
|
||||
|
|
@ -424,15 +423,8 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
|
||||
case PlayerFailedToLoad(tplayer) =>
|
||||
player.Continent match {
|
||||
case "tzshvs" =>
|
||||
failWithError(s"$tplayer failed to load anywhere")
|
||||
//self ! IntergalacticCluster.GiveWorld("", Zone.Nowhere)
|
||||
case "tzdrvs" =>
|
||||
galaxy ! IntergalacticCluster.GetWorld("tzshvs")
|
||||
case "home3" =>
|
||||
galaxy ! IntergalacticCluster.GetWorld("tzdrvs")
|
||||
case _ =>
|
||||
galaxy ! IntergalacticCluster.GetWorld("home3")
|
||||
failWithError(s"$tplayer failed to load anywhere")
|
||||
}
|
||||
|
||||
case Zone.ClientInitialization(/*initList*/_) =>
|
||||
|
|
@ -470,7 +462,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
|
||||
case IntergalacticCluster.ClientInitializationComplete(tplayer)=>
|
||||
//this will cause the client to send back a BeginZoningMessage packet (see below)
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, LoadMapMessage(continent.Map, continent.ZoneId, 40100,25,true,3770441820L))) //VS Sanctuary
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, LoadMapMessage(continent.Map.Name, continent.ZoneId, 40100,25,true,3770441820L))) //VS Sanctuary
|
||||
log.info("Load the now-registered player")
|
||||
//load the now-registered player
|
||||
tplayer.Spawn
|
||||
|
|
@ -585,7 +577,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
}
|
||||
|
||||
import net.psforever.objects.GlobalDefinitions._
|
||||
//this part is created by the player (should be in case of ConnectToWorldRequestMessage, maybe)
|
||||
//this part is created by WSA based on the database query (should be in case of ConnectToWorldRequestMessage, maybe)
|
||||
val energy_cell_box1 = AmmoBox(energy_cell)
|
||||
val energy_cell_box2 = AmmoBox(energy_cell, 16)
|
||||
val bullet_9mm_box1 = AmmoBox(bullet_9mm)
|
||||
|
|
@ -609,7 +601,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
player = Player("IlllIIIlllIlIllIlllIllI", PlanetSideEmpire.VS, CharacterGender.Female, 41, 1)
|
||||
player.Position = Vector3(3674.8438f, 2726.789f, 91.15625f)
|
||||
player.Orientation = Vector3(0f, 0f, 90f)
|
||||
//player.Continent = "home3"
|
||||
player.Slot(0).Equipment = beamer1
|
||||
player.Slot(2).Equipment = suppressor1
|
||||
player.Slot(4).Equipment = forceblade1
|
||||
|
|
@ -621,57 +612,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
player.Slot(39).Equipment = rek
|
||||
player.Slot(5).Equipment.get.asInstanceOf[LockerContainer].Inventory += 0 -> extra_rek
|
||||
|
||||
//for player2
|
||||
val energy_cell_box3 = AmmoBox(PlanetSideGUID(187), energy_cell)
|
||||
val energy_cell_box4 = AmmoBox(PlanetSideGUID(177), energy_cell, 16)
|
||||
val bullet_9mm_box5 = AmmoBox(PlanetSideGUID(183), bullet_9mm)
|
||||
val bullet_9mm_box6 = AmmoBox(PlanetSideGUID(184), bullet_9mm)
|
||||
val bullet_9mm_box7 = AmmoBox(PlanetSideGUID(185), bullet_9mm)
|
||||
val bullet_9mm_box8 = AmmoBox(PlanetSideGUID(179), bullet_9mm, 25)
|
||||
val bullet_9mm_AP_box2 = AmmoBox(PlanetSideGUID(186), bullet_9mm_AP)
|
||||
val melee_ammo_box2 = AmmoBox(PlanetSideGUID(181), melee_ammo)
|
||||
|
||||
val
|
||||
beamer2 = Tool(PlanetSideGUID(176), beamer)
|
||||
beamer2.AmmoSlots.head.Box = energy_cell_box4
|
||||
val
|
||||
suppressor2 = Tool(PlanetSideGUID(178), suppressor)
|
||||
suppressor2.AmmoSlots.head.Box = bullet_9mm_box8
|
||||
val
|
||||
forceblade2 = Tool(PlanetSideGUID(180), forceblade)
|
||||
forceblade2.AmmoSlots.head.Box = melee_ammo_box2
|
||||
val
|
||||
rek2 = SimpleItem(PlanetSideGUID(188), remote_electronics_kit)
|
||||
val
|
||||
player2 = Player(PlanetSideGUID(275), "Doppelganger", PlanetSideEmpire.NC, CharacterGender.Female, 41, 1)
|
||||
player2.Position = Vector3(3680f, 2726.789f, 91.15625f)
|
||||
player2.Orientation = Vector3(0f, 0f, 0f)
|
||||
player2.Continent = "home3"
|
||||
player2.Slot(0).Equipment = beamer2
|
||||
player2.Slot(2).Equipment = suppressor2
|
||||
player2.Slot(4).Equipment = forceblade2
|
||||
player2.Slot(5).Equipment.get.GUID = PlanetSideGUID(182)
|
||||
player2.Slot(6).Equipment = bullet_9mm_box5
|
||||
player2.Slot(9).Equipment = bullet_9mm_box6
|
||||
player2.Slot(12).Equipment = bullet_9mm_box7
|
||||
player2.Slot(33).Equipment = bullet_9mm_AP_box2
|
||||
player2.Slot(36).Equipment = energy_cell_box3
|
||||
player2.Slot(39).Equipment = rek2
|
||||
player2.Spawn
|
||||
|
||||
val hellfire_ammo_box = AmmoBox(PlanetSideGUID(432), hellfire_ammo)
|
||||
|
||||
val
|
||||
fury1 = Vehicle(PlanetSideGUID(313), fury)
|
||||
fury1.Faction = PlanetSideEmpire.VS
|
||||
fury1.Position = Vector3(3674.8438f, 2732f, 91.15625f)
|
||||
fury1.Orientation = Vector3(0.0f, 0.0f, 90.0f)
|
||||
fury1.WeaponControlledFromSeat(0).get.GUID = PlanetSideGUID(300)
|
||||
fury1.WeaponControlledFromSeat(0).get.AmmoSlots.head.Box = hellfire_ammo_box
|
||||
|
||||
val object2Hex = ObjectCreateMessage(ObjectClass.avatar, PlanetSideGUID(275), player2.Definition.Packet.ConstructorData(player2).get)
|
||||
val furyHex = ObjectCreateMessage(ObjectClass.fury, PlanetSideGUID(313), fury1.Definition.Packet.ConstructorData(fury1).get)
|
||||
|
||||
def handleGamePkt(pkt : PlanetSideGamePacket) = pkt match {
|
||||
case ConnectToWorldRequestMessage(server, token, majorVersion, minorVersion, revision, buildDate, unk) =>
|
||||
val clientVersion = s"Client Version: $majorVersion.$minorVersion.$revision, $buildDate"
|
||||
|
|
@ -712,8 +652,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
//TODO continent.ClientConfiguration()
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, SetEmpireMessage(PlanetSideGUID(2), PlanetSideEmpire.VS))) //HART building C
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, SetEmpireMessage(PlanetSideGUID(29), PlanetSideEmpire.NC))) //South Villa Gun Tower
|
||||
//sendResponse(PacketCoding.CreateGamePacket(0, object2Hex))
|
||||
//sendResponse(PacketCoding.CreateGamePacket(0, furyHex))
|
||||
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, TimeOfDayMessage(1191182336)))
|
||||
sendResponse(PacketCoding.CreateGamePacket(0, ReplicationStreamMessage(5, Some(6), Vector(SquadListing())))) //clear squad list
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue