<commit_before>//	@file Version: 1.0
//	@file Name: populateGenStore.sqf
//	@file Author: [404] Deadbeat, [KoS] His_Shadow, AgentRev
//	@file Created: 20/11/2012 05:13
//	@file Args:

#include "dialog\genstoreDefines.sqf";
disableSerialization;
private ["_switch", "_dialog", "_itemlist", "_itemlisttext", "_itemDesc", "_showPicture", "_itemsArray", "_parentCfg", "_weapon", "_picture", "_listIndex", "_showItem", "_factionCfg", "_faction", "_uniformClassCfg", "_sideCfg", "_uniformSides", "_playerSides", "_side"];
_switch = _this select 0;

_getAllowedSides =
{
	private ["_unitType", "_sides", "_side"];

	_unitType = configFile >> "CfgVehicles" >> _this;
	_sides = [];
	
	while {isClass _unitType} do
	{
		_side = getNumber (_unitType >> "side");
		
		if !(_side in _sides) then
		{
			_sides set [count _sides, _side];
		};
		
		_unitType = inheritsFrom _unitType;
	};

	_sides
};

// Grab access to the controls
_dialog = findDisplay genstore_DIALOG;
_itemlist = _dialog displayCtrl genstore_item_list;
_itemlisttext = _dialog displayCtrl genstore_item_TEXT;
_itemDesc = _dialog displayCtrl genstore_item_desc;

[] execVM "client\systems\generalStore\getInventory.sqf";

//Clear the list
lbClear _itemlist;
_itemlist lbSetCurSel -1;
_itemlisttext ctrlSetText "";
_itemDesc ctrlSetText "";

_showPicture = true;

switch(_switch) do 
{
	case 0: 
	{
		_itemsArray = call headArray;
	};
	case 1: 
	{
		_itemsArray = call uniformArray;
	};
	case 2: 
	{
		_itemsArray = call vestArray;
	};
	case 3: 
	{
		_itemsArray = call backpackArray;
	};
	case 4: 
	{
		_itemsArray = call genItemArray;
	};
	case 5: 
	{
		_itemsArray = call customPlayerItems;
	};
	case 6: 
	{
		_itemsArray = call genObjectsArray;
		_showPicture = false;
	};
	default
	{
		_itemsArray = [];
	};
};

