From 121553a3f58dcb45117a367e3f6498b15a4ea3bc Mon Sep 17 00:00:00 2001 From: Yimura Date: Fri, 7 Jan 2022 17:00:42 +0100 Subject: [PATCH] refactor: Only act on an entity if we have control --- BigBaseV2/src/backend/looped/self/noclip.cpp | 9 +++++---- BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp | 11 ++++++----- BigBaseV2/src/util/vehicle.hpp | 4 +--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BigBaseV2/src/backend/looped/self/noclip.cpp b/BigBaseV2/src/backend/looped/self/noclip.cpp index 38aa6398..d49fb36a 100644 --- a/BigBaseV2/src/backend/looped/self/noclip.cpp +++ b/BigBaseV2/src/backend/looped/self/noclip.cpp @@ -85,10 +85,11 @@ namespace big } else if (bNoclip != bLastNoclip) { - entity::take_control_of(ent); - - ENTITY::FREEZE_ENTITY_POSITION(ent, false); - ENTITY::SET_ENTITY_COLLISION(ent, true, false); + if (entity::take_control_of(ent)) + { + ENTITY::FREEZE_ENTITY_POSITION(ent, false); + ENTITY::SET_ENTITY_COLLISION(ent, true, false); + } } bLastNoclip = bNoclip; diff --git a/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp b/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp index 567a1a56..647ec789 100644 --- a/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp @@ -52,11 +52,12 @@ namespace big } else { - entity::take_control_of(ent); + if (entity::take_control_of(ent) && ENTITY::IS_ENTITY_A_PED(ent) && !PED::IS_PED_RAGDOLL(ent)) + { + TASK::SET_HIGH_FALL_TASK(ent, 0, 0, 0); - if (ENTITY::IS_ENTITY_A_PED(ent) && !PED::IS_PED_RAGDOLL(ent)) TASK::SET_HIGH_FALL_TASK(ent, 0, 0, 0); - - notify::above_map("Selected entity at crosshair."); + notify::above_map("Selected entity at crosshair."); + } } } } @@ -75,7 +76,7 @@ namespace big if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 15)) dist += 5; - entity::take_control_of(ent); + if (!entity::take_control_of(ent)) return; ENTITY::SET_ENTITY_COLLISION(ent, false, false); diff --git a/BigBaseV2/src/util/vehicle.hpp b/BigBaseV2/src/util/vehicle.hpp index 8cc32186..fd4585d8 100644 --- a/BigBaseV2/src/util/vehicle.hpp +++ b/BigBaseV2/src/util/vehicle.hpp @@ -35,9 +35,7 @@ namespace big::vehicle inline bool repair(Vehicle veh) { - if (!ENTITY::IS_ENTITY_A_VEHICLE(veh)) return false; - - entity::take_control_of(veh); + if (!ENTITY::IS_ENTITY_A_VEHICLE(veh) || !entity::take_control_of(veh)) return false; VEHICLE::SET_VEHICLE_FIXED(veh); VEHICLE::SET_VEHICLE_DEFORMATION_FIXED(veh);