From b23f9c0de25a3a84b50dc414d7e5cc357b1623a2 Mon Sep 17 00:00:00 2001 From: jokoho48 Date: Sun, 9 Aug 2015 05:25:19 +0200 Subject: [PATCH 1/2] Code cleanup of Disposable module --- addons/disposable/XEH_postInit.sqf | 5 +++-- .../functions/fnc_replaceATWeapon.sqf | 19 ++++++++----------- .../functions/fnc_takeLoadedATWeapon.sqf | 3 ++- .../functions/fnc_updateInventoryDisplay.sqf | 4 +--- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/addons/disposable/XEH_postInit.sqf b/addons/disposable/XEH_postInit.sqf index bc51974bc6..003e46c463 100644 --- a/addons/disposable/XEH_postInit.sqf +++ b/addons/disposable/XEH_postInit.sqf @@ -5,6 +5,7 @@ if (!hasInterface) exitWith {}; ["inventoryDisplayLoaded", {[ACE_player, _this select 0] call FUNC(updateInventoryDisplay)}] call EFUNC(common,addEventHandler); ["playerInventoryChanged", { - [_this select 0, _this select 1 select 11] call FUNC(takeLoadedATWeapon); - [_this select 0] call FUNC(updateInventoryDisplay); + params ["_unit"]; + [_unit, _this select 1 select 11] call FUNC(takeLoadedATWeapon); + [_unit] call FUNC(updateInventoryDisplay); }] call EFUNC(common,addEventHandler); diff --git a/addons/disposable/functions/fnc_replaceATWeapon.sqf b/addons/disposable/functions/fnc_replaceATWeapon.sqf index 8c55209123..3b3d91b6ff 100644 --- a/addons/disposable/functions/fnc_replaceATWeapon.sqf +++ b/addons/disposable/functions/fnc_replaceATWeapon.sqf @@ -21,11 +21,8 @@ */ #include "script_component.hpp" -private ["_unit", "_weapon", "_projectile", "_replacementTube", "_items"]; - -_unit = _this select 0; -_weapon = _this select 1; -_projectile = _this select 6; +private ["_replacementTube", "_items"]; +params ["_unit", "_weapon", "", "", "", "", "_projectile"]; if (!local _unit) exitWith {}; @@ -43,19 +40,19 @@ _unit selectWeapon _replacementTube; //Re-add all attachments to the used tube { if (_x != "") then {_unit addSecondaryWeaponItem _x}; -} forEach _items; +} count _items; // AI - Remove the ai's missle launcher tube after the missle has exploded if !([_unit] call EFUNC(common,isPlayer)) then { [{ - EXPLODE_2_PVT(_this,_params,_pfhId); - EXPLODE_3_PVT(_params,_unit,_tube,_projectile); + params ["args","_idPFH"]; + _args params ["_unit", "_tube", "_projectile"]; //don't do anything until projectile is null (exploded/max range) if (isNull _projectile) then { //Remove PFEH: - [_pfhId] call cba_fnc_removePerFrameHandler; + [_idPFH] call cba_fnc_removePerFrameHandler; //If (tube is dropped) OR (is dead) OR (is player) just exit if (((secondaryWeapon _unit) != _tube) || {!alive _unit} || {([_unit] call EFUNC(common,isPlayer))}) exitWith {}; @@ -66,13 +63,13 @@ if !([_unit] call EFUNC(common,isPlayer)) then { _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; _container setPosAsl (getPosAsl _unit); _container addWeaponCargoGlobal [_tube, 1]; - + //This will duplicate attachements, because we will be adding a weapon that may already have attachments on it //We either need a way to add a clean weapon, or a way to add a fully configured weapon to a container: // { // if (_x != "") then {_container addItemCargoGlobal [_x, 1];}; // } forEach _items; - + _unit removeWeaponGlobal _tube; }; }, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf b/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf index de3875dfa0..d747b77cb1 100644 --- a/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf +++ b/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf @@ -17,7 +17,8 @@ private ["_unit", "_launcher", "_config"]; -PARAMS_1(_unit); +params ["_unit"]; + if (!local _unit) exitWith {}; _launcher = secondaryWeapon _unit; diff --git a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf index 3f9d6f9802..f22afce698 100644 --- a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf +++ b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf @@ -16,9 +16,7 @@ #include "script_component.hpp" disableSerialization; - -PARAMS_1(_player); -DEFAULT_PARAM(1,_display,(findDisplay 602)); +params ["_player",["_display",(findDisplay 602),[(findDisplay 602)]]] _player removeMagazines "ACE_PreloadedMissileDummy"; _player removeMagazines "ACE_FiredMissileDummy"; From fab0eee5ddd933c4fc58bf2c176e44f6444db7bb Mon Sep 17 00:00:00 2001 From: jokoho48 Date: Sun, 9 Aug 2015 15:28:11 +0200 Subject: [PATCH 2/2] corrected some small point --- addons/disposable/XEH_postInit.sqf | 4 ++-- addons/disposable/functions/fnc_updateInventoryDisplay.sqf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/disposable/XEH_postInit.sqf b/addons/disposable/XEH_postInit.sqf index 003e46c463..2f3b936692 100644 --- a/addons/disposable/XEH_postInit.sqf +++ b/addons/disposable/XEH_postInit.sqf @@ -5,7 +5,7 @@ if (!hasInterface) exitWith {}; ["inventoryDisplayLoaded", {[ACE_player, _this select 0] call FUNC(updateInventoryDisplay)}] call EFUNC(common,addEventHandler); ["playerInventoryChanged", { - params ["_unit"]; - [_unit, _this select 1 select 11] call FUNC(takeLoadedATWeapon); + params ["_unit", "_items"]; + [_unit, _items select 11] call FUNC(takeLoadedATWeapon); [_unit] call FUNC(updateInventoryDisplay); }] call EFUNC(common,addEventHandler); diff --git a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf index f22afce698..30ef79ec01 100644 --- a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf +++ b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" disableSerialization; -params ["_player",["_display",(findDisplay 602),[(findDisplay 602)]]] +params ["_player", ["_display",(findDisplay 602),[(findDisplay 602)]]] _player removeMagazines "ACE_PreloadedMissileDummy"; _player removeMagazines "ACE_FiredMissileDummy";