{
	_weaponClass = _x select 1;

	switch (true) do
	{
		case (isClass (configFile >> "CfgVehicles" >> _weaponClass)):  { _parentCfg = configFile >> "CfgVehicles" };
		case (isClass (configFile >> "CfgWeapons" >> _weaponClass)):   { _parentCfg = configFile >> "CfgWeapons" };
		case (isClass (configFile >> "CfgMagazines" >> _weaponClass)): { _parentCfg = configFile >> "CfgMagazines" };
		case (isClass (configFile >> "CfgGlasses" >> _weaponClass)):   { _parentCfg = configFile >> "CfgGlasses" };
	};
	
	_showItem = true;
	
	// Side-based filtering
	if (!isNil "_parentCfg") then
	{
		switch (configName _parentCfg) do
		{
			case "CfgVehicles":
			{
				_factionCfg = _parentCfg >> _weaponClass >> "faction";
				
				switch (true) do
				{
					case (isText _factionCfg):
					{
						_faction = getText _factionCfg;
						
						if (_faction != faction player &&
						   {_faction != "CIV_F"} &&
						   {_faction != "Default"} &&
						   {_faction != ""}) then
						{
							_showItem = false;
						};
					};
				};
			};
			case "CfgWeapons":
			{
				_uniformClassCfg = _parentCfg >> _weaponClass >> "ItemInfo" >> "uniformClass";
				_sideCfg = _parentCfg >> _weaponClass >> "ItemInfo" >> "side";
				
				switch (true) do
				{
					case (isText _uniformClassCfg):
					{
						_uniformSides = (getText _uniformClassCfg) call _getAllowedSides;
						_playerSides = getArray (configFile >> "CfgVehicles" >> typeOf player >> "modelSides");
						
						if ({_x in _playerSides} count _uniformSides == 0) then
						{
							_showItem = false;
						};
					};
					case (isNumber _sideCfg):
					{
						_side = getNumber _sideCfg;
						
						// Yes, the numbers are correct
						if ((_side == 1 && playerSide != BLUFOR) ||
							{_side == 0 && playerSide != OPFOR} ||
							{_side == 2 && playerSide != INDEPENDENT}) then
						{
							_showItem = false;
						};
					};
				};
			};
		};<commit_msg>Modified populateGenStore.sqf to use new canWear function<commit_after>//	@file Version: 1.0
//	@file Name: populateGenStore.sqf
//	@file Author: [404] Deadbeat, [KoS] His_Shadow, AgentRev
//	@file Created: 20/11/2012 05:13
//	@file Args:

#include "dialog\genstoreDefines.sqf";
disableSerialization;
private ["_switch", "_dialog", "_itemlist", "_itemlisttext", "_itemDesc", "_showPicture", "_itemsArray", "_parentCfg", "_weapon", "_picture", "_listIndex", "_showItem", "_factionCfg", "_faction", "_isUniform", "_sideCfg", "_side"];
_switch = _this select 0;

// Grab access to the controls
_dialog = findDisplay genstore_DIALOG;
_itemlist = _dialog displayCtrl genstore_item_list;
_itemlisttext = _dialog displayCtrl genstore_item_TEXT;
_itemDesc = _dialog displayCtrl genstore_item_desc;

[] execVM "client\systems\generalStore\getInventory.sqf";

//Clear the list
lbClear _itemlist;
_itemlist lbSetCurSel -1;
_itemlisttext ctrlSetText "";
_itemDesc ctrlSetText "";

_showPicture = true;

switch(_switch) do 
{
	case 0: 
	{
		_itemsArray = call headArray;
	};
	case 1: 
	{
		_itemsArray = call uniformArray;
	};
	case 2: 
	{
		_itemsArray = call vestArray;
	};
	case 3: 
	{
		_itemsArray = call backpackArray;
	};
	case 4: 
	{
		_itemsArray = call genItemArray;
	};
	case 5: 
	{
		_itemsArray = call customPlayerItems;
	};
	case 6: 
	{
		_itemsArray = call genObjectsArray;
		_showPicture = false;
	};
	default
	{
		_itemsArray = [];
	};
};

{
	_weaponClass = _x select 1;

	switch (true) do
	{
		case (isClass (configFile >> "CfgVehicles" >> _weaponClass)):  { _parentCfg = configFile >> "CfgVehicles" };
		case (isClass (configFile >> "CfgWeapons" >> _weaponClass)):   { _parentCfg = configFile >> "CfgWeapons" };
		case (isClass (configFile >> "CfgMagazines" >> _weaponClass)): { _parentCfg = configFile >> "CfgMagazines" };
		case (isClass (configFile >> "CfgGlasses" >> _weaponClass)):   { _parentCfg = configFile >> "CfgGlasses" };
	};
	
	_showItem = true;
	
	// Side-based filtering
	if (!isNil "_parentCfg") then
	{
		switch (configName _parentCfg) do
		{
			case "CfgVehicles":
			{
				_factionCfg = _parentCfg >> _weaponClass >> "faction";
				
				switch (true) do
				{
					case (isText _factionCfg):
					{
						_faction = getText _factionCfg;
						
						if (_faction != faction player &&
						   {_faction != "CIV_F"} &&
						   {_faction != "Default"} &&
						   {_faction != ""}) then
						{
							_showItem = false;
						};
					};
				};
			};
			case "CfgWeapons":
			{
				_isUniform = isText (_parentCfg >> _weaponClass >> "ItemInfo" >> "uniformClass");
				_sideCfg = _parentCfg >> _weaponClass >> "ItemInfo" >> "side";
				
				switch (true) do
				{
					case (_isUniform):
					{
						if !([player, _weaponClass] call canWear) then
						{
							_showItem = false;
						};
					};
					case (isNumber _sideCfg):
					{
						_side = getNumber _sideCfg;
						
						// Yes, the numbers are correct
						if ((_side == 1 && playerSide != BLUFOR) ||
							{_side == 0 && playerSide != OPFOR} ||
							{_side == 2 && playerSide != INDEPENDENT}) then
						{
							_showItem = false;
						};
					};
				};
			};
		};
{'fraction_non_alphanumeric': 0.14064553819190886, 'fraction_numerical': 0.00890901124580108, 'mean_word_length': 3.162917933130699, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 95, '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': '6953126', 'n_tokens_mistral': 2948, 'n_tokens_neox': 2376, 'n_words': 560}