Initial commit
This commit is contained in:
140
functions/init/fn_initServer.sqf
Normal file
140
functions/init/fn_initServer.sqf
Normal file
@@ -0,0 +1,140 @@
|
||||
if (isServer) then {
|
||||
|
||||
_fixedAssets = [
|
||||
["Ares", "USAF_A10", 0],
|
||||
["Odyssey", "RHSGREF_A29B_HIDF", 0],
|
||||
["Hercules", "USAF_C130J", 0]
|
||||
|
||||
];
|
||||
|
||||
_rotaryAssets = [
|
||||
["Apollo", "RHS_MELB_MH6M", 0],
|
||||
["Artemis", "RHS_MELB_AH6M", 0],
|
||||
["Icarus", "RHS_MELB_H6M", 0],
|
||||
["Achilles", "RHS_CH_47F", 0],
|
||||
["Hades", "ej_MH60MDAP4", 0],
|
||||
["Griffin", "RHS_UH60M", 0],
|
||||
["Dustoff", "RHS_UH60M_MEV2", 0],
|
||||
["Pegasus", "B_T_VTOL_01_INFANTRY_F", 0],
|
||||
["Spartan", "B_T_VTOL_01_ARMED_F", 0],
|
||||
["Orion", "RHS_AH64D", 0],
|
||||
["Athena", "RHS_AH1Z", 0],
|
||||
["Homer", "RHS_UH1Y", 0],
|
||||
["Atlas", "rhsusf_CH53E_USMC", 0]
|
||||
|
||||
];
|
||||
|
||||
_homes = allMissionObjects "ModuleRespawnPosition_F";
|
||||
|
||||
{
|
||||
_home = _x;
|
||||
{
|
||||
_a = _home nearEntities [ _x select 1, 750];
|
||||
_x set [2, (_x select 2) + count _a];
|
||||
|
||||
} forEach _fixedAssets;
|
||||
} forEach _homes;
|
||||
|
||||
missionNamespace setVariable ["milsim_var_fixedAssets", _fixedAssets];
|
||||
|
||||
{
|
||||
_home = _x;
|
||||
{
|
||||
_a = _home nearEntities [ _x select 1, 750];
|
||||
_x set [2, (_x select 2) + count _a];
|
||||
|
||||
} forEach _rotaryAssets;
|
||||
} forEach _homes;
|
||||
|
||||
missionNamespace setVariable ["milsim_var_rotaryAssets", _rotaryAssets];
|
||||
|
||||
publicVariable "milsim_var_fixedAssets";
|
||||
publicVariable "milsim_var_rotaryAssets";
|
||||
|
||||
// Initializes the Dynamic Groups framework and groups
|
||||
["Initialize", [true]] call BIS_fnc_dynamicGroups;
|
||||
|
||||
missionNamespace setVariable["milsim_raw_cps", 0];
|
||||
missionNamespace setVariable["milsim_cps", 0];
|
||||
|
||||
publicVariable "milsim_raw_cps";
|
||||
publicVariable "milsim_cps";
|
||||
|
||||
_cpsPFH = [
|
||||
{
|
||||
|
||||
[] spawn {
|
||||
// warning: while loop without suspension executes multiple times per frame
|
||||
private _counter = 0;
|
||||
private _endTime = diag_tickTime + 5;
|
||||
private _frameNo = diag_frameNo;
|
||||
while { diag_tickTime < _endTime } do
|
||||
{
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
// in an empty mission, the _counter may go well over 2000 times per frame!
|
||||
diag_log text format ["[MILSIM] (initServer) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)];
|
||||
missionNamespace setVariable["milsim_raw_cps", _counter / (diag_frameNo - _frameNo)];
|
||||
publicVariable "milsim_raw_cps";
|
||||
|
||||
// with suspension
|
||||
private _counter = 0;
|
||||
private _endTime = diag_tickTime + 5;
|
||||
private _frameNo = diag_frameNo;
|
||||
while { diag_tickTime < _endTime } do
|
||||
{
|
||||
_counter = _counter + 1;
|
||||
uiSleep 0.001; // waits at least 1 frame
|
||||
};
|
||||
// _counter says one per frame, as expected
|
||||
diag_log text format ["[MILSIM] (initServer) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)];
|
||||
missionNamespace setVariable["milsim_cps", _counter / (diag_frameNo - _frameNo)];
|
||||
publicVariable "milsim_cps";
|
||||
|
||||
["milsim_serverEfficiency", [ [ ["float", "milsim_raw_cps", missionNamespace getVariable ["milsim_raw_cps", -1]], ["float", "milsim_cps", missionNamespace getVariable ["milsim_cps", -1]] ] ] ] call CBA_fnc_localEvent;
|
||||
|
||||
};
|
||||
|
||||
},
|
||||
300,
|
||||
[],
|
||||
{ diag_log text "[MILSIM] (initServer) CPS PFH loaded" },
|
||||
{ diag_log text "IF YOU SEE THIS CPS PFH FUCKED UP" },
|
||||
{ true },
|
||||
{ false },
|
||||
[]
|
||||
] call CBA_fnc_createPerFrameHandlerObject;
|
||||
|
||||
|
||||
missionNamespace setVariable ["milsim_cps_handler", _cpsPFH];
|
||||
|
||||
_playerCpsPFH = [
|
||||
{
|
||||
|
||||
diag_log text "[MILSIM] (initServer) ** Player Executions **";
|
||||
|
||||
{
|
||||
diag_log ( format ["%1: ( %2, %3 )", name _x, _x getVariable ["milsim_player_raw_cps",-1], _x getVariable ["milsim_player_cps",-1] ] )
|
||||
} forEach allPlayers;
|
||||
|
||||
diag_log text "[MILSIM] (initServer) ***********************";
|
||||
|
||||
},
|
||||
300,
|
||||
[],
|
||||
{ diag_log text "[MILSIM] (initServer) Player CPS PFH loaded" },
|
||||
{ diag_log text "IF YOU SEE THIS CPS PFH FUCKED UP" },
|
||||
{ true },
|
||||
{ false },
|
||||
[]
|
||||
] call CBA_fnc_createPerFrameHandlerObject;
|
||||
|
||||
missionNamespace setVariable ["milsim_player_cps_handler", _playerCpsPFH];
|
||||
|
||||
|
||||
missionNamespace setVariable ["milsim_complete", true];
|
||||
diag_log text "[MILSIM] (initServer) milsim_complete";
|
||||
|
||||
publicVariable "milsim_complete";
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user