<commit_before>//===========================================================================
applyPlayerDBValues =
{
	private ["_array","_varName","_varValue","_i","_in","_exe","_backpack","_sendToServer","_uid"];
	diag_log format["applyPlayerDBValues called with %1", _this];
	_array = _this;
	_uid = _array select 0;
	_varName = _array select 1;

	if (count _array == 3) then {
		_varValue = _array select 2;
	} else {
		 //diag_log format["applyPlayerDBValues failed to get a value for %1", _varName];
	};

	// Donation error catch
	if(((getPlayerUID player) != _uid) AND ((getPlayerUID player) + "_donation" != _uid)) exitWith {if(_varName == 'DonationMoney') then {donationMoneyLoaded = 1;};};

	//if there is not a value for items we care about exit early
	if(isNil '_varValue') exitWith 	
	{
		//diag_log format["applyPlayerDBValues early termination with nil value for %1", _varName];
		if(_varName == 'Position') then {positionLoaded = 1;};
		if(_varName == 'DonationMoney') then {donationMoneyLoaded = 1;};
		
		if(_varName == 'PrimaryWeapon') then {primaryLoaded = 1;};
		if(_varName == 'HandgunWeapon') then {handgunLoaded = 1;};
		if(_varName == 'SecondaryWeapon') then {secondaryLoaded = 1;};

		if(_varName == 'Backpack') then { backpackLoaded = 1;};
		if(_varName == 'Vest') then { vestLoaded = 1;};
		if(_varName == 'Uniform') then { uniformLoaded = 1;};
		if(_varName == 'Items') then { itemsLoaded = 1;};
	};
	
	if(_varName == 'DonationMoney') then {player setVariable["donationMoney",_varValue,true]; donationMoneyLoaded = 1;};

	// Inventory item section. Use mf_inventory_all as set up by the mf_inv system
	{
		_itemID = _x select 0;
		if (_varName == _itemID) then {
			// Special call to mf_inventory_add specifying an absolute value
			[_varName, _varValue, true] call mf_inventory_add;
		};
	} forEach call mf_inventory_all;

	if(_varName == 'Health') then {player setDamage _varValue;};

	//if(_varName == 'Magazines') then {{player addMagazine _x;}foreach _varValue;};

	if (_varName == 'MagazinesWithAmmoCount') then {
		{
			_className = _x select 0; // eg. 30Rnd_65x39_caseless_mag
			_ammoCount = _x select 1; // Magazine current ammo count

			_backpack = unitBackpack player;
			_fits = [player, (_className)] call fn_fitsInventory;

			if ((_fits == 1)||(_fits == 2))then
			{
				player addMagazine [_className, _ammoCount];
			};
			if(_fits == 3) then
			{
				_backpack = unitBackpack player;
				_backpack addMagazineCargo [_className,1];
			};
		} forEach _varValue;
	};

	if((_varName == 'Items')) then 
	{
		for "_i" from 0 to (count _varValue) - 1 do 
		{
			_name = _varValue select _i;
			_backpack = unitBackpack player;
			_inCfgWeapons = isClass (configFile >> "cfgWeapons" >> _name);

			// Optics seems to denote an 'item' if 1 or 'weapon' is 0
			_cfgOptics = getNumber (configFile >> "cfgWeapons" >> _name >> "optics");

			if((str(_inCfgWeapons) == "true") && _cfgOptics == 0 && (!isNil '_backpack'))then{_backpack addWeaponCargo [_name,1];}
			else
			{
				_fits = [player, (_name)] call fn_fitsInventory;
				if((_fits == 1)||(_fits == 2))then
				{
					player addItem _name;
				};
				if(_fits == 3) then
				{
					_backpack = unitBackpack player;
					_backpack addItemCargo [_name,1];
				};
			};
		};
		if(_varName == 'Items') then {itemsLoaded = 1;};
	};

	if(_varName == 'PrimaryWeaponItems') then 
	{
		{
			player addPrimaryWeaponItem _x;
		}foreach _varValue;
	};
	if(_varName == 'SecondaryWeaponItems') then 
	{
		{
			player addSecondaryWeaponItem _x;
		}foreach _varValue;
	};
	if(_varName == 'HandgunItems') then 
	{
		{
			player addHandgunItem _x;<commit_msg>Adapted player persistence to fn_fitsInventory changes<commit_after>//===========================================================================
applyPlayerDBValues =
{
	private ["_array","_varName","_varValue","_i","_in","_exe","_backpack","_sendToServer","_uid"];
	diag_log format["applyPlayerDBValues called with %1", _this];
	_array = _this;
	_uid = _array select 0;
	_varName = _array select 1;

	if (count _array == 3) then {
		_varValue = _array select 2;
	} else {
		 //diag_log format["applyPlayerDBValues failed to get a value for %1", _varName];
	};

	// Donation error catch
	if(((getPlayerUID player) != _uid) AND ((getPlayerUID player) + "_donation" != _uid)) exitWith {if(_varName == 'DonationMoney') then {donationMoneyLoaded = 1;};};

	//if there is not a value for items we care about exit early
	if(isNil '_varValue') exitWith 	
	{
		//diag_log format["applyPlayerDBValues early termination with nil value for %1", _varName];
		if(_varName == 'Position') then {positionLoaded = 1;};
		if(_varName == 'DonationMoney') then {donationMoneyLoaded = 1;};
		
		if(_varName == 'PrimaryWeapon') then {primaryLoaded = 1;};
		if(_varName == 'HandgunWeapon') then {handgunLoaded = 1;};
		if(_varName == 'SecondaryWeapon') then {secondaryLoaded = 1;};

		if(_varName == 'Backpack') then { backpackLoaded = 1;};
		if(_varName == 'Vest') then { vestLoaded = 1;};
		if(_varName == 'Uniform') then { uniformLoaded = 1;};
		if(_varName == 'Items') then { itemsLoaded = 1;};
	};
	
	if(_varName == 'DonationMoney') then {player setVariable["donationMoney",_varValue,true]; donationMoneyLoaded = 1;};

	// Inventory item section. Use mf_inventory_all as set up by the mf_inv system
	{
		_itemID = _x select 0;
		if (_varName == _itemID) then {
			// Special call to mf_inventory_add specifying an absolute value
			[_varName, _varValue, true] call mf_inventory_add;
		};
	} forEach call mf_inventory_all;

	if(_varName == 'Health') then {player setDamage _varValue;};

	//if(_varName == 'Magazines') then {{player addMagazine _x;}foreach _varValue;};

	if (_varName == 'MagazinesWithAmmoCount') then {
		{
			_className = _x select 0; // eg. 30Rnd_65x39_caseless_mag
			_ammoCount = _x select 1; // Magazine current ammo count

			if ([player, _className] call fn_fitsInventory) then
			{
				player addMagazine [_className, _ammoCount];
			};
<<<<<<< Updated upstream
			if(_fits == 3) then
			{
				_backpack = unitBackpack player;
				_backpack addMagazineCargo [_className,1];
			};
=======
>>>>>>> Stashed changes
		} forEach _varValue;
	};

	if((_varName == 'Items')) then 
	{
		for "_i" from 0 to (count _varValue) - 1 do 
		{
			_name = _varValue select _i;
			_backpack = unitBackpack player;
			_inCfgWeapons = isClass (configFile >> "cfgWeapons" >> _name);

			// Optics seems to denote an 'item' if 1 or 'weapon' is 0
			_cfgOptics = getNumber (configFile >> "cfgWeapons" >> _name >> "optics");

			if (_inCfgWeapons && _cfgOptics == 0 && (!isNil '_backpack')) then {_backpack addWeaponCargoGlobal [_name,1];}
			else
			{
				if ([player, _name] call fn_fitsInventory) then
				{
					player addItem _name;
				};
			};
		};
		if(_varName == 'Items') then {itemsLoaded = 1;};
	};

	if(_varName == 'PrimaryWeaponItems') then 
	{
		{
			player addPrimaryWeaponItem _x;
		}foreach _varValue;
	};
	if(_varName == 'SecondaryWeaponItems') then 
	{
		{
			player addSecondaryWeaponItem _x;
		}foreach _varValue;
	};
	if(_varName == 'HandgunItems') then 
	{
		{
			player addHandgunItem _x;
{'fraction_non_alphanumeric': 0.1601458420978825, 'fraction_numerical': 0.01093815734118637, 'mean_word_length': 4.224908424908425, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3210699', 'n_tokens_mistral': 2804, 'n_tokens_neox': 2404, 'n_words': 647}