diff --git a/src/main/scala/net/psforever/objects/OwnableByPlayer.scala b/src/main/scala/net/psforever/objects/OwnableByPlayer.scala index 2653dca35..690dabe60 100644 --- a/src/main/scala/net/psforever/objects/OwnableByPlayer.scala +++ b/src/main/scala/net/psforever/objects/OwnableByPlayer.scala @@ -18,16 +18,11 @@ trait OwnableByPlayer { def OwnerGuid_=(owner: Player): Option[PlanetSideGUID] = OwnerGuid_=(Some(owner.GUID)) def OwnerGuid_=(owner: Option[PlanetSideGUID]): Option[PlanetSideGUID] = { - owner match { - case Some(_) => - ownerGuid = owner - case None => - ownerGuid = None - } + ownerGuid = owner OwnerGuid } - def OwnerName: Option[String] = owner.map { _.name } + def OwnerName: Option[String] = owner.map(_.name) def OriginalOwnerName: Option[String] = originalOwnerName @@ -47,7 +42,7 @@ trait OwnableByPlayer { (originalOwnerName, playerOpt) match { case (None, Some(player)) => owner = Some(UniquePlayer(player)) - originalOwnerName = originalOwnerName.orElse { Some(player.Name) } + originalOwnerName = originalOwnerName.orElse(Some(player.Name)) OwnerGuid = player case (_, Some(player)) => owner = Some(UniquePlayer(player)) diff --git a/src/main/scala/net/psforever/objects/ce/DeployableBehavior.scala b/src/main/scala/net/psforever/objects/ce/DeployableBehavior.scala index d6a551a01..21e17818e 100644 --- a/src/main/scala/net/psforever/objects/ce/DeployableBehavior.scala +++ b/src/main/scala/net/psforever/objects/ce/DeployableBehavior.scala @@ -75,7 +75,7 @@ trait DeployableBehavior { } case Deployable.Ownership(Some(player)) - if !DeployableObject.Destroyed && DeployableObject.OwnerGuid.isEmpty => + if !DeployableObject.Destroyed /*&& DeployableObject.OwnerGuid.isEmpty*/ => if (constructed.contains(true)) { gainOwnership(player) } else { @@ -143,7 +143,7 @@ trait DeployableBehavior { DeployableBehavior.changeOwnership( obj, toFaction, - DeployableInfo(obj.GUID, Deployable.Icon.apply(obj.Definition.Item), obj.Position, obj.OwnerGuid.get) + DeployableInfo(obj.GUID, Deployable.Icon.apply(obj.Definition.Item), obj.Position, player.GUID) ) } @@ -292,26 +292,25 @@ object DeployableBehavior { */ def changeOwnership(obj: Deployable, toFaction: PlanetSideEmpire.Value, info: DeployableInfo): Unit = { val originalFaction = obj.Faction + val zone = obj.Zone + val localEvents = zone.LocalEvents if (originalFaction != toFaction) { - val guid = obj.GUID - val zone = obj.Zone - val localEvents = zone.LocalEvents obj.Faction = toFaction //visual tells in regards to ownership by faction zone.AvatarEvents ! AvatarServiceMessage( zone.id, - AvatarAction.SetEmpire(Service.defaultPlayerGUID, guid, toFaction) + AvatarAction.SetEmpire(Service.defaultPlayerGUID, obj.GUID, toFaction) ) //remove knowledge by the previous owner's faction localEvents ! LocalServiceMessage( originalFaction.toString, LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Dismiss, info) ) - //display to the given faction - localEvents ! LocalServiceMessage( - toFaction.toString, - LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Build, info) - ) } + //display to the given faction + localEvents ! LocalServiceMessage( + toFaction.toString, + LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Build, info) + ) } }