refactor: Only act on an entity if we have control

This commit is contained in:
Yimura 2022-01-07 17:00:42 +01:00
parent df92a95aa9
commit 121553a3f5
3 changed files with 12 additions and 12 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);