From c2bb6386af70770ebc21977466a2199a6f607e0e Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 7 May 2015 22:41:44 +0200 Subject: [PATCH 01/32] Added required files for new module --- addons/viewdistance/$PBOPREFIX$ | 1 + addons/viewdistance/CfgEventHandlers.hpp | 6 ++++++ addons/viewdistance/XEH_preInit.sqf | 7 +++++++ addons/viewdistance/config.cpp | 15 +++++++++++++++ addons/viewdistance/functions/fnc_empty.sqf | 3 +++ .../viewdistance/functions/script_component.hpp | 1 + addons/viewdistance/script_component.hpp | 12 ++++++++++++ 7 files changed, 45 insertions(+) create mode 100644 addons/viewdistance/$PBOPREFIX$ create mode 100644 addons/viewdistance/CfgEventHandlers.hpp create mode 100644 addons/viewdistance/XEH_preInit.sqf create mode 100644 addons/viewdistance/config.cpp create mode 100644 addons/viewdistance/functions/fnc_empty.sqf create mode 100644 addons/viewdistance/functions/script_component.hpp create mode 100644 addons/viewdistance/script_component.hpp diff --git a/addons/viewdistance/$PBOPREFIX$ b/addons/viewdistance/$PBOPREFIX$ new file mode 100644 index 00000000000..39789fcaba5 --- /dev/null +++ b/addons/viewdistance/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\blank \ No newline at end of file diff --git a/addons/viewdistance/CfgEventHandlers.hpp b/addons/viewdistance/CfgEventHandlers.hpp new file mode 100644 index 00000000000..f0a9f14d914 --- /dev/null +++ b/addons/viewdistance/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf new file mode 100644 index 00000000000..69abb46fa9f --- /dev/null +++ b/addons/viewdistance/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(empty); + +ADDON = true; diff --git a/addons/viewdistance/config.cpp b/addons/viewdistance/config.cpp new file mode 100644 index 00000000000..a7b7bae6df2 --- /dev/null +++ b/addons/viewdistance/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {""}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/viewdistance/functions/fnc_empty.sqf b/addons/viewdistance/functions/fnc_empty.sqf new file mode 100644 index 00000000000..c60a82b2d87 --- /dev/null +++ b/addons/viewdistance/functions/fnc_empty.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +diag_log text format["This is here as an example!!!"]; diff --git a/addons/viewdistance/functions/script_component.hpp b/addons/viewdistance/functions/script_component.hpp new file mode 100644 index 00000000000..4b7df89f376 --- /dev/null +++ b/addons/viewdistance/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\viewdistance\script_component.hpp" \ No newline at end of file diff --git a/addons/viewdistance/script_component.hpp b/addons/viewdistance/script_component.hpp new file mode 100644 index 00000000000..79e0e488cc3 --- /dev/null +++ b/addons/viewdistance/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT viewdistance +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_VIEWDISTANCE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_VIEWDISTANCE + #define DEBUG_SETTINGS DEBUG_SETTINGS_VIEWDISTANCE +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file From 2c8dddfc473fe156576bd8bba288f0bee00fadd5 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 09:28:48 +0200 Subject: [PATCH 02/32] Adding required files --- addons/viewdistance/ACE_Settings.hpp | 9 +++++++ addons/viewdistance/config.cpp | 5 ++-- .../functions/fnc_changeViewDistance.sqf | 24 +++++++++++++++++++ addons/viewdistance/functions/fnc_empty.sqf | 3 --- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 addons/viewdistance/ACE_Settings.hpp create mode 100644 addons/viewdistance/functions/fnc_changeViewDistance.sqf delete mode 100644 addons/viewdistance/functions/fnc_empty.sqf diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp new file mode 100644 index 00000000000..572358876ac --- /dev/null +++ b/addons/viewdistance/ACE_Settings.hpp @@ -0,0 +1,9 @@ +class ACE_Settings { + class GVAR(viewdistance) { + typeName = "SCALAR"; + isClientSettable = 1; + values[] = {1500,2000,2500,3000,3500,4000,5000,6000,7000,8000,9000,10000}; + displayName = "View Distance"; // has to be changed to string table type + description = "Change View Distance"; + }; +}; \ No newline at end of file diff --git a/addons/viewdistance/config.cpp b/addons/viewdistance/config.cpp index a7b7bae6df2..dcffe0f2573 100644 --- a/addons/viewdistance/config.cpp +++ b/addons/viewdistance/config.cpp @@ -6,10 +6,11 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; - author[] = {""}; - authorUrl = ""; + author[] = {"Winter"}; + authorUrl = "https://github.com/Winter259"; VERSION_CONFIG; }; }; #include "CfgEventHandlers.hpp" +#include "ACE_Settings.hpp" \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf new file mode 100644 index 00000000000..4543be000b6 --- /dev/null +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -0,0 +1,24 @@ +/* + * Author: Winter + * Sets the player's current view distance according to allowed values. + * + * + * Arguments: + * 0: View Distance Setting (SCALAR) + * + * Return Value: + * None + * + * Example: + * [1500] call ace_common_fnc_imanexample + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_new_view_distance"]; + +_new_view_distance = _this select 0; + +player setViewDistance (_new_view_distance); \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_empty.sqf b/addons/viewdistance/functions/fnc_empty.sqf deleted file mode 100644 index c60a82b2d87..00000000000 --- a/addons/viewdistance/functions/fnc_empty.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "script_component.hpp" - -diag_log text format["This is here as an example!!!"]; From 6b604c101cf5f2e1b3af60bba85bf7984ddde7e5 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 14:14:15 +0200 Subject: [PATCH 03/32] First working version --- addons/viewdistance/ACE_Settings.hpp | 25 ++++++++--- addons/viewdistance/CfgEventHandlers.hpp | 6 +++ addons/viewdistance/XEH_postInit.sqf | 4 ++ addons/viewdistance/XEH_preInit.sqf | 6 ++- addons/viewdistance/config.cpp | 2 +- .../functions/fnc_changeViewDistance.sqf | 27 +++++++++--- .../functions/fnc_initViewDistance.sqf | 24 +++++++++++ .../functions/fnc_returnViewDistanceValue.sqf | 42 +++++++++++++++++++ 8 files changed, 123 insertions(+), 13 deletions(-) create mode 100644 addons/viewdistance/XEH_postInit.sqf create mode 100644 addons/viewdistance/functions/fnc_initViewDistance.sqf create mode 100644 addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 572358876ac..48e5f7324ea 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -1,9 +1,24 @@ class ACE_Settings { - class GVAR(viewdistance) { + class GVAR(changeAllowed) { + typeName = "BOOL"; + value = 1; + displayName = "Allow View Distance Changing"; + description = "Enables changing in game view distance"; + }; + class GVAR(top_limit) { + typeName = "SCALAR"; + values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the index values + displayName = "View Distance Limit"; + description = "Sets the top limit for all clients"; + }; + class GVAR(newViewDistance) { typeName = "SCALAR"; isClientSettable = 1; - values[] = {1500,2000,2500,3000,3500,4000,5000,6000,7000,8000,9000,10000}; - displayName = "View Distance"; // has to be changed to string table type - description = "Change View Distance"; + //value = 1; + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; + displayName = "Change View Distance"; + description = "Changes in game view distance"; }; -}; \ No newline at end of file +}; + +// To do: include string table style displayName & description. \ No newline at end of file diff --git a/addons/viewdistance/CfgEventHandlers.hpp b/addons/viewdistance/CfgEventHandlers.hpp index f0a9f14d914..0f1d8878ba2 100644 --- a/addons/viewdistance/CfgEventHandlers.hpp +++ b/addons/viewdistance/CfgEventHandlers.hpp @@ -4,3 +4,9 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; \ No newline at end of file diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf new file mode 100644 index 00000000000..8f1fd94fc3c --- /dev/null +++ b/addons/viewdistance/XEH_postInit.sqf @@ -0,0 +1,4 @@ +#include "script_component.hpp" + +if (!hasInterface || !GVAR(enabled)) exitWith {}; +[] call FUNC(initViewDistance); \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index 69abb46fa9f..4da9b33c831 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -2,6 +2,8 @@ ADDON = false; -PREP(empty); +PREP(returnViewDistanceValue); +PREP(changeViewDistance); +PREP(initViewDistance); -ADDON = true; +ADDON = true; \ No newline at end of file diff --git a/addons/viewdistance/config.cpp b/addons/viewdistance/config.cpp index dcffe0f2573..86453c5be30 100644 --- a/addons/viewdistance/config.cpp +++ b/addons/viewdistance/config.cpp @@ -13,4 +13,4 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" -#include "ACE_Settings.hpp" \ No newline at end of file +#include "ACE_Settings.hpp" \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 4543be000b6..f28ce70e3da 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -4,21 +4,38 @@ * * * Arguments: - * 0: View Distance Setting (SCALAR) + * None * * Return Value: * None * * Example: - * [1500] call ace_common_fnc_imanexample + * [] call ace_viewdistance_fnc_changeViewDistance; * * Public: No */ #include "script_component.hpp" -private ["_new_view_distance"]; +private ["_new_view_distance_index","_new_view_distance"]; + +_new_view_distance_index = GVAR(newViewDistance); + +_new_view_distance = [_new_view_distance_index] call FUNC(returnViewDistanceValue); + +/* +hint format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance]; +diag_log format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance]; +*/ + -_new_view_distance = _this select 0; +// To do: add a check against a sever or module top limit here. -player setViewDistance (_new_view_distance); \ No newline at end of file +if !GVAR(changeAllowed) then +{ + hint "You cannot change the view distance!" +} +else +{ + setViewDistance _new_view_distance; +}; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_initViewDistance.sqf b/addons/viewdistance/functions/fnc_initViewDistance.sqf new file mode 100644 index 00000000000..2a419fe7fcb --- /dev/null +++ b/addons/viewdistance/functions/fnc_initViewDistance.sqf @@ -0,0 +1,24 @@ +/* + * Author: Winter + * Sets the player's current view distance according to allowed values. + * + * + * Arguments: + * 0: View Distance Setting (SCALAR) + * + * Return Value: + * None + * + * Example: + * [1500] call ace_common_fnc_imanexample + * + * Public: No + */ + +#include "script_component.hpp" + +["SettingChanged",{ + if (_this select 0 == QGVAR(newViewDistance)) then { + [] call FUNC(changeViewDistance); + }; +},true] call ace_common_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf new file mode 100644 index 00000000000..7d55062c65a --- /dev/null +++ b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf @@ -0,0 +1,42 @@ +/* + * Author: Winter + * Returns the view distance value according to the given index + * + * + * Arguments: + * 0: View Distance Index (SCALAR) + * + * Return Value: + * View Distance (SCALAR) + * + * Example: + * [2] call ace_viewdistance_fnc_returnViewDistanceValue; + * + * Public: Yes + */ + +#include "script_component.hpp" + +private ["_index","_return"]; + +_index = _this select 0; +_return = 0; + +switch (_index) do +{ + case 0: {_return = 1500}; + case 1: {_return = 2000}; + case 2: {_return = 2500}; + case 3: {_return = 3000}; + case 4: {_return = 3500}; + case 5: {_return = 4000}; + case 6: {_return = 5000}; + case 7: {_return = 6000}; + case 8: {_return = 7000}; + case 9: {_return = 8000}; + case 10: {_return = 9000}; + case 11: {_return = 10000}; + default {hint "something broke!";}; +}; + +_return; \ No newline at end of file From a5d68f122d6975ec20d051b8599f99e35e5255b8 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 14:49:52 +0200 Subject: [PATCH 04/32] Added working limiter (config based) --- addons/viewdistance/ACE_Settings.hpp | 9 +++-- .../functions/fnc_changeViewDistance.sqf | 40 +++++++++---------- .../functions/fnc_returnViewDistanceValue.sqf | 30 +++++++------- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 48e5f7324ea..55b38df7df0 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -3,18 +3,19 @@ class ACE_Settings { typeName = "BOOL"; value = 1; displayName = "Allow View Distance Changing"; - description = "Enables changing in game view distance"; + description = "Allows clients to be able to change their view distance"; }; - class GVAR(top_limit) { + class GVAR(topViewDistanceLimit) { typeName = "SCALAR"; + value = 11; // setting the highest number in the array below means no limit. values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the index values - displayName = "View Distance Limit"; + displayName = "Change View Distance Limit"; description = "Sets the top limit for all clients"; }; class GVAR(newViewDistance) { typeName = "SCALAR"; isClientSettable = 1; - //value = 1; + value = 0; // not sure what to set this to. values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; displayName = "Change View Distance"; description = "Changes in game view distance"; diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index f28ce70e3da..a25837bd0f7 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -17,25 +17,21 @@ #include "script_component.hpp" -private ["_new_view_distance_index","_new_view_distance"]; - -_new_view_distance_index = GVAR(newViewDistance); - -_new_view_distance = [_new_view_distance_index] call FUNC(returnViewDistanceValue); - -/* -hint format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance]; -diag_log format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance]; -*/ - - -// To do: add a check against a sever or module top limit here. - -if !GVAR(changeAllowed) then -{ - hint "You cannot change the view distance!" -} -else -{ - setViewDistance _new_view_distance; -}; \ No newline at end of file +private ["_new_view_distance","_new_view_distance_limit"]; + +_new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue); +_view_distance_limit = [GVAR(topViewDistanceLimit)] call FUNC(returnViewDistanceValue); + +if !GVAR(changeAllowed) then { + hint "You are not allowed to change the view distance!"; +} else { + if (_new_view_distance > _view_distance_limit) then { + hint format ["That option is not allowed! The limit is: %1m",_view_distance_limit]; + } + else { + hint format ["View distance successfully changed to: %1m",_new_view_distance]; + setViewDistance _new_view_distance; + }; +}; + +// To do: add a check against a module limit. \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf index 7d55062c65a..ec55a2a755d 100644 --- a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf +++ b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf @@ -4,10 +4,10 @@ * * * Arguments: - * 0: View Distance Index (SCALAR) + * 0: View Distance Index * * Return Value: - * View Distance (SCALAR) + * View Distance * * Example: * [2] call ace_viewdistance_fnc_returnViewDistanceValue; @@ -22,20 +22,22 @@ private ["_index","_return"]; _index = _this select 0; _return = 0; + +// change to if () exitWith {};? switch (_index) do { - case 0: {_return = 1500}; - case 1: {_return = 2000}; - case 2: {_return = 2500}; - case 3: {_return = 3000}; - case 4: {_return = 3500}; - case 5: {_return = 4000}; - case 6: {_return = 5000}; - case 7: {_return = 6000}; - case 8: {_return = 7000}; - case 9: {_return = 8000}; - case 10: {_return = 9000}; - case 11: {_return = 10000}; + case 0: {_return = 1500;}; + case 1: {_return = 2000;}; + case 2: {_return = 2500;}; + case 3: {_return = 3000;}; + case 4: {_return = 3500;}; + case 5: {_return = 4000;}; + case 6: {_return = 5000;}; + case 7: {_return = 6000;}; + case 8: {_return = 7000;}; + case 9: {_return = 8000;}; + case 10: {_return = 9000;}; + case 11: {_return = 10000;}; default {hint "something broke!";}; }; From bb625aac583e24702e5b09b7591e714e8e9f4448 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 15:27:13 +0200 Subject: [PATCH 05/32] Used ACE common function instead of hint --- .../viewdistance/functions/fnc_changeViewDistance.sqf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index a25837bd0f7..046a483557b 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -17,19 +17,22 @@ #include "script_component.hpp" -private ["_new_view_distance","_new_view_distance_limit"]; +private ["_text","_new_view_distance","_view_distance_limit"]; _new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue); _view_distance_limit = [GVAR(topViewDistanceLimit)] call FUNC(returnViewDistanceValue); if !GVAR(changeAllowed) then { - hint "You are not allowed to change the view distance!"; + _text = "You are not allowed to change the view distance!"; + [_text,2] call EFUNC(common,displayTextStructured); } else { if (_new_view_distance > _view_distance_limit) then { - hint format ["That option is not allowed! The limit is: %1m",_view_distance_limit]; + _text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; + [_text,1] call EFUNC(common,displayTextStructured); } else { - hint format ["View distance successfully changed to: %1m",_new_view_distance]; + _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; + [_text,1] call EFUNC(common,displayTextStructured); setViewDistance _new_view_distance; }; }; From 5732015370f9ca2c8ac1d9e365c822b2ad442554 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 15:36:47 +0200 Subject: [PATCH 06/32] Added moduleViewDistance file --- addons/viewdistance/XEH_preInit.sqf | 1 + .../functions/fnc_changeViewDistance.sqf | 2 +- .../functions/fnc_initViewDistance.sqf | 8 +++---- .../functions/fnc_moduleViewDistance.sqf | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 addons/viewdistance/functions/fnc_moduleViewDistance.sqf diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index 4da9b33c831..94c52ce76ab 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -2,6 +2,7 @@ ADDON = false; +PREP(moduleViewDistance); PREP(returnViewDistanceValue); PREP(changeViewDistance); PREP(initViewDistance); diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 046a483557b..f514951c205 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -12,7 +12,7 @@ * Example: * [] call ace_viewdistance_fnc_changeViewDistance; * - * Public: No + * Public: Yes */ #include "script_component.hpp" diff --git a/addons/viewdistance/functions/fnc_initViewDistance.sqf b/addons/viewdistance/functions/fnc_initViewDistance.sqf index 2a419fe7fcb..c425338c3f5 100644 --- a/addons/viewdistance/functions/fnc_initViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_initViewDistance.sqf @@ -1,18 +1,18 @@ /* * Author: Winter - * Sets the player's current view distance according to allowed values. + * Assigns the Event Handler which fires when a player adjusts their view distance in the menu * * * Arguments: - * 0: View Distance Setting (SCALAR) + * None * * Return Value: * None * * Example: - * [1500] call ace_common_fnc_imanexample + * [] call ace_viewdistance_fnc_initViewDistance; * - * Public: No + * Public: Yes */ #include "script_component.hpp" diff --git a/addons/viewdistance/functions/fnc_moduleViewDistance.sqf b/addons/viewdistance/functions/fnc_moduleViewDistance.sqf new file mode 100644 index 00000000000..5e7d3da94b5 --- /dev/null +++ b/addons/viewdistance/functions/fnc_moduleViewDistance.sqf @@ -0,0 +1,23 @@ +/* + * Author: Winter + * Initialises the view distance limiter module + * + * + * Arguments: + * + * + * Return Value: + * View Distance Limit + * + * Example: + * + */ + +#include "script_component.hpp" + +if (!isServer) exitWith {}; +/* +PARAMS_2(_logic,_activated); + +if !(_activated) exitWith {}; +*/ \ No newline at end of file From 6cda97e3a0cd540d37052c8aed5fcd368171c6d7 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 16:07:57 +0200 Subject: [PATCH 07/32] Adding required files for module integration --- addons/viewdistance/CfgVehicles.hpp | 20 ++++++++++++++ addons/viewdistance/XEH_postInit.sqf | 1 + .../functions/fnc_changeViewDistance.sqf | 3 +++ .../functions/fnc_moduleViewDistance.sqf | 12 ++++++--- .../functions/fnc_returnViewDistanceLimit.sqf | 26 +++++++++++++++++++ .../functions/fnc_returnViewDistanceValue.sqf | 4 +-- 6 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 addons/viewdistance/CfgVehicles.hpp create mode 100644 addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp new file mode 100644 index 00000000000..a39c94c4c52 --- /dev/null +++ b/addons/viewdistance/CfgVehicles.hpp @@ -0,0 +1,20 @@ +class CfgVehicles { + class Module_F; + class ACE_ModuleViewDistance : Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "View Distance Limit"; + function = QFUNC(moduleViewDistance); + scope = 2; + isGlobal = 1; + //icon = ""; // needs an icon + class Arguments { + class ViewDistanceLimit { + displayName = "View Distance setting limit"; + description = "Sets the limit for how high clients can raise their view distance (< 10,000)"; + typeName = "NUMBER"; + defaultValue = 10000; + }; + }; + }; +}; \ No newline at end of file diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index 8f1fd94fc3c..85cd16d387b 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -1,4 +1,5 @@ #include "script_component.hpp" +[] call FUNC(moduleViewDistance); if (!hasInterface || !GVAR(enabled)) exitWith {}; [] call FUNC(initViewDistance); \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index f514951c205..e7529d6116f 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -19,9 +19,12 @@ private ["_text","_new_view_distance","_view_distance_limit"]; +// Change the received index number into an actual view distance number as set in the config: _new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue); + _view_distance_limit = [GVAR(topViewDistanceLimit)] call FUNC(returnViewDistanceValue); + if !GVAR(changeAllowed) then { _text = "You are not allowed to change the view distance!"; [_text,2] call EFUNC(common,displayTextStructured); diff --git a/addons/viewdistance/functions/fnc_moduleViewDistance.sqf b/addons/viewdistance/functions/fnc_moduleViewDistance.sqf index 5e7d3da94b5..582db6ea795 100644 --- a/addons/viewdistance/functions/fnc_moduleViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_moduleViewDistance.sqf @@ -15,9 +15,15 @@ #include "script_component.hpp" -if (!isServer) exitWith {}; -/* +if (!isServer) exitWith { + GVAR(modulePresent) = false +}; + PARAMS_2(_logic,_activated); if !(_activated) exitWith {}; -*/ \ No newline at end of file + +GVAR(modulePresent) = true; +publicVariable QGVAR(modulePresent); + +diag_log text "[ACE]: ViewDistance Module Initialized."; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf new file mode 100644 index 00000000000..cfdb30fe05c --- /dev/null +++ b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf @@ -0,0 +1,26 @@ +/* + * Author: Winter + * Returns the view distance limit depending on either the config or (if present) the module. + * + * + * Arguments: + * None + * + * Return Value: + * View Distance Limit + * + * Example: + * [] call ace_viewdistance_fnc_returnViewDistanceLimit; + * + * Public: Yes + */ + +#include "script_component.hpp" + +if GVAR(modulePresent) then { + // module always takes priority + _view_distance_limit = +} else { + +}; +// To do: add a check against a module limit. \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf index ec55a2a755d..0c14214371f 100644 --- a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf +++ b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf @@ -17,9 +17,9 @@ #include "script_component.hpp" -private ["_index","_return"]; +PARAMS_1(_index); -_index = _this select 0; +private ["_return"]; _return = 0; From 45992e5e7fb0fdce0327609ce827230e17f68aa6 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 18:30:28 +0200 Subject: [PATCH 08/32] All working except module returning any. ace_viewdistance_moduleViewDistanceLimit always returning as any. No error in the RPT relating to readSettingfromModule failing --- addons/viewdistance/ACE_Settings.hpp | 2 +- addons/viewdistance/CfgVehicles.hpp | 8 ++--- addons/viewdistance/XEH_postInit.sqf | 3 +- addons/viewdistance/XEH_preInit.sqf | 3 +- addons/viewdistance/config.cpp | 3 +- .../functions/fnc_changeViewDistance.sqf | 28 ++++++---------- .../functions/fnc_initViewDistance.sqf | 4 ++- addons/viewdistance/functions/fnc_module.sqf | 33 +++++++++++++++++++ .../functions/fnc_moduleViewDistance.sqf | 29 ---------------- .../functions/fnc_returnViewDistanceLimit.sqf | 18 +++++++--- .../functions/fnc_returnViewDistanceValue.sqf | 3 +- 11 files changed, 70 insertions(+), 64 deletions(-) create mode 100644 addons/viewdistance/functions/fnc_module.sqf delete mode 100644 addons/viewdistance/functions/fnc_moduleViewDistance.sqf diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 55b38df7df0..497fe0f330e 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -5,7 +5,7 @@ class ACE_Settings { displayName = "Allow View Distance Changing"; description = "Allows clients to be able to change their view distance"; }; - class GVAR(topViewDistanceLimit) { + class GVAR(viewDistanceLimit) { typeName = "SCALAR"; value = 11; // setting the highest number in the array below means no limit. values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the index values diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index a39c94c4c52..4906edfecfb 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -3,16 +3,16 @@ class CfgVehicles { class ACE_ModuleViewDistance : Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "View Distance Limit"; - function = QFUNC(moduleViewDistance); + displayName = "View Distance Limiter"; + function = QFUNC(module); scope = 2; isGlobal = 1; //icon = ""; // needs an icon class Arguments { - class ViewDistanceLimit { + class moduleViewDistanceLimit { displayName = "View Distance setting limit"; description = "Sets the limit for how high clients can raise their view distance (< 10,000)"; - typeName = "NUMBER"; + typeName = "SCALAR"; defaultValue = 10000; }; }; diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index 85cd16d387b..6fffa14cc68 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -1,5 +1,4 @@ #include "script_component.hpp" -[] call FUNC(moduleViewDistance); -if (!hasInterface || !GVAR(enabled)) exitWith {}; +if (!GVAR(changeAllowed)) exitWith {}; // if viewdistance is disabled from config, exit here. [] call FUNC(initViewDistance); \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index 94c52ce76ab..9f66b79e2e8 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -2,8 +2,9 @@ ADDON = false; -PREP(moduleViewDistance); +PREP(module); PREP(returnViewDistanceValue); +PREP(returnViewDistanceLimit); PREP(changeViewDistance); PREP(initViewDistance); diff --git a/addons/viewdistance/config.cpp b/addons/viewdistance/config.cpp index 86453c5be30..a1afbcc93fe 100644 --- a/addons/viewdistance/config.cpp +++ b/addons/viewdistance/config.cpp @@ -13,4 +13,5 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" -#include "ACE_Settings.hpp" \ No newline at end of file +#include "ACE_Settings.hpp" +#include "CfgVehicles.hpp" \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index e7529d6116f..4d359744665 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -22,22 +22,14 @@ private ["_text","_new_view_distance","_view_distance_limit"]; // Change the received index number into an actual view distance number as set in the config: _new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue); -_view_distance_limit = [GVAR(topViewDistanceLimit)] call FUNC(returnViewDistanceValue); +_view_distance_limit = [] call FUNC(returnViewDistanceLimit); - -if !GVAR(changeAllowed) then { - _text = "You are not allowed to change the view distance!"; - [_text,2] call EFUNC(common,displayTextStructured); -} else { - if (_new_view_distance > _view_distance_limit) then { - _text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; - [_text,1] call EFUNC(common,displayTextStructured); - } - else { - _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; - [_text,1] call EFUNC(common,displayTextStructured); - setViewDistance _new_view_distance; - }; -}; - -// To do: add a check against a module limit. \ No newline at end of file +if (_new_view_distance > _view_distance_limit) then { + _text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; + [_text,1] call EFUNC(common,displayTextStructured); +} +else { + _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; + [_text,1] call EFUNC(common,displayTextStructured); + setViewDistance _new_view_distance; +}; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_initViewDistance.sqf b/addons/viewdistance/functions/fnc_initViewDistance.sqf index c425338c3f5..5372fdedca1 100644 --- a/addons/viewdistance/functions/fnc_initViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_initViewDistance.sqf @@ -14,9 +14,11 @@ * * Public: Yes */ - + #include "script_component.hpp" +if (!hasInterface) exitWith {}; + ["SettingChanged",{ if (_this select 0 == QGVAR(newViewDistance)) then { [] call FUNC(changeViewDistance); diff --git a/addons/viewdistance/functions/fnc_module.sqf b/addons/viewdistance/functions/fnc_module.sqf new file mode 100644 index 00000000000..bf336bc88ec --- /dev/null +++ b/addons/viewdistance/functions/fnc_module.sqf @@ -0,0 +1,33 @@ +/* + * Author: Winter + * Initialises the view distance limiter module + * + * + * Arguments: + * 0: logic + * 1: Synchronised Units + * 2: Module Activated + * + * Return Value: + * None + * + * Example: + * + */ + +#include "script_component.hpp" + +if (!isServer) exitWith {}; + +PARAMS_3(_logic,_units,_activated); + +if (!_activated) exitWith { + diag_log text "[ACE]: View Distance Limit Module is placed but NOT active"; +}; + +GVAR(modulePresent) = true; + +[_logic, QGVAR(moduleViewDistanceLimit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); + +//hint format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; // only used for debug +diag_log format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_moduleViewDistance.sqf b/addons/viewdistance/functions/fnc_moduleViewDistance.sqf deleted file mode 100644 index 582db6ea795..00000000000 --- a/addons/viewdistance/functions/fnc_moduleViewDistance.sqf +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Author: Winter - * Initialises the view distance limiter module - * - * - * Arguments: - * - * - * Return Value: - * View Distance Limit - * - * Example: - * - */ - -#include "script_component.hpp" - -if (!isServer) exitWith { - GVAR(modulePresent) = false -}; - -PARAMS_2(_logic,_activated); - -if !(_activated) exitWith {}; - -GVAR(modulePresent) = true; -publicVariable QGVAR(modulePresent); - -diag_log text "[ACE]: ViewDistance Module Initialized."; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf index cfdb30fe05c..871ac34e678 100644 --- a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf +++ b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf @@ -17,10 +17,18 @@ #include "script_component.hpp" -if GVAR(modulePresent) then { - // module always takes priority - _view_distance_limit = +private ["_limit"]; + +_limit = 20000; // unrealistic amount for debug + +if (!isNil QGVAR(moduleViewDistanceLimit)) then { + _limit = GVAR(moduleViewDistanceLimit); // module always takes priority } else { - + // if module is not present, take the value from the config instead + _limit = [GVAR(viewDistanceLimit)] call FUNC(returnViewDistanceValue); // this function converts the array index in the config to it's relevant scalar value. }; -// To do: add a check against a module limit. \ No newline at end of file + +hint format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; +diag_log format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; + +_limit; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf index 0c14214371f..5f06256b090 100644 --- a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf +++ b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf @@ -22,7 +22,6 @@ PARAMS_1(_index); private ["_return"]; _return = 0; - // change to if () exitWith {};? switch (_index) do { @@ -38,7 +37,7 @@ switch (_index) do case 9: {_return = 8000;}; case 10: {_return = 9000;}; case 11: {_return = 10000;}; - default {hint "something broke!";}; + default {hint "something broke!";}; // should replace with something a bit more graceful }; _return; \ No newline at end of file From 0b4137763d20b5634338c0f24e0f0a4ebffd9bb5 Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 18:41:32 +0200 Subject: [PATCH 09/32] Cleaned up code --- addons/viewdistance/ACE_Settings.hpp | 4 ++-- addons/viewdistance/CfgVehicles.hpp | 2 +- addons/viewdistance/XEH_postInit.sqf | 5 ++++- .../viewdistance/functions/fnc_changeViewDistance.sqf | 1 + addons/viewdistance/functions/fnc_initViewDistance.sqf | 1 + addons/viewdistance/functions/fnc_module.sqf | 4 ++-- .../functions/fnc_returnViewDistanceLimit.sqf | 10 +++++----- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 497fe0f330e..d7a9dbb9fc6 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -8,7 +8,7 @@ class ACE_Settings { class GVAR(viewDistanceLimit) { typeName = "SCALAR"; value = 11; // setting the highest number in the array below means no limit. - values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the index values + values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the INDEX values displayName = "Change View Distance Limit"; description = "Sets the top limit for all clients"; }; @@ -16,7 +16,7 @@ class ACE_Settings { typeName = "SCALAR"; isClientSettable = 1; value = 0; // not sure what to set this to. - values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnViewDistanceValue.sqf displayName = "Change View Distance"; description = "Changes in game view distance"; }; diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index 4906edfecfb..38ef214c098 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -11,7 +11,7 @@ class CfgVehicles { class Arguments { class moduleViewDistanceLimit { displayName = "View Distance setting limit"; - description = "Sets the limit for how high clients can raise their view distance (< 10,000)"; + description = "Sets the limit for how high clients can raise their view distance (< 10000)"; typeName = "SCALAR"; defaultValue = 10000; }; diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index 6fffa14cc68..f5a5079273b 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -1,4 +1,7 @@ #include "script_component.hpp" -if (!GVAR(changeAllowed)) exitWith {}; // if viewdistance is disabled from config, exit here. +if (!GVAR(changeAllowed)) exitWith { + // if viewdistance module is disabled from config, exit here. + diag_log format["[ACE]: View Distance is disabled from the config.cpp in the pbo"]; +}; [] call FUNC(initViewDistance); \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 4d359744665..8c017ec1eb2 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -22,6 +22,7 @@ private ["_text","_new_view_distance","_view_distance_limit"]; // Change the received index number into an actual view distance number as set in the config: _new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue); +// Grab the limit, either from the module OR if the module is not valid, the config. _view_distance_limit = [] call FUNC(returnViewDistanceLimit); if (_new_view_distance > _view_distance_limit) then { diff --git a/addons/viewdistance/functions/fnc_initViewDistance.sqf b/addons/viewdistance/functions/fnc_initViewDistance.sqf index 5372fdedca1..75ca076ff68 100644 --- a/addons/viewdistance/functions/fnc_initViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_initViewDistance.sqf @@ -19,6 +19,7 @@ if (!hasInterface) exitWith {}; +// Set the EH which waits for the View Distance setting to be changed ["SettingChanged",{ if (_this select 0 == QGVAR(newViewDistance)) then { [] call FUNC(changeViewDistance); diff --git a/addons/viewdistance/functions/fnc_module.sqf b/addons/viewdistance/functions/fnc_module.sqf index bf336bc88ec..66c2aed7930 100644 --- a/addons/viewdistance/functions/fnc_module.sqf +++ b/addons/viewdistance/functions/fnc_module.sqf @@ -22,12 +22,12 @@ if (!isServer) exitWith {}; PARAMS_3(_logic,_units,_activated); if (!_activated) exitWith { - diag_log text "[ACE]: View Distance Limit Module is placed but NOT active"; + diag_log text "[ACE]: View Distance Limit Module is placed but NOT active."; }; GVAR(modulePresent) = true; [_logic, QGVAR(moduleViewDistanceLimit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); -//hint format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; // only used for debug +hint format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; // only used for debug, GVAR(moduleViewDistanceLimit) keeps returning as ANY. Remember to remove before finalising the module. diag_log format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf index 871ac34e678..8ae9e6538dd 100644 --- a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf +++ b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf @@ -19,16 +19,16 @@ private ["_limit"]; -_limit = 20000; // unrealistic amount for debug +_limit = 20000; // unrealistic amount since A3 max is 10000, helps in debug if (!isNil QGVAR(moduleViewDistanceLimit)) then { - _limit = GVAR(moduleViewDistanceLimit); // module always takes priority + _limit = GVAR(moduleViewDistanceLimit); // module value always takes priority over config } else { - // if module is not present, take the value from the config instead + // If the module is not present, take the value from the config instead _limit = [GVAR(viewDistanceLimit)] call FUNC(returnViewDistanceValue); // this function converts the array index in the config to it's relevant scalar value. }; -hint format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; -diag_log format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; +hint format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; // only used for debug, trying to get the module to work. Remember to remove before finalising pbo +diag_log format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; // only used for debug, trying to get the module to work. Remember to remove before finalising pbo _limit; \ No newline at end of file From 96e1e9c59fc9dcc6b50fbc0ad74b72bc55b8a21b Mon Sep 17 00:00:00 2001 From: SAM Date: Fri, 8 May 2015 18:46:30 +0200 Subject: [PATCH 10/32] Added name + email to authors.txt --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 366664efbd4..a167a48dce7 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -93,3 +93,4 @@ Bla1337 nikolauska adam3adam Professor +Winter From ae1628ef03f80ca9c3eeaee19ca5684f591a7f78 Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 10:41:55 +0200 Subject: [PATCH 11/32] Renamed init file for neatness --- .../functions/{fnc_initViewDistance.sqf => fnc_init.sqf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename addons/viewdistance/functions/{fnc_initViewDistance.sqf => fnc_init.sqf} (100%) diff --git a/addons/viewdistance/functions/fnc_initViewDistance.sqf b/addons/viewdistance/functions/fnc_init.sqf similarity index 100% rename from addons/viewdistance/functions/fnc_initViewDistance.sqf rename to addons/viewdistance/functions/fnc_init.sqf From 9e40e16c4a0ff6436b2c48235bf2510085061c0e Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 10:43:20 +0200 Subject: [PATCH 12/32] Adjusted XEH_preinit accordingly --- addons/viewdistance/XEH_preInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index 9f66b79e2e8..ca4a7ac90b9 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -6,6 +6,6 @@ PREP(module); PREP(returnViewDistanceValue); PREP(returnViewDistanceLimit); PREP(changeViewDistance); -PREP(initViewDistance); +PREP(init); ADDON = true; \ No newline at end of file From 7201a23d41f23dc35e4e9f936969d73d5c75e659 Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 10:44:01 +0200 Subject: [PATCH 13/32] Adjusted post init, removed redundant settings --- addons/viewdistance/ACE_Settings.hpp | 15 +-------------- addons/viewdistance/XEH_postInit.sqf | 6 +----- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index d7a9dbb9fc6..d3208b1d885 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -1,18 +1,5 @@ class ACE_Settings { - class GVAR(changeAllowed) { - typeName = "BOOL"; - value = 1; - displayName = "Allow View Distance Changing"; - description = "Allows clients to be able to change their view distance"; - }; - class GVAR(viewDistanceLimit) { - typeName = "SCALAR"; - value = 11; // setting the highest number in the array below means no limit. - values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the INDEX values - displayName = "Change View Distance Limit"; - description = "Sets the top limit for all clients"; - }; - class GVAR(newViewDistance) { + class GVAR(viewDistance) { typeName = "SCALAR"; isClientSettable = 1; value = 0; // not sure what to set this to. diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index f5a5079273b..f5c15322bfd 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -1,7 +1,3 @@ #include "script_component.hpp" -if (!GVAR(changeAllowed)) exitWith { - // if viewdistance module is disabled from config, exit here. - diag_log format["[ACE]: View Distance is disabled from the config.cpp in the pbo"]; -}; -[] call FUNC(initViewDistance); \ No newline at end of file +[] call FUNC(init); \ No newline at end of file From bba216ebd2d5382524d4cfd06f352259b4c7cded Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 10:53:09 +0200 Subject: [PATCH 14/32] Rewrote switch statement Per @Glowbal's comment --- .../functions/fnc_returnViewDistanceValue.sqf | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf index 5f06256b090..86b940d5821 100644 --- a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf +++ b/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf @@ -20,24 +20,22 @@ PARAMS_1(_index); private ["_return"]; -_return = 0; -// change to if () exitWith {};? -switch (_index) do +_return = switch (_index) do { - case 0: {_return = 1500;}; - case 1: {_return = 2000;}; - case 2: {_return = 2500;}; - case 3: {_return = 3000;}; - case 4: {_return = 3500;}; - case 5: {_return = 4000;}; - case 6: {_return = 5000;}; - case 7: {_return = 6000;}; - case 8: {_return = 7000;}; - case 9: {_return = 8000;}; - case 10: {_return = 9000;}; - case 11: {_return = 10000;}; - default {hint "something broke!";}; // should replace with something a bit more graceful + case 0: {1500}; + case 1: {2000}; + case 2: {2500}; + case 3: {3000}; + case 4: {3500}; + case 5: {4000}; + case 6: {5000}; + case 7: {6000}; + case 8: {7000}; + case 9: {8000}; + case 10: {9000}; + case 11: {10000}; + default {1000}; }; _return; \ No newline at end of file From 2dfaaa047a0151cf7b456de74ffd7531bf215e13 Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 11:56:27 +0200 Subject: [PATCH 15/32] Reworked limiting system Module limit still not being set properly. --- addons/viewdistance/ACE_Settings.hpp | 10 ++++-- addons/viewdistance/CfgVehicles.hpp | 2 +- addons/viewdistance/XEH_preInit.sqf | 5 ++- .../functions/fnc_changeViewDistance.sqf | 14 ++++---- addons/viewdistance/functions/fnc_init.sqf | 2 +- addons/viewdistance/functions/fnc_module.sqf | 7 ++-- .../functions/fnc_returnViewDistanceLimit.sqf | 34 ------------------- 7 files changed, 21 insertions(+), 53 deletions(-) delete mode 100644 addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index d3208b1d885..4a400a0b312 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -2,11 +2,17 @@ class ACE_Settings { class GVAR(viewDistance) { typeName = "SCALAR"; isClientSettable = 1; - value = 0; // not sure what to set this to. - values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnViewDistanceValue.sqf + value = 11; // index, NOT value // not sure what to set this to. + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf displayName = "Change View Distance"; description = "Changes in game view distance"; }; + class GVAR(limit) { + typeName = "SCALAR"; + value = 10000; // Value, NOT index. + displayName = "View Distance Limit"; + description = "Limit for client's view distance set here and can overridden by module"; + }; }; // To do: include string table style displayName & description. \ No newline at end of file diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index 38ef214c098..d2b014615cb 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -13,7 +13,7 @@ class CfgVehicles { displayName = "View Distance setting limit"; description = "Sets the limit for how high clients can raise their view distance (< 10000)"; typeName = "SCALAR"; - defaultValue = 10000; + defaultValue = 5000; }; }; }; diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index ca4a7ac90b9..a46efc77691 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -3,9 +3,8 @@ ADDON = false; PREP(module); -PREP(returnViewDistanceValue); -PREP(returnViewDistanceLimit); -PREP(changeViewDistance); PREP(init); +PREP(returnValue); +PREP(changeViewDistance); ADDON = true; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 8c017ec1eb2..b118b29a48f 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -20,17 +20,17 @@ private ["_text","_new_view_distance","_view_distance_limit"]; // Change the received index number into an actual view distance number as set in the config: -_new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue); +_new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue); -// Grab the limit, either from the module OR if the module is not valid, the config. -_view_distance_limit = [] call FUNC(returnViewDistanceLimit); +_view_distance_limit = GVAR(limit); // Grab the limit -if (_new_view_distance > _view_distance_limit) then { - _text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; +if (_new_view_distance <= _view_distance_limit) then { + _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; [_text,1] call EFUNC(common,displayTextStructured); + setViewDistance _new_view_distance; + setObjectViewDistance (0.8 * _new_view_distance); // maybe make this 0.8 a constant? } else { - _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; + _text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; [_text,1] call EFUNC(common,displayTextStructured); - setViewDistance _new_view_distance; }; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_init.sqf b/addons/viewdistance/functions/fnc_init.sqf index 75ca076ff68..e9509f3ddd4 100644 --- a/addons/viewdistance/functions/fnc_init.sqf +++ b/addons/viewdistance/functions/fnc_init.sqf @@ -21,7 +21,7 @@ if (!hasInterface) exitWith {}; // Set the EH which waits for the View Distance setting to be changed ["SettingChanged",{ - if (_this select 0 == QGVAR(newViewDistance)) then { + if (_this select 0 == QGVAR(viewDistance)) then { [] call FUNC(changeViewDistance); }; },true] call ace_common_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_module.sqf b/addons/viewdistance/functions/fnc_module.sqf index 66c2aed7930..0e44cd50818 100644 --- a/addons/viewdistance/functions/fnc_module.sqf +++ b/addons/viewdistance/functions/fnc_module.sqf @@ -25,9 +25,6 @@ if (!_activated) exitWith { diag_log text "[ACE]: View Distance Limit Module is placed but NOT active."; }; -GVAR(modulePresent) = true; +diag_log text "[ACE]: View Distance Limit Module Initialized."; -[_logic, QGVAR(moduleViewDistanceLimit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); - -hint format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; // only used for debug, GVAR(moduleViewDistanceLimit) keeps returning as ANY. Remember to remove before finalising the module. -diag_log format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; \ No newline at end of file +[_logic, QGVAR(limit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf b/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf deleted file mode 100644 index 8ae9e6538dd..00000000000 --- a/addons/viewdistance/functions/fnc_returnViewDistanceLimit.sqf +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Author: Winter - * Returns the view distance limit depending on either the config or (if present) the module. - * - * - * Arguments: - * None - * - * Return Value: - * View Distance Limit - * - * Example: - * [] call ace_viewdistance_fnc_returnViewDistanceLimit; - * - * Public: Yes - */ - -#include "script_component.hpp" - -private ["_limit"]; - -_limit = 20000; // unrealistic amount since A3 max is 10000, helps in debug - -if (!isNil QGVAR(moduleViewDistanceLimit)) then { - _limit = GVAR(moduleViewDistanceLimit); // module value always takes priority over config -} else { - // If the module is not present, take the value from the config instead - _limit = [GVAR(viewDistanceLimit)] call FUNC(returnViewDistanceValue); // this function converts the array index in the config to it's relevant scalar value. -}; - -hint format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; // only used for debug, trying to get the module to work. Remember to remove before finalising pbo -diag_log format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; // only used for debug, trying to get the module to work. Remember to remove before finalising pbo - -_limit; \ No newline at end of file From f64f76e92f52463bbbb3ccb4cfa96ca872ffc2dd Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 12:07:05 +0200 Subject: [PATCH 16/32] Fixed wrong file name --- .../{fnc_returnViewDistanceValue.sqf => fnc_returnValue.sqf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename addons/viewdistance/functions/{fnc_returnViewDistanceValue.sqf => fnc_returnValue.sqf} (100%) diff --git a/addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf b/addons/viewdistance/functions/fnc_returnValue.sqf similarity index 100% rename from addons/viewdistance/functions/fnc_returnViewDistanceValue.sqf rename to addons/viewdistance/functions/fnc_returnValue.sqf From a9d6fbd841a0141d344a9baf9c70c602bc50fc2f Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 12:36:11 +0200 Subject: [PATCH 17/32] Attempting to fix module value not being read --- addons/viewdistance/ACE_Settings.hpp | 2 +- addons/viewdistance/CfgVehicles.hpp | 4 ++-- addons/viewdistance/functions/fnc_changeViewDistance.sqf | 2 ++ addons/viewdistance/functions/fnc_module.sqf | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 4a400a0b312..de1b0226c62 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -9,7 +9,7 @@ class ACE_Settings { }; class GVAR(limit) { typeName = "SCALAR"; - value = 10000; // Value, NOT index. + value = 10000; // Value, NOT index. 10000 is the maximum in A3 displayName = "View Distance Limit"; description = "Limit for client's view distance set here and can overridden by module"; }; diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index d2b014615cb..832b2c55a2a 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -10,10 +10,10 @@ class CfgVehicles { //icon = ""; // needs an icon class Arguments { class moduleViewDistanceLimit { - displayName = "View Distance setting limit"; + displayName = "View Distance Limit"; description = "Sets the limit for how high clients can raise their view distance (< 10000)"; typeName = "SCALAR"; - defaultValue = 5000; + defaultValue = 6000; }; }; }; diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index b118b29a48f..0a2467bace3 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -24,6 +24,8 @@ _new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue); _view_distance_limit = GVAR(limit); // Grab the limit +diag_log format ["[ACE]: DEBUG View Distance change requested: %1 Limit is: %2 Under Limit: %3",_new_view_distance,_view_distance_limit,_new_view_distance<_view_distance_limit]; // ONLY FOR DEBUG, REMOVE LATER ON + if (_new_view_distance <= _view_distance_limit) then { _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; [_text,1] call EFUNC(common,displayTextStructured); diff --git a/addons/viewdistance/functions/fnc_module.sqf b/addons/viewdistance/functions/fnc_module.sqf index 0e44cd50818..2ca2a6bd360 100644 --- a/addons/viewdistance/functions/fnc_module.sqf +++ b/addons/viewdistance/functions/fnc_module.sqf @@ -25,6 +25,6 @@ if (!_activated) exitWith { diag_log text "[ACE]: View Distance Limit Module is placed but NOT active."; }; -diag_log text "[ACE]: View Distance Limit Module Initialized."; +[_logic, QGVAR(limit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(limit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); \ No newline at end of file +diag_log format ["[ACE]: View Distance Limit Module Initialized. Limit set by module: %1",GVAR(limit)]; \ No newline at end of file From f4d7c6818bf483f79916ea3c865840ba9253d7af Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 13:05:36 +0200 Subject: [PATCH 18/32] Attempted fix #2 --- addons/viewdistance/CfgVehicles.hpp | 6 +++--- addons/viewdistance/XEH_preInit.sqf | 2 +- .../functions/{fnc_module.sqf => fnc_initModule.sqf} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename addons/viewdistance/functions/{fnc_module.sqf => fnc_initModule.sqf} (100%) diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index 832b2c55a2a..a9a35dcfe4c 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -1,10 +1,10 @@ class CfgVehicles { - class Module_F; - class ACE_ModuleViewDistance : Module_F { + class ACE_Module; + class GVAR(ModuleSettings) : ACE_Module { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; + function = QUOTE(DFUNC(initModule)); displayName = "View Distance Limiter"; - function = QFUNC(module); scope = 2; isGlobal = 1; //icon = ""; // needs an icon diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index a46efc77691..883e393c8ae 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -2,7 +2,7 @@ ADDON = false; -PREP(module); +PREP(initModule); PREP(init); PREP(returnValue); PREP(changeViewDistance); diff --git a/addons/viewdistance/functions/fnc_module.sqf b/addons/viewdistance/functions/fnc_initModule.sqf similarity index 100% rename from addons/viewdistance/functions/fnc_module.sqf rename to addons/viewdistance/functions/fnc_initModule.sqf From cad86280c1600351aba3205248979e2d6fe3935e Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 14:51:23 +0200 Subject: [PATCH 19/32] Fixed module value not overriding. --- addons/viewdistance/CfgVehicles.hpp | 4 ++-- addons/viewdistance/functions/fnc_changeViewDistance.sqf | 5 +---- addons/viewdistance/functions/fnc_init.sqf | 2 +- addons/viewdistance/functions/fnc_initModule.sqf | 2 -- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index a9a35dcfe4c..2a2f85e611a 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -12,8 +12,8 @@ class CfgVehicles { class moduleViewDistanceLimit { displayName = "View Distance Limit"; description = "Sets the limit for how high clients can raise their view distance (< 10000)"; - typeName = "SCALAR"; - defaultValue = 6000; + typeName = "NUMBER"; + defaultValue = 10000; }; }; }; diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 0a2467bace3..7a92b70748b 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -19,13 +19,10 @@ private ["_text","_new_view_distance","_view_distance_limit"]; -// Change the received index number into an actual view distance number as set in the config: +// Change the received index number into an actual view distance: _new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue); - _view_distance_limit = GVAR(limit); // Grab the limit -diag_log format ["[ACE]: DEBUG View Distance change requested: %1 Limit is: %2 Under Limit: %3",_new_view_distance,_view_distance_limit,_new_view_distance<_view_distance_limit]; // ONLY FOR DEBUG, REMOVE LATER ON - if (_new_view_distance <= _view_distance_limit) then { _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; [_text,1] call EFUNC(common,displayTextStructured); diff --git a/addons/viewdistance/functions/fnc_init.sqf b/addons/viewdistance/functions/fnc_init.sqf index e9509f3ddd4..0d5ec7cf792 100644 --- a/addons/viewdistance/functions/fnc_init.sqf +++ b/addons/viewdistance/functions/fnc_init.sqf @@ -1,6 +1,6 @@ /* * Author: Winter - * Assigns the Event Handler which fires when a player adjusts their view distance in the menu + * Assigns the Event Handler which triggers when a player adjusts their view distance in the menu * * * Arguments: diff --git a/addons/viewdistance/functions/fnc_initModule.sqf b/addons/viewdistance/functions/fnc_initModule.sqf index 2ca2a6bd360..6dd7105439c 100644 --- a/addons/viewdistance/functions/fnc_initModule.sqf +++ b/addons/viewdistance/functions/fnc_initModule.sqf @@ -10,8 +10,6 @@ * * Return Value: * None - * - * Example: * */ From 737b1cc2160291a88ceb98da34f57b2335a28e6c Mon Sep 17 00:00:00 2001 From: SAM Date: Sat, 9 May 2015 18:42:02 +0200 Subject: [PATCH 20/32] Renamed variable limit to limitViewDistance For future limiting of terraingrid --- addons/viewdistance/ACE_Settings.hpp | 2 +- addons/viewdistance/functions/fnc_changeViewDistance.sqf | 2 +- addons/viewdistance/functions/fnc_initModule.sqf | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index de1b0226c62..6572e4790e4 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -7,7 +7,7 @@ class ACE_Settings { displayName = "Change View Distance"; description = "Changes in game view distance"; }; - class GVAR(limit) { + class GVAR(limitViewDistance) { typeName = "SCALAR"; value = 10000; // Value, NOT index. 10000 is the maximum in A3 displayName = "View Distance Limit"; diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 7a92b70748b..f1274343d85 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -21,7 +21,7 @@ private ["_text","_new_view_distance","_view_distance_limit"]; // Change the received index number into an actual view distance: _new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue); -_view_distance_limit = GVAR(limit); // Grab the limit +_view_distance_limit = GVAR(limitViewDistance); // Grab the limit if (_new_view_distance <= _view_distance_limit) then { _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; diff --git a/addons/viewdistance/functions/fnc_initModule.sqf b/addons/viewdistance/functions/fnc_initModule.sqf index 6dd7105439c..cff8e9685fa 100644 --- a/addons/viewdistance/functions/fnc_initModule.sqf +++ b/addons/viewdistance/functions/fnc_initModule.sqf @@ -23,6 +23,6 @@ if (!_activated) exitWith { diag_log text "[ACE]: View Distance Limit Module is placed but NOT active."; }; -[_logic, QGVAR(limit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(limitViewDistance),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); -diag_log format ["[ACE]: View Distance Limit Module Initialized. Limit set by module: %1",GVAR(limit)]; \ No newline at end of file +diag_log format ["[ACE]: View Distance Limit Module Initialized. Limit set by module: %1",GVAR(limitViewDistance)]; \ No newline at end of file From 69648f0e1b2a213cae8100749b167871a84e6dbe Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 12:00:19 +0200 Subject: [PATCH 21/32] Added adaptive view distance depending on vehicle --- addons/viewdistance/ACE_Settings.hpp | 36 ++++++++++++++++--- addons/viewdistance/CfgVehicles.hpp | 8 ++++- addons/viewdistance/XEH_preInit.sqf | 1 + .../functions/fnc_adaptViewDistance.sqf | 35 ++++++++++++++++++ .../functions/fnc_changeViewDistance.sqf | 21 +++++++---- addons/viewdistance/functions/fnc_init.sqf | 18 +++++++--- 6 files changed, 103 insertions(+), 16 deletions(-) create mode 100644 addons/viewdistance/functions/fnc_adaptViewDistance.sqf diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 6572e4790e4..46f7a8955ab 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -1,11 +1,27 @@ class ACE_Settings { - class GVAR(viewDistance) { + class GVAR(viewDistanceOnFoot) { typeName = "SCALAR"; isClientSettable = 1; - value = 11; // index, NOT value // not sure what to set this to. + value = 11; // index, NOT value // Can set it to client's actual viewdistance in the init function once ACE_Settings supports numbers (if ever). values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf - displayName = "Change View Distance"; - description = "Changes in game view distance"; + displayName = "Client View Distance (On Foot)"; + description = "Changes in game view distance when the player is on foot."; + }; + class GVAR(viewDistanceLandVehicle) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 11; // index, NOT value + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf + displayName = "Client View Distance (Land Vehicle)"; + description = "Changes in game view distance when the player is in a land vehicle."; + }; + class GVAR(viewDistanceAirVehicle) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 11; // index, NOT value + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf + displayName = "Client View Distance (Air Vehicle)"; + description = "Changes in game view distance when the player is in an air vehicle."; }; class GVAR(limitViewDistance) { typeName = "SCALAR"; @@ -13,6 +29,18 @@ class ACE_Settings { displayName = "View Distance Limit"; description = "Limit for client's view distance set here and can overridden by module"; }; + class GVAR(terrainGrid) { + typeName = "SCALAR"; + value = 10; // MP default as found in: https://community.bistudio.com/wiki/setTerrainGrid + displayName = "Client Terrain Grid"; + description = "Changes in game terrain grid"; + }; + class GVAR(shadows) { + typeName = "SCALAR"; + value = 200; // MP default as found in: https://community.bistudio.com/wiki/setObjectViewDistance + displayName = "Client Shadows distance"; + description = "Changes in game shadows"; + }; }; // To do: include string table style displayName & description. \ No newline at end of file diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index 2a2f85e611a..99897f54415 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -11,10 +11,16 @@ class CfgVehicles { class Arguments { class moduleViewDistanceLimit { displayName = "View Distance Limit"; - description = "Sets the limit for how high clients can raise their view distance (< 10000)"; + description = "Sets the limit for how high clients can raise their view distance (<= 10000)"; typeName = "NUMBER"; defaultValue = 10000; }; + class moduleTerrainGridLimit { + displayName = "Terrain Grid Limit"; + description = "Sets the limit for how high clients can raise their terrain grid (<= 50)"; + typeName = "NUMBER"; + defaultValue = 50; // range is 3.125 - 50 Reference: https://community.bistudio.com/wiki/setTerrainGrid + }; }; }; }; \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index 883e393c8ae..a44fab61692 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -6,5 +6,6 @@ PREP(initModule); PREP(init); PREP(returnValue); PREP(changeViewDistance); +PREP(adaptViewDistance); ADDON = true; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf new file mode 100644 index 00000000000..bc56955893a --- /dev/null +++ b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf @@ -0,0 +1,35 @@ +/* + * Author: Winter + * Sets the player's current view distance according to whether s/he is on foot, in a land vehicle or in an air vehicle. + * + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_viewdistance_fnc_adaptViewDistance; + * + * Public: Yes + */ + +#include "script_component.hpp" + +private["_land_vehicle","_air_vehicle"]; + +_land_vehicle = (vehicle player) isKindOf "LandVehicle"; +_air_vehicle = (vehicle player) isKindOf "Air"; + +if (!_land_vehicle && !_air_vehicle) exitWith { + [GVAR(viewDistanceOnFoot),true] call FUNC(changeViewDistance); +}; + +if (_land_vehicle) exitWith { + [GVAR(viewDistanceLandVehicle),true] call FUNC(changeViewDistance); +}; + +if (_air_vehicle) exitWith { + [GVAR(viewDistanceAirVehicle),true] call FUNC(changeViewDistance); +}; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index f1274343d85..596c86d5212 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -4,7 +4,8 @@ * * * Arguments: - * None + * 0: View Distance setting INDEX + * 1: Show Prompt * * Return Value: * None @@ -18,18 +19,24 @@ #include "script_component.hpp" private ["_text","_new_view_distance","_view_distance_limit"]; +PARAMS_2(_index_requested,_prompt); -// Change the received index number into an actual view distance: -_new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue); +_new_view_distance = [_index_requested] call FUNC(returnValue); // change the index into an actual view distance value _view_distance_limit = GVAR(limitViewDistance); // Grab the limit if (_new_view_distance <= _view_distance_limit) then { - _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; - [_text,1] call EFUNC(common,displayTextStructured); + if (_prompt) then { + _text = composeText ["View distance: ",str(_new_view_distance)]; + [_text,1] call EFUNC(common,displayTextStructured); + }; setViewDistance _new_view_distance; setObjectViewDistance (0.8 * _new_view_distance); // maybe make this 0.8 a constant? } else { - _text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; - [_text,1] call EFUNC(common,displayTextStructured); + if (_prompt) then { + _text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)]; + [_text,1] call EFUNC(common,displayTextStructured); + setViewDistance _view_distance_limit; + setObjectViewDistance (0.8 * _view_distance_limit); // maybe make this 0.8 a constant? + }; }; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_init.sqf b/addons/viewdistance/functions/fnc_init.sqf index 0d5ec7cf792..72fc2ee0e68 100644 --- a/addons/viewdistance/functions/fnc_init.sqf +++ b/addons/viewdistance/functions/fnc_init.sqf @@ -19,9 +19,19 @@ if (!hasInterface) exitWith {}; -// Set the EH which waits for the View Distance setting to be changed +if (viewDistance > GVAR(limitViewDistance)) then { + setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit. + setObjectViewDistance (0.8 * GVAR(limitViewDistance)); +} else { + [] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle. +}; + +// Set the EH which waits for any of the view distance settings to be changed (avoids the player having to enter or leave their vehicle for the changes to have effect.) ["SettingChanged",{ - if (_this select 0 == QGVAR(viewDistance)) then { - [] call FUNC(changeViewDistance); + if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then { + [] call FUNC(adaptViewDistance); }; -},true] call ace_common_fnc_addEventHandler; \ No newline at end of file +},true] call ace_common_fnc_addEventHandler; + +// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle +["playerVehicleChanged",{[] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; \ No newline at end of file From c05a91f5308d0f0ab63059c2ef17f67d73308d1c Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 12:15:34 +0200 Subject: [PATCH 22/32] Suppress prompts when changing vehicle. They're only shown when the player changes the setting. --- .../viewdistance/functions/fnc_adaptViewDistance.sqf | 10 ++++++---- .../viewdistance/functions/fnc_changeViewDistance.sqf | 2 +- addons/viewdistance/functions/fnc_init.sqf | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf index bc56955893a..946c601fc88 100644 --- a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf @@ -4,7 +4,7 @@ * * * Arguments: - * None + * 0: Show Prompt * * Return Value: * None @@ -17,19 +17,21 @@ #include "script_component.hpp" +PARAMS_1(_show_prompt); + private["_land_vehicle","_air_vehicle"]; _land_vehicle = (vehicle player) isKindOf "LandVehicle"; _air_vehicle = (vehicle player) isKindOf "Air"; if (!_land_vehicle && !_air_vehicle) exitWith { - [GVAR(viewDistanceOnFoot),true] call FUNC(changeViewDistance); + [GVAR(viewDistanceOnFoot),_show_prompt] call FUNC(changeViewDistance); }; if (_land_vehicle) exitWith { - [GVAR(viewDistanceLandVehicle),true] call FUNC(changeViewDistance); + [GVAR(viewDistanceLandVehicle),_show_prompt] call FUNC(changeViewDistance); }; if (_air_vehicle) exitWith { - [GVAR(viewDistanceAirVehicle),true] call FUNC(changeViewDistance); + [GVAR(viewDistanceAirVehicle),_show_prompt] call FUNC(changeViewDistance); }; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 596c86d5212..bf5f610c0d0 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -26,7 +26,7 @@ _view_distance_limit = GVAR(limitViewDistance); // Grab the limit if (_new_view_distance <= _view_distance_limit) then { if (_prompt) then { - _text = composeText ["View distance: ",str(_new_view_distance)]; + _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; [_text,1] call EFUNC(common,displayTextStructured); }; setViewDistance _new_view_distance; diff --git a/addons/viewdistance/functions/fnc_init.sqf b/addons/viewdistance/functions/fnc_init.sqf index 72fc2ee0e68..07befd157cb 100644 --- a/addons/viewdistance/functions/fnc_init.sqf +++ b/addons/viewdistance/functions/fnc_init.sqf @@ -23,15 +23,15 @@ if (viewDistance > GVAR(limitViewDistance)) then { setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit. setObjectViewDistance (0.8 * GVAR(limitViewDistance)); } else { - [] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle. + [true] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle. }; -// Set the EH which waits for any of the view distance settings to be changed (avoids the player having to enter or leave their vehicle for the changes to have effect.) +// Set the EH which waits for any of the view distance settings to be changed, avoids the player having to enter or leave a vehicle for the changes to have effect. ["SettingChanged",{ if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then { - [] call FUNC(adaptViewDistance); + [true] call FUNC(adaptViewDistance); }; },true] call ace_common_fnc_addEventHandler; // Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle -["playerVehicleChanged",{[] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; \ No newline at end of file +["playerVehicleChanged",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; \ No newline at end of file From 2ce133675a6a946a69f3686d0742881b41889aa6 Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 12:28:58 +0200 Subject: [PATCH 23/32] Removed terrain grid related configs --- addons/viewdistance/CfgVehicles.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp index 99897f54415..870c669601a 100644 --- a/addons/viewdistance/CfgVehicles.hpp +++ b/addons/viewdistance/CfgVehicles.hpp @@ -15,12 +15,6 @@ class CfgVehicles { typeName = "NUMBER"; defaultValue = 10000; }; - class moduleTerrainGridLimit { - displayName = "Terrain Grid Limit"; - description = "Sets the limit for how high clients can raise their terrain grid (<= 50)"; - typeName = "NUMBER"; - defaultValue = 50; // range is 3.125 - 50 Reference: https://community.bistudio.com/wiki/setTerrainGrid - }; }; }; }; \ No newline at end of file From 6a6681872cc1f3d29009c1fa666deed8eec4647b Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 12:54:53 +0200 Subject: [PATCH 24/32] Replaced player with ACE_player --- addons/viewdistance/functions/fnc_adaptViewDistance.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf index 946c601fc88..c81b5227470 100644 --- a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf @@ -21,8 +21,8 @@ PARAMS_1(_show_prompt); private["_land_vehicle","_air_vehicle"]; -_land_vehicle = (vehicle player) isKindOf "LandVehicle"; -_air_vehicle = (vehicle player) isKindOf "Air"; +_land_vehicle = (vehicle ACE_player) isKindOf "LandVehicle"; +_air_vehicle = (vehicle ACE_player) isKindOf "Air"; if (!_land_vehicle && !_air_vehicle) exitWith { [GVAR(viewDistanceOnFoot),_show_prompt] call FUNC(changeViewDistance); From 283768fabb2da7e5741a3c305be449bff8e07699 Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 12:56:05 +0200 Subject: [PATCH 25/32] Fixed code style in switch statement --- .../functions/fnc_returnValue.sqf | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/addons/viewdistance/functions/fnc_returnValue.sqf b/addons/viewdistance/functions/fnc_returnValue.sqf index 86b940d5821..80e82feee24 100644 --- a/addons/viewdistance/functions/fnc_returnValue.sqf +++ b/addons/viewdistance/functions/fnc_returnValue.sqf @@ -21,21 +21,20 @@ PARAMS_1(_index); private ["_return"]; -_return = switch (_index) do -{ - case 0: {1500}; - case 1: {2000}; - case 2: {2500}; - case 3: {3000}; - case 4: {3500}; - case 5: {4000}; - case 6: {5000}; - case 7: {6000}; - case 8: {7000}; - case 9: {8000}; - case 10: {9000}; - case 11: {10000}; - default {1000}; +_return = switch (_index) do { + case 0: {1500}; + case 1: {2000}; + case 2: {2500}; + case 3: {3000}; + case 4: {3500}; + case 5: {4000}; + case 6: {5000}; + case 7: {6000}; + case 8: {7000}; + case 9: {8000}; + case 10: {9000}; + case 11: {10000}; + default {1000}; }; _return; \ No newline at end of file From 495e94f3f0071d2355e6af636c6bb15a3ac768b9 Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 13:04:08 +0200 Subject: [PATCH 26/32] Merged fnc_init.sqf into XEH_postInit.sqf --- addons/viewdistance/XEH_postInit.sqf | 19 ++++++++++- addons/viewdistance/XEH_preInit.sqf | 1 - addons/viewdistance/functions/fnc_init.sqf | 37 ---------------------- 3 files changed, 18 insertions(+), 39 deletions(-) delete mode 100644 addons/viewdistance/functions/fnc_init.sqf diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index f5c15322bfd..d3924666c25 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -1,3 +1,20 @@ #include "script_component.hpp" -[] call FUNC(init); \ No newline at end of file +if (!hasInterface) exitWith {}; + +if (viewDistance > GVAR(limitViewDistance)) then { + setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit. + setObjectViewDistance (0.8 * GVAR(limitViewDistance)); +} else { + [true] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle. +}; + +// Set the EH which waits for any of the view distance settings to be changed, avoids the player having to enter or leave a vehicle for the changes to have effect. +["SettingChanged",{ + if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then { + [true] call FUNC(adaptViewDistance); + }; +},true] call ace_common_fnc_addEventHandler; + +// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle +["playerVehicleChanged",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index a44fab61692..a55e0a3075c 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -3,7 +3,6 @@ ADDON = false; PREP(initModule); -PREP(init); PREP(returnValue); PREP(changeViewDistance); PREP(adaptViewDistance); diff --git a/addons/viewdistance/functions/fnc_init.sqf b/addons/viewdistance/functions/fnc_init.sqf deleted file mode 100644 index 07befd157cb..00000000000 --- a/addons/viewdistance/functions/fnc_init.sqf +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Author: Winter - * Assigns the Event Handler which triggers when a player adjusts their view distance in the menu - * - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * [] call ace_viewdistance_fnc_initViewDistance; - * - * Public: Yes - */ - -#include "script_component.hpp" - -if (!hasInterface) exitWith {}; - -if (viewDistance > GVAR(limitViewDistance)) then { - setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit. - setObjectViewDistance (0.8 * GVAR(limitViewDistance)); -} else { - [true] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle. -}; - -// Set the EH which waits for any of the view distance settings to be changed, avoids the player having to enter or leave a vehicle for the changes to have effect. -["SettingChanged",{ - if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then { - [true] call FUNC(adaptViewDistance); - }; -},true] call ace_common_fnc_addEventHandler; - -// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle -["playerVehicleChanged",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; \ No newline at end of file From cb64f7d1a9276d1bf256e66039b57f2b3f281cc5 Mon Sep 17 00:00:00 2001 From: SAM Date: Sun, 10 May 2015 13:28:18 +0200 Subject: [PATCH 27/32] Adjusted PBOPREFIX --- addons/viewdistance/$PBOPREFIX$ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/viewdistance/$PBOPREFIX$ b/addons/viewdistance/$PBOPREFIX$ index 39789fcaba5..278df54db31 100644 --- a/addons/viewdistance/$PBOPREFIX$ +++ b/addons/viewdistance/$PBOPREFIX$ @@ -1 +1 @@ -z\ace\addons\blank \ No newline at end of file +z\ace\addons\viewdistance \ No newline at end of file From d8cce9ece43ce5483275ffe200d6a444c354ff2b Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 17:07:20 +0200 Subject: [PATCH 28/32] Removed redundant settings --- addons/viewdistance/ACE_Settings.hpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 46f7a8955ab..91ac257c014 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -29,18 +29,6 @@ class ACE_Settings { displayName = "View Distance Limit"; description = "Limit for client's view distance set here and can overridden by module"; }; - class GVAR(terrainGrid) { - typeName = "SCALAR"; - value = 10; // MP default as found in: https://community.bistudio.com/wiki/setTerrainGrid - displayName = "Client Terrain Grid"; - description = "Changes in game terrain grid"; - }; - class GVAR(shadows) { - typeName = "SCALAR"; - value = 200; // MP default as found in: https://community.bistudio.com/wiki/setObjectViewDistance - displayName = "Client Shadows distance"; - description = "Changes in game shadows"; - }; }; // To do: include string table style displayName & description. \ No newline at end of file From 7fe73c2c8084183a5d6d4b45edfdfebeb3df7ab8 Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 17:11:52 +0200 Subject: [PATCH 29/32] Added Object View Distance Coefficient setting --- addons/viewdistance/ACE_Settings.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 91ac257c014..0fff9f0daf4 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -29,6 +29,14 @@ class ACE_Settings { displayName = "View Distance Limit"; description = "Limit for client's view distance set here and can overridden by module"; }; + class GVAR(objectViewDistanceCoeff) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 0; // index. Actual coefficient is given by functions/fnc_returnObjectCoeff.sqf + values[] = {"Off","Low","Medium","High"}; + displayName = "Dynamic Object View Distance"; + description = "Sets the object view distance as a coefficient of the view distance."; + }; }; // To do: include string table style displayName & description. \ No newline at end of file From 853333ac494b1cb8dea8e71bdb99257ea4fc85f4 Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 17:19:14 +0200 Subject: [PATCH 30/32] Added new function, updated settings --- addons/viewdistance/ACE_Settings.hpp | 2 +- .../functions/fnc_returnObjectCoeff.sqf | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 addons/viewdistance/functions/fnc_returnObjectCoeff.sqf diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index 0fff9f0daf4..ba773f5fc56 100644 --- a/addons/viewdistance/ACE_Settings.hpp +++ b/addons/viewdistance/ACE_Settings.hpp @@ -33,7 +33,7 @@ class ACE_Settings { typeName = "SCALAR"; isClientSettable = 1; value = 0; // index. Actual coefficient is given by functions/fnc_returnObjectCoeff.sqf - values[] = {"Off","Low","Medium","High"}; + values[] = {"Off","Very Low","Low","Medium","High","Very High"}; displayName = "Dynamic Object View Distance"; description = "Sets the object view distance as a coefficient of the view distance."; }; diff --git a/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf new file mode 100644 index 00000000000..476478a4480 --- /dev/null +++ b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf @@ -0,0 +1,34 @@ +/* + * Author: Winter + * Returns the object view distance coefficient according to the given index + * + * + * Arguments: + * 0: Object View Distance setting Index + * + * Return Value: + * Object View Distance + * + * Example: + * [2] call ace_viewdistance_fnc_returnObjectCoeff; + * + * Public: No + */ + +#include "script_component.hpp" + +PARAMS_1(_index); + +private ["_return"]; + +_return = switch (_index) do { + case 0: {0.00}; // Off + case 1: {0.20}; // Very Low + case 2: {0.40}; // Low + case 3: {0.60}; // Medium + case 4: {0.80}; // High + case 5: {1.00}; // Very High + default {0.50}; // something broke if this returns +}; + +_return; \ No newline at end of file From 3480168e05e900af0cdb1e346b0f780cccb32ed5 Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 17:44:35 +0200 Subject: [PATCH 31/32] Integrated new function into module --- addons/viewdistance/XEH_postInit.sqf | 7 +++++ addons/viewdistance/XEH_preInit.sqf | 1 + .../functions/fnc_changeViewDistance.sqf | 27 ++++++++++++------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf index d3924666c25..6c4f41d3743 100644 --- a/addons/viewdistance/XEH_postInit.sqf +++ b/addons/viewdistance/XEH_postInit.sqf @@ -16,5 +16,12 @@ if (viewDistance > GVAR(limitViewDistance)) then { }; },true] call ace_common_fnc_addEventHandler; +// Set the EH which waits for the Object View Distance coefficient to be changed, so that the effect is show immediately +["SettingChanged",{ + if (_this select 0 == QGVAR(objectViewDistanceCoeff)) then { + [true] call FUNC(adaptViewDistance); + }; +},true] call ace_common_fnc_addEventHandler; + // Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle ["playerVehicleChanged",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf index a55e0a3075c..a68416cada1 100644 --- a/addons/viewdistance/XEH_preInit.sqf +++ b/addons/viewdistance/XEH_preInit.sqf @@ -4,6 +4,7 @@ ADDON = false; PREP(initModule); PREP(returnValue); +PREP(returnObjectCoeff); PREP(changeViewDistance); PREP(adaptViewDistance); diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index bf5f610c0d0..9aab955db8d 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -18,25 +18,32 @@ #include "script_component.hpp" -private ["_text","_new_view_distance","_view_distance_limit"]; -PARAMS_2(_index_requested,_prompt); +private ["_text","_new_view_distance","_view_distance_limit","_object_view_distance_coeff"]; +PARAMS_2(_index_requested,_show_prompt); _new_view_distance = [_index_requested] call FUNC(returnValue); // change the index into an actual view distance value +_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); _view_distance_limit = GVAR(limitViewDistance); // Grab the limit if (_new_view_distance <= _view_distance_limit) then { - if (_prompt) then { - _text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; - [_text,1] call EFUNC(common,displayTextStructured); + if (_show_prompt) then { + //_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; + _text = format ["View distance successfully changed to: %1, Object View Distance Coefficient is: %2",str(_new_view_distance),str(_object_view_distance_coeff)]; + [_text,3] call EFUNC(common,displayTextStructured); }; setViewDistance _new_view_distance; - setObjectViewDistance (0.8 * _new_view_distance); // maybe make this 0.8 a constant? + if (_object_view_distance_coeff > 0) then { + setObjectViewDistance (_object_view_distance_coeff * _new_view_distance); + }; } else { - if (_prompt) then { - _text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)]; - [_text,1] call EFUNC(common,displayTextStructured); + if (_show_prompt) then { + //_text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)]; + _text = format ["That option is invalid! The limit is: %1, Object View Distance Coefficient is: %2",str(_view_distance_limit),str(_object_view_distance_coeff)]; + [_text,3] call EFUNC(common,displayTextStructured); setViewDistance _view_distance_limit; - setObjectViewDistance (0.8 * _view_distance_limit); // maybe make this 0.8 a constant? + if (_object_view_distance_coeff > 0) then { + setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit); + }; }; }; \ No newline at end of file From 8c7d752fcc6f41067208a26fa0ec0eb366e159c6 Mon Sep 17 00:00:00 2001 From: SAM Date: Thu, 14 May 2015 18:25:41 +0200 Subject: [PATCH 32/32] Made final adjustments Centred prompts, fixed erroneous if statement, adjusted function headers. --- .../functions/fnc_adaptViewDistance.sqf | 2 +- .../functions/fnc_changeViewDistance.sqf | 25 +++++++++---------- .../functions/fnc_returnObjectCoeff.sqf | 14 +++++------ .../functions/fnc_returnValue.sqf | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf index c81b5227470..5012b40c93b 100644 --- a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf @@ -12,7 +12,7 @@ * Example: * [] call ace_viewdistance_fnc_adaptViewDistance; * - * Public: Yes + * Public: No */ #include "script_component.hpp" diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf index 9aab955db8d..61b568bc2ab 100644 --- a/addons/viewdistance/functions/fnc_changeViewDistance.sqf +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -13,23 +13,23 @@ * Example: * [] call ace_viewdistance_fnc_changeViewDistance; * - * Public: Yes + * Public: No */ #include "script_component.hpp" private ["_text","_new_view_distance","_view_distance_limit","_object_view_distance_coeff"]; + PARAMS_2(_index_requested,_show_prompt); -_new_view_distance = [_index_requested] call FUNC(returnValue); // change the index into an actual view distance value -_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); +_new_view_distance = [_index_requested] call FUNC(returnValue); // changes the setting index into an actual view distance value +_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); // changes the setting index into a coefficient. _view_distance_limit = GVAR(limitViewDistance); // Grab the limit if (_new_view_distance <= _view_distance_limit) then { if (_show_prompt) then { - //_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)]; - _text = format ["View distance successfully changed to: %1, Object View Distance Coefficient is: %2",str(_new_view_distance),str(_object_view_distance_coeff)]; - [_text,3] call EFUNC(common,displayTextStructured); + _text = parseText format ["View Distance: %1
Object View Distance Coefficient: %2
",str(_new_view_distance),str(_object_view_distance_coeff)]; + [_text,2] call EFUNC(common,displayTextStructured); }; setViewDistance _new_view_distance; if (_object_view_distance_coeff > 0) then { @@ -38,12 +38,11 @@ if (_new_view_distance <= _view_distance_limit) then { } else { if (_show_prompt) then { - //_text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)]; - _text = format ["That option is invalid! The limit is: %1, Object View Distance Coefficient is: %2",str(_view_distance_limit),str(_object_view_distance_coeff)]; - [_text,3] call EFUNC(common,displayTextStructured); - setViewDistance _view_distance_limit; - if (_object_view_distance_coeff > 0) then { - setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit); - }; + _text = parseText format ["That option is invalid! The limit is: %1
Object View Distance Coefficient: %2
",str(_view_distance_limit),str(_object_view_distance_coeff)]; + [_text,2] call EFUNC(common,displayTextStructured); + }; + setViewDistance _view_distance_limit; + if (_object_view_distance_coeff > 0) then { + setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit); }; }; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf index 476478a4480..145b8ae9e6c 100644 --- a/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf +++ b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf @@ -22,13 +22,13 @@ PARAMS_1(_index); private ["_return"]; _return = switch (_index) do { - case 0: {0.00}; // Off - case 1: {0.20}; // Very Low - case 2: {0.40}; // Low - case 3: {0.60}; // Medium - case 4: {0.80}; // High - case 5: {1.00}; // Very High - default {0.50}; // something broke if this returns + case 0: {0.00}; // Off + case 1: {0.20}; // Very Low + case 2: {0.40}; // Low + case 3: {0.60}; // Medium + case 4: {0.80}; // High + case 5: {1.00}; // Very High + default {0.50}; // something broke if this returns }; _return; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnValue.sqf b/addons/viewdistance/functions/fnc_returnValue.sqf index 80e82feee24..9d4725c72e8 100644 --- a/addons/viewdistance/functions/fnc_returnValue.sqf +++ b/addons/viewdistance/functions/fnc_returnValue.sqf @@ -12,7 +12,7 @@ * Example: * [2] call ace_viewdistance_fnc_returnViewDistanceValue; * - * Public: Yes + * Public: No */ #include "script_component.hpp"