Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CBATeam/CBA_A3 into enoch…
Browse files Browse the repository at this point in the history
…-jr-compat1
  • Loading branch information
commy2 committed Jul 27, 2019
2 parents 6ee185f + b6df6ac commit 35f39a8
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 133 deletions.
46 changes: 9 additions & 37 deletions addons/common/fnc_removeBackpackCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -94,45 +94,17 @@ private _fnc_addContents = {
// weaponsItems magazineGL does not exist if not loaded (not even as empty array)
if (count _x < 7) then {
_bipod = _magazineGL;
_magazineGL = "";
_magazineGL = [];
};

// Some weapons don't have non-preset parents
private _weaponNonPreset = [_weapon] call CBA_fnc_getNonPresetClass;
if (_weaponNonPreset == "") then {
_weaponNonPreset = _weapon;
};

_container addWeaponCargoGlobal [_weaponNonPreset, 1];

// If weapon does not have a non-preset parent, only add attachments that were custom added
// Removed attachments cannot be handled (engine limitation) and will be readded due to having to readd preset weapon
private _presetAttachments = [];
if (_weaponNonPreset == _weapon) then {
_presetAttachments = _weapon call CBA_fnc_weaponComponents;
};
if !(toLower _muzzle in _presetAttachments) then {
_container addItemCargoGlobal [_muzzle, 1];
};
if !(toLower _pointer in _presetAttachments) then {
_container addItemCargoGlobal [_pointer, 1];
};
if !(toLower _optic in _presetAttachments) then {
_container addItemCargoGlobal [_optic, 1];
};
if !(toLower _bipod in _presetAttachments) then {
_container addItemCargoGlobal [_bipod, 1];
};

_magazine params [["_magazineClass", ""], ["_magazineAmmoCount", 0]];
if (_magazineClass != "") then {
_container addMagazineAmmoCargo [_magazineClass, 1, _magazineAmmoCount];
};

_magazineGL params [["_magazineGLClass", ""], ["_magazineGLAmmoCount", 0]];
if (_magazineGLClass != "") then {
_container addMagazineAmmoCargo [_magazineGLClass, 1, _magazineGLAmmoCount];
};
_container addWeaponWithAttachmentsCargoGlobal [
[
_weapon,
_muzzle, _pointer, _optic,
_magazine, _magazineGL,
_bipod
], 1
];
} forEach _weaponsItemsCargo;
};

Expand Down
46 changes: 9 additions & 37 deletions addons/common/fnc_removeItemCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -111,45 +111,17 @@ private _fnc_addContents = {
// weaponsItems magazineGL does not exist if not loaded (not even as empty array)
if (count _x < 7) then {
_bipod = _magazineGL;
_magazineGL = "";
_magazineGL = [];
};

// Some weapons don't have non-preset parents
private _weaponNonPreset = [_weapon] call CBA_fnc_getNonPresetClass;
if (_weaponNonPreset == "") then {
_weaponNonPreset = _weapon;
};

_container addWeaponCargoGlobal [_weaponNonPreset, 1];

// If weapon does not have a non-preset parent, only add attachments that were custom added
// Removed attachments cannot be handled (engine limitation) and will be readded due to having to readd preset weapon
private _presetAttachments = [];
if (_weaponNonPreset == _weapon) then {
_presetAttachments = _weapon call CBA_fnc_weaponComponents;
};
if !(toLower _muzzle in _presetAttachments) then {
_container addItemCargoGlobal [_muzzle, 1];
};
if !(toLower _pointer in _presetAttachments) then {
_container addItemCargoGlobal [_pointer, 1];
};
if !(toLower _optic in _presetAttachments) then {
_container addItemCargoGlobal [_optic, 1];
};
if !(toLower _bipod in _presetAttachments) then {
_container addItemCargoGlobal [_bipod, 1];
};

_magazine params [["_magazineClass", ""], ["_magazineAmmoCount", 0]];
if (_magazineClass != "") then {
_container addMagazineAmmoCargo [_magazineClass, 1, _magazineAmmoCount];
};

_magazineGL params [["_magazineGLClass", ""], ["_magazineGLAmmoCount", 0]];
if (_magazineGLClass != "") then {
_container addMagazineAmmoCargo [_magazineGLClass, 1, _magazineGLAmmoCount];
};
_container addWeaponWithAttachmentsCargoGlobal [
[
_weapon,
_muzzle, _pointer, _optic,
_magazine, _magazineGL,
_bipod
], 1
];
} forEach _weaponsItemsCargo;
};

Expand Down
40 changes: 9 additions & 31 deletions addons/common/fnc_removeWeaponCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ clearWeaponCargoGlobal _container;
// weaponsItems magazineGL does not exist if not loaded (not even as empty array)
if (count _x < 7) then {
_bipod = _magazineGL;
_magazineGL = "";
_magazineGL = [];
};

