From 0d194bdeb57854db097c98588bc3587eb7210d0c Mon Sep 17 00:00:00 2001 From: dimmyi <32691211+dimmyi@users.noreply.github.com> Date: Sat, 9 Mar 2024 00:25:16 -0300 Subject: [PATCH 1/2] Update player_impl.hpp Stream the vehicle driver immediately to avoid the vehicle teleport bug after spectating a vehicle and a player is driving the vehicle. --- Server/Source/player_impl.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Server/Source/player_impl.hpp b/Server/Source/player_impl.hpp index f7b728652..0a0d12872 100644 --- a/Server/Source/player_impl.hpp +++ b/Server/Source/player_impl.hpp @@ -1672,6 +1672,13 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy pos_ = target.getPosition(); target.streamInForPlayer(*this); + IPlayer* vdriver = target.getDriver(); + // Stream vehicle driver immediately. + if (vdriver != nullptr) + { + vdriver->streamInForPlayer(*this); + } + spectateData_.type = PlayerSpectateData::ESpectateType::Vehicle; spectateData_.spectateID = target.getID(); From 4ddc3d724ae8becd2ab3ee2282cafa626e725bdc Mon Sep 17 00:00:00 2001 From: dimmyi <32691211+dimmyi@users.noreply.github.com> Date: Sat, 9 Mar 2024 00:41:58 -0300 Subject: [PATCH 2/2] Reversing issue 735 Forcing someone to exit spectator mode when destroying a vehicle breaks many systems. Most admin spectator systems when a player enters a vehicle, the admin starts spectating the player's vehicle, and if some other system, for example storing the vehicle in the garage using DestroyVehicle, would force the admin to stop the mode spectator before even knowing that the player left the vehicle. --- Server/Components/Vehicles/vehicle.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Server/Components/Vehicles/vehicle.cpp b/Server/Components/Vehicles/vehicle.cpp index b39c7f74d..f91823930 100644 --- a/Server/Components/Vehicles/vehicle.cpp +++ b/Server/Components/Vehicles/vehicle.cpp @@ -809,16 +809,7 @@ void Vehicle::destream() { vehicleData->setVehicle(nullptr, 0); } - - // Related issue: https://github.com/openmultiplayer/open.mp/issues/735 - // Disable spectator's spectating state when spectated vehicle is removed - // This also makes spectateData values to be accurate and not remain with old data - auto spectateData = player->getSpectateData(); - if (spectateData.type == PlayerSpectateData::ESpectateType::Vehicle && spectateData.spectateID == poolID) - { - player->setSpectating(false); - } - + if (isStreamedInForPlayer(*player)) { streamOutForClient(*player);