From dc19bff1892f6646a449f69098d52d33a26aa7b3 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Tue, 21 Jul 2015 15:53:20 +0100 Subject: [PATCH] Improve handling of invalid modes --- addons/spectator/XEH_postInit.sqf | 8 ++------ addons/spectator/functions/fnc_handleInterface.sqf | 4 +--- addons/spectator/functions/fnc_transitionCamera.sqf | 5 +++++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index deab8fc675..0cea638022 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -6,16 +6,12 @@ // Run spectator framework if enabled ["SettingsInitialized", { - if !(hasInterface) exitWith {}; - - /*if (GVAR(tracking)) then { - [FUNC(checkUnits), 2] call CBA_fnc_addPerFrameHandler; - [FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler; - };*/ GVAR(availableModes) = [[0,1,2], [1,2], [0], [1], [2]] select GVAR(restrictModes); GVAR(availableVisions) = [[-2,-1,0,1], [-2,-1], [-2,0,1], [-2]] select GVAR(restrictVisions); GVAR(camMode) = GVAR(availableModes) select 0; + if !(hasInterface) exitWith {}; + if (GVAR(system)) then { // Add event handlers to correctly enter spectator upon death player addEventHandler ["Killed", FUNC(handleKilled)]; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 3fff2a9bb5..199c4830d1 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -260,9 +260,7 @@ switch (toLower _mode) do { _newMode = [2,2,1] select GVAR(camMode); }; - if (_newMode in GVAR(availableModes)) then { - [_newMode,_newUnit] call FUNC(transitionCamera); - }; + [_newMode,_newUnit] call FUNC(transitionCamera); }; }; case "onunitsupdate": { diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index 0dcea4d6c0..65b4aa3456 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -27,6 +27,11 @@ params [["_newMode",GVAR(camMode)], ["_newUnit",GVAR(camUnit)], ["_newVision",GVAR(camVision)]]; +// If new mode isn't available then keep current +if !(_newMode in GVAR(availableModes)) then { + _newMode = GVAR(camMode); +}; + // When no units available to spectate, exit to freecam if (GVAR(unitList) isEqualTo []) then { _newMode = 0;