diff --git a/src/main/scala/net/psforever/actors/session/support/SessionData.scala b/src/main/scala/net/psforever/actors/session/support/SessionData.scala index 2aa1feb4..d98e5b86 100644 --- a/src/main/scala/net/psforever/actors/session/support/SessionData.scala +++ b/src/main/scala/net/psforever/actors/session/support/SessionData.scala @@ -963,13 +963,26 @@ class SessionData( log.debug(s"$pkt") } + // This is for excluding cargo vehicles from attempting to charge their shield while mounted in a carrier vehicle. + // As per issue 1126, this would cause the client of the cargo vehicle occupant(s) to disconnect + def handleGetCargoVehicles(vehicle: Vehicle): List[Vehicle] = { + val mountedVehicle = vehicle.MountedIn.flatMap { mountedGUID => + continent.GUID(mountedGUID.guid).collect { case mountedVehicle: Vehicle => mountedVehicle } + }.toList + mountedVehicle + } + + def handleIsCargoVehicle(vehicle: Vehicle): Boolean = { + handleGetCargoVehicles(vehicle).nonEmpty + } + def handleFacilityBenefitShieldChargeRequest(pkt: FacilityBenefitShieldChargeRequestMessage): Unit = { val FacilityBenefitShieldChargeRequestMessage(_) = pkt val vehicleGuid = player.VehicleSeated continent .GUID(vehicleGuid) .foreach { - case obj: Vehicle if !obj.Destroyed => //vehicle will try to charge even if destroyed + case obj: Vehicle if !obj.Destroyed && !handleIsCargoVehicle(obj) => // vehicle will try to charge even if destroyed obj.Actor ! CommonMessages.ChargeShields( 15, Some(continent.blockMap.sector(obj).buildingList.maxBy(_.Definition.SOIRadius))