From 2104e5b45f3c7a3dbbbac33d77a08ef63fd95e24 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 8 Jun 2015 17:52:33 +0200 Subject: [PATCH] Optimized condition functions, Removed redundant toLower for animation names --- addons/sitting/functions/fnc_canSit.sqf | 7 +------ addons/sitting/functions/fnc_canStand.sqf | 7 +++---- addons/sitting/functions/fnc_getRandomAnimation.sqf | 12 ++---------- addons/sitting/functions/fnc_sit.sqf | 3 +-- addons/sitting/functions/fnc_stand.sqf | 7 +++++-- 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/addons/sitting/functions/fnc_canSit.sqf b/addons/sitting/functions/fnc_canSit.sqf index 1c00e79cd8..3e270c9f1a 100644 --- a/addons/sitting/functions/fnc_canSit.sqf +++ b/addons/sitting/functions/fnc_canSit.sqf @@ -19,9 +19,4 @@ PARAMS_2(_seat,_player); // If seat object and not occupied -if (getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && - {isNil{_seat getVariable QGVAR(seatOccupied)}} -) exitWith {true}; - -// Default -false +(getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && {isNil{_seat getVariable QGVAR(seatOccupied)}}) diff --git a/addons/sitting/functions/fnc_canStand.sqf b/addons/sitting/functions/fnc_canStand.sqf index 853eadc3d1..1e862ecaea 100644 --- a/addons/sitting/functions/fnc_canStand.sqf +++ b/addons/sitting/functions/fnc_canStand.sqf @@ -15,8 +15,7 @@ */ #include "script_component.hpp" -// If sitting -if (_this getVariable [QGVAR(sitting),false]) exitWith {true}; +PARAMS_1(_player); -// Default -false +// If sitting +(_player getVariable [QGVAR(sitting),false]) diff --git a/addons/sitting/functions/fnc_getRandomAnimation.sqf b/addons/sitting/functions/fnc_getRandomAnimation.sqf index 79b8c5628f..65249f24f6 100644 --- a/addons/sitting/functions/fnc_getRandomAnimation.sqf +++ b/addons/sitting/functions/fnc_getRandomAnimation.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" // Animations Pool -_animPool = [ +_animations = [ "HubSittingChairUA_idle1", "HubSittingChairUA_idle2", "HubSittingChairUA_idle3", @@ -43,13 +43,5 @@ _animPool = [ "HubSittingChairC_move1" ]; -// Set all animation names to lower-case -_animations = []; -{ - _animations pushBack (toLower _x); -} forEach _animPool; - // Select random animation -_animation = _animations select (floor (random (count _animations))); - -_animation +(_animations select (floor (random (count _animations)))) diff --git a/addons/sitting/functions/fnc_sit.sqf b/addons/sitting/functions/fnc_sit.sqf index 07026c6e35..355da12613 100644 --- a/addons/sitting/functions/fnc_sit.sqf +++ b/addons/sitting/functions/fnc_sit.sqf @@ -33,8 +33,7 @@ _player setDir ((getDir _seat) + _sitDirection); _player setPos (_seat modelToWorld _sitPosition); // Get random animation and perform it -_animation = call FUNC(getRandomAnimation); -[_player, _animation, 2] call EFUNC(common,doAnimation); +[_player, call FUNC(getRandomAnimation), 2] call EFUNC(common,doAnimation); // Set variables _player setVariable [QGVAR(sitting), true]; diff --git a/addons/sitting/functions/fnc_stand.sqf b/addons/sitting/functions/fnc_stand.sqf index 5474720b47..673cb67ccc 100644 --- a/addons/sitting/functions/fnc_stand.sqf +++ b/addons/sitting/functions/fnc_stand.sqf @@ -15,9 +15,12 @@ */ #include "script_component.hpp" +PARAMS_1(_player); + // Restore animation -[_this, "", 2] call EFUNC(common,doAnimation); +[_player, "", 2] call EFUNC(common,doAnimation); // Set variables to nil -_this setVariable [QGVAR(sitting), nil]; +_player setVariable [QGVAR(sitting), nil]; GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true]; +GVAR(seat) = nil;