Skip to content

Commit 201ff28

Browse files
authored
More validity checks for vehicles (mainly trailers) (#985)
* Check for non-streamed trailer * Check driver and passenger sync if the reported vehicle is streamed in * Passenger sync without stream check as train carriages always aren't streamed * Add turnSpeed validation for trailers
1 parent a672484 commit 201ff28

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Server/Components/Vehicles/vehicle.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void Vehicle::streamOutForClient(IPlayer& player)
159159

160160
bool Vehicle::updateFromDriverSync(const VehicleDriverSyncPacket& vehicleSync, IPlayer& player)
161161
{
162-
if (respawning)
162+
if (respawning || !streamedFor_.valid(player.getID()))
163163
{
164164
return false;
165165
}
@@ -233,7 +233,15 @@ bool Vehicle::updateFromDriverSync(const VehicleDriverSyncPacket& vehicleSync, I
233233
trailer = static_cast<Vehicle*>(pool->get(vehicleSync.TrailerID));
234234
if (trailer)
235235
{
236-
trailer->cab = this;
236+
const bool isStreamedIn = trailer->isStreamedInForPlayer(player);
237+
if (!isStreamedIn)
238+
{
239+
trailer = nullptr;
240+
}
241+
else
242+
{
243+
trailer->cab = this;
244+
}
237245
}
238246
}
239247
}

Server/Source/player_pool.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,11 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
15321532
return false;
15331533
}
15341534

1535+
if (trailerSync.TurnVelocity.x < -1.0f || trailerSync.TurnVelocity.x > 1.0f || trailerSync.TurnVelocity.y < -1.0f || trailerSync.TurnVelocity.y > 1.0f || trailerSync.TurnVelocity.z < -1.0f || trailerSync.TurnVelocity.z > 1.0f)
1536+
{
1537+
return false;
1538+
}
1539+
15351540
IVehicle* vehiclePtr = self.vehiclesComponent->get(trailerSync.VehicleID);
15361541
if (!vehiclePtr)
15371542
{

0 commit comments

Comments
 (0)