common code fixes

This commit is contained in:
commy2 2015-12-12 17:26:47 +01:00
parent 3d5ea74c7e
commit 2839cff753
13 changed files with 17 additions and 18 deletions

View File

@ -18,7 +18,7 @@ params ["_number", ["_minLength", 8]];
_number = round _number; _number = round _number;
private _array = []; private _array = [];
private _array resize _minLength; _array resize _minLength;
for "_index" from 0 to (_minLength - 1) do { for "_index" from 0 to (_minLength - 1) do {
_array set [_index, false]; _array set [_index, false];
@ -27,7 +27,7 @@ for "_index" from 0 to (_minLength - 1) do {
private _index = 0; private _index = 0;
while {_number > 0} do { while {_number > 0} do {
_rest = _number mod 2; private _rest = _number mod 2;
_number = floor (_number / 2); _number = floor (_number / 2);
_array set [_index, _rest == 1]; _array set [_index, _rest == 1];

View File

@ -23,8 +23,7 @@ if (isNil QGVAR(lastHint)) then {
if !(typeName _text in ["STRING", "TEXT"]) then {_text = str _text}; if !(typeName _text in ["STRING", "TEXT"]) then {_text = str _text};
private _lastHintTime = GVAR(lastHint) select 0; GVAR(lastHint) params ["_lastHintTime", "_lastHintPriority"];
private _lastHintPriority = GVAR(lastHint) select 1;
private _time = ACE_time; private _time = ACE_time;

View File

@ -15,6 +15,6 @@
params ["_vehicle"]; params ["_vehicle"];
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle; private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _turret = [_vehicle] call FUNC(getTurretCommander); private _turret = _vehicle call FUNC(getTurretCommander);
[_config, _turret] call FUNC(getTurretConfigPath) // return [_config, _turret] call FUNC(getTurretConfigPath) // return

View File

@ -15,6 +15,6 @@
params ["_vehicle"]; params ["_vehicle"];
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle; private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _turret = [_vehicle] call FUNC(getTurretGunner); private _turret = _vehicle call FUNC(getTurretGunner);
[_config, _turret] call FUNC(getTurretConfigPath) // return [_config, _turret] call FUNC(getTurretConfigPath) // return

View File

@ -21,7 +21,7 @@ if (isNil "_value") then {
if (!isNil "_defaultValue") then { if (!isNil "_defaultValue") then {
_value = _defaultValue; _value = _defaultValue;
} else { } else {
private _definedVariable = [_variable] call FUNC(getDefinedVariableInfo); private _definedVariable = _variable call FUNC(getDefinedVariableInfo);
if (count _definedVariable > 1) then { if (count _definedVariable > 1) then {
_value = _definedVariable select 1; _value = _definedVariable select 1;

View File

@ -14,7 +14,7 @@
params ["_varName"]; params ["_varName"];
private _variableDefinition = [_varName] call FUNC(getDefinedVariableInfo); private _variableDefinition = _varName call FUNC(getDefinedVariableInfo);
if !(_variableDefinition isEqualTo []) exitWith { if !(_variableDefinition isEqualTo []) exitWith {
_variableDefinition select 1; _variableDefinition select 1;

View File

@ -19,8 +19,7 @@ if (!isLightOn _vehicle) exitWith {[]};
private _reflectorsWithSelections = [[_vehicle], FUNC(getReflectorsWithSelections), uiNamespace, format [QEGVAR(cache,%1_%2), QUOTE(DFUNC(getReflectorsWithSelections)), typeOf _vehicle], 1E11] call FUNC(cachedCall); private _reflectorsWithSelections = [[_vehicle], FUNC(getReflectorsWithSelections), uiNamespace, format [QEGVAR(cache,%1_%2), QUOTE(DFUNC(getReflectorsWithSelections)), typeOf _vehicle], 1E11] call FUNC(cachedCall);
//_reflectorsWithSelections = [_vehicle] call FUNC(getReflectorsWithSelections); //_reflectorsWithSelections = [_vehicle] call FUNC(getReflectorsWithSelections);
private _lights = _reflectorsWithSelections select 0; _reflectorsWithSelections params ["_lights", "_hitpoints"];
private _hitpoints = _reflectorsWithSelections select 1;
private _turnedOnLights = []; private _turnedOnLights = [];

View File

@ -18,7 +18,7 @@
params ["_unit", "_weapon"]; params ["_unit", "_weapon"];
private _muzzles = [_weapon] call FUNC(getWeaponMuzzles); private _muzzles = _weapon call FUNC(getWeaponMuzzles);
private _weaponInfo = [["","","",""], primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit] select ((["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] find _weapon) max 0); private _weaponInfo = [["","","",""], primaryWeaponItems _unit, secondaryWeaponItems _unit, handgunItems _unit] select ((["", primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] find _weapon) max 0);

View File

@ -18,8 +18,8 @@ ERRORDATA(2);
private _hash = nil; private _hash = nil;
try { try {
if(VALIDHASH(_hashList)) then { if(VALIDHASH(_hashList)) then {
private _keys = _hashList select 0; _hashList params ["_keys", "_hashes"];
private _hashes = _hashList select 1;
if(_index < (count _hashes)) then { if(_index < (count _hashes)) then {
private _values = _hashes select _index; private _values = _hashes select _index;

View File

@ -18,7 +18,7 @@ ERRORDATA(3);
try { try {
if(VALIDHASH(_hashList)) then { if(VALIDHASH(_hashList)) then {
if(VALIDHASH(_value)) then { if(VALIDHASH(_value)) then {
private _vals = _value select 1; _value params ["", "_vals"];
(_hashList select 1) set[_index, _vals]; (_hashList select 1) set[_index, _vals];
} else { } else {

View File

@ -12,6 +12,6 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_modName", "", [""]]; params [["_modName", "", [""]]];
isClass (configFile >> "CfgPatches" >> _modName) // return isClass (configFile >> "CfgPatches" >> _modName) // return

View File

@ -48,14 +48,14 @@ if (_lightSource isKindOf "CAManBase") then {
} else { } else {
// handle any object, strcutures, cars, tanks, etc. @todo campfires, burning vehicles // handle any object, strcutures, cars, tanks, etc. @todo campfires, burning vehicles
private _lights = [_lightSource] call FUNC(getTurnedOnLights); private _lights = _lightSource call FUNC(getTurnedOnLights);
{ {
private _properties = [[_lightSource, _x], FUNC(getLightProperties), uiNamespace, format [QEGVAR(cache,%1_%2_%3), QUOTE(DFUNC(getLightProperties)), typeOf _lightSource, _x], 1E11] call FUNC(cachedCall); private _properties = [[_lightSource, _x], FUNC(getLightProperties), uiNamespace, format [QEGVAR(cache,%1_%2_%3), QUOTE(DFUNC(getLightProperties)), typeOf _lightSource, _x], 1E11] call FUNC(cachedCall);
//_properties = [_lightSource, _x] call FUNC(getLightProperties); //_properties = [_lightSource, _x] call FUNC(getLightProperties);
// @todo intensity affects range? // @todo intensity affects range?
//private _intensity = _properties select 0; //_properties params ["_intensity"];
private _innerAngle = (_properties select 3) / 2; private _innerAngle = (_properties select 3) / 2;
private _outerAngle = (_properties select 4) / 2; private _outerAngle = (_properties select 4) / 2;

View File

@ -16,7 +16,8 @@
GVAR(settings) = []; GVAR(settings) = [];
private _fnc_parseConfigForSettings = { private _fnc_parseConfigForSettings = {
private _config = _this select 0; params ["_config"];
private _countOptions = count _config; private _countOptions = count _config;
for "_index" from 0 to (_countOptions - 1) do { for "_index" from 0 to (_countOptions - 1) do {