Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more queryExtension return value checks, update cmake-conan #725

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SDK/lib/cmake-conan
Submodule cmake-conan updated 5 files
+2 −2 CMakeLists.txt
+28 −11 README.md
+2 −2 conan-omp.cmake
+152 −15 conan.cmake
+86 −35 tests.py
7 changes: 6 additions & 1 deletion Server/Components/Pawn/Scripting/TextLabel/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ SCRIPT_API_FAILRET(CreatePlayer3DTextLabel, INVALID_TEXT_LABEL_ID, int(IPlayer&

SCRIPT_API(DeletePlayer3DTextLabel, bool(IPlayer& player, IPlayerTextLabel& textlabel))
{
queryExtension<IPlayerTextLabelData>(player)->release(textlabel.getID());
auto data = queryExtension<IPlayerTextLabelData>(player);
if (!data)
{
return false;
}
data->release(textlabel.getID());
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions Server/Components/Pickups/pickups_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ class PickupsComponent final : public IPickupsComponent, public PlayerConnectEve
{
return false;
}

auto data = queryExtension<IPlayerPickupData>(peer);
if (!data)
{
return false;
}

int id = data->fromClientID(onPlayerPickUpPickupRPC.PickupID);
if (!id)
{
Expand Down
9 changes: 9 additions & 0 deletions Server/Components/Vehicles/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ bool Vehicle::updateFromTrailerSync(const VehicleTrailerSyncPacket& trailerSync,
updateOccupied();

PlayerVehicleData* playerData = queryExtension<PlayerVehicleData>(player);
if (!playerData)
{
return false;
}

Vehicle* vehicle = static_cast<Vehicle*>(playerData->getVehicle());

if (!vehicle || vehicle->detaching)
Expand Down Expand Up @@ -369,6 +374,10 @@ bool Vehicle::updateFromTrailerSync(const VehicleTrailerSyncPacket& trailerSync,
bool Vehicle::updateFromPassengerSync(const VehiclePassengerSyncPacket& passengerSync, IPlayer& player)
{
PlayerVehicleData* data = queryExtension<PlayerVehicleData>(player);
if (!data)
{
return false;
}
// Only do heavy processing if switching vehicle or switching between driver and passenger
int passengerSeats = Impl::getVehiclePassengerSeats(getModel());
// TODO: Deal with two players in the same seat.
Expand Down
7 changes: 6 additions & 1 deletion Server/Components/Vehicles/vehicles_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class VehiclesComponent final : public IVehiclesComponent, public CoreEventHandl
}

IPlayerVehicleData* vehData = queryExtension<IPlayerVehicleData>(peer);
if (!lock.entry->isStreamedInForPlayer(peer) || !(peer.getState() == PlayerState_Driver || peer.getState() == PlayerState_Passenger) || vehData->getVehicle() != lock.entry)
if (vehData == nullptr || !lock.entry->isStreamedInForPlayer(peer) || !(peer.getState() == PlayerState_Driver || peer.getState() == PlayerState_Passenger) || vehData->getVehicle() != lock.entry)
{
return false;
}
Expand Down Expand Up @@ -126,6 +126,11 @@ class VehiclesComponent final : public IVehiclesComponent, public CoreEventHandl
}

PlayerVehicleData* data = queryExtension<PlayerVehicleData>(peer);
if (!data)
{
return false;
}

IVehicle* vehicle = data->getVehicle();
if (vehicle && vehicle->getDriver() == &peer)
{
Expand Down
2 changes: 1 addition & 1 deletion Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
Player& player = static_cast<Player&>(peer);
PlayerState state = player.getState();
IPlayerVehicleData* vehData = queryExtension<IPlayerVehicleData>(peer);
if (state != PlayerState_Driver || vehData->getVehicle() == nullptr)
if (state != PlayerState_Driver || vehData == nullptr || vehData->getVehicle() == nullptr)
{
return false;
}
Expand Down
Loading