Arsenal - Fix #9040 bugs/regressions (#9293)

* fix saving loadout with weapon in container

* readd magazine refill
This commit is contained in:
Grim 2023-07-28 07:53:53 +03:00 committed by GitHub
parent 2578ead13b
commit 12905a0702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 14 deletions

View File

@ -27,6 +27,7 @@ private _itemIndex = [IDC_buttonMuzzle, IDC_buttonItemAcc, IDC_buttonOptic, IDC_
switch (_currentItemsIndex) do { switch (_currentItemsIndex) do {
// Primary weapon // Primary weapon
case IDX_CURR_PRIMARY_WEAPON_ITEMS: { case IDX_CURR_PRIMARY_WEAPON_ITEMS: {
private _currentItemInSlot = (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select _itemIndex;
// If removal // If removal
if (_item == "") then { if (_item == "") then {
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select 5; private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select 5;
@ -40,11 +41,11 @@ switch (_currentItemsIndex) do {
// Add magazine back into primary muzzle // Add magazine back into primary muzzle
GVAR(center) addWeaponItem [primaryWeapon GVAR(center), _secondaryMagazine, true]; GVAR(center) addWeaponItem [primaryWeapon GVAR(center), _secondaryMagazine, true];
} else { } else {
GVAR(center) removePrimaryWeaponItem ((GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select _itemIndex); GVAR(center) removePrimaryWeaponItem _currentItemInSlot;
}; };
} else { } else {
// Don't add item if it isn't a different item than what the unit already has // Don't add item if it isn't a magazine or a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_PRIMARY_WEAPON_ITEMS) select _itemIndex)) then { if (_itemIndex >= 4 || {_item != _currentItemInSlot}) then {
// If magazine, make sure to add to correct muzzle // If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then { if (_itemIndex >= 4) then {
private _weapon = primaryWeapon GVAR(center); private _weapon = primaryWeapon GVAR(center);
@ -64,6 +65,7 @@ switch (_currentItemsIndex) do {
}; };
// Secondary weapon // Secondary weapon
case IDX_CURR_SECONDARY_WEAPON_ITEMS: { case IDX_CURR_SECONDARY_WEAPON_ITEMS: {
private _currentItemInSlot = (GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select _itemIndex;
private _isDisposable = CBA_disposable_replaceDisposableLauncher && {!isNil {CBA_disposable_loadedLaunchers getVariable (secondaryWeapon GVAR(center))}}; private _isDisposable = CBA_disposable_replaceDisposableLauncher && {!isNil {CBA_disposable_loadedLaunchers getVariable (secondaryWeapon GVAR(center))}};
// If removal // If removal
@ -84,11 +86,11 @@ switch (_currentItemsIndex) do {
// Add magazine back into primary muzzle // Add magazine back into primary muzzle
GVAR(center) addWeaponItem [secondaryWeapon GVAR(center), _secondaryMagazine, true]; GVAR(center) addWeaponItem [secondaryWeapon GVAR(center), _secondaryMagazine, true];
} else { } else {
GVAR(center) removeSecondaryWeaponItem ((GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select _itemIndex); GVAR(center) removeSecondaryWeaponItem _currentItemInSlot;
}; };
} else { } else {
// Don't add item if it isn't a different item than what the unit already has // Don't add item if it isn't a magazine or a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_SECONDARY_WEAPON_ITEMS) select _itemIndex)) then { if (_itemIndex >= 4 || {_item != _currentItemInSlot}) then {
// If magazine, make sure to add to correct muzzle // If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then { if (_itemIndex >= 4) then {
private _weapon = secondaryWeapon GVAR(center); private _weapon = secondaryWeapon GVAR(center);
@ -110,6 +112,7 @@ switch (_currentItemsIndex) do {
}; };
// Handgun weapon // Handgun weapon
case IDX_CURR_HANDGUN_WEAPON_ITEMS: { case IDX_CURR_HANDGUN_WEAPON_ITEMS: {
private _currentItemInSlot = (GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select _itemIndex;
if (_item == "") then { if (_item == "") then {
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select 5; private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select 5;
@ -122,11 +125,11 @@ switch (_currentItemsIndex) do {
// Add magazine back into primary muzzle // Add magazine back into primary muzzle
GVAR(center) addWeaponItem [handgunWeapon GVAR(center), _secondaryMagazine, true]; GVAR(center) addWeaponItem [handgunWeapon GVAR(center), _secondaryMagazine, true];
} else { } else {
GVAR(center) removeHandgunItem ((GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select _itemIndex); GVAR(center) removeHandgunItem _currentItemInSlot;
}; };
} else { } else {
// Don't add item if it isn't a different item than what the unit already has // Don't add item if it isn't a magazine or a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_HANDGUN_WEAPON_ITEMS) select _itemIndex)) then { if (_itemIndex >= 4 || {_item != _currentItemInSlot}) then {
// If magazine, make sure to add to correct muzzle // If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then { if (_itemIndex >= 4) then {
private _weapon = handgunWeapon GVAR(center); private _weapon = handgunWeapon GVAR(center);
@ -154,6 +157,7 @@ switch (_currentItemsIndex) do {
}; };
// Binoculars // Binoculars
case IDX_CURR_BINO_ITEMS: { case IDX_CURR_BINO_ITEMS: {
private _currentItemInSlot = (GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select _itemIndex;
if (_item == "") then { if (_item == "") then {
private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select 5; private _secondaryMagazine = (GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select 5;
@ -166,11 +170,11 @@ switch (_currentItemsIndex) do {
// Add magazine back into primary muzzle // Add magazine back into primary muzzle
GVAR(center) addWeaponItem [binocular GVAR(center), _secondaryMagazine, true]; GVAR(center) addWeaponItem [binocular GVAR(center), _secondaryMagazine, true];
} else { } else {
GVAR(center) removeBinocularItem ((GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select _itemIndex); GVAR(center) removeBinocularItem _currentItemInSlot;
}; };
} else { } else {
// Don't add item if it isn't a different item than what the unit already has // Don't add item if it isn't a magazine or a different item than what the unit already has
if (_item != ((GVAR(currentItems) select IDX_CURR_BINO_ITEMS) select _itemIndex)) then { if (_itemIndex >= 4 || {_item != _currentItemInSlot}) then {
// If magazine, make sure to add to correct muzzle // If magazine, make sure to add to correct muzzle
if (_itemIndex >= 4) then { if (_itemIndex >= 4) then {
private _weapon = binocular GVAR(center); private _weapon = binocular GVAR(center);

View File

@ -98,9 +98,10 @@ private _cfgVehicles = configFile >> "CfgVehicles";
// Check weapon & weapon attachments // Check weapon & weapon attachments
{ {
// Magazines // Magazines in weapons have 2 entries: Name and ammo count
if (_forEachIndex in [4, 5]) then { if (_forEachIndex in [4, 5]) then {
_uniqueBaseCfgText = (getText (_cfgMagazines >> _x >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName); _x params ["_magazine"];
_uniqueBaseCfgText = (getText (_cfgMagazines >> _magazine >> QGVAR(uniqueBase))) call EFUNC(common,getConfigName);
if (_uniqueBaseCfgText != "") then { if (_uniqueBaseCfgText != "") then {
_weaponsInfo set [_forEachIndex, _uniqueBaseCfgText]; _weaponsInfo set [_forEachIndex, _uniqueBaseCfgText];