Skip to content

Commit

Permalink
More validity checks for vehicles (mainly trailers) (#985)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
NexiusTailer authored Oct 8, 2024
1 parent a672484 commit 201ff28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Server/Components/Vehicles/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void Vehicle::streamOutForClient(IPlayer& player)

bool Vehicle::updateFromDriverSync(const VehicleDriverSyncPacket& vehicleSync, IPlayer& player)
{
if (respawning)
if (respawning || !streamedFor_.valid(player.getID()))
{
return false;
}
Expand Down Expand Up @@ -233,7 +233,15 @@ bool Vehicle::updateFromDriverSync(const VehicleDriverSyncPacket& vehicleSync, I
trailer = static_cast<Vehicle*>(pool->get(vehicleSync.TrailerID));
if (trailer)
{
trailer->cab = this;
const bool isStreamedIn = trailer->isStreamedInForPlayer(player);
if (!isStreamedIn)
{
trailer = nullptr;
}
else
{
trailer->cab = this;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,11 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
return false;
}

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)
{
return false;
}

IVehicle* vehiclePtr = self.vehiclesComponent->get(trailerSync.VehicleID);
if (!vehiclePtr)
{
Expand Down

0 comments on commit 201ff28

Please sign in to comment.