From 6ef6d6834f9f4cf4d1209308546a0dc26feb16a6 Mon Sep 17 00:00:00 2001 From: FateJH Date: Wed, 13 May 2020 21:53:55 -0400 Subject: [PATCH] vehicle ownership change on zone change and on logout --- .../account/AccountPersistenceService.scala | 35 ++++--------------- .../src/main/scala/WorldSessionActor.scala | 8 +++++ 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/common/src/main/scala/services/account/AccountPersistenceService.scala b/common/src/main/scala/services/account/AccountPersistenceService.scala index bbc261f2..98d50227 100644 --- a/common/src/main/scala/services/account/AccountPersistenceService.scala +++ b/common/src/main/scala/services/account/AccountPersistenceService.scala @@ -277,7 +277,7 @@ class PersistenceMonitor(name : String, squadService : ActorRef, taskResolver : AvatarLogout(avatar) inZone.GUID(avatar.VehicleOwned) match { case Some(obj : Vehicle) if obj.OwnerName.contains(avatar.name) => - obj.AssignOwnership(None) + obj.Actor ! Vehicle.Ownership(None) case _ => ; } taskResolver.tell(GUIDTask.UnregisterLocker(avatar.Locker)(inZone.GUID), context.parent) @@ -296,7 +296,6 @@ class PersistenceMonitor(name : String, squadService : ActorRef, taskResolver : * @see `Avatar` * @see `AvatarAction.ObjectDelete` * @see `AvatarServiceMessage` - * @see `DisownVehicle` * @see `GUIDTask.UnregisterAvatar` * @see `Player` * @see `Zone.AvatarEvents` @@ -309,7 +308,11 @@ class PersistenceMonitor(name : String, squadService : ActorRef, taskResolver : val parent = context.parent player.Position = Vector3.Zero player.Health = 0 - DisownVehicle(player) + inZone.GUID(player.VehicleOwned) match { + case Some(vehicle : Vehicle) if vehicle.OwnerName.contains(player.Name) => + vehicle.Actor ! Vehicle.Ownership(None) + case _ => ; + } inZone.Population.tell(Zone.Population.Release(avatar), parent) inZone.AvatarEvents.tell(AvatarServiceMessage(inZone.Id, AvatarAction.ObjectDelete(pguid, pguid)), parent) AvatarLogout(avatar) @@ -334,32 +337,6 @@ class PersistenceMonitor(name : String, squadService : ActorRef, taskResolver : Deployables.Disown(inZone, avatar, parent) inZone.Population.tell(Zone.Population.Leave(avatar), parent) } - - /** - * Vehicle cleanup that is specific to log out behavior. - * @see `Vehicles.Disown` - * @see `RemoverActor.AddTask` - * @see `RemoverActor.ClearSpecific` - * @see `Vehicle.Flying` - * @see `VehicleDefinition.DeconstructionTime` - * @see `VehicleServiceMessage.Decon` - * @see `Zone.VehicleEvents` - */ - def DisownVehicle(player : Player) : Unit = { - Vehicles.Disown(player, inZone) match { - case Some(vehicle) if vehicle.Health == 0 || (vehicle.Seats.values.forall(seat => !seat.isOccupied) && vehicle.Owner.isEmpty) => - vehicle.Actor ! Vehicle.Deconstruct( - if(vehicle.Flying) { - //TODO gravity - None //immediate deconstruction - } - else { - vehicle.Definition.DeconstructionTime //normal deconstruction - } - ) - case _ => ; - } - } } /** diff --git a/pslogin/src/main/scala/WorldSessionActor.scala b/pslogin/src/main/scala/WorldSessionActor.scala index fa8e0093..5039370f 100644 --- a/pslogin/src/main/scala/WorldSessionActor.scala +++ b/pslogin/src/main/scala/WorldSessionActor.scala @@ -9889,6 +9889,14 @@ class WorldSessionActor extends Actor * It also sets up actions for the new zone loading process. */ def LoadZoneCommonTransferActivity() : Unit = { + if(player.VehicleOwned.nonEmpty && player.VehicleSeated != player.VehicleOwned) { + continent.GUID(player.VehicleOwned) match { + case Some(vehicle : Vehicle) => + vehicle.Actor ! Vehicle.Ownership(None) + case _ => ; + } + player.VehicleOwned = None + } RemoveBoomerTriggersFromInventory().foreach(obj => { taskResolver ! GUIDTask.UnregisterObjectTask(obj)(continent.GUID) })