mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-14 01:20:34 +00:00
prototyping utility addition to Zones; resolved issue with Avatar registration causing onFailure case to fire on success
This commit is contained in:
parent
402d4c5b3e
commit
0c7c4dc58f
5 changed files with 37 additions and 32 deletions
|
|
@ -7,13 +7,15 @@ import net.psforever.objects.Player
|
|||
import scala.annotation.tailrec
|
||||
|
||||
class IntergalacticCluster(continents : List[Zone]) extends Actor {
|
||||
//private[this] val log = org.log4s.getLogger
|
||||
private[this] val log = org.log4s.getLogger
|
||||
for(continent <- continents) {
|
||||
log.info(s"Built continent ${continent.ZoneId}")
|
||||
continent.Actor //seed context
|
||||
}
|
||||
|
||||
def receive : Receive = {
|
||||
case IntergalacticCluster.GetWorld(zoneId) =>
|
||||
log.info(s"Asked to find $zoneId")
|
||||
findWorldInCluster(continents.iterator, zoneId) match {
|
||||
case Some(continent) =>
|
||||
sender ! IntergalacticCluster.GiveWorld(zoneId, continent)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import net.psforever.objects.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}
|
||||
import net.psforever.objects.guid.actor.{NumberPoolAccessorActor, NumberPoolActor, Register}
|
||||
import net.psforever.objects.guid.selector.RandomSelector
|
||||
import net.psforever.objects.guid.source.LimitedNumberSource
|
||||
import net.psforever.packet.GamePacket
|
||||
|
|
@ -17,17 +17,20 @@ import scala.collection.mutable.ListBuffer
|
|||
|
||||
class Zone(id : String, zoneNumber : Int, map : String) {
|
||||
private var actor = ActorRef.noSender
|
||||
private var guid : NumberPoolHub = new NumberPoolHub(new LimitedNumberSource(6))
|
||||
private var guid : NumberPoolHub = new NumberPoolHub(new LimitedNumberSource(65536))
|
||||
private var accessor : ActorRef = ActorRef.noSender
|
||||
private var startupUtilities : List[(IdentifiableEntity, Int)] = List()
|
||||
|
||||
def Actor(implicit context : ActorContext) : ActorRef = {
|
||||
if(actor == ActorRef.noSender) {
|
||||
actor = context.actorOf(Props(classOf[ZoneActor], this), s"$id-actor")
|
||||
|
||||
val pool = guid.AddPool("pool", 6 :: Nil)//(400 to 599).toList)
|
||||
val pool = guid.AddPool("pool", (200 to 400).toList)
|
||||
val poolActor = context.actorOf(Props(classOf[NumberPoolActor], pool), name = s"$ZoneId-poolActor")
|
||||
pool.Selector = new RandomSelector
|
||||
accessor = context.actorOf(Props(classOf[NumberPoolAccessorActor], guid, pool, poolActor), s"$ZoneId-accessor")
|
||||
|
||||
startupUtilities.foreach({case ((obj, uid)) => accessor ! Register(obj, uid, actor)})
|
||||
}
|
||||
actor
|
||||
}
|
||||
|
|
@ -53,6 +56,10 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
|
||||
def EquipmentOnGround : ListBuffer[Equipment] = equipmentOnGround
|
||||
|
||||
def AddUtility(obj : IdentifiableEntity, id : Int) : Unit = {
|
||||
startupUtilities = startupUtilities :+ (obj, id)
|
||||
}
|
||||
|
||||
def ZoneInitialization() : List[GamePacket] = {
|
||||
List.empty[GamePacket]
|
||||
}
|
||||
|
|
@ -63,6 +70,7 @@ class Zone(id : String, zoneNumber : Int, map : String) {
|
|||
}
|
||||
|
||||
object Zone {
|
||||
final def BlankInitFunction() : Unit = { }
|
||||
final def Nowhere : Zone = { Zone("nowhere", 0, "nowhere") } //TODO needs overrides
|
||||
|
||||
final case class DropItemOnGround(item : Equipment, pos : Vector3, orient : Vector3)
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ object Terminal {
|
|||
*/
|
||||
final case class InfantryLoadout(exosuit : ExoSuitType.Value, subtype : Int = 0, holsters : List[InventoryItem], inventory : List[InventoryItem]) extends Exchange
|
||||
|
||||
def apply(tdef : TerminalDefinition) : Terminal = {
|
||||
new Terminal(tdef)
|
||||
}
|
||||
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
def apply(guid : PlanetSideGUID, tdef : TerminalDefinition) : Terminal = {
|
||||
val obj = new Terminal(tdef)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ 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.{Zone, IntergalacticCluster}
|
||||
import net.psforever.objects.continent.{IntergalacticCluster, Zone}
|
||||
import net.psforever.objects.guid.TaskResolver
|
||||
import net.psforever.objects.terminals.{OrderTerminalDefinition, Terminal}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import org.slf4j
|
||||
import org.fusesource.jansi.Ansi._
|
||||
import org.fusesource.jansi.Ansi.Color._
|
||||
|
|
@ -220,7 +222,11 @@ object PsLogin {
|
|||
}
|
||||
|
||||
def createContinents() : List[Zone] = {
|
||||
Zone("home3",13,"map13") :: Nil
|
||||
val home3 = Zone("home3",13,"map13")
|
||||
home3.AddUtility(Terminal(new OrderTerminalDefinition), 336)
|
||||
|
||||
home3 ::
|
||||
Nil
|
||||
}
|
||||
|
||||
def main(args : Array[String]) : Unit = {
|
||||
|
|
|
|||
|
|
@ -412,6 +412,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
sendResponse(PacketCoding.CreateGamePacket(0, CharacterInfoMessage(0, PlanetSideZoneID(1), 0, PlanetSideGUID(0), true, 0)))
|
||||
|
||||
case IntergalacticCluster.GiveWorld(zoneId, zone) =>
|
||||
log.info(s"Zone $zoneId has been loaded")
|
||||
player.Continent = zoneId
|
||||
continent = zone
|
||||
taskResolver ! RegisterAvatar(player)
|
||||
|
|
@ -424,8 +425,8 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case PlayerFailedToLoad(tplayer) =>
|
||||
player.Continent match {
|
||||
case "tzshvs" =>
|
||||
log.error(s"$tplayer failed to load anywhere")
|
||||
self ! IntergalacticCluster.GiveWorld("", Zone.Nowhere)
|
||||
failWithError(s"$tplayer failed to load anywhere")
|
||||
//self ! IntergalacticCluster.GiveWorld("", Zone.Nowhere)
|
||||
case "tzdrvs" =>
|
||||
galaxy ! IntergalacticCluster.GetWorld("tzshvs")
|
||||
case "home3" =>
|
||||
|
|
@ -434,7 +435,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
galaxy ! IntergalacticCluster.GetWorld("home3")
|
||||
}
|
||||
|
||||
case Zone.ZoneInitialization(initList) =>
|
||||
case Zone.ZoneInitialization(/*initList*/_) =>
|
||||
//TODO iterate over initList; for now, just do this
|
||||
sendResponse(
|
||||
PacketCoding.CreateGamePacket(0,
|
||||
|
|
@ -470,6 +471,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case IntergalacticCluster.ZoneInitializationComplete(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
|
||||
log.info("Load the now-registered player")
|
||||
//load the now-registered player
|
||||
tplayer.Spawn
|
||||
sendResponse(PacketCoding.CreateGamePacket(0,
|
||||
|
|
@ -1322,7 +1324,12 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
private val localAnnounce = self
|
||||
|
||||
override def isComplete : Task.Resolution.Value = {
|
||||
Task.Resolution.Incomplete
|
||||
if(localPlayer.HasGUID) {
|
||||
Task.Resolution.Success
|
||||
}
|
||||
else {
|
||||
Task.Resolution.Incomplete
|
||||
}
|
||||
}
|
||||
|
||||
def Execute(resolver : ActorRef) : Unit = {
|
||||
|
|
@ -1462,17 +1469,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
tplayer.Holsters().foreach(holster => {
|
||||
SetCharacterSelectScreenGUID_SelectEquipment(holster.Equipment, gen)
|
||||
})
|
||||
// tplayer.Inventory.Items.foreach({ case((_, entry : InventoryItem)) =>
|
||||
// SetCharacterSelectScreenGUID_SelectEquipment(Some(entry.obj), gen)
|
||||
// })
|
||||
// tplayer.Slot(5).Equipment match {
|
||||
// case Some(locker) =>
|
||||
// locker.GUID = PlanetSideGUID(gen.getAndIncrement)
|
||||
// locker.asInstanceOf[LockerContainer].Inventory.Items.foreach({ case((_, entry : InventoryItem)) =>
|
||||
// SetCharacterSelectScreenGUID_SelectEquipment(Some(entry.obj), gen)
|
||||
// })
|
||||
// case None => ;
|
||||
// }
|
||||
tplayer.GUID = PlanetSideGUID(gen.getAndIncrement)
|
||||
}
|
||||
|
||||
|
|
@ -1504,17 +1500,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
tplayer.Holsters().foreach(holster => {
|
||||
RemoveCharacterSelectScreenGUID_SelectEquipment(holster.Equipment)
|
||||
})
|
||||
// tplayer.Inventory.Items.foreach({ case((_, entry : InventoryItem)) =>
|
||||
// RemoveCharacterSelectScreenGUID_SelectEquipment(Some(entry.obj))
|
||||
// })
|
||||
// tplayer.Slot(5).Equipment match {
|
||||
// case Some(locker) =>
|
||||
// locker.Invalidate()
|
||||
// locker.asInstanceOf[LockerContainer].Inventory.Items.foreach({ case((_, entry : InventoryItem)) =>
|
||||
// RemoveCharacterSelectScreenGUID_SelectEquipment(Some(entry.obj))
|
||||
// })
|
||||
// case None => ;
|
||||
// }
|
||||
tplayer.Invalidate()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue