From 98dd60c6cacf8fd047020c810bc1aca333420a50 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 16 Aug 2015 22:21:39 +0200 Subject: [PATCH 1/3] Alphabetized PREPs, removed newlines and repair references --- addons/cargo/CfgEventHandlers.hpp | 1 - addons/cargo/CfgVehicles.hpp | 11 ++--------- addons/cargo/XEH_preInit.sqf | 13 +++++++------ addons/cargo/config.cpp | 2 +- addons/cargo/menu.hpp | 3 +-- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/addons/cargo/CfgEventHandlers.hpp b/addons/cargo/CfgEventHandlers.hpp index f5dd29da0e..f80fefa3aa 100644 --- a/addons/cargo/CfgEventHandlers.hpp +++ b/addons/cargo/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index ecca6ee341..d5572741da 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -1,13 +1,11 @@ - class CfgVehicles { - class ACE_Module; class ACE_moduleCargoSettings: ACE_Module { scope = 2; displayName = CSTRING(SettingsModule_DisplayName); icon = QUOTE(PATHTOF(UI\Icon_Module_Cargo_ca.paa)); category = "ACE"; - function = QUOTE(DFUNC(moduleSettings)); + function = QFUNC(moduleSettings); functionPriority = 1; isGlobal = 1; isTriggerActivated = 0; @@ -41,11 +39,11 @@ class CfgVehicles { };*/ }; }; - class Tank: LandVehicle { GVAR(space) = 4; GVAR(hasCargo) = 1; }; + class Car_F; class Truck_F: Car_F { GVAR(space) = 8; @@ -53,25 +51,20 @@ class CfgVehicles { }; class Air; - // Repair helicopters class Helicopter: Air { GVAR(space) = 8; GVAR(hasCargo) = 1; }; - class Heli_Transport_02_base_F; class I_Heli_Transport_02_F : Heli_Transport_02_base_F { GVAR(space) = 20; GVAR(hasCargo) = 1; }; - - // Repair fixed wing aircraft class Plane: Air { GVAR(space) = 4; GVAR(hasCargo) = 1; }; - // boats class Ship; class Ship_F: Ship { GVAR(space) = 4; diff --git a/addons/cargo/XEH_preInit.sqf b/addons/cargo/XEH_preInit.sqf index f0cf3357cd..9cc90501c1 100644 --- a/addons/cargo/XEH_preInit.sqf +++ b/addons/cargo/XEH_preInit.sqf @@ -2,22 +2,23 @@ ADDON = false; +PREP(canLoad); PREP(canLoadItemIn); PREP(canUnloadItem); -PREP(canLoad); PREP(findNearestVehicle); PREP(getCargoSpaceLeft); -PREP(GetSizeItem); +PREP(getSizeItem); +PREP(handleDestroyed); PREP(initObject); PREP(initVehicle); -PREP(handleDestroyed); -PREP(moduleSettings); PREP(loadItem); +PREP(moduleSettings); PREP(onMenuOpen); -PREP(unloadItem); -PREP(validateCargoSpace); PREP(startLoadIn); PREP(startUnload); +PREP(unloadItem); +PREP(validateCargoSpace); + GVAR(initializedItemClasses) = []; if (isServer) then { diff --git a/addons/cargo/config.cpp b/addons/cargo/config.cpp index 2972e8ef1b..1aefa49616 100644 --- a/addons/cargo/config.cpp +++ b/addons/cargo/config.cpp @@ -12,7 +12,7 @@ class CfgPatches { }; }; +#include "ACE_Settings.hpp" #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "menu.hpp" -#include "ACE_Settings.hpp" diff --git a/addons/cargo/menu.hpp b/addons/cargo/menu.hpp index 35976d19ad..6e2bf45a47 100644 --- a/addons/cargo/menu.hpp +++ b/addons/cargo/menu.hpp @@ -1,4 +1,3 @@ - #include "\z\ace\addons\common\define.hpp" class GVAR(menu) { @@ -101,4 +100,4 @@ class GVAR(menu) { action = QUOTE([] call FUNC(startUnload);); }; }; -}; \ No newline at end of file +}; From bbc715b2ee90a20c76f0369412f9e7f79ac4139e Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 16 Aug 2015 22:41:35 +0200 Subject: [PATCH 2/3] Cleaned function headers --- addons/cargo/functions/fnc_canLoad.sqf | 13 ++++++------ addons/cargo/functions/fnc_canLoadItemIn.sqf | 10 +++++---- addons/cargo/functions/fnc_canUnloadItem.sqf | 16 ++++++++------ .../functions/fnc_findNearestVehicle.sqf | 21 +++++++++++-------- .../cargo/functions/fnc_getCargoSpaceLeft.sqf | 11 ++++++---- addons/cargo/functions/fnc_getSizeItem.sqf | 16 +++++++++----- .../cargo/functions/fnc_handleDestroyed.sqf | 10 +++++---- addons/cargo/functions/fnc_initObject.sqf | 10 +++++---- addons/cargo/functions/fnc_initVehicle.sqf | 12 ++++++----- addons/cargo/functions/fnc_loadItem.sqf | 15 +++++++------ addons/cargo/functions/fnc_moduleSettings.sqf | 17 ++++++++++----- addons/cargo/functions/fnc_onMenuOpen.sqf | 21 +++++++++++-------- addons/cargo/functions/fnc_startLoadIn.sqf | 15 ++++++------- addons/cargo/functions/fnc_startUnload.sqf | 20 +++++++++++------- addons/cargo/functions/fnc_unloadItem.sqf | 19 ++++++++++------- .../functions/fnc_validateCargoSpace.sqf | 16 +++++++++----- addons/cargo/functions/script_component.hpp | 2 +- addons/cargo/menu.hpp | 8 +++---- 18 files changed, 152 insertions(+), 100 deletions(-) diff --git a/addons/cargo/functions/fnc_canLoad.sqf b/addons/cargo/functions/fnc_canLoad.sqf index 88391e80da..f61c145fdf 100644 --- a/addons/cargo/functions/fnc_canLoad.sqf +++ b/addons/cargo/functions/fnc_canLoad.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * Check if player can load item into the nearest vehicle + * Check if player can load an item into the nearest vehicle. * * Arguments: * 0: Player @@ -9,9 +9,11 @@ * Return value: * Can load * + * Example: + * [player, object] call ace_cargo_fnc_canLoad + * * Public: No */ - #include "script_component.hpp" params ["_player", "_object"]; @@ -20,12 +22,11 @@ private ["_nearestVehicle"]; _nearestVehicle = [_player] call FUNC(findNearestVehicle); if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then { - { - if ([_object, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; - }foreach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); + if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_nearestVehicle = _x}; + } forEach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); }; -if (isNull _nearestVehicle) exitwith {false}; +if (isNull _nearestVehicle) exitWith {false}; [_object, _nearestVehicle] call FUNC(canLoadItemIn); diff --git a/addons/cargo/functions/fnc_canLoadItemIn.sqf b/addons/cargo/functions/fnc_canLoadItemIn.sqf index 5d844cc91c..d3553b91bf 100644 --- a/addons/cargo/functions/fnc_canLoadItemIn.sqf +++ b/addons/cargo/functions/fnc_canLoadItemIn.sqf @@ -1,22 +1,24 @@ /* * Author: Glowbal - * Check if item can be loaded into other Object + * Check if item can be loaded into other Object. * * Arguments: * 0: Item Object - * 1: Holder Object (vehicle) + * 1: Holder Object (Vehicle) * * Return value: * Can load in * + * Example: + * [item, holder] call ace_cargo_fnc_canLoadItemIn + * * Public: No */ - #include "script_component.hpp" params ["_item", "_vehicle"]; -if (speed _vehicle > 1 || (((getPos _vehicle) select 2) > 3)) exitwith {false}; +if (speed _vehicle > 1 || (((getPos _vehicle) select 2) > 3)) exitWith {false}; private "_itemSize"; _itemSize = ([_item] call FUNC(getSizeItem)); diff --git a/addons/cargo/functions/fnc_canUnloadItem.sqf b/addons/cargo/functions/fnc_canUnloadItem.sqf index 74b4c1bb9e..c390092ad1 100644 --- a/addons/cargo/functions/fnc_canUnloadItem.sqf +++ b/addons/cargo/functions/fnc_canUnloadItem.sqf @@ -1,23 +1,27 @@ /* * Author: Glowbal, ViperMaul - * Check if item can be unloaded + * Check if item can be unloaded. * * Arguments: - * 0: loaded object + * 0: loaded Object * 1: Object * * Return value: * Can be unloaded * + * Example: + * [item, holder] call ace_cargo_fnc_canUnloadItem + * * Public: No */ - #include "script_component.hpp" private ["_loaded", "_validVehiclestate", "_emptyPos"]; + params ["_item", "_vehicle"]; -_loaded = _vehicle getvariable [QGVAR(loaded), []]; -if !(_item in _loaded) exitwith {false}; + +_loaded = _vehicle getVariable [QGVAR(loaded), []]; +if !(_item in _loaded) exitWith {false}; _validVehiclestate = true; _emptyPos = []; @@ -35,5 +39,5 @@ if (_vehicle isKindOf "Ship" ) then { }; }; -if (!_validVehiclestate) exitwith { false }; +if (!_validVehiclestate) exitWith {false}; (count _emptyPos != 0); diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index 40f554adc1..3f6b6ae9dc 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -1,34 +1,37 @@ /* * Author: Glowbal - * Get nearest vehicle, priority car, air, tank, ship + * Get nearest vehicle from unit, priority: Car-Air-Tank-Ship. * * Arguments: - * 0: Object + * 0: Unit * * Return value: - * Vehicle that is in Distance + * Vehicle in Distance + * + * Example: + * [unit] call ace_cargo_fnc_findNearestVehicle * * Public: No */ - #include "script_component.hpp" private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip", "_loadContainer"]; + params ["_unit"]; _loadCar = nearestObject [_unit, "car"]; -if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitwith {_loadCar}; +if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitWith {_loadCar}; _loadHelicopter = nearestObject [_unit, "air"]; -if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitwith {_loadHelicopter}; +if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitWith {_loadHelicopter}; _loadTank = nearestObject [_unit, "tank"]; -if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitwith {_loadTank}; +if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitWith {_loadTank}; _loadShip = nearestObject [_unit, "ship"]; -if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitwith {_loadShip}; +if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitWith {_loadShip}; _loadContainer = nearestObject [_unit,"Cargo_base_F"]; -if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitwith {_loadContainer}; +if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitWith {_loadContainer}; objNull; diff --git a/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf b/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf index 3c50e24ad3..2f8d32201d 100644 --- a/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf +++ b/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * Get the cargo space left on object + * Get the cargo space left on object. * * Arguments: * 0: Object @@ -8,10 +8,13 @@ * Return value: * Cargo space left * + * Example: + * [object] call ace_cargo_fnc_getCargoSpaceLeft + * * Public: No */ - #include "script_component.hpp" -params ["_vehicle"]; -_vehicle getvariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> QGVAR(space))]; +params ["_object"]; + +_object getVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _object >> QGVAR(space))]; diff --git a/addons/cargo/functions/fnc_getSizeItem.sqf b/addons/cargo/functions/fnc_getSizeItem.sqf index 02e5313217..0ee4e0aafd 100644 --- a/addons/cargo/functions/fnc_getSizeItem.sqf +++ b/addons/cargo/functions/fnc_getSizeItem.sqf @@ -1,22 +1,28 @@ /* * Author: Glowbal - * Get the cargo size of an object + * Get the cargo size of an object. * * Arguments: * 0: Object * * Return value: - * Cargo size. (default: -1) + * Cargo size (default: -1) + * + * Example: + * [object] call ace_cargo_fnc_getSizeItem * * Public: No */ - #include "script_component.hpp" private "_config"; + params ["_item"]; + _config = (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size)); -if (isNumber (_config)) exitwith { - _item getvariable [QGVAR(size), getNumber (_config)]; + +if (isNumber (_config)) exitWith { + _item getVariable [QGVAR(size), getNumber (_config)]; }; + -1 diff --git a/addons/cargo/functions/fnc_handleDestroyed.sqf b/addons/cargo/functions/fnc_handleDestroyed.sqf index 25e7a6a4e0..c11dd3bfad 100644 --- a/addons/cargo/functions/fnc_handleDestroyed.sqf +++ b/addons/cargo/functions/fnc_handleDestroyed.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * Handle object being destroyed + * Handle object being destroyed. * * Arguments: * 0: Object @@ -8,17 +8,19 @@ * Return value: * None * + * Example: + * [object] call ace_cargo_fnc_handleDestroyed + * * Public: No */ - #include "script_component.hpp" params ["_vehicle"]; private["_loaded"]; -_loaded = _vehicle getvariable [QGVAR(loaded), []]; -if (count _loaded == 0) exitwith {}; +_loaded = _vehicle getVariable [QGVAR(loaded), []]; +if (count _loaded == 0) exitWith {}; { // TODO deleteVehicle or just delete vehicle? Do we want to be able to recover destroyed equipment? diff --git a/addons/cargo/functions/fnc_initObject.sqf b/addons/cargo/functions/fnc_initObject.sqf index c834bcf7b0..f9b48b19e1 100644 --- a/addons/cargo/functions/fnc_initObject.sqf +++ b/addons/cargo/functions/fnc_initObject.sqf @@ -1,21 +1,23 @@ /* * Author: Glowbal - * Initialize variables for loadable objects. Called from init EH. + * Initializes variables for loadable objects. Called from init EH. * * Arguments: - * 0: Any object + * 0: Object * * Return value: * None * + * Example: + * [object] call ace_cargo_fnc_initObject + * * Public: No */ - #include "script_component.hpp" params ["_object"]; -if (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> QGVAR(canLoad)) != 1) exitwith {}; +if (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> QGVAR(canLoad)) != 1) exitWith {}; private ["_type", "_action"]; _type = typeOf _object; diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 48e83c3858..8449a316b2 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -1,16 +1,18 @@ /* * Author: Glowbal - * initalize vehicle. Adds open caro menu action if available + * Initializes vehicle, adds open caro menu action if available. * * Arguments: - * 0: vehicle + * 0: Vehicle * * Return Value: * None * + * Example: + * [vehicle] call ace_cargo_fnc_initVehicle + * * Public: No */ - #include "script_component.hpp" params ["_vehicle"]; @@ -31,7 +33,7 @@ if (isServer) then { _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 { + if !([_object, _vehicle] call FUNC(loadItem)) exitWith { deleteVehicle _object; }; }; @@ -46,7 +48,7 @@ if (_type in _initializedClasses) exitWith {}; _initializedClasses pushBack _type; SETMVAR(GVAR(initializedClasses),_initializedClasses); -if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitwith {}; +if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitWith {}; private ["_text", "_condition", "_statement", "_icon", "_action"]; _condition = {GVAR(enable)}; diff --git a/addons/cargo/functions/fnc_loadItem.sqf b/addons/cargo/functions/fnc_loadItem.sqf index 0abebdd43c..52ec517889 100644 --- a/addons/cargo/functions/fnc_loadItem.sqf +++ b/addons/cargo/functions/fnc_loadItem.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * Load object into vehicle + * Load object into vehicle. * * Arguments: * 0: Object @@ -9,23 +9,26 @@ * Return value: * None * + * Example: + * [object, vehicle] call ace_cargo_fnc_loadItem + * * Public: No */ - #include "script_component.hpp" private ["_loaded", "_space", "_itemSize"]; + params ["_item", "_vehicle"]; -if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitwith {false}; +if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith {false}; -_loaded = _vehicle getvariable [QGVAR(loaded), []]; +_loaded = _vehicle getVariable [QGVAR(loaded), []]; _loaded pushback _item; -_vehicle setvariable [QGVAR(loaded), _loaded, true]; +_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 attachTo [_vehicle,[0,0,100]]; diff --git a/addons/cargo/functions/fnc_moduleSettings.sqf b/addons/cargo/functions/fnc_moduleSettings.sqf index bb876c2840..35e6aede7a 100644 --- a/addons/cargo/functions/fnc_moduleSettings.sqf +++ b/addons/cargo/functions/fnc_moduleSettings.sqf @@ -3,19 +3,26 @@ * Module for adjusting the cargo settings * * Arguments: - * 0: The module logic - * 1: units - * 2: activated + * 0: The module logic + * 1: Synchronized units + * 2: Activated * * Return Value: * None * + * Example: + * function = "ace_cargo_fnc_loadItem" + * * Public: No */ - #include "script_component.hpp" +if (!isServer) exitWith {}; + params ["_logic", "_units", "_activated"]; -if !(_activated) exitWith {}; + +if (!_activated) exitWith {}; [_logic, QGVAR(enable), "enable"] call EFUNC(common,readSettingFromModule); + +diag_log text "[ACE]: Cargo Module Initialized."; diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index 8c3bbfecf2..031bea01cc 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -1,37 +1,40 @@ /* * Author: Glowbal - * Handle the UI data display + * Handle the UI data display. * * Arguments: - * 0: display + * 0: Display * * Return value: * None * + * Example: + * [display] call ace_cargo_fnc_onMenuOpen + * * Public: No */ - #include "script_component.hpp" disableSerialization; -params["_display"]; -uiNamespace setvariable [QGVAR(menuDisplay), _display]; +params ["_display"]; + +uiNamespace setVariable [QGVAR(menuDisplay), _display]; [{ private ["_display","_loaded", "_ctrl", "_label"]; disableSerialization; - _display = uiNamespace getvariable QGVAR(menuDisplay); - if (isnil "_display") exitwith { + _display = uiNamespace getVariable QGVAR(menuDisplay); + if (isnil "_display") exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; - if (isNull GVAR(interactionVehicle) || ACE_player distance GVAR(interactionVehicle) >= 10) exitwith { + if (isNull GVAR(interactionVehicle) || ACE_player distance GVAR(interactionVehicle) >= 10) exitWith { closeDialog 0; [_this select 1] call CBA_fnc_removePerFrameHandler; }; - _loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; + _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []]; _ctrl = _display displayCtrl 100; _label = _display displayCtrl 2; diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index 0da44ba04c..31b63f1d6c 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -1,16 +1,18 @@ /* * Author: Glowbal - * Start load item + * Start load item. * * Arguments: - * 0: Any object + * 0: Object * * Return value: * None * + * Example: + * [object] call ace_cargo_fnc_starLoadIn + * * Public: No */ - #include "script_component.hpp" params ["_player", "_object"]; @@ -19,11 +21,10 @@ private ["_nearestVehicle"]; _nearestVehicle = [_player] call FUNC(findNearestVehicle); if (isNull _nearestVehicle || _nearestVehicle isKindOf "Cargo_Base_F") then { - { - if ([_object, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; - }foreach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); + if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_nearestVehicle = _x}; + } foreach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); }; -if (isNull _nearestVehicle) exitwith {false}; +if (isNull _nearestVehicle) exitWith {false}; [_object, _nearestVehicle] call FUNC(loadItem); diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 615c1cafbd..28ae034167 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * Start unload action + * Start unload action. * * Arguments: * None @@ -8,24 +8,28 @@ * Return value: * None * + * Example: + * [] call ace_cargo_fnc_startUnload + * * Public: No */ - #include "script_component.hpp" private ["_display", "_loaded", "_ctrl", "_selected", "_item"]; -disableSerialization; -_display = uiNamespace getvariable QGVAR(menuDisplay); -if (isnil "_display") exitwith {}; -_loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; -if (count _loaded == 0) exitwith {}; +disableSerialization; + +_display = uiNamespace getVariable QGVAR(menuDisplay); +if (isnil "_display") exitWith {}; + +_loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []]; +if (count _loaded == 0) exitWith {}; _ctrl = _display displayCtrl 100; _selected = (lbCurSel _ctrl) max 0; -if (count _loaded <= _selected) exitwith {}; +if (count _loaded <= _selected) exitWith {}; _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 0209c5256e..705ba37e85 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal, ViperMaul - * Unload object from vehicle + * Unload object from vehicle. * * Arguments: * 0: Object @@ -9,15 +9,18 @@ * Return value: * None * + * Example: + * [object, vehicle] call ace_cargo_fnc_unloadItem + * * Public: No */ - #include "script_component.hpp" private ["_loaded", "_space", "_itemSize", "_emptyPos", "_validVehiclestate"]; + params ["_item", "_vehicle"]; -if !([_item, _vehicle] call FUNC(canUnloadItem)) exitwith { +if !([_item, _vehicle] call FUNC(canUnloadItem)) exitWith { false }; @@ -41,17 +44,17 @@ if (_vehicle isKindOf "Ship" ) then { }; TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle); -if (!_validVehiclestate) exitwith { false }; +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 = _vehicle getVariable [QGVAR(loaded), []]; _loaded = _loaded - [_item]; -_vehicle setvariable [QGVAR(loaded), _loaded, true]; +_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 6452e850bc..6caf664ca5 100644 --- a/addons/cargo/functions/fnc_validateCargoSpace.sqf +++ b/addons/cargo/functions/fnc_validateCargoSpace.sqf @@ -1,6 +1,6 @@ /* * Author: Glowbal - * Validate the vehicle cargo space + * Validate the vehicle cargo space. * * Arguments: * 0: Object @@ -8,14 +8,19 @@ * Return value: * None * + * Example: + * [object] call ace_cargo_fnc_validateCargoSpace + * * Public: No */ - #include "script_component.hpp" private ["_loaded", "_newLoaded", "_totalSpaceOccupied"]; + params ["_vehicle"]; -_loaded = _vehicle getvariable [QGVAR(loaded), []]; + +_loaded = _vehicle getVariable [QGVAR(loaded), []]; + _newLoaded = []; _totalSpaceOccupied = 0; { @@ -27,6 +32,7 @@ _totalSpaceOccupied = 0; } count _loaded; if (count _loaded != count _newLoaded) then { - _vehicle setvariable [QGVAR(loaded), _newLoaded, true]; + _vehicle setVariable [QGVAR(loaded), _newLoaded, true]; }; -_vehicle setvariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> QGVAR(space)) - _totalSpaceOccupied, true]; + +_vehicle setVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> QGVAR(space)) - _totalSpaceOccupied, true]; diff --git a/addons/cargo/functions/script_component.hpp b/addons/cargo/functions/script_component.hpp index bd91738fd3..cc6204b83b 100644 --- a/addons/cargo/functions/script_component.hpp +++ b/addons/cargo/functions/script_component.hpp @@ -1 +1 @@ -#include "\z\ace\addons\cargo\script_component.hpp" \ No newline at end of file +#include "\z\ace\addons\cargo\script_component.hpp" diff --git a/addons/cargo/menu.hpp b/addons/cargo/menu.hpp index 6e2bf45a47..bde617b311 100644 --- a/addons/cargo/menu.hpp +++ b/addons/cargo/menu.hpp @@ -4,7 +4,7 @@ class GVAR(menu) { idd = 314614; movingEnable = true; onLoad = QUOTE([_this select 0] call FUNC(onMenuOpen)); - onUnload = QUOTE(uiNamespace setvariable [ARR_2(QUOTE(QGVAR(menuDisplay)),nil)];); + onUnload = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(menuDisplay)),nil)];); class controlsBackground { class HeaderBackground: ACE_gui_backgroundBase{ idc = -1; @@ -19,8 +19,8 @@ class GVAR(menu) { y = "2.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; h = "14 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; text = "#(argb,8,8,3)color(0,0,0,0.8)"; - colorText[] = {0, 0, 0, "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.9])"}; - colorBackground[] = {0,0,0,"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.9])"}; + colorText[] = {0, 0, 0, "(profilenamespace getVariable ['GUI_BCG_RGB_A',0.9])"}; + colorBackground[] = {0,0,0,"(profilenamespace getVariable ['GUI_BCG_RGB_A',0.9])"}; }; }; @@ -36,7 +36,7 @@ class GVAR(menu) { font = "PuristaMedium"; SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)"; colorText[] = {0.95, 0.95, 0.95, 0.75}; - colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.9])"}; + colorBackground[] = {"(profilenamespace getVariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getVariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getVariable ['GUI_BCG_RGB_B',0.5])", "(profilenamespace getVariable ['GUI_BCG_RGB_A',0.9])"}; text = CSTRING(cargoMenu); }; class SubHeader: HeaderName { From 7b89784aae7fc6c10602237a31286ee28d20e8ef Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 16 Aug 2015 22:48:52 +0200 Subject: [PATCH 3/3] Removed semi-colons from return statements, command capitalization --- addons/cargo/functions/fnc_canLoad.sqf | 2 +- addons/cargo/functions/fnc_canLoadItemIn.sqf | 6 +++++- addons/cargo/functions/fnc_canUnloadItem.sqf | 3 ++- addons/cargo/functions/fnc_findNearestVehicle.sqf | 2 +- addons/cargo/functions/fnc_getCargoSpaceLeft.sqf | 2 +- addons/cargo/functions/fnc_getSizeItem.sqf | 2 +- addons/cargo/functions/fnc_loadItem.sqf | 4 ++-- addons/cargo/functions/fnc_startLoadIn.sqf | 5 +++-- addons/cargo/functions/fnc_unloadItem.sqf | 8 ++++---- 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/cargo/functions/fnc_canLoad.sqf b/addons/cargo/functions/fnc_canLoad.sqf index f61c145fdf..da41d93358 100644 --- a/addons/cargo/functions/fnc_canLoad.sqf +++ b/addons/cargo/functions/fnc_canLoad.sqf @@ -29,4 +29,4 @@ if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then { if (isNull _nearestVehicle) exitWith {false}; -[_object, _nearestVehicle] call FUNC(canLoadItemIn); +[_object, _nearestVehicle] call FUNC(canLoadItemIn) diff --git a/addons/cargo/functions/fnc_canLoadItemIn.sqf b/addons/cargo/functions/fnc_canLoadItemIn.sqf index d3553b91bf..8cfe9e194b 100644 --- a/addons/cargo/functions/fnc_canLoadItemIn.sqf +++ b/addons/cargo/functions/fnc_canLoadItemIn.sqf @@ -22,4 +22,8 @@ if (speed _vehicle > 1 || (((getPos _vehicle) select 2) > 3)) exitWith {false}; private "_itemSize"; _itemSize = ([_item] call FUNC(getSizeItem)); -_itemSize > 0 && {alive _item && alive _vehicle} && {(_item distance _vehicle <= MAX_LOAD_DISTANCE)} && {_itemSize <= ([_vehicle] call FUNC(getCargoSpaceLeft))}; + +(_itemSize > 0) && +{alive _item && alive _vehicle} && +{(_item distance _vehicle <= MAX_LOAD_DISTANCE)} && +{_itemSize <= ([_vehicle] call FUNC(getCargoSpaceLeft))} diff --git a/addons/cargo/functions/fnc_canUnloadItem.sqf b/addons/cargo/functions/fnc_canUnloadItem.sqf index c390092ad1..779a7533a9 100644 --- a/addons/cargo/functions/fnc_canUnloadItem.sqf +++ b/addons/cargo/functions/fnc_canUnloadItem.sqf @@ -40,4 +40,5 @@ if (_vehicle isKindOf "Ship" ) then { }; if (!_validVehiclestate) exitWith {false}; -(count _emptyPos != 0); + +(count _emptyPos != 0) diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index 3f6b6ae9dc..c0ec154d47 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -34,4 +34,4 @@ if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitWith {_loadShip}; _loadContainer = nearestObject [_unit,"Cargo_base_F"]; if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitWith {_loadContainer}; -objNull; +objNull diff --git a/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf b/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf index 2f8d32201d..cae27a2d58 100644 --- a/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf +++ b/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf @@ -17,4 +17,4 @@ params ["_object"]; -_object getVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _object >> QGVAR(space))]; +_object getVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _object >> QGVAR(space))] diff --git a/addons/cargo/functions/fnc_getSizeItem.sqf b/addons/cargo/functions/fnc_getSizeItem.sqf index 0ee4e0aafd..a3556c8a25 100644 --- a/addons/cargo/functions/fnc_getSizeItem.sqf +++ b/addons/cargo/functions/fnc_getSizeItem.sqf @@ -22,7 +22,7 @@ params ["_item"]; _config = (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size)); if (isNumber (_config)) exitWith { - _item getVariable [QGVAR(size), getNumber (_config)]; + _item getVariable [QGVAR(size), getNumber (_config)] }; -1 diff --git a/addons/cargo/functions/fnc_loadItem.sqf b/addons/cargo/functions/fnc_loadItem.sqf index 52ec517889..f8816f3b8f 100644 --- a/addons/cargo/functions/fnc_loadItem.sqf +++ b/addons/cargo/functions/fnc_loadItem.sqf @@ -7,7 +7,7 @@ * 1: Vehicle * * Return value: - * None + * Object loaded * * Example: * [object, vehicle] call ace_cargo_fnc_loadItem @@ -34,4 +34,4 @@ detach _item; _item attachTo [_vehicle,[0,0,100]]; ["cargo_hideItem", [_item, true]] call EFUNC(common,serverEvent); -true; +true diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index 31b63f1d6c..b4ba50fbb6 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -6,7 +6,7 @@ * 0: Object * * Return value: - * None + * Object loaded * * Example: * [object] call ace_cargo_fnc_starLoadIn @@ -27,4 +27,5 @@ if (isNull _nearestVehicle || _nearestVehicle isKindOf "Cargo_Base_F") then { }; if (isNull _nearestVehicle) exitWith {false}; -[_object, _nearestVehicle] call FUNC(loadItem); + +[_object, _nearestVehicle] call FUNC(loadItem) diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf index 705ba37e85..f6d70591df 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -7,7 +7,7 @@ * 1: Vehicle * * Return value: - * None + * Object unloaded * * Example: * [object, vehicle] call ace_cargo_fnc_unloadItem @@ -44,9 +44,9 @@ if (_vehicle isKindOf "Ship" ) then { }; TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle); -if (!_validVehiclestate) exitWith { false }; +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]; @@ -62,4 +62,4 @@ _item setPosASL (_emptyPos call EFUNC(common,PositiontoASL)); // TOOO maybe drag/carry the unloaded item? -true; +true