diagnostics.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. //
  19. // Filename: diagnostics.cpp
  20. // Project: Network.lib, for Commando
  21. // Author: Tom Spencer-Smith
  22. // Date: Dec 1998
  23. // Description:
  24. //
  25. #include "diagnostics.h"
  26. #include <stdio.h>
  27. #include "wwdebug.h"
  28. #include "assets.h"
  29. #include "font3d.h"
  30. #include "render2d.h"
  31. //
  32. // Add any includes for exposed interfaces that you are diagnosing
  33. //
  34. #include "devoptions.h"
  35. #include "cnetwork.h"
  36. #include "gamedata.h"
  37. #include "networkobjectmgr.h"
  38. #include "serverfps.h"
  39. #include "sbbomanager.h"
  40. #include "singlepl.h"
  41. #include "gameobjmanager.h"
  42. #include "gamemode.h"
  43. #include "humanphys.h"
  44. #include "playermanager.h"
  45. #include "useroptions.h"
  46. #include "packetmgr.h"
  47. #include "apppacketstats.h"
  48. #include "connect.h"
  49. #include "wwprofile.h"
  50. #include "vehicle.h"
  51. #include "csdamageevent.h"
  52. #include "specialbuilds.h"
  53. #include "consolemode.h"
  54. #include "gametype.h"
  55. static int RendererFps;
  56. static int RendererSFps;
  57. static int RendererPing;
  58. static int RendererBandwidthBps;
  59. static bool RendererGodStatus;
  60. static bool RendererVipStatus;
  61. //
  62. // Class statics
  63. //
  64. Render2DTextClass * cDiagnostics::PRenderer = NULL;
  65. Font3DInstanceClass * cDiagnostics::PFont = NULL;
  66. float cDiagnostics::DiagnosticX = 0;
  67. float cDiagnostics::DiagnosticY = 0;
  68. //-----------------------------------------------------------------------------
  69. void cDiagnostics::Init(void)
  70. {
  71. if (!ConsoleBox.Is_Exclusive()) {
  72. WWASSERT(WW3DAssetManager::Get_Instance() != NULL);
  73. PFont = WW3DAssetManager::Get_Instance()->Get_Font3DInstance("FONT6x8.TGA");
  74. WWASSERT(PFont != NULL);
  75. SET_REF_OWNER(PFont);
  76. PFont->Set_Mono_Spaced();
  77. PRenderer = new Render2DTextClass(PFont);
  78. WWASSERT(PRenderer != NULL);
  79. RectClass rect = Render2DClass::Get_Screen_Resolution();
  80. PRenderer->Set_Coordinate_Range(rect);
  81. DiagnosticX = 10;
  82. //DiagnosticY = 10;
  83. RendererFps=0;
  84. RendererSFps=0;
  85. RendererPing = 0;
  86. RendererBandwidthBps = 0;
  87. RendererGodStatus=false;
  88. RendererVipStatus=false;
  89. }
  90. }
  91. //-----------------------------------------------------------------------------
  92. void cDiagnostics::Close(void)
  93. {
  94. if (PFont != NULL) {
  95. PFont->Release_Ref();
  96. PFont = NULL;
  97. }
  98. if (PRenderer != NULL) {
  99. delete PRenderer;
  100. PRenderer = NULL;
  101. }
  102. }
  103. //-----------------------------------------------------------------------------
  104. void cDiagnostics::Show_Object_Tally(void)
  105. {
  106. cAppPacketStats::Update_Object_Tally();
  107. Add_Diagnostic("");
  108. Add_Diagnostic("Object stats (reset with APTR command):");
  109. Add_Diagnostic(cAppPacketStats::Get_Heading());
  110. for (BYTE i = 0; i < APPPACKETTYPE_COUNT; i++)
  111. {
  112. Add_Diagnostic(cAppPacketStats::Get_Description(i));
  113. }
  114. }
  115. //-----------------------------------------------------------------------------
  116. void cDiagnostics::Add_Diagnostic(LPCSTR format, ...)
  117. {
  118. if (PRenderer) {
  119. va_list va;
  120. char buffer[1024];
  121. va_start(va, format);
  122. ::vsprintf(buffer, format, va);
  123. WWASSERT(PRenderer != NULL);
  124. PRenderer->Set_Location(Vector2(DiagnosticX, DiagnosticY));
  125. PRenderer->Draw_Text(buffer);
  126. WWASSERT(PRenderer->Peek_Font() != NULL);
  127. DiagnosticY += (int)(PRenderer->Peek_Font()->Char_Height() * 1.2);
  128. }
  129. }
  130. //-----------------------------------------------------------------------------
  131. void cDiagnostics::Render(void)
  132. {
  133. if (PFont == NULL || PRenderer == NULL) {
  134. return;
  135. }
  136. #ifdef BETACLIENT
  137. PRenderer->Reset();
  138. RectClass rect = Render2DClass::Get_Screen_Resolution();
  139. PRenderer->Set_Location(Vector2(rect.Left + 5, rect.Bottom - 10));
  140. PRenderer->Draw_Text("BETACLIENT");
  141. PRenderer->Render();
  142. #endif // BETACLIENT
  143. #ifdef FREEDEDICATEDSERVER
  144. PRenderer->Reset();
  145. RectClass rect = Render2DClass::Get_Screen_Resolution();
  146. PRenderer->Set_Location(Vector2(rect.Left + 5, rect.Bottom - 10));
  147. PRenderer->Draw_Text("FREEDEDICATEDSERVER");
  148. PRenderer->Render();
  149. #endif // FREEDEDICATEDSERVER
  150. #ifdef MULTIPLAYERDEMO
  151. PRenderer->Reset();
  152. RectClass rect = Render2DClass::Get_Screen_Resolution();
  153. PRenderer->Set_Location(Vector2(rect.Left + 5, rect.Bottom - 10));
  154. PRenderer->Draw_Text("MULTIPLAYER DEMO");
  155. PRenderer->Render();
  156. #endif // MULTIPLAYERDEMO
  157. bool changed=false;
  158. if (cDevOptions::ShowFps.Is_True()) {
  159. int fps=cNetwork::Get_Fps();
  160. if (fps!=RendererFps) {
  161. RendererFps=fps;
  162. changed=true;
  163. }
  164. if (cNetwork::I_Am_Only_Client())
  165. {
  166. fps=cServerFps::Get_Instance()->Get_Fps();
  167. if (fps!=RendererSFps) {
  168. RendererSFps=fps;
  169. changed=true;
  170. }
  171. if (cNetwork::PClientConnection) {
  172. cRemoteHost *server = cNetwork::PClientConnection->Get_Remote_Host(0);
  173. if (server) {
  174. int ping = server->Get_Average_Internal_Pingtime_Ms();
  175. if (ping && ping != RendererPing) {
  176. RendererPing = ping;
  177. changed = true;
  178. }
  179. int bps = PacketManager.Get_Compressed_Bandwidth_In(&server->Get_Address());
  180. if (bps && bps != RendererBandwidthBps) {
  181. RendererBandwidthBps = bps;
  182. changed = true;
  183. }
  184. }
  185. }
  186. } else {
  187. int bps = PacketManager.Get_Total_Compressed_Bandwidth_Out();
  188. if (bps && bps != RendererBandwidthBps) {
  189. RendererBandwidthBps = bps;
  190. changed = true;
  191. }
  192. }
  193. }
  194. // If we displayed fps last frame, turn it off now
  195. else {
  196. if (RendererFps) {
  197. changed=true;
  198. }
  199. RendererFps=0;
  200. }
  201. #ifdef WWDEBUG
  202. bool god_status = cDevOptions::ShowGodStatus.Is_True() && cNetwork::I_Am_Client();
  203. if (god_status!=RendererGodStatus) {
  204. RendererGodStatus=god_status;
  205. changed=true;
  206. }
  207. bool vip_status = cNetwork::I_Am_Client();
  208. if (vip_status != RendererVipStatus) {
  209. RendererVipStatus = vip_status;
  210. changed = true;
  211. }
  212. // If diagnostics are displayed, changes happen most likely every frame
  213. if (cDevOptions::ShowDiagnostics.Is_True() || cDevOptions::ShowObjectTally.Is_True()) {
  214. changed=true;
  215. }
  216. #endif //WWDEBUG
  217. if (cDevOptions::ShowFps.Is_True()) {
  218. // Stop the flicker
  219. changed = true;
  220. }
  221. // Render only if changed!
  222. if (!changed) {
  223. PRenderer->Render();
  224. return;
  225. }
  226. PRenderer->Reset();
  227. DiagnosticY = 75;
  228. if (cDevOptions::ShowFps.Is_True()) {
  229. StringClass fps_text;
  230. fps_text.Format("FPS = %3d", RendererFps);
  231. if (cNetwork::I_Am_Only_Client())
  232. {
  233. StringClass server_fps_text;
  234. server_fps_text.Format(", SFPS = %3d", RendererSFps);
  235. fps_text += server_fps_text;
  236. if (cNetwork::PClientConnection && cNetwork::PClientConnection->Get_Remote_Host(0)) {
  237. StringClass ping_time;
  238. ping_time.Format(", PING = %4d", min(9999, RendererPing));
  239. fps_text += ping_time;
  240. }
  241. }
  242. if (!IS_SOLOPLAY) {
  243. StringClass bps_text;
  244. bps_text.Format(", KBPS = %4d", RendererBandwidthBps / 1024);
  245. fps_text += bps_text;
  246. }
  247. float width = PFont->String_Width(fps_text);
  248. RectClass rect = Render2DClass::Get_Screen_Resolution();
  249. PRenderer->Set_Location(Vector2(rect.Right - width - 5, rect.Top + 2));
  250. PRenderer->Draw_Text(fps_text);
  251. }
  252. #ifdef WWDEBUG
  253. //
  254. // Show god status
  255. //
  256. if (god_status) {
  257. cPlayer * p_player = cNetwork::Get_My_Player_Object();
  258. if (p_player != NULL && p_player->Invulnerable.Is_True()) {
  259. RectClass rect = Render2DClass::Get_Screen_Resolution();
  260. PRenderer->Set_Location(Vector2(rect.Left + 10, rect.Bottom - 20));
  261. PRenderer->Draw_Text("GOD");
  262. }
  263. }
  264. //
  265. // Show vip status
  266. //
  267. if (vip_status) {
  268. cPlayer * p_player = cNetwork::Get_My_Player_Object();
  269. if (p_player != NULL && p_player->Get_Damage_Scale_Factor() < 100) {
  270. RectClass rect = Render2DClass::Get_Screen_Resolution();
  271. PRenderer->Set_Location(Vector2(rect.Left + 10, rect.Bottom - 30));
  272. PRenderer->Draw_Text("VIP");
  273. }
  274. }
  275. /*
  276. if (cNetwork::I_Am_Server() && cDevOptions::ShowBandwidthBudgetOut.Is_True()) {
  277. Add_Diagnostic("BBO: %d bps\n", cNetwork::PServerConnection->Get_Bandwidth_Budget_Out());
  278. }
  279. */
  280. if (cDevOptions::ShowObjectTally.Is_True()) {
  281. Show_Object_Tally();
  282. }
  283. if (cDevOptions::ShowDiagnostics.Is_True()) {
  284. if (cNetwork::I_Am_Server()) {
  285. Add_Diagnostic("BBO (server): %d bps\n", cNetwork::PServerConnection->Get_Bandwidth_Budget_Out());
  286. }
  287. if (cNetwork::I_Am_Client()) {
  288. Add_Diagnostic("BBO (client): %d bps\n", cNetwork::PClientConnection->Get_Bandwidth_Budget_Out());
  289. Add_Diagnostic("CSC Last Ping: %d ms", CombatManager::Get_Last_Round_Trip_Ping_Ms());
  290. Add_Diagnostic("CSC Avg. Ping: %d ms", CombatManager::Get_Avg_Round_Trip_Ping_Ms());
  291. }
  292. int low = 0;
  293. int high = 0;
  294. int current = 0;
  295. cConnection::Get_Latency(low, high, current);
  296. Add_Diagnostic("latency sim: (%d, %d) : %d", low, high, current);
  297. cConnection::Get_Latency(low, high, current);
  298. Add_Diagnostic("#netobjects: %d", NetworkObjectMgrClass::Get_Object_Count());
  299. Add_Diagnostic("#players: %d", cPlayerManager::Count());
  300. if (cNetwork::I_Am_Server()) {
  301. Add_Diagnostic("NetToCombatRatio: %-5.2f", cSbboManager::Get_Net_To_Combat_Ratio());
  302. Add_Diagnostic("ThinkCount: %d", cNetwork::Get_Think_Count());
  303. }
  304. Add_Diagnostic("I_Am_Client: %d", cNetwork::I_Am_Client());
  305. Add_Diagnostic("I_Am_Server: %d", cNetwork::I_Am_Server());
  306. Add_Diagnostic("NetUpdateRate: %d", cUserOptions::NetUpdateRate.Get());
  307. Add_Diagnostic("ClientHintFactor: %5.2f", cUserOptions::ClientHintFactor.Get());
  308. Add_Diagnostic("MaxFacingPenalty: %5.2f", cUserOptions::MaxFacingPenalty.Get());
  309. if (cNetwork::I_Am_Client()) {
  310. SoldierGameObj * p_my_soldier = GameObjManager::Find_Soldier_Of_Client_ID(cNetwork::Get_My_Id());
  311. if (p_my_soldier != NULL) {
  312. int tally = p_my_soldier->Tally_Vis_Visible_Soldiers();
  313. if (tally >= 0) {
  314. Add_Diagnostic("Soldiers VV: %d", tally);
  315. } else {
  316. Add_Diagnostic("Soldiers VV: NO VIS HERE");
  317. }
  318. //Add_Diagnostic("--------------------");
  319. //Add_Diagnostic("In elevator: %d", p_my_soldier->Is_In_Elevator());
  320. }
  321. }
  322. if (PTheGameData != NULL) {
  323. Add_Diagnostic("ip addy: %s:%u",
  324. cNetUtil::Address_To_String(PTheGameData->Get_Ip_Address()),
  325. PTheGameData->Get_Port());
  326. Add_Diagnostic("mapname: %s", PTheGameData->Get_Map_Name());
  327. Add_Diagnostic("HostedGameNumber: %d", cGameData::Get_Hosted_Game_Number());
  328. }
  329. Add_Diagnostic("PacketManager:");
  330. Add_Diagnostic(" FlushFrequency: %d", PacketManager.Get_Flush_Frequency());
  331. Add_Diagnostic(" AllowDeltas: %d", PacketManager.Get_Allow_Deltas());
  332. Add_Diagnostic(" AllowCombos: %d", PacketManager.Get_Allow_Combos());
  333. //Add_Diagnostic("Frames: %d", WWProfileManager::Get_Frame_Count_Since_Reset());
  334. //
  335. // Let's track how many vehicles are in the world, and how many of those
  336. // have drivers.
  337. //
  338. int vehicle_count = 0;
  339. int vehicle_driven_count = 0;
  340. SLNode<BaseGameObj> * objnode;
  341. for (objnode = GameObjManager::Get_Game_Obj_List()->Head(); objnode; objnode = objnode->Next()) {
  342. WWASSERT(objnode->Data() != NULL);
  343. PhysicalGameObj * p_phys_obj = objnode->Data()->As_PhysicalGameObj();
  344. if (p_phys_obj != NULL && p_phys_obj->As_VehicleGameObj() != NULL) {
  345. vehicle_count++;
  346. if (p_phys_obj->As_VehicleGameObj()->Get_Driver() != NULL) {
  347. vehicle_driven_count++;
  348. }
  349. }
  350. }
  351. Add_Diagnostic("Vehicles: %d (%d with driver)", vehicle_count, vehicle_driven_count);
  352. //Add_Diagnostic("AreClientsTrusted: %d", cCsDamageEvent::Get_Are_Clients_Trusted());
  353. //Add_Diagnostic("DriverIsAlwaysGunner: %d", VehicleGameObj::Get_Driver_Is_Always_Gunner());
  354. //Add_Diagnostic("CameraLockedToTurret: %d", VehicleGameObj::Get_Camera_Locked_To_Turret());
  355. if (PTheGameData != NULL) {
  356. Add_Diagnostic("SpawnWeapons: %d", PTheGameData->SpawnWeapons.Get());
  357. /*
  358. StringClass mvp_name;
  359. PTheGameData->Get_Mvp_Name().Convert_To(mvp_name);
  360. Add_Diagnostic("MVP: %s", mvp_name.Peek_Buffer());
  361. */
  362. Add_Diagnostic("Win Type: %d", (int) PTheGameData->Get_Win_Type());
  363. Add_Diagnostic("DurationS: %u", (int) PTheGameData->Get_Game_Duration_S());
  364. }
  365. }
  366. #endif // WWDEBUG
  367. PRenderer->Render();
  368. }
  369. /*
  370. Add_Diagnostic("PTheGameData: %d", PTheGameData);
  371. if (PTheGameData != NULL) {
  372. Add_Diagnostic("ip addy: %s", cNetUtil::Address_To_String(
  373. PTheGameData->Get_Ip_Address()));
  374. Add_Diagnostic("owner: %s", PTheGameData->Get_Owner());
  375. Add_Diagnostic("map: %s", PTheGameData->Get_Map_Name());
  376. if (PTheGameData->Is_Lms()) {
  377. Add_Diagnostic("reap: %5.2f", The_Lms_Game()->Get_Reaper_Countdown_Seconds());
  378. }
  379. }
  380. //
  381. // Toss all the defunct diagnostics down here
  382. //
  383. if (cDevOptions::ShowMenuStack.Is_True()) {
  384. Add_Diagnostic("MENU STACK:");
  385. for (int i = 0; i <= MenuManager::Get_Current_Depth(); i++) {
  386. //Add_Diagnostic(" %-30s %d",
  387. // MenuManager::Get_Menu_Stack_Name_Element(i),
  388. // MenuManager::Get_Menu_Stack_Index_Element(i));
  389. Add_Diagnostic(" %-30s",
  390. MenuManager::Get_Menu_Stack_Name_Element(i));
  391. }
  392. }
  393. if (cNetwork::I_Am_Only_Client()) {
  394. Add_Diagnostic("CIM : %d", cUserOptions::ClientInterpolationModel.Get());
  395. }
  396. Add_Diagnostic("I_Am_Server: %d", cNetwork::I_Am_Server());
  397. Add_Diagnostic("I_Am_Client: %d", cNetwork::I_Am_Client());
  398. Add_Diagnostic("cNetwork::Get_Update_Count: %d", cNetwork::Get_Update_Count());
  399. if (cNetwork::I_Am_Client()) {
  400. cPlayer * p_me = cNetwork::Get_My_Player_Object();
  401. if (p_me == NULL) {
  402. Add_Diagnostic("p_me == NULL");
  403. } else {
  404. Add_Diagnostic("p_me != NULL");
  405. if (p_me->Is_Living()) {
  406. Add_Diagnostic("p_me->Is_Living()");
  407. } else {
  408. Add_Diagnostic("! p_me->Is_Living()");
  409. }
  410. Add_Diagnostic("p_me->Get_Spectatee_Id() == %d", p_me->Get_Spectatee_Id());
  411. }
  412. }
  413. //Add_Diagnostic("Menu elements = %d", MenuManager::Get_Count());
  414. //Add_Diagnostic("Get_Current_Entry_Index = %d", MenuManager::Get_Current_Entry_Index());
  415. if (cDevOptions::ShowMenuStack.Is_True()) {
  416. Add_Diagnostic("MENU STACK:");
  417. for (int i = 0; i <= MenuManager::Get_Current_Depth(); i++) {
  418. //Add_Diagnostic(" %-30s %d",
  419. // MenuManager::Get_Menu_Stack_Name_Element(i),
  420. // MenuManager::Get_Menu_Stack_Index_Element(i));
  421. Add_Diagnostic(" %-30s",
  422. MenuManager::Get_Menu_Stack_Name_Element(i));
  423. }
  424. }
  425. //Add_Diagnostic("Will_Be_Server: %d", cNetwork::Will_Be_Server());
  426. //Add_Diagnostic("Will_Be_Client: %d", cNetwork::Will_Be_Client());
  427. SLNode<BaseGameObj> * objnode;
  428. PhysicalGameObj * p_phys_obj;
  429. for (objnode = GameObjManager::Get_Game_Obj_List()->Head(); objnode; objnode = objnode->Next()) {
  430. WWASSERT(objnode->Data() != NULL);
  431. p_phys_obj = objnode->Data()->As_PhysicalGameObj();
  432. if (p_phys_obj != NULL && p_phys_obj->As_SoldierGameObj() != NULL) {
  433. Add_Diagnostic("Soldier: ID %d, Type %d",
  434. p_phys_obj->Get_ID(),
  435. p_phys_obj->Get_Player_Type());
  436. }
  437. }
  438. cRemoteHost * p_rhost = NULL;
  439. if (cNetwork::I_Am_Client_Server()) {
  440. p_rhost = cNetwork::Get_Server_Rhost(2);
  441. } else if (cNetwork::I_Am_Only_Server()) {
  442. p_rhost = cNetwork::Get_Server_Rhost(1);
  443. } else if (cNetwork::I_Am_Client()) {
  444. p_rhost = cNetwork::Get_Client_Rhost();
  445. }
  446. if (p_rhost != NULL) {
  447. float sample_target_bits = cNetUtil::Get_Net_Stats_Sample_Time_Ms() / 1000.0f * p_rhost->Get_Target_Bps();
  448. Add_Diagnostic("TargetBps : %d / %d",
  449. (int) sample_target_bits, p_rhost->Get_Target_Bps());
  450. Add_Diagnostic("STAT_BitsSent : %-d", p_rhost->Stats.StatSnapshot[STAT_BitsSent]);
  451. }
  452. if (cNetwork::I_Am_Server()) {
  453. for (int i = 0; i < 20; i++) {
  454. if (cNetwork::Get_Server_Rhost(i) != NULL) {
  455. Add_Diagnostic("Server rhost %d", i);
  456. }
  457. }
  458. }
  459. Add_Diagnostic("MENU STACK:");
  460. for (int i = 0; i <= MenuManager::Get_Current_Depth(); i++) {
  461. Add_Diagnostic(" %-30s %d",
  462. MenuManager::Get_Menu_Stack_Name_Element(i),
  463. MenuManager::Get_Menu_Stack_Index_Element(i));
  464. }
  465. Add_Diagnostic("menu_direction: %d", MenuManager::Get_Menu_Direction());
  466. Add_Diagnostic("SPG: %d", xxx);
  467. Add_Diagnostic("LEVEL : %s", SaveGameManager::Get_Level_Filename());
  468. if (cNetwork::I_Am_Server()) {
  469. Add_Diagnostic("Host 0 = %d", cNetwork::PServerConnection->Get_Remote_Host(0));
  470. Add_Diagnostic("Host 1 = %d", cNetwork::PServerConnection->Get_Remote_Host(1));
  471. }
  472. Add_Diagnostic("Duration: %d s", The_Game()->Get_Duration_Seconds());
  473. Add_Diagnostic("ServerQuickstart: %d", cUserOptions::ServerQuickstart.Get());
  474. Add_Diagnostic("ClientQuickstart: %d", cUserOptions::ClientQuickstart.Get());
  475. Add_Diagnostic("# teams = %d", cTeamManager::Count());
  476. Add_Diagnostic("Team: %d", cUserOptions::Get_Player_Type_Choice());
  477. Add_Diagnostic("Players: %d", cPlayerManager::Count());
  478. Add_Diagnostic("game channels: %d", cGameChannelList::Get_Chan_List()->Get_Count());
  479. extern int menu_direction;
  480. Add_Diagnostic("menu_direction: %d", MenuManager::Get_Menu_Direction());
  481. Add_Diagnostic("COMBAT ACTIVE: %d", GameModeManager::Find("Combat")->Is_Active());
  482. if (PLC != NULL) {
  483. Add_Diagnostic("Location: %s",
  484. Translate_Location(PLC->Get_Current_Location()));
  485. } else if (PWC != NULL) {
  486. Add_Diagnostic("Location: %s",
  487. Translate_Location(PWC->CurrentLocation));
  488. }
  489. Add_Diagnostic("ENTRIES:");
  490. int index = 0;
  491. MenuEntryClass * p_entry;
  492. do {
  493. p_entry = MenuManager::Find_Entry(index);
  494. if (p_entry != NULL) {
  495. Add_Diagnostic("%2d. %s (%d)",
  496. index, p_entry->Get_Name(), p_entry->Is_Cancel_Option());
  497. }
  498. index++;
  499. } while (p_entry != NULL);
  500. if (PWC != NULL) {
  501. SLNode<cNick> * objnode;
  502. for (objnode = PWC->Get_Banned_List()->Head(); objnode; objnode = objnode->Next()) {
  503. cNick * p_nick = objnode->Data();
  504. WWASSERT(p_nick != NULL);
  505. Add_Diagnostic("Banned : %s", p_nick->Nickname);
  506. }
  507. }
  508. */
  509. /*
  510. //#include "lcw.h"
  511. //
  512. // LCW - slow to compress, fast to decompress
  513. //
  514. char source[5000]; // datasize
  515. for (int i = 0; i < sizeof(source); i++) {
  516. source[i] = rand() % 256;
  517. }
  518. char dest[6000]; // >= datasize + datasize/128
  519. int retcode = LCW_Comp(source, dest, sizeof(source));
  520. Debug_Say(("Compressed down to %d bytes\n", retcode));
  521. */
  522. /*
  523. //#include "lzo.h"
  524. //
  525. // LZO - fast to compress, fast to decompress
  526. //
  527. #define SOURCE_BUFFER_SIZE 5000
  528. #define COMPRESSED_BUFFER_SIZE LZO_BUFFER_SIZE(SOURCE_BUFFER_SIZE)
  529. char source[SOURCE_BUFFER_SIZE];
  530. char dest[COMPRESSED_BUFFER_SIZE];
  531. char source2[SOURCE_BUFFER_SIZE];
  532. int source_size = sizeof(source);
  533. //
  534. // Put some data in source
  535. //
  536. for (int i = 0; i < source_size; i++) {
  537. source[i] = rand() % 256;
  538. }
  539. //
  540. // Compress
  541. //
  542. int compressed_size;
  543. int lzo_code = LZOCompressor::Compress((const lzo_byte *) source,
  544. (lzo_uint) source_size,
  545. (lzo_byte *) dest,
  546. (unsigned *) &compressed_size);
  547. WWASSERT(lzo_code == LZO_E_OK);
  548. WWASSERT(compressed_size <= COMPRESSED_BUFFER_SIZE);
  549. Debug_Say(("Compressed from %d to %d bytes\n",
  550. source_size, compressed_size));
  551. //
  552. // Decompress
  553. //
  554. int lzo_code_2;
  555. int decompressed_size;
  556. lzo_code_2 = LZOCompressor::Decompress((const lzo_byte*) dest,
  557. (lzo_uint) compressed_size,
  558. (lzo_byte*) source2,
  559. (unsigned *) &decompressed_size);
  560. WWASSERT(lzo_code_2 == LZO_E_OK);
  561. WWASSERT(decompressed_size <= SOURCE_BUFFER_SIZE);
  562. Debug_Say(("Decompressed from %d to %d bytes\n",
  563. compressed_size, decompressed_size));
  564. //
  565. // Compare with original
  566. //
  567. WWASSERT(decompressed_size == source_size);
  568. WWASSERT(memcmp(source, source2, source_size) == 0);
  569. */
  570. //void test(Vector3 v) {}
  571. //const Vector3 white = Vector3(1, 1, 1);
  572. //Vector3 test2(void) {return white;}
  573. /*
  574. #include "overlay.h"
  575. #include "langmode.h"
  576. #include "wolgmode.h"
  577. #include "chatshre.h"
  578. #include "useroptions.h"
  579. #include "menu.h"
  580. #include "playermanager.h"
  581. #include "gamechanlist.h"
  582. #include "menuentry.h"
  583. #include "savegame.h"
  584. #include "gameobjmanager.h"
  585. #include "gametype.h"
  586. #include "quat.h"
  587. #include "wwprofile.h"
  588. */
  589. //#include "nettgas.h"
  590. //sprintf(buffer, "SFPS %d", cNetwork::Get_Server_Fps());
  591. /*
  592. if (cNetwork::I_Am_Server() &&
  593. GameModeManager::Find("Combat")->Is_Active() &&
  594. The_Game() != NULL &&
  595. The_Game()->As_Lms() != NULL) {
  596. Add_Diagnostic("ReaperCountdownSeconds = %d",
  597. (int) The_Game()->As_Lms()->Get_Reaper_Countdown_Seconds());
  598. }
  599. */
  600. //#include "gdlms.h"
  601. //Add_Diagnostic("#delobjects: %d", NetworkObjectMgrClass::Get_Pending_Object_Count());
  602. //Add_Diagnostic("CSC Last Ping: %d ms", cClientPingManager::Get_Last_Round_Trip_Ping_Ms());
  603. //Add_Diagnostic("CSC Avg. Ping: %d ms", cClientPingManager::Compute_Average_Round_Trip_Ping_Ms());
  604. //#include "clientpingmanager.h"
  605. /*
  606. char buffer[20];
  607. RectClass rect;
  608. sprintf(buffer, "%d", RendererFps);
  609. rect = Render2DClass::Get_Screen_Resolution();
  610. PRenderer->Set_Location(Vector2(rect.Right - 25, rect.Top + 10));
  611. PRenderer->Draw_Text(buffer);
  612. if (cNetwork::I_Am_Only_Client())
  613. {
  614. WWASSERT(cServerFps::Get_Instance() != NULL);
  615. sprintf(buffer, "SFPS %d", RendererSFps);
  616. rect = Render2DClass::Get_Screen_Resolution();
  617. PRenderer->Set_Location(Vector2(rect.Right - 70, rect.Top + 20));
  618. PRenderer->Draw_Text(buffer);
  619. }
  620. */
  621. /*
  622. //
  623. // Strip the leading "APPPACKETTYPE_"
  624. //
  625. WWASSERT(::strlen(cAppPacketStats::Interpret_Type(i)) > 14);
  626. char name[200] = "";
  627. ::strcpy(name, &cAppPacketStats::Interpret_Type(i)[14]);
  628. int tally = cAppPacketStats::Get_Object_Tally(i);
  629. char line[1000];
  630. if (tally > 0)
  631. {
  632. ::sprintf(line, "%-3d %s", tally, name);
  633. }
  634. else
  635. {
  636. ::sprintf(line, " %s", name);
  637. }
  638. Add_Diagnostic(line);
  639. */
  640. /*
  641. #ifdef BETASERVER
  642. PRenderer->Reset();
  643. RectClass rect = Render2DClass::Get_Screen_Resolution();
  644. PRenderer->Set_Location(Vector2(rect.Left + 5, rect.Bottom - 10));
  645. PRenderer->Draw_Text("BETASERVER");
  646. PRenderer->Render();
  647. #endif // BETASERVER
  648. */
  649. //Add_Diagnostic("Is_Single_Player: %d", cSinglePlayerData::Is_Single_Player());