From 20740679cca12701f22aea15cae0b5ce7ccec91f Mon Sep 17 00:00:00 2001 From: ulteq Date: Sun, 19 Apr 2015 17:40:49 +0200 Subject: [PATCH] Fixed inconsistent 'workingMemory' initialization --- addons/atragmx/functions/fnc_change_gun.sqf | 26 ++++++++++++------- .../atragmx/functions/fnc_create_dialog.sqf | 2 +- .../atragmx/functions/fnc_cycle_gun_list.sqf | 2 +- .../functions/fnc_restore_user_data.sqf | 2 +- .../atragmx/functions/fnc_toggle_gun_list.sqf | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/addons/atragmx/functions/fnc_change_gun.sqf b/addons/atragmx/functions/fnc_change_gun.sqf index a401a849e3..7c5abac47e 100644 --- a/addons/atragmx/functions/fnc_change_gun.sqf +++ b/addons/atragmx/functions/fnc_change_gun.sqf @@ -4,7 +4,8 @@ * * Arguments: * gunID - * update solution + * restore workingMemory from gunList + * update display * * Return Value: * Nothing @@ -16,23 +17,30 @@ */ #include "script_component.hpp" -private ["_gunID", "_updateSolution"]; -_gunID = _this select 0; -_updateSolution = _this select 1; +private ["_gunID", "_restoreMemory", "_updateDisplay"]; +_gunID = _this select 0; +_restoreMemory = _this select 1; +_updateDisplay = _this select 2; if (_gunID < 0 || _gunID > (count GVAR(gunList)) - 1) exitWith {}; -GVAR(workingMemory) = +(GVAR(gunList) select _gunID); +if (_restoreMemory) then { + GVAR(workingMemory) = +(GVAR(gunList) select _gunID); +}; GVAR(currentGun) = _gunID; -lbSetCurSel [6000, GVAR(currentGun)]; +if (_updateDisplay) then { + lbSetCurSel [6000, GVAR(currentGun)]; +}; GVAR(currentScopeUnit) = 0 max (GVAR(workingMemory) select 6) min 3; GVAR(currentScopeClickUnit) = 0 max (GVAR(workingMemory) select 7) min 2; GVAR(currentScopeClickNumber) = 1 max (GVAR(workingMemory) select 8) min 10; -[] call FUNC(update_gun); -[] call FUNC(update_gun_ammo_data); +if (_updateDisplay) then { + [] call FUNC(update_gun); + [] call FUNC(update_gun_ammo_data); +}; GVAR(elevationOutput) set [GVAR(currentTarget), 0]; GVAR(windage1Output) set [GVAR(currentTarget), 0]; @@ -41,6 +49,6 @@ GVAR(leadOutput) set [GVAR(currentTarget), 0]; GVAR(tofOutput) set [GVAR(currentTarget), 0]; GVAR(velocityOutput) set [GVAR(currentTarget), 0]; -if (_updateSolution) then { +if (_updateDisplay) then { [] call FUNC(calculate_target_solution); }; diff --git a/addons/atragmx/functions/fnc_create_dialog.sqf b/addons/atragmx/functions/fnc_create_dialog.sqf index 1646b0ec25..b4d51bd894 100644 --- a/addons/atragmx/functions/fnc_create_dialog.sqf +++ b/addons/atragmx/functions/fnc_create_dialog.sqf @@ -40,7 +40,7 @@ GVAR(showTargetRangeAssist) call FUNC(show_target_range_assist); GVAR(showTargetSpeedAssist) call FUNC(show_target_speed_assist); GVAR(showTargetSpeedAssistTimer) call FUNC(show_target_speed_assist_timer); -[GVAR(currentGun), false] call FUNC(change_gun); +[GVAR(currentGun), false, true] call FUNC(change_gun); { lbAdd [6000, _x select 0]; diff --git a/addons/atragmx/functions/fnc_cycle_gun_list.sqf b/addons/atragmx/functions/fnc_cycle_gun_list.sqf index 75f54c79fb..3796bb78e6 100644 --- a/addons/atragmx/functions/fnc_cycle_gun_list.sqf +++ b/addons/atragmx/functions/fnc_cycle_gun_list.sqf @@ -17,4 +17,4 @@ if (!(GVAR(showMainPage) || GVAR(showGunList))) exitWith {}; -[(GVAR(currentGun) + (count GVAR(gunList)) + _this) % (count GVAR(gunList)), true] call FUNC(change_gun); +[(GVAR(currentGun) + (count GVAR(gunList)) + _this) % (count GVAR(gunList)), true, true] call FUNC(change_gun); diff --git a/addons/atragmx/functions/fnc_restore_user_data.sqf b/addons/atragmx/functions/fnc_restore_user_data.sqf index 54d1f3cd2b..55b73cc5b5 100644 --- a/addons/atragmx/functions/fnc_restore_user_data.sqf +++ b/addons/atragmx/functions/fnc_restore_user_data.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" GVAR(currentUnit) = 0 max (profileNamespace getVariable ["ACE_ATragMX_currentUnit", 2]) min 2; -GVAR(currentGun) = 0 max (profileNamespace getVariable ["ACE_ATragMX_currentGun", 0]); +[(profileNamespace getVariable ["ACE_ATragMX_currentGun", 0]), true, false] call FUNC(change_gun); GVAR(currentTarget) = 0 max (profileNamespace getVariable ["ACE_ATragMX_currentTarget", 0]) min 3; GVAR(currentScopeUnit) = 0 max (profileNamespace getVariable ["ACE_ATragMX_currentScopeUnit", 0]) min 3; diff --git a/addons/atragmx/functions/fnc_toggle_gun_list.sqf b/addons/atragmx/functions/fnc_toggle_gun_list.sqf index 714e6e848d..1cc1f9338b 100644 --- a/addons/atragmx/functions/fnc_toggle_gun_list.sqf +++ b/addons/atragmx/functions/fnc_toggle_gun_list.sqf @@ -20,7 +20,7 @@ if (ctrlVisible 6000) then { true call FUNC(show_main_page); if (_this) then { - [lbCurSel 6000, true] call FUNC(change_gun); + [lbCurSel 6000, true, true] call FUNC(change_gun); }; } else { false call FUNC(show_main_page);