Prevent abuse of combine M24 and 2RndShotGun ammo #1848

Prevents duping exploit described in #1848

Fixes #1848
This commit is contained in:
ebaydayz
2017-01-04 16:16:15 -05:00
parent cfe01e609e
commit 731175f46b
2 changed files with 19 additions and 3 deletions

View File

@@ -47,6 +47,7 @@
[FIXED] Switching weapons properly interrupts autorun now. #1850 @DeVloek
[FIXED] Duplicate matchbox or knife error when lighting a fire or gutting with multiple matchboxes or knives on toolbelt. #1849 @DeVloek
[FIXED] RU crates having zero cargo capacity and wrong classname DZ_ExplosivesBoxRU in loot table. #1852 @oiad
[FIXED] Combining M24 or 2Rnd shotgun ammo can no longer be abused to dupe mags via the method described in #1848. @DeVloek
[NOTE] The fixes below are included in the 1.0.6 Build C server package released December 29th, 2016 (http://dayzepoch.com/a2dayzepoch.php)
[FIXED] Hive child 309 errors that resulted in broken saving of newly built storage object inventory. @icomrade

View File

@@ -1,7 +1,7 @@
private ["_item","_config","_consume","_create","_item_ammo","_consume_magsize","_create_magsize","_consume_type","_slotstart",
"_slotend","_dialog","_qty_total_ammo","_qty_consume_ammo","_qty_create_ammo","_qty_consume_mags","_qty_create_mags","_qty_free_slots",
"_control","_mag","_qtynew_create_ammo","_qtynew_consume_ammo","_qtynew_create_mags","_qtynew_consume_mags","_qtynew_consume_mags_full",
"_qtynew_create_mags_full","_qtynew_consume_ammo_rest","_qtynew_create_ammo_rest","_mags","_i"];
"_qtynew_create_mags_full","_qtynew_consume_ammo_rest","_qtynew_create_ammo_rest","_mags","_use"];
disableSerialization;
call gear_ui_init;
@@ -16,7 +16,8 @@ if (!(_item in magazines player)) exitWith {dayz_actionInProgress = false;};
_config = configFile >> "CfgMagazines" >> _item;
_consume = getArray (_config >> "ItemActions" >> "ReloadMag" >> "use") select 0;
_use = getArray (_config >> "ItemActions" >> "ReloadMag" >> "use");
_consume = _use select 0;
_create = getArray (_config >> "ItemActions" >> "ReloadMag" >> "output") select 0;
_item_ammo = gearSlotAmmoCount (uiNamespace getVariable 'uiControl');
@@ -118,7 +119,21 @@ for "_i" from 1 to _qtynew_create_mags_full do {
player addMagazine _create;
};
if (_qtynew_create_ammo_rest != 0) then {
if (count _use == 4) then {
//Prevent combine to partially full 8RndShotgun or 20RndDMR (i.e. 2x5RndM24 = 10RndDMR)
//Stops duping via move partial in backpack, relog, split, combine to partial again, repeat
_qtynew_consume_mags_full = floor(_qtynew_create_ammo_rest/_consume_magsize);
_qtynew_consume_ammo_rest = _qtynew_create_ammo_rest - (_qtynew_consume_mags_full*_consume_magsize);
for "_i" from 1 to _qtynew_consume_mags_full do {
player addMagazine _consume;
};
if (_qtynew_consume_ammo_rest > 0) then {
player addMagazine [_consume,_qtynew_consume_ammo_rest];
};
} else {
player addMagazine [_create,_qtynew_create_ammo_rest];
};
};
uiSleep 1;
dayz_actionInProgress = false;