/*%FSM*/ /*%FSM*/ /* item0[] = {"Init",0,250,600.000000,-575.000000,700.000000,-525.000000,0.000000,"Init"}; item1[] = {"_",8,218,600.000000,-500.000000,700.000000,-450.000000,0.000000,""}; item2[] = {"Process",2,250,600.000000,-350.000000,700.000000,-300.000000,0.000000,"Process"}; item3[] = {"Vehicle_and_Player",4,218,750.986694,-310.854675,850.986694,-260.854675,1.000000,"" \n "Vehicle and Player" \n "Checks"}; item4[] = {"CMD_queue",4,218,450.000000,-450.000000,550.000000,-400.000000,10.000000,"CMD queue"}; item5[] = {"Save_Players",4,218,450.000000,-375.000000,550.000000,-325.000000,3.000000,"Save" \n "Players"}; item6[] = {"Cleanup",4,218,750.000000,-375.000000,850.000000,-325.000000,8.000000,"Cleanup"}; item7[] = {"Events_Manager",4,218,599.992371,-192.435822,699.992371,-142.435822,0.000000,"Events" \n "Manager"}; item8[] = {"Save_Vehicles",4,218,450.000000,-300.000000,550.000000,-250.000000,4.000000,"Save" \n "Vehicles"}; item9[] = {"Cleanup_Handler",4,218,750.000000,-450.000000,850.000000,-400.000000,8.000000,"Cleanup" \n "Handler"}; item10[] = {"Server_FPS",4,218,746.045227,-248.683014,846.045227,-198.683014,0.000000,"Server FPS"}; item11[] = {"Forced_Restart",4,4314,684.856567,-214.145233,784.856567,-164.145233,0.000000,"Forced" \n "Restart"}; link0[] = {0,1}; link1[] = {1,2}; link2[] = {2,3}; link3[] = {2,4}; link4[] = {2,5}; link5[] = {2,6}; link6[] = {2,7}; link7[] = {2,8}; link8[] = {2,9}; link9[] = {2,10}; link10[] = {2,11}; link11[] = {3,2}; link12[] = {4,2}; link13[] = {5,2}; link14[] = {6,2}; link15[] = {7,2}; link16[] = {8,2}; link17[] = {9,2}; link18[] = {10,2}; link19[] = {11,2}; globals[] = {0.000000,0,0,0,0,640,480,1,5,6316128,1,275.180084,1161.319580,208.497711,-659.879456,898,884,1}; window[] = {2,-1,-1,-1,-1,864,104,1396,104,3,916}; *//*%FSM*/ class FSM { fsmName = "Server Monitor"; class States { /*%FSM*/ class Init { name = "Init"; init = /*%FSM*/"diag_log ""Loaded Server FSM"";" \n "" \n "_cfgSecConf = (configFile >> ""CfgSecConf"");" \n "_cfgSecConf_vehicles = (_cfgSecConf >> ""vehicles"");" \n "_safeVehicles = [_cfgSecConf_vehicles, ""safeVehicles"", [""I_UAV_01_F"",""B_Heli_Transport_01_F"",""Steerable_Parachute_F"",""NonSteerable_Parachute_F"",""Land_Camping_Light_F"",""container_epoch""]] call EPOCH_fnc_returnConfigEntry;" \n "" \n "_serverSettingsConfig = configFile >> ""CfgEpochServer"";" \n "_ahInitAuthCfg = [_serverSettingsConfig, ""antihack_ahInitAuthCfg"", [0,180]] call EPOCH_fnc_returnConfigEntry;" \n "_events = [_serverSettingsConfig, ""events"", []] call EPOCH_fnc_returnConfigEntry;" \n "" \n "_initAhInitBanOrLog = _ahInitAuthCfg select 0;" \n "_initTimeLimit = _ahInitAuthCfg select 1;" \n "" \n "// Load Epoch Events 3.0" \n "{" \n " diag_log format[""Loading Settings for %1 event..."",configName _x];" \n " _events pushBack [getNumber (_x >> ""delay""),getText (_x >> ""script""),getNumber (_x >> ""runOnStart""),getNumber (_x >> ""usePrefix""),getNumber (_x >> ""runNumTimes""),getArray (_x >> ""input""),getArray (_x >> ""disallowedWorlds"")];" \n "} forEach (""isClass _x"" configClasses (configFile >> ""CfgEpochServerEvents""));" \n "" \n "_cmdDelay = EPOCH_hiveAdminCmdTime;" \n "_cmdRun = EPOCH_hiveAdminCmdExec;" \n "_savePlayerList = EPOCH_hiveAdminSavePlayerList;" \n "" \n "_scriptBasedRestart = EPOCH_ServerRestart;" \n "_forceRestartTime = EPOCH_forceRestartTime;" \n "_forceRestartTimeWarning = _forceRestartTime-300;" \n "" \n "_prevRestartIn = 0;" \n "_serverLocked = false;" \n "_serverRestarting = false;" \n "_players = [];" \n "_prevPlayers = [];" \n "_cleanupItems = [];" \n "_oldFPS = -1;" \n "EPOCH_diag_fps = -1;" \n "_serverFpsTime = diag_tickTime;" \n "_serverFPSCheckFine = true;" \n "" \n "_delayTimeSim = diag_tickTime;" \n "_delayTimeCMD = diag_tickTime;" \n "_delayTimeDeSim = diag_tickTime;" \n "_delayTimeSaveVeh = diag_tickTime;" \n "_lastWeatherChange = diag_tickTime;" \n "_lastObjectCleanup = diag_tickTime;" \n "_lastObjectCleanup1 = diag_tickTime;" \n "" \n "_pvehTime = diag_tickTime;" \n "_forcedrestartTimer = diag_tickTime;" \n "" \n "_instanceID = call EPOCH_fn_InstanceID;" \n "" \n "_checkAuth = {" \n " params [""_puid"",""_player""];" \n " if !(isNull _player) then {" \n " if !(_puid call EPOCH_server_Authed) then {" \n " private _lastCheck = _player getVariable ""LAST_AUTH_CHECK"";" \n " if (isNil ""_lastCheck"") then {" \n " _player setVariable[""LAST_AUTH_CHECK"", diag_tickTime];" \n " _lastCheck = diag_tickTime;" \n " };" \n " if (diag_tickTime - _lastCheck > _initTimeLimit) then {" \n " _player setVariable[""LAST_AUTH_CHECK"", nil];" \n " if (_initAhInitBanOrLog == 0) then {" \n " 'epochserver' callExtension format['820|%1|EpochMod.com Autoban #R2', _puid];" \n " ['ahb', format['%1 (%2): Player not Authenticated', name _player, _puid]] call EPOCH_fnc_server_hiveLog;" \n " } else {" \n " ['ahl', format['%1 (%2): Player not Authenticated', name _player, _puid]] call EPOCH_fnc_server_hiveLog;" \n " };" \n " };" \n " } else {" \n " _player setVariable[""LAST_AUTH_CHECK"", nil];" \n " };" \n " };" \n "};" \n "" \n "_cleanIt = {" \n " if !(isNull _this) then {" \n " private _lastCheck = _this getVariable ""LAST_CHECK"";" \n " if (isNil ""_lastCheck"") then {" \n " _this setVariable[""LAST_CHECK"", diag_tickTime];" \n " _lastCheck = diag_tickTime;" \n " };" \n " if (diag_tickTime - _lastCheck > 1200) then {" \n " private _list = (_this nearEntities [[""Epoch_Male_F"",""Epoch_Female_F"",""LandVehicle"",""Ship"",""Air"",""Tank""], 45]) select {isPlayer _x};" \n " if (_list isEqualTo []) then {" \n " _this setVariable [""LAST_CHECK"",nil];" \n " //diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n " deleteVehicle _this;" \n " };" \n " };" \n " };" \n "};" \n "" \n "_cleanIt2 = {" \n " if !(isNull _this) then {" \n " private _removed = false;" \n " private _lastCheck = _this getVariable ""LAST_CHECK"";" \n " if (isNil ""_lastCheck"") then {" \n " _this setVariable[""LAST_CHECK"", diag_tickTime];" \n " _lastCheck = diag_tickTime;" \n " };" \n " if (diag_tickTime - _lastCheck > 1200) then {" \n " private _list = (_this nearEntities [[""Epoch_Male_F"",""Epoch_Female_F"",""LandVehicle"",""Ship"",""Air"",""Tank""], 45]) select {isPlayer _x};" \n " if (_list isEqualTo []) then {" \n " {" \n " deleteVehicle _x;" \n " }forEach nearestObjects[_this, [""WeaponHolder""], 2];" \n " _this setVariable [""LAST_CHECK"",nil];" \n " //diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n " deleteVehicle _this;" \n " _removed = true;" \n " };" \n " };" \n " if !(_removed) then {" \n " EPOCH_cleanupQueue pushBack _this;" \n " };" \n " };" \n "};" \n ""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links { /*%FSM*/ class _ { priority = 0.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"true"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ }; }; /*%FSM*/ /*%FSM*/ class Process { name = "Process"; init = /*%FSM*/""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links { /*%FSM*/ class CMD_queue { priority = 10.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_cmdRun && ((diag_tickTime - _delayTimeCMD) > _cmdDelay)"/*%FSM*/; action=/*%FSM*/"_delayTimeCMD = diag_tickTime;" \n "" \n "// Execute next item from CMD queue" \n "_response = ""epochserver"" callExtension format[""600|%1"",_instanceID];" \n "if (_response != '[1,""""]') then { " \n " _output = call compile _response; " \n " if (_output select 0 == 1 && _output select 1 != """") then {" \n " 0 spawn compile (_output select 1);" \n " };" \n "};" \n ""/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Cleanup { priority = 8.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _lastObjectCleanup1) > 1)"/*%FSM*/; action=/*%FSM*/"_lastObjectCleanup1 = diag_tickTime;" \n "" \n "if !(_cleanupItems isEqualTo []) then {" \n " (_cleanupItems deleteAt 0) call _cleanIt;" \n "};" \n "if !(EPOCH_cleanupQueue isEqualTo []) then {" \n " (EPOCH_cleanupQueue deleteAt 0) call _cleanIt2;" \n "};"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Cleanup_Handler { priority = 8.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _lastObjectCleanup) > 300)"/*%FSM*/; action=/*%FSM*/"_lastObjectCleanup = diag_tickTime;" \n "" \n "// TODO need better way allMissionObjects is not performant" \n "if (_cleanupItems isEqualTo []) then {" \n " _cleanupItems = allMissionObjects ""groundWeaponHolder"" + entities ""WeaponHolderSimulated"";" \n "};"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Save_Vehicles { priority = 4.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _delayTimeSaveVeh) > 1)"/*%FSM*/; action=/*%FSM*/"_delayTimeSaveVeh = diag_tickTime;" \n "if !(EPOCH_saveVehQueue isEqualTo []) then {" \n " _saveVehicle = EPOCH_saveVehQueue deleteAt 0;" \n " if !(isNull _saveVehicle) then {" \n " _saveVehicle call EPOCH_server_save_vehicle;" \n " };" \n "};" \n "if !(EPOCH_saveStorQueue isEqualTo []) then {" \n " _saveStorage = EPOCH_saveStorQueue deleteAt 0;" \n " if !(isNull _saveStorage) then {" \n " _saveStorage call EPOCH_server_save_storage;" \n " };" \n "};" \n "if !(EPOCH_saveBuildQueue isEqualTo []) then {" \n " _saveBuilding = EPOCH_saveBuildQueue deleteAt 0;" \n " if !(isNull _saveBuilding) then {" \n " _saveBuilding call EPOCH_saveBuilding;" \n " };" \n "};"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Save_Players { priority = 3.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"!(_players isEqualTo _prevPlayers)"/*%FSM*/; action=/*%FSM*/"_prevPlayers = _players;" \n "" \n "if (_savePlayerList) then {" \n " [""PLAYERS"", (call EPOCH_fn_InstanceID), _players] call EPOCH_fnc_server_hiveSET;" \n "};" \n "// Group cleanup" \n "{if (units _x isEqualTo []) then {deleteGroup _x}}forEach allGroups"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Vehicle_and_Player { priority = 1.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _delayTimeSim) > 5)"/*%FSM*/; action=/*%FSM*/"_delayTimeSim = diag_tickTime;" \n "_playersTemp = [];" \n "{" \n " private _vehicle = vehicle _x;" \n " // if player is inside a vehicle check vehicle is in allowed safe vehicles list." \n " if (_vehicle != _x && {!(typeOf _vehicle in _safeVehicles)}) then {" \n " // check if vehicle has token set server side and ignore vehicle if was spawned by a Curator (zeus)" \n " if ((objectCurators _vehicle) isEqualTo [] && {!(_vehicle call EPOCH_server_getVToken)}) then {" \n " diag_log format[""ADMIN: Invalid Vehicle detected and deleted %1 with %2 driving"",_vehicle,_x];" \n " deleteVehicle _vehicle;" \n " };" \n " };" \n "" \n " private _pUID = getPlayerUID _x;" \n " // Add all player UIDs to array for use later." \n " if (_pUID != """") then { _playersTemp pushBack _pUID; };" \n "" \n " // If player is not admin check perform checks." \n " if !(_x call EPOCH_server_isPAdmin) then {" \n " // check if player is hidden and if so force back visable." \n " if (isObjectHidden _x) then {" \n " _x hideObjectGlobal false;" \n " diag_log format[""ADMIN: Warning!!! player was hidden and forced visable %1"",_x];" \n " };" \n " // check player has authenticated with reverse token check." \n " if (_pUID != """") then {" \n " [_pUID, _x] call _checkAuth;" \n " };" \n " };" \n "" \n "}forEach allPlayers;" \n "_players = _playersTemp;" \n ""/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Events_Manager { priority = 0.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _pvehTime) > 1)"/*%FSM*/; action=/*%FSM*/"// Epoch Events" \n "_pvehTime = diag_tickTime;" \n "_events append (missionNamespace getVariable [""EPOCH_dynamicEvents"", []]);" \n "missionNamespace setVariable [""EPOCH_dynamicEvents"", nil];" \n "_newEvents = [];" \n "{" \n " _x params [""_time"", ""_scriptName"", [""_runAtStart"",0], [""_usePrePostfix"",1], [""_runNumTimes"",-1], [""_input"",[]], [""_disallowedWorlds"",[]] ];" \n " _scriptParams = [];" \n " _scriptcmdMode = ""execVM"";" \n " if (_scriptName isEqualType []) then {" \n " _scriptParams = _scriptName param [0,[]];" \n " _scriptcmdMode = _scriptName param [1,""call""];" \n " _scriptName = _scriptName param [2,""""];" \n " };" \n " _eventKey = format[""EPOCH_EVENT_%1"", _scriptName];" \n " _eventCounter = format[""EPOCH_EVENT_COUNTER_%1"", _scriptName];" \n " _lastTime = missionNamespace getVariable _eventKey;" \n " _counter = missionNamespace getVariable [_eventCounter,0];" \n " if (isNil ""_lastTime"") then {" \n " _startTime = diag_tickTime;" \n " if (_runAtStart isEqualTo 1) then {" \n " _startTime = diag_tickTime - _time;" \n " };" \n " missionNamespace setVariable[_eventKey, _startTime];" \n " _lastTime = _startTime;" \n " };" \n " if ((_counter >= _runNumTimes && _runNumTimes != -1) || worldName in _disallowedWorlds) then {" \n " diag_log format[""DEBUG: server event removed %1"", _scriptName];" \n " missionNamespace setVariable[_eventKey, nil];" \n " missionNamespace setVariable[_eventCounter, nil];" \n " } else {" \n " _newEvents pushBack _x;" \n " if ((diag_tickTime - _lastTime) >= _time) then {" \n " missionNamespace setVariable[_eventKey, diag_tickTime];" \n " _preFix = """";" \n " _postFix = """";" \n " if (_usePrePostfix == 1) then {" \n " _preFix = ""\epoch_server_settings\EpochEvents\"";" \n " _postFix = "".sqf"";" \n " };" \n " if (_usePrePostfix == 2) then {" \n " _preFix = ""\epoch_server_events\EpochEvents\"";" \n " _postFix = "".sqf"";" \n " };" \n " switch (_scriptcmdMode) do {" \n " case (""call""): {" \n " // call" \n " _scriptParams call (missionNamespace getVariable [_scriptName, {}]);" \n " };" \n " case (""spawn""): {" \n " // spawn" \n " _scriptParams spawn (missionNamespace getVariable [_scriptName, {}]);" \n " };" \n " default {" \n " // execVM" \n " _handle = _input execVM format[""%1%2%3"",_preFix,_scriptName,_postFix];" \n " };" \n " };" \n " _counter = _counter + 1;" \n " missionNamespace setVariable[_eventCounter, _counter];" \n " diag_log format[""DEBUG: server event %1"", _scriptName];" \n " };" \n " };" \n "} forEach _events;" \n "// remove expired events" \n "_events = _newEvents;"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Server_FPS { priority = 0.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _serverFpsTime) > 30) && _serverFPSCheckFine"/*%FSM*/; action=/*%FSM*/"_serverFpsTime = diag_tickTime;" \n "" \n "if (_oldFPS isEqualTo EPOCH_diag_fps) then {" \n " _currentFPS = round(diag_fps);" \n " if !(_oldFPS isEqualTo _currentFPS) then {" \n " missionNamespace setVariable [""EPOCH_diag_fps"",_currentFPS,true];" \n " _oldFPS = _currentFPS;" \n " };" \n "} else {" \n " missionNamespace setVariable [""EPOCH_diag_fps"", compileFinal """",true];" \n " _serverFPSCheckFine = false;" \n "};" \n ""/*%FSM*/; }; /*%FSM*/ /*%FSM*/ class Forced_Restart { priority = 0.000000; to="Process"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"((diag_tickTime - _forcedrestartTimer) > 20)"/*%FSM*/; action=/*%FSM*/"// restart script" \n "_forcedrestartTimer = diag_tickTime;" \n "if (_scriptBasedRestart) then {" \n " if (diag_tickTime >= _forceRestartTimeWarning) then {" \n " if (!_serverLocked) then {" \n " diag_log ""server shutdown: locked"";" \n " _serverLocked = true;" \n " [""lock""] call EPOCH_serverCommand;" \n " } else {" \n " if (allPlayers isEqualTo []) then {" \n " [""shutdown""] call EPOCH_serverCommand;" \n " diag_log ""server shutdown: now"";" \n " };" \n " };" \n " _restartIn = round((_forceRestartTime-diag_tickTime)/60);" \n " if (_prevRestartIn != _restartIn) then {" \n " _prevRestartIn = _restartIn;" \n " if (_restartIn > 1) then {" \n " [""message"", format[""Server restart in %1 minutes"",_restartIn]] call EPOCH_serverCommand;" \n " } else {" \n " [""message"", format[""Server restart in %1 minute"",1]] call EPOCH_serverCommand;" \n " };" \n " };" \n " };" \n " // kick all remaining players before shutdown to force player save" \n " if (diag_tickTime >= _forceRestartTime) then {" \n " if (_serverRestarting) then {" \n " [""shutdown""] call EPOCH_serverCommand;" \n " diag_log ""server shutdown: now"";" \n " } else {" \n " {" \n " [""kick"", _x , ""Server Restarting""] call EPOCH_serverCommand;" \n " } forEach allPlayers;" \n " _serverRestarting = true;" \n " };" \n " };" \n "};" \n ""/*%FSM*/; }; /*%FSM*/ }; }; /*%FSM*/ }; initState="Init"; finalStates[] = { }; }; /*%FSM*/