All working except module returning any.

ace_viewdistance_moduleViewDistanceLimit always returning as any. No
error in the RPT relating to readSettingfromModule failing
This commit is contained in:
SAM 2015-05-08 18:30:28 +02:00
parent 6cda97e3a0
commit 45992e5e7f
11 changed files with 70 additions and 64 deletions

View File

@ -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

View File

@ -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;
};
};

View File

@ -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);

View File

@ -2,8 +2,9 @@
ADDON = false;
PREP(moduleViewDistance);
PREP(module);
PREP(returnViewDistanceValue);
PREP(returnViewDistanceLimit);
PREP(changeViewDistance);
PREP(initViewDistance);

View File

@ -13,4 +13,5 @@ class CfgPatches {
};
#include "CfgEventHandlers.hpp"
#include "ACE_Settings.hpp"
#include "ACE_Settings.hpp"
#include "CfgVehicles.hpp"

View File

@ -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.
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;
};

View File

@ -14,9 +14,11 @@
*
* Public: Yes
*/
#include "script_component.hpp"
if (!hasInterface) exitWith {};
["SettingChanged",{
if (_this select 0 == QGVAR(newViewDistance)) then {
[] call FUNC(changeViewDistance);

View File

@ -0,0 +1,33 @@
/*
* Author: Winter
* Initialises the view distance limiter module
*
*
* Arguments:
* 0: logic <OBJECT>
* 1: Synchronised Units <ARRAY>
* 2: Module Activated <BOOL>
*
* 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)];

View File

@ -1,29 +0,0 @@
/*
* Author: Winter
* Initialises the view distance limiter module
*
*
* Arguments:
*
*
* Return Value:
* View Distance Limit <SCALAR>
*
* 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.";

View File

@ -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.
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;

View File

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