Make array of cargo holders dynamic (#5274)

This commit is contained in:
PabstMirror 2017-06-14 08:36:23 -05:00 committed by jonpas
parent bb8d5cadd7
commit af0f7f36d8
6 changed files with 14 additions and 5 deletions

View File

@ -8,5 +8,6 @@ PREP_RECOMPILE_END;
GVAR(initializedItemClasses) = [];
GVAR(initializedVehicleClasses) = [];
GVAR(cargoHolderTypes) = ["Car", "Air", "Tank", "Ship", "Cargo_base_F", "Land_PaperBox_closed_F"];
ADDON = true;

View File

@ -40,6 +40,6 @@ private _actions = [];
private _action = [format ["%1", _x], _name, _icon, _statement, {true}, {}, [_x]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
};
} forEach (nearestObjects [_player, CARGO_VEHICLE_CLASSES, MAX_LOAD_DISTANCE]);
} forEach (nearestObjects [_player, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE]);
_actions

View File

@ -56,7 +56,7 @@ private _condition = {
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1;
(_hasCargoPublic || _hasCargoConfig) && {_x != _target}
} count (nearestObjects [_player, CARGO_VEHICLE_CLASSES, MAX_LOAD_DISTANCE])}
} count (nearestObjects [_player, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE])}
};
private _statement = {
params ["_target", "_player"];

View File

@ -27,6 +27,16 @@ private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGV
// Nothing to do here if vehicle has no cargo space
if !(_hasCargoConfig || _hasCargoPublic) exitWith {};
// Check if cargo is in cargo holder types (checked when trying to search for loadable objects)
private _addCargoType = true;
{
if (_type isKindOf _x) exitWith {_addCargoType = false};
} forEach GVAR(cargoHolderTypes);
TRACE_2("",_addCargoType,_type);
if (_addCargoType) then {
GVAR(cargoHolderTypes) pushBack _type;
};
// Vehicle can have default ace cargo in its config
if (isServer) then {
{

View File

@ -24,7 +24,7 @@ private _vehicle = _cargoVehicle;
if (isNull _vehicle) then {
{
if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x};
} forEach (nearestObjects [_player, CARGO_VEHICLE_CLASSES, MAX_LOAD_DISTANCE]);
} forEach (nearestObjects [_player, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE]);
};
if (isNull _vehicle) exitWith {

View File

@ -18,8 +18,6 @@
#define MAX_LOAD_DISTANCE 10
#define CARGO_VEHICLE_CLASSES ["Car", "Air", "Tank", "Ship", "Cargo_base_F", "Land_PaperBox_closed_F"]
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
// Default cargo size is -1 as 0 is a valid size