From 8b802006a43908ef573c6d7266c6a92ad283f7fa Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 7 Aug 2015 00:32:12 +0200 Subject: [PATCH] Moved no interaction menu support inside the function, made code run selectively on server/clients, fixes #2037, closes #1945 --- addons/slideshow/CfgVehicles.hpp | 2 +- .../functions/fnc_createSlideshow.sqf | 21 ++++++++++++++----- addons/slideshow/functions/fnc_moduleInit.sqf | 9 ++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/addons/slideshow/CfgVehicles.hpp b/addons/slideshow/CfgVehicles.hpp index 7bb3b81713..7e82d48ffc 100644 --- a/addons/slideshow/CfgVehicles.hpp +++ b/addons/slideshow/CfgVehicles.hpp @@ -6,7 +6,7 @@ class CfgVehicles { displayName = CSTRING(DisplayName); function = QFUNC(moduleInit); scope = 2; - isGlobal = 0; // Server only + isGlobal = 1; isTriggerActivated = 0; isDisposable = 0; icon = QUOTE(PATHTOF(UI\Icon_Module_Slideshow_ca.paa)); diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index debeac3340..6165453a1a 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -40,15 +40,24 @@ if (count _controllers == 0) then { TRACE_4("Information",_objects,_controllers,_images,_names); // Default images on whiteboards (first image) -{ - _x setObjectTextureGlobal [0, _images select 0]; -} forEach _objects; +if (isServer) then { + { + _x setObjectTextureGlobal [0, _images select 0]; + } forEach _objects; + + // Number of slideshows (multiple modules support) + GVAR(slideshows) = GVAR(slideshows) + 1; +}; -// Number of slideshows (multiple modules support) -GVAR(slideshows) = GVAR(slideshows) + 1; private ["_currentSlideshow"]; _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets changed during execution of below code +// If interaction menu module is not present, set default duration value +if (["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { + _duration = 5; + diag_log text format ["[ACE]: Slideshow: Interaction Menu module not present, defaulting duration value to %1", _duration]; +}; + // Add interactions if automatic transitions are disabled, else setup automatic transitions if (_duration == 0) then { private ["_actionsObject", "_actionsClass", "_mainAction", "_slidesAction"]; @@ -67,6 +76,8 @@ if (_duration == 0) then { [_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject); } forEach _controllers; } else { + if !(isServer) exitWith {}; + // Formatted GVAR string (multiple modules support) private ["_varString"]; _varString = format [QGVAR(slideshow%1), _currentSlideshow]; diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf index 54f04b3a16..8684ffb9ba 100644 --- a/addons/slideshow/functions/fnc_moduleInit.sqf +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -15,7 +15,8 @@ //#define DEBUG_MODE_FULL #include "script_component.hpp" -if !(isServer) exitWith {}; +// Exit on Headless Client +if (!hasInterface && !isDedicated) exitWith {}; PARAMS_3(_logic,_units,_activated); @@ -33,12 +34,6 @@ _images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList); _names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList); _duration = _logic getVariable ["Duration", 0]; -// If interaction menu module is not present, set default duration value -if (["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { - _duration = 5; - diag_log "[ACE]: ace_interact_menu not present, assuming default Slideshow duration value."; -}; - // Prepare with actions [_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow);