Fnc_ServerFPSReport.SQF 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. Fnc_ServerFPSReport.SQF
  3. An on-the-fly server and headless client FPS report that sends information on owned AI and vehicles
  4. as well as any of the two that might have cached ones
  5. Check Config_SCFramework for configuration options
  6. */
  7. diag_log format["(SCFramework) ServerFPSReport Script started."];
  8. // Action and default global var
  9. s_player_FPSReport = -1;
  10. ServerFPSReport_Enabled = false;
  11. SCFramework_DisplayFPSReport = {
  12. _DoLoop = true;
  13. while {_DoLoop} do {
  14. ServerFPSReport_Received = [];
  15. SCFramework_ServerFPSRequest = SCFramework_ClientID;
  16. publicVariable "SCFramework_ServerFPSRequest";
  17. sleep 1; // Wait for response (Server_SCFramework)
  18. // Re-organize
  19. _SArray = [0,0,0,0,0,0];
  20. _HC1Array = [0,0,0,0,0,0];
  21. _HC2Array = [0,0,0,0,0,0];
  22. _HC3Array = [0,0,0,0,0,0];
  23. _HC4Array = [0,0,0,0,0,0];
  24. _HC5Array = [0,0,0,0,0,0];
  25. {
  26. _ProcessArray = _x;
  27. _Name = _ProcessArray select 0;
  28. switch (_Name) do {
  29. case "Server": { _SArray = _ProcessArray; };
  30. case "HC1": { _HC1Array = _ProcessArray; };
  31. case "HC2": { _HC2Array = _ProcessArray; };
  32. case "HC3": { _HC3Array = _ProcessArray; };
  33. case "HC4": { _HC4Array = _ProcessArray; };
  34. case "HC5": { _HC5Array = _ProcessArray; };
  35. };
  36. } forEach ServerFPSReport_Received;
  37. // Create main array to be split up
  38. ServerFPSReport_Received = [_SArray,_HC1Array,_HC2Array,_HC3Array,_HC4Array,_HC5Array];
  39. // Gather module names
  40. _SrvName = "";
  41. _HC1Name = "";
  42. _HC2Name = "";
  43. _HC3Name = "";
  44. _HC4Name = "";
  45. _HC5Name = "";
  46. if (BDC_SCFramework_ServerFPSReport_ModulesNames select 0 != "") then {
  47. _SrvName = format["\n%1",BDC_SCFramework_ServerFPSReport_ModulesNames select 0];
  48. };
  49. if (BDC_SCFramework_ServerFPSReport_ModulesNames select 1 != "") then {
  50. _HC1Name = format["\n%1",BDC_SCFramework_ServerFPSReport_ModulesNames select 1];
  51. };
  52. if (BDC_SCFramework_ServerFPSReport_ModulesNames select 2 != "") then {
  53. _HC2Name = format["\n%1",BDC_SCFramework_ServerFPSReport_ModulesNames select 2];
  54. };
  55. if (BDC_SCFramework_ServerFPSReport_ModulesNames select 3 != "") then {
  56. _HC3Name = format["\n%1",BDC_SCFramework_ServerFPSReport_ModulesNames select 3];
  57. };
  58. if (BDC_SCFramework_ServerFPSReport_ModulesNames select 4 != "") then {
  59. _HC4Name = format["\n%1",BDC_SCFramework_ServerFPSReport_ModulesNames select 4];
  60. };
  61. if (BDC_SCFramework_ServerFPSReport_ModulesNames select 5 != "") then {
  62. _HC5Name = format["\n%1",BDC_SCFramework_ServerFPSReport_ModulesNames select 5];
  63. };
  64. // Create vars for display
  65. _SA = ServerFPSReport_Received select 0;
  66. _SFPS = _SA select 1; _SOAI = _SA select 2; _SCAI = _SA select 3; _SLAI = (_SOAI - _SCAI); _SOV = _SA select 4; _SCV = _SA select 5; _SAV = _SOV - _SCV;
  67. _HC1A = ServerFPSReport_Received select 1;
  68. _HC1FPS = _HC1A select 1; _HC1OAI = _HC1A select 2; _HC1CAI = _HC1A select 3; _HC1LAI = (_HC1OAI - _HC1CAI);
  69. _HC2A = ServerFPSReport_Received select 2;
  70. _HC2FPS = _HC2A select 1; _HC2OAI = _HC2A select 2; _HC2CAI = _HC2A select 3; _HC2LAI = (_HC2OAI - _HC2CAI);
  71. _HC3A = ServerFPSReport_Received select 3;
  72. _HC3FPS = _HC3A select 1; _HC3OAI = _HC3A select 2; _HC3CAI = _HC3A select 3; _HC3LAI = (_HC3OAI - _HC3CAI);
  73. _HC4A = ServerFPSReport_Received select 4;
  74. _HC4FPS = _HC4A select 1; _HC4OAI = _HC4A select 2; _HC4CAI = _HC4A select 3; _HC4LAI = (_HC4OAI - _HC4CAI);
  75. _HC5A = ServerFPSReport_Received select 5;
  76. _HC5FPS = _HC5A select 1; _HC5OAI = _HC5A select 2; _HC5CAI = _HC5A select 3; _HC5LAI = (_HC5OAI - _HC5CAI);
  77. _TActiveAI = 0;
  78. _TActiveAI = _SLAI + _HC1LAI + _HC2LAI + _HC3LAI + _HC4LAI + _HC5LAI;
  79. //_TVActive = _HC1AV + _HC2AV + _HC3AV + _HC4AV + _HC5AV;
  80. _LocalGroups = 0;
  81. _LocalAI = 0;
  82. _LocalGroupsStr = "";
  83. _LocalGroupsCont = 0;
  84. {
  85. if (local _x) then {
  86. if (group player != _x && (count units _x > 0)) then {
  87. _LocalGroups = _LocalGroups + 1;
  88. _LocalAI = _LocalAI + (count units _x);
  89. _ZeusFlagged = _x getVariable ["ZeusFlagged",false];
  90. _Str = format["%1 %2\n",_x,side _x];
  91. if (_ZeusFlagged) then {
  92. _Str = format["%1 %2 (Flagged)\n",_x,side _x];
  93. };
  94. _LocalGroupsCont = _LocalGroupsCont + 1;
  95. if (_LocalGroupsCont == 1) then {
  96. _LocalGroupsStr = "\nLocally Owned Groups:\n";
  97. };
  98. _LocalGroupsStr = _LocalGroupsStr + _Str;
  99. };
  100. };
  101. } forEach allGroups;
  102. _AutomaticOffloading = "Enabled";
  103. if (!BDC_SCFramework_HCOffloading_AutomaticOffloading_Enable) then {
  104. _AutomaticOffloading = "Disabled";
  105. };
  106. _TransferZeusOpAI = "Enabled";
  107. if (!BDC_SCFramework_HCOffloading_AutomaticOffLoading_TransferZeusOperatorAI_Enable) then {
  108. _TransferZeusOpAI = "Disabled";
  109. };
  110. // Display hint
  111. hint format [
  112. "Server/HC FPS Report:\n\nServer - %2 FPS%1\nAI: %3 Active | %4 Owned | %5 Cached\nVehs: %6 Active | %7 Total | %8 Cached\n\n
  113. Headless Client 1 - %10 FPS%9\nAI: %11 Active | %12 Owned | %13 Cached\n\n
  114. Headless Client 2 - %15 FPS%14\nAI: %16 Active | %17 Owned | %18 Cached\n\n
  115. Headless Client 3 - %20 FPS%19\nAI: %21 Active | %22 Owned | %23 Cached\n\n
  116. Headless Client 4 - %25 FPS%24\nAI: %26 Active | %27 Owned | %28 Cached\n\n
  117. Headless Client 5 - %30 FPS%29\nAI: %31 Active | %32 Owned | %33 Cached\n\n
  118. %34 Total Active Server AI\n\nAutomatic HCOffloading: %35\nAuto-Transfer Zeus-Op AI: %36\n\nLocally Owned Groups: %37 (%38 AI)\n
  119. %39",
  120. _SrvName,_SFPS,_SLAI,_SOAI,_SCAI,_SAV,_SOV,_SCV,
  121. _HC1Name,_HC1FPS,_HC1LAI,_HC1OAI,_HC1CAI,
  122. _HC2Name,_HC2FPS,_HC2LAI,_HC2OAI,_HC2CAI,
  123. _HC3Name,_HC3FPS,_HC3LAI,_HC3OAI,_HC3CAI,
  124. _HC4Name,_HC4FPS,_HC4LAI,_HC4OAI,_HC4CAI,
  125. _HC5Name,_HC5FPS,_HC5LAI,_HC5OAI,_HC5CAI,
  126. _TActiveAI,_AutomaticOffloading,_TransferZeusOpAI,
  127. _LocalGroups,_LocalAI,_LocalGroupsStr
  128. ];
  129. if (!ServerFPSReport_Enabled) then { _DoLoop = false; hint ""; };
  130. };
  131. };