Skip to content

Commit

Permalink
Make array of cargo holders dynamic (#5274)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored and jonpas committed Jun 14, 2017
1 parent 183eaae commit feee7f5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions addons/cargo/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion addons/cargo/functions/fnc_addCargoVehiclesActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion addons/cargo/functions/fnc_initObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
10 changes: 10 additions & 0 deletions addons/cargo/functions/fnc_initVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
{
Expand Down
2 changes: 1 addition & 1 deletion addons/cargo/functions/fnc_startLoadIn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions addons/cargo/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit feee7f5

Please sign in to comment.