Skip to content

Commit

Permalink
config setting for allowed vehicle transports. minor refactor. (#119)
Browse files Browse the repository at this point in the history
config setting for allowed vehicle transports. minor refactor.
  • Loading branch information
Fusselwurm authored May 2, 2021
1 parent 7c01285 commit 38ef939
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 26 deletions.
38 changes: 28 additions & 10 deletions addons/cars/functions/fnc_initConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ INFO("initConfig running...");

private _settingsGroup = ["GRAD Civs", "7) cars - basic settings for civilian drivers"];

[
QGVAR(vehicles),
"EDITBOX",
"Vehicles that civilians may drive (class names).",
_settingsGroup,
"[""C_Van_01_fuel_F"",""C_Hatchback_01_F"",""C_Truck_02_fuel_F"",""C_Truck_02_covered_F"",""C_Offroad_01_F"",""C_SUV_01_F"",""C_Van_01_transport_F"",""C_Van_01_box_F""]",
true,
{
params ["_value"];
GVAR(vehiclesArray) = [_value] call EFUNC(common,parseCsv);
},
false
] call CBA_fnc_addSetting;

[
QGVAR(animalTransportVehicles),
"EDITBOX",
"Vehicles with animals as cargo (class names)",
_settingsGroup,
"",
true,
{
params ["_value"];
GVAR(animalTransportVehiclesArray) = [_value] call EFUNC(common,parseCsv);
},
false
] call CBA_fnc_addSetting;

[
QGVAR(animalTransportChance),
"SLIDER",
Expand All @@ -26,13 +54,3 @@ private _settingsGroup = ["GRAD Civs", "7) cars - basic settings for civilian dr
false
] call CBA_fnc_addSetting;

[
QGVAR(vehicles),
"EDITBOX",
"Classnames of vehicles that civilians may drive.",
_settingsGroup,
"[""C_Van_01_fuel_F"",""C_Hatchback_01_F"",""C_Truck_02_fuel_F"",""C_Truck_02_covered_F"",""C_Offroad_01_F"",""C_SUV_01_F"",""C_Van_01_transport_F"",""C_Van_01_box_F""]",
true,
{},
false
] call CBA_fnc_addSetting;
5 changes: 4 additions & 1 deletion addons/cars/functions/fnc_loadAnimals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ if ((random 1) >= _chance) exitWith {};

if (isNil "grad_animalTransport_fnc_getSupportedAnimalConfigs") exitWith {
WARNING("grad_animalTransport does not exist, not spawning animals");
grad_animalTransport_fnc_getSupportedAnimalConfigs = {[]}; // yes this is evil.
grad_animalTransport_fnc_getSupportedAnimalConfigs = {[]}; // yes this is evil, but this way the warning will be printed once only.
};

if ((GVAR(animalTransportVehiclesArray) isNotEqualTo []) && !([GVAR(animalTransportVehiclesArray), {_vehicle isKindOf _this#0}] call EFUNC(common,arraySome))) exitWith {
TRACE_1("animalTransportVehicles does not contain vehicle of type %1", typeOf _vehicle);
};

private _supportedAnimalConfigs = [] call grad_animalTransport_fnc_getSupportedAnimalConfigs;
if (_supportedAnimalConfigs isEqualTo []) exitWith {};
Expand Down
2 changes: 1 addition & 1 deletion addons/cars/functions/fnc_spawnCarAndCrew.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (_vehicleClass != "") then {
_vehicleClasses = [_vehicleClass];
};
if (_vehicleClasses isEqualTo []) then {
_vehicleClasses = [GVAR(vehicles)] call EFUNC(common,parseCsv);
_vehicleClasses = GVAR(vehiclesArray);
};
if (_vehicleClasses isEqualTo []) exitWith {
WARNING("will not spawn vehicles as zero vehicle classes are defined");
Expand Down
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PREP(addExclusionZone);
PREP(addPopulationZone);
PREP(arraySome);
PREP(augmentStateMachine);
PREP(civGetState);
PREP(clearExclusionZones);
Expand Down
9 changes: 9 additions & 0 deletions addons/common/functions/fnc_arraySome.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
params [
["_arr", [], [[]]],
["_callback", {false}, [{}]] // function that receives array value, array index and returns boolean
];

{
if ([_x, _forEachIndex] call _callback) exitWith {true};
false
} forEach _arr;
13 changes: 0 additions & 13 deletions addons/transit/functions/fnc_addTransitRoute.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ params [

assert(isServer);

scopeName "main";

if (_vehicleClasses isEqualTo []) then {
_vehicleClasses = [GVAR(vehicles)] call EFUNC(common,parseCsv);
};
if (_vehicleClasses isEqualTo []) then {
_vehicleClasses = [EGVAR(cars,vehicles)] call EFUNC(common,parseCsv);
};
if (_vehicleClasses isEqualTo []) then {
WARNING_1("will not spawn vehicles in transit source %1 as no vehicle classes are defined anywhere");
breakOut "main";
};

assert(_interval > 0);
assert(!(_source isEqualTo [0, 0, 0]));

Expand Down
6 changes: 6 additions & 0 deletions addons/transit/functions/fnc_addTransitVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ params [
assert(count _pos > 1);
assert(count _destination > 1);

if (_vehicleClasses isEqualTo []) then {
_vehicleClasses = GVAR(vehiclesArray);
};
if (_vehicleClasses isEqualTo []) then {
_vehicleClasses = EGVAR(cars,vehiclesArray);
};
if (_vehicleClasses isEqualTo []) exitWith {
WARNING_2("will not spawn vehicles as zero vehicle classes are defined for route from %1 to %2", _pos, _destination);
};
Expand Down
5 changes: 4 additions & 1 deletion addons/transit/functions/fnc_initConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ private _settingsGroup = ["GRAD Civs", "a) transit - traffic between pre-set poi
_settingsGroup,
"[]",
true,
{},
{
params ["_vehicles"];
GVAR(vehiclesArray) = [_vehicles] call EFUNC(common,parseCsv);
},
false
] call CBA_fnc_addSetting;

0 comments on commit 38ef939

Please sign in to comment.