From 2423798753571dacb663b1f396d8f32fec8f72c0 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Tue, 4 Aug 2015 05:11:45 +0200 Subject: [PATCH] Updated parameterization in Vehiclelock module. --- .../functions/fnc_addKeyForVehicle.sqf | 2 +- .../functions/fnc_getVehicleSideKey.sqf | 2 +- .../functions/fnc_handleVehicleInitPost.sqf | 17 ++++++++++------- .../functions/fnc_hasKeyForVehicle.sqf | 2 +- addons/vehiclelock/functions/fnc_lockpick.sqf | 19 +++++++------------ .../vehiclelock/functions/fnc_moduleInit.sqf | 5 +++-- .../vehiclelock/functions/fnc_moduleSync.sqf | 9 ++++++--- .../functions/fnc_onOpenInventory.sqf | 2 +- .../functions/fnc_serverSetupCustomKeyEH.sqf | 2 +- .../functions/fnc_setVehicleLockEH.sqf | 2 +- 10 files changed, 32 insertions(+), 30 deletions(-) diff --git a/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf b/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf index d683073286..1adec69413 100644 --- a/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf +++ b/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf @@ -20,7 +20,7 @@ private ["_previousMags","_newMags","_keyMagazine","_keyName"]; -PARAMS_3(_unit,_veh,_useCustom); +params ["_unit", "_veh", "_useCustom"]; if (isNull _unit) exitWith {ERROR("null unit");}; if (isNull _veh) exitWith {ERROR("null vehicle");}; diff --git a/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf b/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf index 999f471ac3..e981a16842 100644 --- a/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf +++ b/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf @@ -17,7 +17,7 @@ private ["_vehConfigSide","_vehSide","_returnValue"]; -PARAMS_1(_veh); +params ["_veh"]; if (isNull _veh) exitWith {ERROR("null vehicle"); "error"}; diff --git a/addons/vehiclelock/functions/fnc_handleVehicleInitPost.sqf b/addons/vehiclelock/functions/fnc_handleVehicleInitPost.sqf index 5a2bc3f7bd..f252c25c93 100644 --- a/addons/vehiclelock/functions/fnc_handleVehicleInitPost.sqf +++ b/addons/vehiclelock/functions/fnc_handleVehicleInitPost.sqf @@ -16,23 +16,26 @@ */ #include "script_component.hpp" -PARAMS_1(_vehicle); - if (!isServer) exitWith {}; +params ["_vehicle"]; + [{ //If the module wasn't placed, just exit (needs to be in wait because objectInitEH is before moduleInit) if (GVAR(VehicleStartingLockState) == -1) exitWith {}; + private ["_lock"]; - PARAMS_1(_vehicle); + + params ["_vehicle"]; + if ((_vehicle isKindOf "Car") || {_vehicle isKindOf "Tank"} || {_vehicle isKindOf "Helicopter"}) then { //set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states) _lock = switch (GVAR(VehicleStartingLockState)) do { - case (0): {(locked _vehicle) in [2, 3]}; - case (1):{true}; - case (2):{false}; + case (0): { (locked _vehicle) in [2, 3] }; + case (1): { true }; + case (2): { false }; }; - if (((_lock) && {(locked _vehicle) != 2}) || {(!_lock) && {(locked _vehicle) != 0}}) then { + if ((_lock && {(locked _vehicle) != 2}) || {!_lock && {(locked _vehicle) != 0}}) then { TRACE_3("Setting Lock State",_lock,(typeOf _vehicle),_vehicle); ["VehicleLock_SetVehicleLock", [_vehicle], [_vehicle, _lock]] call EFUNC(common,targetEvent); }; diff --git a/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf b/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf index 779f4a363e..6b91c1cc0d 100644 --- a/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf +++ b/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf @@ -18,7 +18,7 @@ private ["_returnValue","_sideKeyName","_customKeys"]; -PARAMS_2(_unit,_veh); +params ["_unit", "_veh"]; if (isNull _unit) exitWith {ERROR("null unit"); false}; if (isNull _veh) exitWith {ERROR("null vehicle"); false}; diff --git a/addons/vehiclelock/functions/fnc_lockpick.sqf b/addons/vehiclelock/functions/fnc_lockpick.sqf index 613a7b35dc..75a7f59240 100644 --- a/addons/vehiclelock/functions/fnc_lockpick.sqf +++ b/addons/vehiclelock/functions/fnc_lockpick.sqf @@ -22,7 +22,7 @@ private ["_vehLockpickStrenth","_condition","_returnValue"]; -PARAMS_3(_unit,_veh,_funcType); +params ["_unit", "_veh", "_funcType"]; if (isNull _unit) exitWith {ERROR("null unit"); false}; if (isNull _veh) exitWith {ERROR("null vehicle"); false}; @@ -41,25 +41,20 @@ if (_vehLockpickStrenth < 0) exitWith {false}; //Condition check for progressBar _condition = { - PARAMS_1(_args); - EXPLODE_2_PVT(_args,_unit,_veh); + params ["_args"]; + _args params ["_args", "_unit", "_veh"]; ((_unit distance _veh) < 5) && {(speed _veh) < 0.1} }; if (!([[_unit, _veh]] call _condition)) exitWith {false}; -_returnValue = false; -switch (true) do { -case (_funcType == "canLockpick"): { - _returnValue = true; - }; -case (_funcType == "startLockpick"): { +_returnValue = _funcType in ["canLockpick", "startLockpick", "finishLockpick"]; +switch (_funcType) do { + case "startLockpick": { [_vehLockpickStrenth, [_unit, _veh, "finishLockpick"], {(_this select 0) call FUNC(lockpick)}, {}, (localize LSTRING(Action_LockpickInUse)), _condition] call EFUNC(common,progressBar); - _returnValue = true; }; -case (_funcType == "finishLockpick"): { + case "finishLockpick": { ["VehicleLock_SetVehicleLock", [_veh], [_veh, false]] call EFUNC(common,targetEvent); - _returnValue = true; }; default { ERROR("bad function type"); diff --git a/addons/vehiclelock/functions/fnc_moduleInit.sqf b/addons/vehiclelock/functions/fnc_moduleInit.sqf index 510b8ec7be..2b0889b814 100644 --- a/addons/vehiclelock/functions/fnc_moduleInit.sqf +++ b/addons/vehiclelock/functions/fnc_moduleInit.sqf @@ -17,10 +17,11 @@ */ #include "script_component.hpp" -PARAMS_3(_logic,_syncedUnits,_activated); +if (!isServer) exitWith {}; + +params ["_logic", "_syncedUnits", "_activated"]; if (!_activated) exitWith {WARNING("Vehicle Lock Init Module - placed but not active");}; -if (!isServer) exitWith {}; //Set the GVAR for default lockpick strength [_logic, QGVAR(DefaultLockpickStrength), "DefaultLockpickStrength"] call EFUNC(common,readSettingFromModule); diff --git a/addons/vehiclelock/functions/fnc_moduleSync.sqf b/addons/vehiclelock/functions/fnc_moduleSync.sqf index ede20e3196..a43e462113 100644 --- a/addons/vehiclelock/functions/fnc_moduleSync.sqf +++ b/addons/vehiclelock/functions/fnc_moduleSync.sqf @@ -17,14 +17,17 @@ */ #include "script_component.hpp" -PARAMS_3(_logic,_syncedObjects,_activated); +if (!isServer) exitWith {}; + +params ["_logic", "_syncedObjects", "_activated"]; if !(_activated) exitWith {WARNING("Vehicle Lock Sync Module - placed but not active");}; -if (!isServer) exitWith {}; [{ private ["_listOfVehicles"]; - PARAMS_1(_syncedObjects); + + params ["_syncedObjects"]; + _listOfVehicles = []; { if ((_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")) then { diff --git a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf index 8199f4b850..0105f5ae3f 100644 --- a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf +++ b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf @@ -16,7 +16,7 @@ */ #include "script_component.hpp" -PARAMS_2(_unit,_container); +params ["_unit", "_container"]; //Only check for player: if (_unit != ace_player) exitWith {false}; diff --git a/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf b/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf index 9d8a396e31..6f1c2ffdbe 100644 --- a/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf +++ b/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf @@ -18,7 +18,7 @@ private ["_currentKeys"]; -PARAMS_2(_veh,_key); +params ["_veh", "_key"]; if (!isServer) exitWith {ERROR("only run on server");}; if (isNull _veh) exitWith {ERROR("null vehicle");}; diff --git a/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf b/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf index cb51cb27a8..611ce76e30 100644 --- a/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf +++ b/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf @@ -18,7 +18,7 @@ private ["_lockNumber"]; -PARAMS_2(_veh,_isLocked); +params ["_veh", "_isLocked"]; _lockNumber = if (_isLocked) then {2} else {0}; TRACE_2("Setting Lock State", _veh, _lockNumber);