<commit_before>//	@file Author: [404] Costlyy
//	@file Name: objectLockStateMachine.sqf
//	@file Version: 1.0
//  @file Date:	21/11/2012
//	@file Description: Locks an object until the player disconnects.
//	@file Args: [object,player,int,lockState(lock = 0 / unlock = 1)]

// Check if mutex lock is active.
if(R3F_LOG_mutex_local_verrou) exitWith {
	player globalChat STR_R3F_LOG_mutex_action_en_cours;
};

private["_locking", "_object", "_lockState", "_lockDuration", "_stringEscapePercent", "_iteration", "_unlockDuration", "_totalDuration", "_checks", "_success","_IsProtected","_IsAllowed"];

_object = _this select 0;
_lockState = _this select 3;

_IsProtected = false;
_IsAllowed = false;

if (((_object distance getMarkerPos "_BluBaseMarker") < 100) && !(side player == blufor)) exitwith {
	hint "This base can only be changed by Blufor"; R3F_LOG_mutex_local_verrou = false;
};

if (((_object distance getMarkerPos "_OPFBaseMarker") < 100) && !(side player == opfor)) exitwith {
	hint "This base can only be changed by Opfor"; R3F_LOG_mutex_local_verrou = false;
};

_totalDuration = 0;
_stringEscapePercent = "%";

switch (_lockState) do
{
	case 0: // LOCK
	{
		R3F_LOG_mutex_local_verrou = true;
		_totalDuration = 1;
		_checks =
		{
			private ["_progress", "_object", "_failed", "_text", "_reLocker"];
			_progress = _this select 0;
			_object = _this select 1;
			_failed = true;

			switch (true) do
			{
				case (!alive player): { _text = "" };
				case (doCancelAction): { doCancelAction = false; _text = "Locking cancelled" };
				case (vehicle player != player): { _text = "Action failed! You can't do this in a vehicle" };
				case (!isNull (_object getVariable ["R3F_LOG_est_transporte_par", objNull])): { _text = "Action failed! Somebody moved the object" };
				case (_object getVariable ["objectLocked", false]): { _text = "Somebody else locked it before you" };
				default
				{<commit_msg>fixed bug allowing objects to lock near missions<commit_after>//	@file Author: [404] Costlyy
//	@file Name: objectLockStateMachine.sqf
//	@file Version: 1.0
//  @file Date:	21/11/2012
//	@file Description: Locks an object until the player disconnects.
//	@file Args: [object,player,int,lockState(lock = 0 / unlock = 1)]

// Check if mutex lock is active.
if(R3F_LOG_mutex_local_verrou) exitWith {
	player globalChat STR_R3F_LOG_mutex_action_en_cours;
};

private["_locking", "_object", "_lockState", "_lockDuration", "_stringEscapePercent", "_iteration", "_unlockDuration", "_totalDuration", "_checks", "_success","_IsProtected","_IsAllowed"];

_object = _this select 0;
_lockState = _this select 3;

_IsProtected = false;
_IsAllowed = false;

if (((_object distance getMarkerPos "_BluBaseMarker") < 100) && !(side player == blufor)) exitwith {
	hint "This base can only be changed by Blufor"; R3F_LOG_mutex_local_verrou = false;
};

if (((_object distance getMarkerPos "_OPFBaseMarker") < 100) && !(side player == opfor)) exitwith {
	hint "This base can only be changed by Opfor"; R3F_LOG_mutex_local_verrou = false;
};

_totalDuration = 0;
_stringEscapePercent = "%";

switch (_lockState) do
{
	case 0: // LOCK
	{
		R3F_LOG_mutex_local_verrou = true;
		_totalDuration = 1;
		// Points of interest
		_poiDist = ["A3W_poiObjLockDistance", 100] call getPublicVar;
		_poiMarkers = allMapMarkers select {[["GenStore","GunStore","VehStore","Mission_","Jet_","Sniper_","RoadBlock_","Patrol_", "TERRITORY_", "NOBASE_"], _x] call fn_startsWith};

		if ({(getPosASL player) vectorDistance (ATLtoASL getMarkerPos _x) < _poiDist} count _poiMarkers > 0) exitWith
		{
			playSound "FD_CP_Not_Clear_F";
			[format ["You are not allowed to lock objects within %1m of stores and mission spawns, or within Territory Areas and Airfields", _poiDist], 5] call mf_notify_client;
			R3F_LOG_mutex_local_verrou = false;
		};

		_checks =
		{
			private ["_progress", "_object", "_failed", "_text", "_reLocker"];
			_progress = _this select 0;
			_object = _this select 1;
			_failed = true;

			switch (true) do
			{
				case (!alive player): { _text = "" };
				case (doCancelAction): { doCancelAction = false; _text = "Locking cancelled" };
				case (vehicle player != player): { _text = "Action failed! You can't do this in a vehicle" };
				case (!isNull (_object getVariable ["R3F_LOG_est_transporte_par", objNull])): { _text = "Action failed! Somebody moved the object" };
				case (_object getVariable ["objectLocked", false]): { _text = "Somebody else locked it before you" };
				default
				{
{'fraction_non_alphanumeric': 0.13256227758007116, 'fraction_numerical': 0.016903914590747332, 'mean_word_length': 4.787644787644788, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, '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': '1795501', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1508, 'n_words': 441}