diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 4fb9dc3744..0b6a2614d7 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -10,9 +10,15 @@ PREP(handleRespawn); PREP(handleTree); PREP(moduleSpectatorSettings); PREP(setSpectator); +PREP(updateCamera); PREP(updateInterface); PREP(updateUnits); -PREP(updateView); + +// Permanent variables +GVAR(camMode) = 0; +GVAR(camPan) = 0; +GVAR(camPos) = getPos cameraOn; +GVAR(camUnit) = objNull; GVAR(showComp) = true; GVAR(showHelp) = true; diff --git a/addons/spectator/functions/fnc_handleCamera.sqf b/addons/spectator/functions/fnc_handleCamera.sqf index be45a97db5..b7c5154eb7 100644 --- a/addons/spectator/functions/fnc_handleCamera.sqf +++ b/addons/spectator/functions/fnc_handleCamera.sqf @@ -65,7 +65,7 @@ switch (GVAR(camMode)) do { {vehicle GVAR(camUnit) == GVAR(camUnit)} && {GVAR(camUnit) in GVAR(unitList)} ) then { - [] call FUNC(updateView); + [] call FUNC(updateCamera); }; }; }; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index ab51902c57..5853fbe4c7 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -28,12 +28,6 @@ switch (toLower _mode) do { // Prevent reopening if !(isNull (GETUVAR(GVAR(display),displayNull))) exitWith {}; - // Initalize preserved variables - if (isNil QGVAR(camMode)) then { GVAR(camMode) = 0; }; - if (isNil QGVAR(camPan)) then { GVAR(camPan) = 0; }; - if (isNil QGVAR(camPos)) then { GVAR(camPos) = getPos cameraOn; }; - if (isNil QGVAR(camUnit)) then { GVAR(camUnit) = objNull; }; - // Initalize camera variables GVAR(camBank) = 0; GVAR(camBoom) = [false,false]; @@ -56,7 +50,7 @@ switch (toLower _mode) do { // Initalize the camera view GVAR(camera) = "Camera" camCreate GVAR(camPos); GVAR(camera) setDir GVAR(camPan); - [] call FUNC(updateView); + [] call FUNC(updateCamera); GVAR(camera) camSetFOV GVAR(camFOV); @@ -157,7 +151,7 @@ switch (toLower _mode) do { if ((_button == 1) && (GVAR(camMode) == 1)) then { // In first person toggle sights mode GVAR(gunCam) = !GVAR(gunCam); - [] call FUNC(updateView); + [] call FUNC(updateCamera); }; }; case "onmousebuttonup": { @@ -245,7 +239,7 @@ switch (toLower _mode) do { //[_show] call FUNC(handleMap); }; case 57: { // Spacebar - [[2,0,1] select GVAR(camMode)] call FUNC(updateView); + [[2,0,1] select GVAR(camMode)] call FUNC(updateCamera); }; }; @@ -300,7 +294,7 @@ switch (toLower _mode) do { _newMode = [2,2,1] select GVAR(camMode); }; - [_newMode,_newUnit] call FUNC(updateView); + [_newMode,_newUnit] call FUNC(updateCamera); }; }; }; diff --git a/addons/spectator/functions/fnc_updateView.sqf b/addons/spectator/functions/fnc_updateCamera.sqf similarity index 97% rename from addons/spectator/functions/fnc_updateView.sqf rename to addons/spectator/functions/fnc_updateCamera.sqf index 706b9e251e..fc16e85d06 100644 --- a/addons/spectator/functions/fnc_updateView.sqf +++ b/addons/spectator/functions/fnc_updateCamera.sqf @@ -11,12 +11,13 @@ if (_newMode != GVAR(camMode)) then { // When no units available to spectate, exit to freecam if (GVAR(unitList) isEqualTo []) then { GVAR(camMode) = 0; - GVAR(camUnit) = objNull; }; if (GVAR(camMode) == 0) then { // Free GVAR(camera) cameraEffect ["internal", "back"]; + GVAR(camUnit) = GVAR(camera); + // HUD stuff showCinemaBorder false; cameraEffectEnableHUD false;