avoid having to compute distance when it's already passed as a parameter

This commit is contained in:
Nicolás Badano 2015-02-15 18:06:17 -03:00
parent 2105bc18db
commit a1e5931f4e
2 changed files with 15 additions and 14 deletions

View File

@ -19,7 +19,8 @@ _turret = _this select 1;
_distance = call FUNC(getRange);
if !(!GVAR(enabled) && [] call FUNC(canUseFCS)) exitWith {};
if (GVAR(Enabled)) exitWith {};
if !([] call FUNC(canUseFCS)) exitWith {};
GVAR(Enabled) = true;
GVAR(Time) = time;

View File

@ -19,18 +19,22 @@ _turret = _this select 1;
_turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
_distance = call FUNC(getRange);
_distance = 0;
if (count _this > 2) then {
_distance = _this select 2;
} else {
_distance = call FUNC(getRange);
if (_distance == 0) then {
_distance = [
getNumber (_turretConfig >> QGVAR(DistanceInterval)),
getNumber (_turretConfig >> QGVAR(MaxDistance)),
getNumber (_turretConfig >> QGVAR(MinDistance))
] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
};
};
_magazines = _vehicle magazinesTurret _turret;
if (_distance == 0) then {
_distance = [
getNumber (_turretConfig >> QGVAR(DistanceInterval)),
getNumber (_turretConfig >> QGVAR(MaxDistance)),
getNumber (_turretConfig >> QGVAR(MinDistance))
] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
};
private ["_weaponDirection", "_angleTarget"];
_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets
@ -45,10 +49,6 @@ if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turr
_angleTarget = asin (_weaponDirection select 2);
if (count _this > 2) then {
_distance = _this select 2;
};
if (!(isNil QGVAR(backgroundCalculation)) and {!(scriptDone GVAR(backgroundCalculation))}) then {
terminate GVAR(backgroundCalculation);
};