improve inventory check performance and logging #10
@@ -5,34 +5,7 @@ params [
|
|||||||
|
|
||||||
if (!isPlayer _player) exitWith { diag_log("exitWith logPlayerInventory")};
|
if (!isPlayer _player) exitWith { diag_log("exitWith logPlayerInventory")};
|
||||||
|
|
||||||
_items = [];
|
// DEFINITIONS
|
||||||
_ietms pushback headgear _player;
|
|
||||||
_items pushback uniform _player;
|
|
||||||
_items append uniformItems _player;
|
|
||||||
_items pushback vest _player;
|
|
||||||
_items append vestItems _player;
|
|
||||||
_items pushback backpack _player;
|
|
||||||
_items append backpackItems _player;
|
|
||||||
_items pushback hmd _player;
|
|
||||||
_items pushback binocular _player;
|
|
||||||
_items pushback primaryWeapon _player;
|
|
||||||
_items append primaryWeaponItems _player;
|
|
||||||
_items pushback secondaryWeapon _player;
|
|
||||||
_items append secondaryWeaponItems _player;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_unlisted = [];
|
|
||||||
|
|
||||||
_restricted = [];
|
|
||||||
_blacklist = [];
|
|
||||||
_tabbed = [];
|
|
||||||
_meme = [];
|
|
||||||
|
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", name _player];
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
_blackListItems = [ // Items that NO member is allowed to use.
|
_blackListItems = [ // Items that NO member is allowed to use.
|
||||||
"17BN_ANPVS14", // NVG AN/PVS-14
|
"17BN_ANPVS14", // NVG AN/PVS-14
|
||||||
"USP_PVS_14", // NVG AN/PVS-14
|
"USP_PVS_14", // NVG AN/PVS-14
|
||||||
@@ -232,13 +205,71 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
// INSTANTIATE VARS
|
||||||
|
_unlisted = [];
|
||||||
|
|
||||||
|
_restricted = [];
|
||||||
|
_blacklist = [];
|
||||||
|
_tabbed = [];
|
||||||
|
_meme = [];
|
||||||
|
|
||||||
|
private _nonCompliantItemsCount = 0;
|
||||||
|
|
||||||
|
// PRIVATE FUNCTIONS
|
||||||
|
private _logItem = {
|
||||||
|
params ["_playerObj", "_categoryText", "_itemClassName"];
|
||||||
|
private _cfg = _itemClassName call CBA_fnc_getItemConfig;
|
||||||
|
diag_log text format[
|
||||||
|
"[MILSIM] (logPlayerInventory): Found %1 :: className=""%2"" displayName=""%3"" %4",
|
||||||
|
_categoryText,
|
||||||
|
_itemClassName,
|
||||||
|
[_cfg] call BIS_fnc_displayName,
|
||||||
|
[_playerObj] call _playerInfoString
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
private _playerInfoString = {
|
||||||
|
params ["_playerObj"];
|
||||||
|
format["playerName=""%1"" playerUID=""%2"" playerGroup=""%3""", name _playerObj, getPlayerUID _playerObj, groupId (group _playerObj)];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// GATHER INVENTORY
|
||||||
|
// _items = [];
|
||||||
|
// _items pushback headgear _player;
|
||||||
|
// _items pushback uniform _player;
|
||||||
|
// _items append uniformItems _player;
|
||||||
|
// _items pushback vest _player;
|
||||||
|
// _items append vestItems _player;
|
||||||
|
// _items pushback backpack _player;
|
||||||
|
// _items append backpackItems _player;
|
||||||
|
// _items pushback hmd _player;
|
||||||
|
// _items pushback binocular _player;
|
||||||
|
// _items pushback primaryWeapon _player;
|
||||||
|
// _items append primaryWeaponItems _player;
|
||||||
|
// _items pushback secondaryWeapon _player;
|
||||||
|
// _items append secondaryWeaponItems _player;
|
||||||
|
|
||||||
|
_items = [
|
||||||
|
_player, // Unit
|
||||||
|
true, // Include weapons, attachments, loaded magazines
|
||||||
|
true, // Include items in backpack
|
||||||
|
true, // Include items in vest
|
||||||
|
true, // Include items in uniform
|
||||||
|
true, // Include assigned items
|
||||||
|
true // Include not loaded magazines
|
||||||
|
] call CBA_fnc_uniqueUnitItems;
|
||||||
|
|
||||||
|
_items pushBack (headgear _player);
|
||||||
|
_items pushBack (uniform _player);
|
||||||
|
|
||||||
|
// CHECK INVENTORY
|
||||||
|
diag_log text format[
|
||||||
|
"[MILSIM] (logPlayerInventory): Checking inventory :: %1",
|
||||||
|
[_player] call _playerInfoString
|
||||||
|
];
|
||||||
|
|
||||||
|
{
|
||||||
_item = _x;
|
_item = _x;
|
||||||
_modes = getArray(configfile >> "CfgWeapons" >> _item >> "visionMode");
|
_modes = getArray(configfile >> "CfgWeapons" >> _item >> "visionMode");
|
||||||
|
|
||||||
@@ -274,32 +305,40 @@ diag_log text format["[MILSIM] (logPlayerInventory): Checking %1 inventory.", na
|
|||||||
|
|
||||||
} forEach _items;
|
} forEach _items;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a blacklisted inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||||
|
[_player, "a blacklisted inventory item", _x] call _logItem;
|
||||||
} forEach _blacklist;
|
} forEach _blacklist;
|
||||||
|
|
||||||
{
|
{
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a restricted inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||||
|
[_player, "a restricted inventory item", _x] call _logItem;
|
||||||
} forEach _restricted;
|
} forEach _restricted;
|
||||||
|
|
||||||
{
|
{
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a tabbed inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||||
|
[_player, "a tabbed inventory item", _x] call _logItem;
|
||||||
} forEach _tabbed;
|
} forEach _tabbed;
|
||||||
|
|
||||||
{
|
{
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has a meme inventory item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||||
|
[_player, "a meme inventory item", _x] call _logItem;
|
||||||
} forEach _meme;
|
} forEach _meme;
|
||||||
|
|
||||||
{
|
{
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 has an unlisted thermal item: %2", name _player, getText( configfile >> "CfgWeapons" >> _x >> "displayName" )];
|
if (
|
||||||
|
_x in _blackListItems ||
|
||||||
|
_x in _restrictedItems
|
||||||
|
) then {continue}; // Skip items that are already checked
|
||||||
|
_nonCompliantItemsCount = _nonCompliantItemsCount + 1;
|
||||||
|
[_player, "an unlisted thermal item", _x] call _logItem;
|
||||||
} forEach _unlisted;
|
} forEach _unlisted;
|
||||||
|
|
||||||
if (
|
if (_nonCompliantItemsCount isEqualTo 0) then {
|
||||||
[_blacklist, _restricted, _tabbed, _meme, _unlisted] find {
|
diag_log text format["[MILSIM] (logPlayerInventory): %1's inventory is compliant :: playerName=""%1"" playerUID=""%2""", name _player, getPlayerUID _player];
|
||||||
count _x > 0
|
|
||||||
} isEqualTo -1
|
|
||||||
) then {
|
|
||||||
diag_log text format["[MILSIM] (logPlayerInventory): %1 inventory in fully base inventory compliant.", name _player];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nil
|
nil
|
||||||
Reference in New Issue
Block a user