// Some weapons don't have non-preset parents
Expand Down Expand Up @@ -103,36 +103,14 @@ clearWeaponCargoGlobal _container;
};
};
} else {
_container addWeaponCargoGlobal [_weaponNonPreset, 1];

// If weapon does not have a non-preset parent, only add attachments that were custom added
// Removed attachments cannot be handled (engine limitation) and will be readded due to having to readd preset weapon
private _presetAttachments = [];
if (_weaponNonPreset == _weapon) then {
_presetAttachments = _weapon call CBA_fnc_weaponComponents;
};
if !(toLower _muzzle in _presetAttachments) then {
_container addItemCargoGlobal [_muzzle, 1];
};
if !(toLower _pointer in _presetAttachments) then {
_container addItemCargoGlobal [_pointer, 1];
};
if !(toLower _optic in _presetAttachments) then {
_container addItemCargoGlobal [_optic, 1];
};
if !(toLower _bipod in _presetAttachments) then {
_container addItemCargoGlobal [_bipod, 1];
};

_magazine params [["_magazineClass", ""], ["_magazineAmmoCount", 0]];
if (_magazineClass != "") then {
_container addMagazineAmmoCargo [_magazineClass, 1, _magazineAmmoCount];
};

_magazineGL params [["_magazineGLClass", ""], ["_magazineGLAmmoCount", 0]];
if (_magazineGLClass != "") then {
_container addMagazineAmmoCargo [_magazineGLClass, 1, _magazineGLAmmoCount];
};
_container addWeaponWithAttachmentsCargoGlobal [
[
_weaponNonPreset,
_muzzle, _pointer, _optic,
_magazine, _magazineGL,
_bipod
], 1
];
};
} forEach _weaponsItemsCargo;

Expand Down
2 changes: 1 addition & 1 deletion addons/common/test_inventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ _container addBackpackCargoGlobal ["B_AssaultPack_mcamo", 1];
((everyBackpack _container) select 0) addWeaponCargoGlobal ["arifle_MX_ACO_pointer_F", 1];
_result = [_container, "B_AssaultPack_mcamo", 1, true] call CBA_fnc_removeBackpackCargo;
TEST_TRUE(_result,_funcName);
TEST_TRUE(count (backpackCargo _container) == 0 && count (weaponCargo _container) == 1 && count (itemCargo _container) == 2,_funcName);
TEST_TRUE(count (backpackCargo _container) == 0 && count (weaponCargo _container) == 1 && count (itemCargo _container) == 0,_funcName);
clearBackpackCargoGlobal _container;
clearWeaponCargoGlobal _container;
clearItemCargoGlobal _container;
Expand Down
35 changes: 10 additions & 25 deletions addons/disposable/fnc_firedDisposable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -79,42 +79,27 @@ if (isNil "_usedLauncher") exitWith {};
}) exitWith {
if (GVAR(dropUsedLauncher) isEqualTo 1 && {_unit == call CBA_fnc_currentUnit}) exitWith {true};

private _launcherItems = secondaryWeaponItems _unit;
private _launcherMagazines = WEAPON_MAGAZINES(_unit,secondaryWeapon _unit);
secondaryWeaponItems _unit params ["_silencer", "_pointer", "_optic", "_bipod"];
WEAPON_MAGAZINES(_unit,secondaryWeapon _unit) params [["_magazineAmmo1", []], ["_magazineAmmo2", []]];

_unit removeWeapon _usedLauncher;

private _dir = getDir _unit - 180;

private _container = createVehicle ["WeaponHolderSimulated", [0,0,0], [], 0, "CAN_COLLIDE"];
_container addWeaponCargoGlobal [_usedLauncher, 1];
_container addWeaponWithAttachmentsCargoGlobal [
[
_usedLauncher,
_silencer, _pointer, _optic,
_magazineAmmo1, _magazineAmmo2,
_bipod
], 1
];

_container setDir (_dir + 90);
_container setPosASL AGLToASL (_unit modelToWorld (_unit selectionPosition "rightshoulder" vectorAdd [0, 0.2, 0.1]));
_container setVelocity (velocity _unit vectorAdd ([sin _dir, cos _dir, 0] vectorMultiply 1.5));

/*
_container addWeaponWithAttachmentsCargoGlobal [
_usedLauncher,
_silencer, _pointer, _optic, _bipod, [
_magazine1, _ammo1,
_magazine2, _ammo2
],
1];
*/

{
_container addItemCargoGlobal [_x, 1];
} forEach _launcherItems;

{
_x params ["_magazine", "_ammo"];

if (_ammo > 0) then {
_container addMagazineAmmoCargo [_x, 1, _ammo];
};
} forEach _launcherMagazines;

true // quit
};

Expand Down
2 changes: 1 addition & 1 deletion addons/settings/fnc_gui_sourceChanged.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private _selectedAddon = uiNamespace getVariable QGVAR(addon);
// toggle source buttons
{
private _ctrlX = _display displayCtrl _x;
_ctrlX ctrlSetTextColor ([COLOR_BUTTON_ENABLED, COLOR_BUTTON_DISABLED] select (_control == _ctrlX));
_ctrlX ctrlSetTextColor ([COLOR_BUTTON_ENABLED, COLOR_BUTTON_DISABLED] select (_control == _ctrlX && {!isClass (configFile >> "CfgPatches" >> "A3_Data_F_Contact")}));
_ctrlX ctrlSetBackgroundColor ([COLOR_BUTTON_DISABLED, COLOR_BUTTON_ENABLED] select (_control == _ctrlX));
} forEach [IDC_BTN_SERVER, IDC_BTN_MISSION, IDC_BTN_CLIENT];

Expand Down
4 changes: 3 additions & 1 deletion addons/ui/fnc_initDisplayInterrupt.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ if (!isMultiplayer && {getNumber (missionConfigFile >> "replaceAbortButton") > 0
];

// --- create custom buttons
private _buttonType = ["RscButtonMenu", "RscButtonMenuLeft"] select isClass (configFile >> "CfgPatches" >> "A3_Data_F_Contact");

{
_offset = _offset + 1.1;
_x params ["_displayName", "_tooltip", "_dialog"];

private _button = _display ctrlCreate ["RscButtonMenu", -1];
private _button = _display ctrlCreate [_buttonType, -1];

_button ctrlSetText toUpper _displayName;
_button ctrlSetTooltip _tooltip;
Expand Down

0 comments on commit 35f39a8

Please sign in to comment.