diff --git a/addons/cargo/XEH_preInit.sqf b/addons/cargo/XEH_preInit.sqf index 067d131717..b6c5342042 100644 --- a/addons/cargo/XEH_preInit.sqf +++ b/addons/cargo/XEH_preInit.sqf @@ -20,7 +20,7 @@ PREP(startUnload); GVAR(initializedItemClasses) = []; if (isServer) then { - ["cargo_hideItem", {(_this select 0) hideObjectGlobal (_this select 1);}] call EFUNC(common,addEventHandler); + ["cargo_hideItem", {params ["_object", "_status"]; _object hideObjectGlobal _status;}] call EFUNC(common,addEventHandler); }; ADDON = true; diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index 7828eca8a9..0db9b307e7 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -6,26 +6,26 @@ * 0: Object * * Return value: - * Can load + * Vehicle that is in Distance * * Public: No */ #include "script_component.hpp" -private ["_vehicle"]; +private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip"]; params ["_unit"]; -_vehicle = nearestObject [_unit, "car"]; +_loadCar = nearestObject [_unit, "car"]; if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; -_loadhelicopter = nearestObject [_unit, "air"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +_loadHelicopter = nearestObject [_unit, "air"]; +if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitwith {_loadHelicopter}; -_loadtank = nearestObject [_unit, "tank"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +_loadTank = nearestObject [_unit, "tank"]; +if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitwith {_loadTank}; -_loadtank = nearestObject [_unit, "ship"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +_loadShip = nearestObject [_unit, "ship"]; +if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitwith {_loadShip}; objNull; diff --git a/addons/cargo/functions/fnc_getSizeItem.sqf b/addons/cargo/functions/fnc_getSizeItem.sqf index 3d079d6b3a..02e5313217 100644 --- a/addons/cargo/functions/fnc_getSizeItem.sqf +++ b/addons/cargo/functions/fnc_getSizeItem.sqf @@ -6,15 +6,17 @@ * 0: Object * * Return value: - * Cargo size. -1 is not a size defined + * Cargo size. (default: -1) * * Public: No */ #include "script_component.hpp" +private "_config"; params ["_item"]; -if (isNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))) exitwith { - _item getvariable [QGVAR(size), getNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))]; +_config = (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size)); +if (isNumber (_config)) exitwith { + _item getvariable [QGVAR(size), getNumber (_config)]; }; --1; +-1 diff --git a/addons/cargo/functions/fnc_handleDestroyed.sqf b/addons/cargo/functions/fnc_handleDestroyed.sqf index 54d4f1103b..b235631a89 100644 --- a/addons/cargo/functions/fnc_handleDestroyed.sqf +++ b/addons/cargo/functions/fnc_handleDestroyed.sqf @@ -22,6 +22,6 @@ if (count _loaded == 0) exitwith {}; // TODO deleteVehicle or just delete vehicle? Do we want to be able to recover destroyed equipment? deleteVehicle _x; //_x setDamage 1; -}foreach _loaded; +} count _loaded; [_vehicle] call FUNC(validateCargoSpace); diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 28648a75ba..39750e78fc 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -28,8 +28,8 @@ if (isServer) then { _className = getText (_x >> "type"); _amount = getNumber (_x >> "amount"); _position = getPos _vehicle; - _position set [2, (_position select 2) + 7.5]; _position set [1, (_position select 1) + 1]; + _position set [2, (_position select 2) + 7.5]; for "_i" from 1 to _amount do { _object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"]; if !([_object, _vehicle] call FUNC(loadItem)) exitwith { @@ -38,7 +38,7 @@ if (isServer) then { }; }; nil - }count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo")); + } count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo")); }; diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index e51e6ee2e8..766a22f612 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -38,7 +38,8 @@ uiNamespace setvariable [QGVAR(menuDisplay), _display]; lbClear _ctrl; { _ctrl lbAdd (getText(configfile >> "CfgVehicles" >> typeOf _x >> "displayName")); - }foreach _loaded; + true + } count _loaded; _label ctrlSetText format[localize "STR_ACE_Cargo_labelSpace", [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)]; }, 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 03bad9299b..9b654838ef 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -13,19 +13,20 @@ #include "script_component.hpp" -private ["_display", "_loaded", "_ctrl", "_selected", "_item"]; +private ["_display", "_loaded", "_loadedCount", "_ctrl", "_selected", "_item"]; disableSerialization; _display = uiNamespace getvariable QGVAR(menuDisplay); if (isnil "_display") exitwith {}; _loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; -if (count _loaded == 0) exitwith {}; +_loadedCount = count _loaded; +if (_loadedCount == 0) exitwith {}; _ctrl = _display displayCtrl 100; _selected = (lbCurSel _ctrl) max 0; -if (count _loaded <= _selected) exitwith {systemChat format["count: %1 %2", count _loaded, _selected]}; +if (_loadedCount <= _selected) exitwith {systemChat format["count: %1 %2", _loadedCount, _selected]}; _item = _loaded select _selected; [_item, GVAR(interactionVehicle)] call FUNC(unloadItem); diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf index fcc2a07796..16248f879d 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -44,7 +44,7 @@ if (_vehicle isKindOf "Ship" ) then { TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle); if (!_validVehiclestate) exitwith { false }; -if (count _emptyPos == 0) exitwith { false}; //consider displaying text saying there are no safe places to exit the vehicle +if (count _emptyPos == 0) exitwith { false }; //consider displaying text saying there are no safe places to exit the vehicle _loaded = _vehicle getvariable [QGVAR(loaded), []]; _loaded = _loaded - [_item]; @@ -52,7 +52,7 @@ _vehicle setvariable [QGVAR(loaded), _loaded, true]; _space = [_vehicle] call FUNC(getCargoSpaceLeft); _itemSize = [_item] call FUNC(getSizeItem); -_vehicle setvariable [QGVAR(space), _space + _itemSize, true]; +_vehicle setvariable [QGVAR(space), (_space + _itemSize), true]; detach _item; _item setPosASL (_emptyPos call EFUNC(common,PositiontoASL)); diff --git a/addons/cargo/functions/fnc_validateCargoSpace.sqf b/addons/cargo/functions/fnc_validateCargoSpace.sqf index 34ac1ef981..6452e850bc 100644 --- a/addons/cargo/functions/fnc_validateCargoSpace.sqf +++ b/addons/cargo/functions/fnc_validateCargoSpace.sqf @@ -23,7 +23,8 @@ _totalSpaceOccupied = 0; _newLoaded pushback _x; _totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem)); }; -}foreach _loaded; + true +} count _loaded; if (count _loaded != count _newLoaded) then { _vehicle setvariable [QGVAR(loaded), _newLoaded, true];