don't charge cargo

This commit is contained in:
ScrawnyRonnie 2023-11-14 11:05:58 -05:00
parent 9e76fcc42a
commit 962904b3d9

View file

@ -963,13 +963,26 @@ class SessionData(
log.debug(s"$pkt") 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 = { def handleFacilityBenefitShieldChargeRequest(pkt: FacilityBenefitShieldChargeRequestMessage): Unit = {
val FacilityBenefitShieldChargeRequestMessage(_) = pkt val FacilityBenefitShieldChargeRequestMessage(_) = pkt
val vehicleGuid = player.VehicleSeated val vehicleGuid = player.VehicleSeated
continent continent
.GUID(vehicleGuid) .GUID(vehicleGuid)
.foreach { .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( obj.Actor ! CommonMessages.ChargeShields(
15, 15,
Some(continent.blockMap.sector(obj).buildingList.maxBy(_.Definition.SOIRadius)) Some(continent.blockMap.sector(obj).buildingList.maxBy(_.Definition.SOIRadius))