diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp index d3208b1d88..4a400a0b31 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 38ef214c09..d2b014615c 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 ca4a7ac90b..a46efc7769 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 8c017ec1eb..b118b29a48 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)]; - [_text,1] call EFUNC(common,displayTextStructured); -} -else { +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 ["That option is not allowed! The limit is: ",str(_view_distance_limit)]; + [_text,1] call EFUNC(common,displayTextStructured); }; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_init.sqf b/addons/viewdistance/functions/fnc_init.sqf index 75ca076ff6..e9509f3ddd 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 66c2aed793..0e44cd5081 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 8ae9e6538d..0000000000 --- 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