Reworked limiting system

Module limit still not being set properly.
This commit is contained in:
SAM 2015-05-09 11:56:27 +02:00
parent bba216ebd2
commit 2dfaaa047a
7 changed files with 22 additions and 54 deletions

View File

@ -2,11 +2,17 @@ class ACE_Settings {
class GVAR(viewDistance) { class GVAR(viewDistance) {
typeName = "SCALAR"; typeName = "SCALAR";
isClientSettable = 1; isClientSettable = 1;
value = 0; // not sure what to set this to. 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_returnViewDistanceValue.sqf 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"; displayName = "Change View Distance";
description = "Changes in game 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. // To do: include string table style displayName & description.

View File

@ -13,7 +13,7 @@ class CfgVehicles {
displayName = "View Distance setting limit"; displayName = "View Distance setting 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 = "SCALAR"; typeName = "SCALAR";
defaultValue = 10000; defaultValue = 5000;
}; };
}; };
}; };

View File

@ -3,9 +3,8 @@
ADDON = false; ADDON = false;
PREP(module); PREP(module);
PREP(returnViewDistanceValue);
PREP(returnViewDistanceLimit);
PREP(changeViewDistance);
PREP(init); PREP(init);
PREP(returnValue);
PREP(changeViewDistance);
ADDON = true; ADDON = true;

View File

@ -20,17 +20,17 @@
private ["_text","_new_view_distance","_view_distance_limit"]; 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 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 = GVAR(limit); // Grab the limit
_view_distance_limit = [] call FUNC(returnViewDistanceLimit);
if (_new_view_distance > _view_distance_limit) then { 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 = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
[_text,1] call EFUNC(common,displayTextStructured); [_text,1] call EFUNC(common,displayTextStructured);
setViewDistance _new_view_distance; 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);
}; };

View File

@ -21,7 +21,7 @@ if (!hasInterface) exitWith {};
// Set the EH which waits for the View Distance setting to be changed // Set the EH which waits for the View Distance setting to be changed
["SettingChanged",{ ["SettingChanged",{
if (_this select 0 == QGVAR(newViewDistance)) then { if (_this select 0 == QGVAR(viewDistance)) then {
[] call FUNC(changeViewDistance); [] call FUNC(changeViewDistance);
}; };
},true] call ace_common_fnc_addEventHandler; },true] call ace_common_fnc_addEventHandler;

View File

@ -25,9 +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 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); [_logic, QGVAR(limit),"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)];

View File

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