Don't unload vehicle inventory contents if the player is seated in it (fixes race condition with PSUM + vehicle mounting)

This commit is contained in:
Mazo 2021-02-02 20:56:47 +00:00
parent c02a71f2ee
commit 7cc1dbbc63
2 changed files with 5 additions and 6 deletions

View file

@ -119,10 +119,7 @@ object MiddlewareActor {
packet.isInstanceOf[CharacterInfoMessage] packet.isInstanceOf[CharacterInfoMessage]
} }
/** /** `KeepAliveMessage` packets are bundled by themselves. They're special. */
* `KeepAliveMessage` packets are bundled by themselves.
* They're special.
*/
def keepAliveMessageGuard(packet: PlanetSidePacket): Boolean = { def keepAliveMessageGuard(packet: PlanetSidePacket): Boolean = {
packet.isInstanceOf[KeepAliveMessage] packet.isInstanceOf[KeepAliveMessage]
} }

View file

@ -3655,7 +3655,9 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
} }
} }
accessedContainer match { accessedContainer match {
case Some(veh: Vehicle) => // Ensure we don't unload the contents of the vehicle trunk for players seated in the vehicle.
// This can happen if PSUM arrives during the mounting process
case Some(veh: Vehicle) if player.VehicleSeated.isEmpty || player.VehicleSeated.get != veh.GUID =>
if ( if (
isMoving || veh.isMoving(1) || Vector3.DistanceSquared( isMoving || veh.isMoving(1) || Vector3.DistanceSquared(
player.Position, player.Position,
@ -3668,7 +3670,7 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
UnaccessContainer(veh) UnaccessContainer(veh)
} }
case Some(container) => //just in case case Some(container) => //just in case
if (isMovingPlus) { if (isMovingPlus && (player.VehicleSeated.isEmpty || player.VehicleSeated.get != container.GUID)) { // Ensure we don't close the container if the player is seated in it
val guid = player.GUID val guid = player.GUID
// If the container is a corpse and gets removed just as this runs it can cause a client disconnect, so we'll check the container has a GUID first. // If the container is a corpse and gets removed just as this runs it can cause a client disconnect, so we'll check the container has a GUID first.
if (container.HasGUID) { if (container.HasGUID) {