Improve handling of invalid modes

This commit is contained in:
SilentSpike 2015-07-21 15:53:20 +01:00
parent dcea8f4929
commit dc19bff189
3 changed files with 8 additions and 9 deletions

View File

@ -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)];

View File

@ -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": {

View File

@ -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;