diff --git a/addons/cars/functions/fnc_initConfig.sqf b/addons/cars/functions/fnc_initConfig.sqf index ceccf59b..bf9607c9 100644 --- a/addons/cars/functions/fnc_initConfig.sqf +++ b/addons/cars/functions/fnc_initConfig.sqf @@ -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", @@ -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; diff --git a/addons/cars/functions/fnc_loadAnimals.sqf b/addons/cars/functions/fnc_loadAnimals.sqf index fe007b4c..6569d15c 100644 --- a/addons/cars/functions/fnc_loadAnimals.sqf +++ b/addons/cars/functions/fnc_loadAnimals.sqf @@ -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 {}; diff --git a/addons/cars/functions/fnc_spawnCarAndCrew.sqf b/addons/cars/functions/fnc_spawnCarAndCrew.sqf index ff4c66d7..87dddd56 100644 --- a/addons/cars/functions/fnc_spawnCarAndCrew.sqf +++ b/addons/cars/functions/fnc_spawnCarAndCrew.sqf @@ -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"); diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 075f9972..3315d3d1 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -1,5 +1,6 @@ PREP(addExclusionZone); PREP(addPopulationZone); +PREP(arraySome); PREP(augmentStateMachine); PREP(civGetState); PREP(clearExclusionZones); diff --git a/addons/common/functions/fnc_arraySome.sqf b/addons/common/functions/fnc_arraySome.sqf new file mode 100644 index 00000000..a6d53d43 --- /dev/null +++ b/addons/common/functions/fnc_arraySome.sqf @@ -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; diff --git a/addons/transit/functions/fnc_addTransitRoute.sqf b/addons/transit/functions/fnc_addTransitRoute.sqf index bd4e4e11..64e2ad06 100644 --- a/addons/transit/functions/fnc_addTransitRoute.sqf +++ b/addons/transit/functions/fnc_addTransitRoute.sqf @@ -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])); diff --git a/addons/transit/functions/fnc_addTransitVehicle.sqf b/addons/transit/functions/fnc_addTransitVehicle.sqf index 40ae536f..8c3f0324 100644 --- a/addons/transit/functions/fnc_addTransitVehicle.sqf +++ b/addons/transit/functions/fnc_addTransitVehicle.sqf @@ -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); }; diff --git a/addons/transit/functions/fnc_initConfig.sqf b/addons/transit/functions/fnc_initConfig.sqf index d3dfca7c..ded484ed 100644 --- a/addons/transit/functions/fnc_initConfig.sqf +++ b/addons/transit/functions/fnc_initConfig.sqf @@ -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;