netgraphs.cpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/netgraphs.cpp $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 12/11/01 1:42p $*
  29. * *
  30. * $Revision:: 40 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifdef WWDEBUG
  36. #include "cnetwork.h"
  37. #include <stdio.h>
  38. #include "systimer.h"
  39. #include "font3d.h"
  40. #include "miscutil.h"
  41. #include "gamemode.h"
  42. #include "wolgmode.h"
  43. #include "player.h"
  44. #include "devoptions.h"
  45. #include "msgstatlistgroup.h"
  46. #include "render2d.h"
  47. #include "networkobjectmgr.h"
  48. #include "apppackettypes.h"
  49. #define COLOR_BLACK 0xFF000000
  50. #define COLOR_WHITE 0xFFFFFFFF
  51. #define COLOR_RED 0xFFFF0000
  52. #define COLOR_BLUE 0xFF6060FF
  53. #define COLOR_GREEN 0xFF48FF48
  54. #define COLOR_DARK_GREEN 0xFF00C800
  55. #define COLOR_YELLOW 0xFFFFFF00
  56. #define COLOR_DARK_RED 0xFF990000
  57. #define COLOR_RED_DIM 0xFF800000
  58. #define COLOR_CYAN 0xFF00FFFF
  59. #define COLOR_GRAY 0xFF808080
  60. //-----------------------------------------------------------------------------
  61. void cNetwork::Packet_Graph(Render2DTextClass * renderer, cMsgStatList * p_stat_list,
  62. int watch_type, LPCSTR label)
  63. {
  64. WWASSERT(renderer != NULL);
  65. WWASSERT(p_stat_list != NULL);
  66. WWASSERT(label != NULL);
  67. GraphingY = cMathUtil::Round(GraphingY);
  68. //
  69. // Draw scaling bar
  70. //
  71. const float bar_length = 200.0f;
  72. const float bar_height = cMathUtil::Round(renderer->Peek_Font()->Char_Height());
  73. const float y_increment = cMathUtil::Round(bar_height * 1.25f);
  74. renderer->Draw_Block(RectClass(0, GraphingY, bar_length, GraphingY + bar_height), COLOR_BLACK);
  75. const int max_samples = 500;
  76. char full_label[300];
  77. ::sprintf(full_label, "%s / %d", label, max_samples);
  78. renderer->Set_Location(Vector2(2, GraphingY));
  79. renderer->Draw_Text(full_label);
  80. GraphingY += y_increment;
  81. for (int message_type = 0; message_type <= p_stat_list->Get_Num_Stats(); message_type++) {
  82. int count = 0;
  83. switch (watch_type) {
  84. case 0:
  85. count = p_stat_list->Get_Num_Msg_Sent(message_type);
  86. break;
  87. case 1:
  88. count = p_stat_list->Get_Num_Byte_Sent(message_type);
  89. break;
  90. case 2:
  91. count = p_stat_list->Get_Num_Msg_Recd(message_type);
  92. break;
  93. case 3:
  94. count = p_stat_list->Get_Num_Byte_Recd(message_type);
  95. break;
  96. case 4:
  97. count = p_stat_list->Compute_Avg_Num_Byte_Sent(message_type);
  98. break;
  99. case 5:
  100. count = p_stat_list->Compute_Avg_Num_Byte_Recd(message_type);
  101. break;
  102. default:
  103. DIE;
  104. break;
  105. }
  106. float fraction = (count % (max_samples + 1)) / (float) max_samples;
  107. renderer->Draw_Block(RectClass(0, GraphingY, fraction * bar_length, GraphingY + bar_height), COLOR_RED_DIM);
  108. char text[200];
  109. strcpy(text, p_stat_list->Get_Name(message_type));
  110. renderer->Set_Location(Vector2(2, GraphingY));
  111. renderer->Draw_Text(text);
  112. sprintf(text, "%d", count);
  113. renderer->Set_Location(Vector2(bar_length, GraphingY));
  114. renderer->Draw_Text(text);
  115. GraphingY += y_increment;
  116. }
  117. }
  118. //-----------------------------------------------------------------------------
  119. void cNetwork::Watch_Packets(Render2DTextClass * renderer)
  120. {
  121. WWASSERT(renderer != NULL);
  122. char text[100] = "";
  123. cMsgStatList * p_stat_list = NULL;
  124. int watch_type = -1;
  125. if (cDevOptions::PacketsSentServer.Is_True() && PServerStatListGroup != NULL) {
  126. sprintf(text, "PacketsSentServer");
  127. p_stat_list = PServerStatListGroup->Get_Stat_List(cMsgStatListGroup::ALL_LISTS);
  128. watch_type = 0;
  129. }
  130. if (cDevOptions::PacketsSentClient.Is_True()) {
  131. sprintf(text, "PacketsSentClient");
  132. p_stat_list = PClientStatList;
  133. watch_type = 0;
  134. }
  135. if (cDevOptions::PacketsRecdServer.Is_True() && PServerStatListGroup != NULL) {
  136. sprintf(text, "PacketsRecdServer");
  137. p_stat_list = PServerStatListGroup->Get_Stat_List(cMsgStatListGroup::ALL_LISTS);
  138. watch_type = 2;
  139. }
  140. if (cDevOptions::PacketsRecdClient.Is_True()) {
  141. sprintf(text, "PacketsRecdClient");
  142. p_stat_list = PClientStatList;
  143. watch_type = 2;
  144. }
  145. if (cDevOptions::AvgSizePacketsSentServer.Is_True() && PServerStatListGroup != NULL) {
  146. sprintf(text, "AvgSizePacketsSentServer");
  147. p_stat_list = PServerStatListGroup->Get_Stat_List(cMsgStatListGroup::ALL_LISTS);
  148. watch_type = 4;
  149. }
  150. if (cDevOptions::AvgSizePacketsSentClient.Is_True()) {
  151. sprintf(text, "AvgSizePacketsSentClient");
  152. p_stat_list = PClientStatList;
  153. watch_type = 4;
  154. }
  155. if (cDevOptions::AvgSizePacketsRecdServer.Is_True() && PServerStatListGroup != NULL) {
  156. sprintf(text, "AvgSizePacketsRecdServer");
  157. p_stat_list = PServerStatListGroup->Get_Stat_List(cMsgStatListGroup::ALL_LISTS);
  158. watch_type = 5;
  159. }
  160. if (cDevOptions::AvgSizePacketsRecdClient.Is_True()) {
  161. sprintf(text, "AvgSizePacketsRecdClient");
  162. p_stat_list = PClientStatList;
  163. watch_type = 5;
  164. }
  165. if (cDevOptions::BytesSentServer.Is_True() && PServerStatListGroup != NULL) {
  166. sprintf(text, "BytesSentServer");
  167. p_stat_list = PServerStatListGroup->Get_Stat_List(cMsgStatListGroup::ALL_LISTS);
  168. watch_type = 1;
  169. }
  170. if (cDevOptions::BytesSentClient.Is_True()) {
  171. sprintf(text, "BytesSentClient");
  172. p_stat_list = PClientStatList;
  173. watch_type = 1;
  174. }
  175. if (cDevOptions::BytesRecdServer.Is_True() && PServerStatListGroup != NULL) {
  176. sprintf(text, "BytesRecdServer");
  177. p_stat_list = PServerStatListGroup->Get_Stat_List(cMsgStatListGroup::ALL_LISTS);
  178. watch_type = 3;
  179. }
  180. if (cDevOptions::BytesRecdClient.Is_True()) {
  181. sprintf(text, "BytesRecdClient");
  182. p_stat_list = PClientStatList;
  183. watch_type = 3;
  184. }
  185. if (cDevOptions::WwnetPacketsSentServer.Is_True() && PServerConnection != NULL) {
  186. sprintf(text, "WwnetPacketsSentServer");
  187. p_stat_list = PServerConnection->Get_Stat_List();
  188. watch_type = 0;
  189. }
  190. if (cDevOptions::WwnetPacketsSentClient.Is_True() && PClientConnection != NULL) {
  191. sprintf(text, "WwnetPacketsSentClient");
  192. p_stat_list = PClientConnection->Get_Stat_List();
  193. watch_type = 0;
  194. }
  195. if (cDevOptions::WwnetPacketsRecdServer.Is_True() && PServerConnection != NULL) {
  196. sprintf(text, "WwnetPacketsRecdServer");
  197. p_stat_list = PServerConnection->Get_Stat_List();
  198. watch_type = 2;
  199. }
  200. if (cDevOptions::WwnetPacketsRecdClient.Is_True() && PClientConnection != NULL) {
  201. sprintf(text, "WwnetPacketsRecdClient");
  202. p_stat_list = PClientConnection->Get_Stat_List();
  203. watch_type = 2;
  204. }
  205. if (cDevOptions::WwnetAvgSizePacketsSentServer.Is_True() && PServerConnection != NULL) {
  206. sprintf(text, "WwnetAvgSizePacketsSentServer");
  207. p_stat_list = PServerConnection->Get_Stat_List();
  208. watch_type = 4;
  209. }
  210. if (cDevOptions::WwnetAvgSizePacketsSentClient.Is_True() && PClientConnection != NULL) {
  211. sprintf(text, "WwnetAvgSizePacketsSentClient");
  212. p_stat_list = PClientConnection->Get_Stat_List();
  213. watch_type = 4;
  214. }
  215. if (cDevOptions::WwnetAvgSizePacketsRecdServer.Is_True() && PServerConnection != NULL) {
  216. sprintf(text, "WwnetAvgSizePacketsRecdServer");
  217. p_stat_list = PServerConnection->Get_Stat_List();
  218. watch_type = 5;
  219. }
  220. if (cDevOptions::WwnetAvgSizePacketsRecdClient.Is_True() && PClientConnection != NULL) {
  221. sprintf(text, "WwnetAvgSizePacketsRecdClient");
  222. p_stat_list = PClientConnection->Get_Stat_List();
  223. watch_type = 5;
  224. }
  225. if (cDevOptions::WwnetBytesSentServer.Is_True() && PServerConnection != NULL) {
  226. sprintf(text, "WwnetBytesSentServer");
  227. p_stat_list = PServerConnection->Get_Stat_List();
  228. watch_type = 1;
  229. }
  230. if (cDevOptions::WwnetBytesSentClient.Is_True() && PClientConnection != NULL) {
  231. sprintf(text, "WwnetBytesSentClient");
  232. p_stat_list = PClientConnection->Get_Stat_List();
  233. watch_type = 1;
  234. }
  235. if (cDevOptions::WwnetBytesRecdServer.Is_True() && PServerConnection != NULL) {
  236. sprintf(text, "WwnetBytesRecdServer");
  237. p_stat_list = PServerConnection->Get_Stat_List();
  238. watch_type = 3;
  239. }
  240. if (cDevOptions::WwnetBytesRecdClient.Is_True() && PClientConnection != NULL) {
  241. sprintf(text, "WwnetBytesRecdClient");
  242. p_stat_list = PClientConnection->Get_Stat_List();
  243. watch_type = 3;
  244. }
  245. if (p_stat_list != NULL)
  246. {
  247. WWASSERT(watch_type != -1);
  248. Packet_Graph(renderer, p_stat_list, watch_type, text);
  249. }
  250. }
  251. //-----------------------------------------------------------------------------
  252. void cNetwork::Bandwidth_Graph(Render2DTextClass * renderer,
  253. LPCSTR label, int count, int target_bps,
  254. float packetloss_pc, const int bar_color, bool is_send,
  255. float threshold_priority)
  256. {
  257. WWASSERT(renderer != NULL);
  258. WWASSERT(label != NULL);
  259. const int screen_width = Render2DClass::Get_Screen_Resolution().Width();
  260. const int screen_height = Render2DClass::Get_Screen_Resolution().Height();
  261. WWASSERT(packetloss_pc > -MISCUTIL_EPSILON && packetloss_pc < 100 + MISCUTIL_EPSILON);
  262. const float bar_height = cMathUtil::Round(renderer->Peek_Font()->Char_Height());
  263. const float y_increment = cMathUtil::Round(bar_height * 1.25f);
  264. float end_x;
  265. float full_x;
  266. //float end_y;
  267. float ratio = (100 - packetloss_pc) / 100.0f;
  268. if (is_send) {
  269. full_x = count / (float) BandwidthScaler * BandwidthBarLength;
  270. end_x = full_x * ratio;
  271. } else {
  272. end_x = count / (float) BandwidthScaler * BandwidthBarLength;
  273. full_x = end_x / ratio;
  274. }
  275. //end_y = GraphingY + bar_height;
  276. if (packetloss_pc > 0) {
  277. //char text[200];
  278. //sprintf(text, "PL %7.4f%%", packetloss_pc);
  279. //p_text_drawer->Print(p_font, text, 0.3f, GraphingY);
  280. renderer->Draw_Block(RectClass( 0, GraphingY, full_x, GraphingY + bar_height), COLOR_DARK_RED);
  281. }
  282. renderer->Draw_Block(RectClass(0, GraphingY, end_x, GraphingY + bar_height), bar_color);
  283. renderer->Set_Location(Vector2(2, GraphingY));
  284. renderer->Draw_Text(label);
  285. /*
  286. char text[200];
  287. sprintf(text, "%d", count);
  288. p_text_drawer->Print(p_font, text, 0.3f, GraphingY);
  289. */
  290. if (target_bps != -1) {
  291. float target_x;
  292. //
  293. // Per second
  294. //
  295. target_x = target_bps / (float) BandwidthScaler * BandwidthBarLength;
  296. renderer->Draw_Block(RectClass(target_x - 1, GraphingY, target_x + 1, GraphingY + bar_height));
  297. /**/
  298. //
  299. // For this sample
  300. //
  301. target_bps = (int) (target_bps * cNetUtil::NETSTATS_SAMPLE_TIME_MS / 1000.0f);
  302. target_x = target_bps / (float) BandwidthScaler * BandwidthBarLength;
  303. renderer->Draw_Block(RectClass(target_x - 1, GraphingY, target_x + 1, GraphingY + bar_height));
  304. /**/
  305. }
  306. //
  307. // ThresholdPriority
  308. //
  309. if (threshold_priority > -1) {
  310. char tp_text[100];
  311. sprintf(tp_text, "TP:%-8.6f", threshold_priority);
  312. renderer->Set_Location(Vector2(500, GraphingY));
  313. renderer->Draw_Text(tp_text);
  314. /*
  315. const float TPLine_size = 1;
  316. float x1 = threshold_priority - TPLine_size;
  317. float x2 = x1 + 2 * TPLine_size;
  318. renderer->Draw_Block(RectClass(x1, GraphingY, x2, GraphingY + bar_height), COLOR_GREEN);
  319. */
  320. float tp = threshold_priority * screen_width;
  321. //TSS2001d renderer->Draw_Block(RectClass(tp - 1, GraphingY, tp + 1, GraphingY + bar_height), COLOR_GREEN);
  322. renderer->Draw_Block(RectClass(tp - 1, GraphingY, tp + 1, screen_height), COLOR_GREEN);
  323. }
  324. GraphingY += y_increment;
  325. /*
  326. if (full_x > 1 || end_x > 1) {
  327. //BandwidthBarLength /= 2.0f;
  328. BandwidthScaler *= 2;
  329. }
  330. */
  331. /*
  332. //
  333. // TSS101101
  334. //
  335. if (full_x > Render2DClass::Get_Screen_Resolution().Width() || end_x > Render2DClass::Get_Screen_Resolution().Width()) {
  336. //BandwidthBarLength /= 2.0f;
  337. BandwidthScaler *= 2;
  338. }
  339. */
  340. //TSS2001d
  341. //
  342. // Render object prioritys so can compare against threshold priority
  343. //
  344. if (cNetwork::I_Am_Server()) {
  345. int top = (int)(0.2 * screen_height);
  346. int count = NetworkObjectMgrClass::Get_Object_Count();
  347. int x_pos = screen_width - 75;
  348. renderer->Set_Location(Vector2(x_pos, 300));
  349. renderer->Draw_Text("UNKNOWN", COLOR_BLACK);
  350. renderer->Set_Location(Vector2(x_pos, 310));
  351. renderer->Draw_Text("SOLDIER", COLOR_RED);
  352. renderer->Set_Location(Vector2(x_pos, 320));
  353. renderer->Draw_Text("VEHICLE", COLOR_GREEN);
  354. renderer->Set_Location(Vector2(x_pos, 330));
  355. renderer->Draw_Text("TURRET", COLOR_DARK_GREEN);
  356. renderer->Set_Location(Vector2(x_pos, 340));
  357. renderer->Draw_Text("BUILDING", COLOR_BLUE);
  358. renderer->Set_Location(Vector2(x_pos, 350));
  359. renderer->Draw_Text("PLAYER", COLOR_YELLOW);
  360. renderer->Set_Location(Vector2(x_pos, 360));
  361. renderer->Draw_Text("POWERUP", COLOR_CYAN);
  362. renderer->Set_Location(Vector2(x_pos, 370));
  363. renderer->Draw_Text("OTHER", COLOR_WHITE);
  364. for (int index = 0; index < count; index ++) {
  365. NetworkObjectClass * p_object = NetworkObjectMgrClass::Get_Object(index);
  366. WWASSERT(p_object != NULL);
  367. float priority = 0;//XXX p_object->Get_Cached_Priority();
  368. if (priority > 0) {
  369. RectClass rect;
  370. rect.Left = (int)(priority * screen_width) - 3;
  371. rect.Right = rect.Left + 6;
  372. rect.Top = top;
  373. rect.Bottom = rect.Top + 1;
  374. /*
  375. if (p_object->Is_Tagged())
  376. {
  377. renderer->Draw_Block(rect, COLOR_YELLOW);
  378. }
  379. else
  380. {
  381. renderer->Draw_Block(rect, COLOR_WHITE);
  382. }
  383. */
  384. int color = COLOR_WHITE;
  385. switch (p_object->Get_App_Packet_Type())
  386. {
  387. case APPPACKETTYPE_UNKNOWN: color = COLOR_BLACK; break;
  388. case APPPACKETTYPE_SOLDIER: color = COLOR_RED; break;
  389. case APPPACKETTYPE_VEHICLE: color = COLOR_GREEN; break;
  390. case APPPACKETTYPE_TURRET: color = COLOR_DARK_GREEN; break;
  391. case APPPACKETTYPE_BUILDING: color = COLOR_BLUE; break;
  392. case APPPACKETTYPE_PLAYER: color = COLOR_YELLOW; break;
  393. case APPPACKETTYPE_POWERUP: color = COLOR_CYAN; break;
  394. case APPPACKETTYPE_ALL: DIE; break;
  395. default: color = COLOR_WHITE; break;
  396. }
  397. renderer->Draw_Block(rect, color);
  398. top += 3;
  399. }
  400. }
  401. }
  402. }
  403. //-----------------------------------------------------------------------------
  404. void cNetwork::Watch_Bandwidth(Render2DTextClass * renderer)
  405. {
  406. WWASSERT(renderer != NULL);
  407. bool bail = true;
  408. #ifdef WWDEBUG
  409. if (cDevOptions::ShowBandwidth.Is_True()) {
  410. bail = false;
  411. }
  412. #endif // WWDEBUG
  413. if (bail) {
  414. return;
  415. }
  416. //
  417. // Draw the scale at the top
  418. //
  419. const int screen_width = Render2DClass::Get_Screen_Resolution().Width();
  420. const float bar_height = cMathUtil::Round(renderer->Peek_Font()->Char_Height());
  421. const float y_increment = cMathUtil::Round(bar_height * 1.25f);
  422. //BandwidthBarLength = screen_width / 8.0f;
  423. BandwidthBarLength = screen_width / 10.0f;
  424. float x1 = 0;
  425. float x2 = 0;
  426. int i = 0;
  427. do {
  428. x2 = x1 + BandwidthBarLength;
  429. renderer->Draw_Block(RectClass(x1, GraphingY, x2, GraphingY + bar_height), (i % 2) ? COLOR_WHITE : COLOR_BLACK);
  430. x1 = x2;
  431. i++;
  432. } while (x2 < screen_width);
  433. //
  434. // Label the scale
  435. //
  436. char label[100];
  437. sprintf(label, "BW / %d", BandwidthScaler);
  438. renderer->Set_Location(Vector2(2, GraphingY));
  439. renderer->Draw_Text(label);
  440. GraphingY += y_increment;
  441. char text[100];
  442. if (I_Am_Client() && PClientConnection->Is_Established()) {
  443. sprintf(text, "c%d->s", Get_My_Id());
  444. Bandwidth_Graph(
  445. renderer,
  446. text,
  447. //XXX Get_Client_Rhost()->Get_Stats().StatSnapshot[STAT_BitsSent],
  448. Get_Client_Rhost()->Get_Stats().StatMacroSnapshot[STAT_BitsSent],
  449. Get_Client_Rhost()->Get_Target_Bps(),
  450. Get_Client_Rhost()->Get_Stats().Get_Pc_Packetloss_Sent(),
  451. COLOR_RED,
  452. true,
  453. Get_Client_Rhost()->Get_Threshold_Priority());
  454. sprintf(text, "c%d<-s", Get_My_Id());
  455. Bandwidth_Graph(
  456. renderer,
  457. text,
  458. //XXX Get_Client_Rhost()->Get_Stats().StatSnapshot[STAT_BitsRcv],
  459. Get_Client_Rhost()->Get_Stats().StatMacroSnapshot[STAT_BitsRcv],
  460. -1,
  461. Get_Client_Rhost()->Get_Stats().Get_Pc_Packetloss_Received(),
  462. COLOR_RED,
  463. false,
  464. -1);
  465. /*
  466. char text[200];
  467. sprintf(text, "PACKETLOSS %7.4f",
  468. Get_Client_Rhost()->Get_Stats().Get_Pc_Packetloss_Received());
  469. p_text_drawer->Print(p_font, text, 0.5f, 0.2f);
  470. */
  471. }
  472. if (PServerConnection != NULL) {
  473. Bandwidth_Graph(
  474. renderer,
  475. "s->c*",
  476. //XXX PServerConnection->Get_Combined_Stats().StatSnapshot[STAT_BitsSent],
  477. PServerConnection->Get_Combined_Stats().StatMacroSnapshot[STAT_BitsSent],
  478. PServerConnection->Get_Bandwidth_Budget_Out(),
  479. 0,
  480. COLOR_BLUE,
  481. true,
  482. -1);
  483. Bandwidth_Graph(
  484. renderer,
  485. "s<-c*",
  486. //XXX PServerConnection->Get_Combined_Stats().StatSnapshot[STAT_BitsRcv],
  487. PServerConnection->Get_Combined_Stats().StatMacroSnapshot[STAT_BitsRcv],
  488. -1,
  489. 0,
  490. COLOR_BLUE,
  491. false,
  492. -1);
  493. for (int i = PServerConnection->Get_Min_RHost(); i <= PServerConnection->Get_Max_RHost(); i++) {
  494. WWASSERT(
  495. i >= cNetwork::PServerConnection->Get_Min_RHost() &&
  496. i <= cNetwork::PServerConnection->Get_Max_RHost());
  497. cRemoteHost * p_rhost = Get_Server_Rhost(i);
  498. if (p_rhost != NULL) {
  499. sprintf(text, "s->c%d", i);
  500. Bandwidth_Graph(
  501. renderer,
  502. text,
  503. //XXX p_rhost->Get_Stats().StatSnapshot[STAT_BitsSent],
  504. p_rhost->Get_Stats().StatMacroSnapshot[STAT_BitsSent],
  505. p_rhost->Get_Target_Bps(),
  506. p_rhost->Get_Stats().Get_Pc_Packetloss_Sent(),
  507. COLOR_RED,
  508. true,
  509. p_rhost->Get_Threshold_Priority());
  510. sprintf(text, "s<-c%d", i);
  511. Bandwidth_Graph(
  512. renderer,
  513. text,
  514. //XXX p_rhost->Get_Stats().StatSnapshot[STAT_BitsRcv],
  515. p_rhost->Get_Stats().StatMacroSnapshot[STAT_BitsRcv],
  516. -1,
  517. p_rhost->Get_Stats().Get_Pc_Packetloss_Received(),
  518. COLOR_RED,
  519. false,
  520. -1);
  521. /*
  522. char text[200];
  523. sprintf(text, "PACKETLOSS %7.4f",
  524. p_rhost->Get_Stats().Get_Pc_Packetloss_Received());
  525. p_text_drawer->Print(p_font, text, 0.5f, 0.5 + 0.05 * i);
  526. */
  527. }
  528. }
  529. }
  530. }
  531. //-----------------------------------------------------------------------------
  532. void cNetwork::Latency_Graph(Render2DTextClass * renderer, LPCSTR label,
  533. const float bar_length, cRemoteHost * p_rhost)
  534. {
  535. WWASSERT(renderer != NULL);
  536. WWASSERT(label != NULL);
  537. WWASSERT(p_rhost != NULL);
  538. int count = p_rhost->Get_Average_Internal_Pingtime_Ms();
  539. const float bar_width = 8;
  540. const float latency_block = 100.0f;
  541. const float graph_separation = 7;
  542. float end_x;
  543. float end_y;
  544. end_x = count / latency_block * bar_length;
  545. end_y = GraphingY + bar_width;
  546. renderer->Draw_Block( RectClass( 0, GraphingY, end_x, end_y ), COLOR_RED );
  547. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  548. renderer->Draw_Text( label, COLOR_YELLOW );
  549. /*
  550. char remote_framerate[20];
  551. sprintf(remote_framerate, "%d fps", p_rhost->Get_Stats().Get_Remote_Service_Count());
  552. renderer->Set_Location( Vector2( 200, GraphingY+1 ) );
  553. renderer->Draw_Text( remote_framerate, COLOR_YELLOW );
  554. */
  555. /*
  556. char txt[200];
  557. sprintf(txt, "%s: %d/%d = %d", label, p_rhost->TotalInternalPingtimeMs,
  558. p_rhost->NumInternalPings, p_rhost->AverageInternalPingtimeMs);
  559. p_text_drawer->Print(p_font, txt, 0, GraphingY);
  560. */
  561. GraphingY += bar_width + graph_separation;
  562. }
  563. //-----------------------------------------------------------------------------
  564. void cNetwork::Watch_Latency(Render2DTextClass * renderer)
  565. {
  566. WWASSERT(renderer != NULL);
  567. if (cDevOptions::ShowLatency.Is_False()) {
  568. return;
  569. }
  570. const float bar_length = 64;
  571. float x1 = 0;
  572. float x2;
  573. float end_y = GraphingY + 8;
  574. for (int i = 0; i < 10; i++) {
  575. x2 = x1 + bar_length;
  576. renderer->Draw_Block( RectClass( x1, GraphingY, x2, end_y ), (i%2)?COLOR_WHITE:COLOR_BLACK );
  577. x1 = x2;
  578. }
  579. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  580. renderer->Draw_Text( "LAT/100ms", COLOR_YELLOW );
  581. GraphingY += 10;
  582. char text[100];
  583. if (I_Am_Client() && PClientConnection->Is_Established()) {
  584. sprintf(text, "c%d->s", Get_My_Id());
  585. Latency_Graph(renderer, text, bar_length, Get_Client_Rhost());
  586. }
  587. if (I_Am_Server()) {
  588. for (int i = PServerConnection->Get_Min_RHost(); i <= PServerConnection->Get_Max_RHost(); i++) {
  589. if (Get_Server_Rhost(i) != NULL) {
  590. sprintf(text, "s->c%d", i);
  591. Latency_Graph(renderer, text, bar_length, Get_Server_Rhost(i));
  592. }
  593. }
  594. }
  595. }
  596. //-----------------------------------------------------------------------------
  597. void cNetwork::Last_Contact_Graph(Render2DTextClass * renderer,
  598. LPCSTR label, const float bar_length,
  599. cRemoteHost * p_rhost)
  600. {
  601. WWASSERT(renderer != NULL);
  602. WWASSERT(label != NULL);
  603. WWASSERT(p_rhost != NULL);
  604. int count = TIMEGETTIME() - p_rhost->Get_Last_Contact_Time();
  605. WWASSERT(count >= 0);
  606. const float bar_width = 0.017f;
  607. const float time_block = 1000.0f;
  608. const float graph_separation = 0.01f;
  609. float end_x;
  610. float end_y;
  611. end_x = count / time_block * bar_length;
  612. end_y = GraphingY + bar_width;
  613. renderer->Draw_Block( RectClass( 0, GraphingY, end_x, end_y ), COLOR_RED );
  614. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  615. renderer->Draw_Text( label, COLOR_RED );
  616. GraphingY = end_y + graph_separation;
  617. }
  618. //-----------------------------------------------------------------------------
  619. void cNetwork::Watch_Last_Contact(Render2DTextClass * renderer)
  620. {
  621. WWASSERT(renderer != NULL);
  622. if (cDevOptions::ShowLastContact.Is_False()) {
  623. return;
  624. }
  625. const float bar_length = 24;
  626. float x1 = 0;
  627. float x2;
  628. float end_y = GraphingY + 8;
  629. for (int i = 0; i < 20; i++) {
  630. x2 = x1 + bar_length;
  631. renderer->Draw_Block( RectClass( x1, GraphingY, x2, end_y ), (i%2)?COLOR_WHITE:COLOR_BLACK );
  632. x1 = x2;
  633. }
  634. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  635. renderer->Draw_Text( "LAST/1s", COLOR_RED );
  636. GraphingY += 14;
  637. char text[100];
  638. if (I_Am_Client() && PClientConnection->Is_Established()) {
  639. sprintf(text, "c%d->s", Get_My_Id());
  640. Last_Contact_Graph(renderer, text, bar_length, Get_Client_Rhost());
  641. }
  642. if (I_Am_Server()) {
  643. for (int i = PServerConnection->Get_Min_RHost(); i <= PServerConnection->Get_Max_RHost(); i++) {
  644. if (Get_Server_Rhost(i) != NULL) {
  645. sprintf(text, "s->c%d", i);
  646. Last_Contact_Graph(renderer, text, bar_length, Get_Server_Rhost(i));
  647. }
  648. }
  649. }
  650. }
  651. //-----------------------------------------------------------------------------
  652. void cNetwork::List_Size_Graph(Render2DTextClass * renderer,
  653. LPCSTR label, const float bar_length, int count)
  654. {
  655. WWASSERT(renderer != NULL);
  656. WWASSERT(label != NULL);
  657. const float bar_width = 12;
  658. const float list_size_block = 10.0f;
  659. const float graph_separation = 5;
  660. float end_x = count / list_size_block * bar_length;
  661. float end_y = GraphingY + bar_width;
  662. renderer->Draw_Block( RectClass( 0, GraphingY, end_x, end_y ), COLOR_RED );
  663. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  664. renderer->Draw_Text( label, COLOR_RED );
  665. GraphingY += bar_width + graph_separation;
  666. }
  667. //-----------------------------------------------------------------------------
  668. void cNetwork::List_Time_Graph(Render2DTextClass * renderer,
  669. LPCSTR label, const float bar_length, int time_ms)
  670. {
  671. WWASSERT(renderer != NULL);
  672. WWASSERT(label != NULL);
  673. const float bar_width = 12;
  674. const float list_block = 50.0f;
  675. const float graph_separation = 5;
  676. float end_x = time_ms / list_block * bar_length;
  677. float end_y = GraphingY + bar_width;
  678. renderer->Draw_Block( RectClass( 0, GraphingY, end_x, end_y ), COLOR_RED );
  679. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  680. renderer->Draw_Text( label, COLOR_RED );
  681. GraphingY += bar_width + graph_separation;
  682. }
  683. //-----------------------------------------------------------------------------
  684. void cNetwork::List_Packet_Size_Graph(Render2DTextClass * renderer,
  685. LPCSTR label, const float bar_length, int count)
  686. {
  687. WWASSERT(renderer != NULL);
  688. WWASSERT(label != NULL);
  689. const float bar_width = 12;
  690. const float list_block = 200.0f;
  691. const float graph_separation = 5;
  692. float end_x = count / list_block * bar_length;
  693. float end_y = GraphingY + bar_width;
  694. renderer->Draw_Block( RectClass( 0, GraphingY, end_x, end_y ), COLOR_RED );
  695. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  696. renderer->Draw_Text( label, COLOR_RED );
  697. GraphingY += bar_width + graph_separation;
  698. }
  699. //-----------------------------------------------------------------------------
  700. void cNetwork::Watch_Size_Lists(Render2DTextClass * renderer)
  701. {
  702. WWASSERT(renderer != NULL);
  703. if (cDevOptions::ShowListSizes.Is_False()) {
  704. return;
  705. }
  706. const float bar_length = 64;
  707. float x1 = 0;
  708. float x2;
  709. float end_y = GraphingY + 12;
  710. for (int i = 0; i < 10; i++) {
  711. x2 = x1 + bar_length;
  712. renderer->Draw_Block( RectClass( x1, GraphingY, x2, end_y ), (i%2)?COLOR_WHITE:COLOR_BLACK );
  713. x1 = x2;
  714. }
  715. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  716. renderer->Draw_Text( "LIST/10", COLOR_RED );
  717. GraphingY += 18;
  718. char text[100];
  719. if (I_Am_Client() && PClientConnection->Is_Established()) {
  720. sprintf(text, "c rsnd");
  721. List_Size_Graph(renderer, text, bar_length,
  722. Get_Client_Rhost()->Get_List_Max(RELIABLE_SEND_LIST));
  723. sprintf(text, "c rrcv");
  724. List_Size_Graph(renderer, text, bar_length,
  725. Get_Client_Rhost()->Get_List_Max(RELIABLE_RCV_LIST));
  726. sprintf(text, "c usnd");
  727. List_Size_Graph(renderer, text, bar_length,
  728. Get_Client_Rhost()->Get_List_Max(UNRELIABLE_SEND_LIST));
  729. sprintf(text, "c urcv");
  730. List_Size_Graph(renderer, text, bar_length,
  731. Get_Client_Rhost()->Get_List_Max(UNRELIABLE_RCV_LIST));
  732. }
  733. if (I_Am_Server()) {
  734. for (int i = PServerConnection->Get_Min_RHost(); i <= PServerConnection->Get_Max_RHost(); i++) {
  735. if (Get_Server_Rhost(i) != NULL) {
  736. sprintf(text, "s rsnd %d", i);
  737. List_Size_Graph(renderer, text, bar_length,
  738. Get_Server_Rhost(i)->Get_List_Max(RELIABLE_SEND_LIST));
  739. sprintf(text, "s rrcv %d", i);
  740. List_Size_Graph(renderer, text, bar_length,
  741. Get_Server_Rhost(i)->Get_List_Max(RELIABLE_RCV_LIST));
  742. sprintf(text, "s usnd %d", i);
  743. List_Size_Graph(renderer, text, bar_length,
  744. Get_Server_Rhost(i)->Get_List_Max(UNRELIABLE_SEND_LIST));
  745. sprintf(text, "s urcv %d", i);
  746. List_Size_Graph(renderer, text, bar_length,
  747. Get_Server_Rhost(i)->Get_List_Max(UNRELIABLE_RCV_LIST));
  748. }
  749. }
  750. }
  751. }
  752. //-----------------------------------------------------------------------------
  753. void cNetwork::Watch_Time_Lists(Render2DTextClass * renderer)
  754. {
  755. WWASSERT(renderer != NULL);
  756. if (cDevOptions::ShowListTimes.Is_False()) {
  757. return;
  758. }
  759. const float bar_length = 64;
  760. float x1 = 0;
  761. float x2;
  762. float end_y = GraphingY + 12;
  763. for (int i = 0; i < 10; i++) {
  764. x2 = x1 + bar_length;
  765. renderer->Draw_Block( RectClass( x1, GraphingY, x2, end_y ), (i%2)?COLOR_WHITE:COLOR_BLACK );
  766. x1 = x2;
  767. }
  768. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  769. renderer->Draw_Text( "LISTTIME/50ms", COLOR_RED );
  770. GraphingY += 20;
  771. char text[100];
  772. if (I_Am_Client() && PClientConnection->Is_Established()) {
  773. /*
  774. sprintf(text, "c rsnd");
  775. List_Size_Graph(p_text_drawer, p_graph_drawer,
  776. text, bar_length,
  777. Get_Client_Rhost()->Get_List_Max(RELIABLE_SEND_LIST),
  778. Get_Client_Rhost()->Get_List_Processing_Time(RELIABLE_SEND_LIST));
  779. sprintf(text, "c rrcv");
  780. List_Size_Graph(p_text_drawer, p_graph_drawer,
  781. text, bar_length,
  782. Get_Client_Rhost()->Get_List_Max(RELIABLE_RCV_LIST),
  783. Get_Client_Rhost()->Get_List_Processing_Time(RELIABLE_RCV_LIST));
  784. sprintf(text, "c usnd");
  785. List_Size_Graph(p_text_drawer, p_graph_drawer,
  786. text, bar_length,
  787. Get_Client_Rhost()->Get_List_Max(UNRELIABLE_SEND_LIST),
  788. Get_Client_Rhost()->Get_List_Processing_Time(UNRELIABLE_SEND_LIST));
  789. */
  790. sprintf(text, "c urcv");
  791. List_Time_Graph(renderer, text, bar_length,
  792. Get_Client_Rhost()->Get_List_Processing_Time(UNRELIABLE_RCV_LIST));
  793. }
  794. /*
  795. if (I_Am_Server()) {
  796. for (int i = 0; i < MAX_RHOSTS; i++) {
  797. if (Get_Server_Rhost(i) != NULL) {
  798. sprintf(text, "s rsnd %d", i);
  799. List_Size_Graph(p_text_drawer, p_graph_drawer,
  800. text, bar_length,
  801. Get_Server_Rhost(i)->Get_List_Max(RELIABLE_SEND_LIST),
  802. Get_Server_Rhost(i)->Get_List_Processing_Time(RELIABLE_SEND_LIST));
  803. sprintf(text, "s rrcv %d", i);
  804. List_Size_Graph(p_text_drawer, p_graph_drawer,
  805. text, bar_length,
  806. Get_Server_Rhost(i)->Get_List_Max(RELIABLE_RCV_LIST),
  807. Get_Server_Rhost(i)->Get_List_Processing_Time(RELIABLE_RCV_LIST));
  808. sprintf(text, "s usnd %d", i);
  809. List_Size_Graph(p_text_drawer, p_graph_drawer,
  810. text, bar_length,
  811. Get_Server_Rhost(i)->Get_List_Max(UNRELIABLE_SEND_LIST),
  812. Get_Server_Rhost(i)->Get_List_Processing_Time(UNRELIABLE_SEND_LIST));
  813. sprintf(text, "s urcv %d", i);
  814. List_Size_Graph(p_text_drawer, p_graph_drawer,
  815. text, bar_length,
  816. Get_Server_Rhost(i)->Get_List_Max(UNRELIABLE_RCV_LIST),
  817. Get_Server_Rhost(i)->Get_List_Processing_Time(UNRELIABLE_RCV_LIST));
  818. }
  819. }
  820. }
  821. */
  822. }
  823. //-----------------------------------------------------------------------------
  824. void cNetwork::Watch_Packet_Size_Lists(Render2DTextClass * renderer)
  825. {
  826. WWASSERT(renderer != NULL);
  827. if (cDevOptions::ShowListPacketSizes.Is_False()) {
  828. return;
  829. }
  830. const float bar_length = 64;
  831. float x1 = 0;
  832. float x2;
  833. float end_y = GraphingY + 12;
  834. for (int i = 0; i < 10; i++) {
  835. x2 = x1 + bar_length;
  836. renderer->Draw_Block( RectClass( x1, GraphingY, x2, end_y ), (i%2)?COLOR_WHITE:COLOR_BLACK );
  837. x1 = x2;
  838. }
  839. renderer->Set_Location( Vector2( 0, GraphingY+1 ) );
  840. renderer->Draw_Text( "LISTPSZ/200b", COLOR_RED );
  841. GraphingY += 20;
  842. /*
  843. char text[100];
  844. if (I_Am_Client() && PClientConnection->Is_Established()) {
  845. sprintf(text, "c rsnd");
  846. List_Size_Graph(p_text_drawer, p_graph_drawer,
  847. text, bar_length,
  848. Get_Client_Rhost()->Get_List_Max(RELIABLE_SEND_LIST),
  849. Get_Client_Rhost()->Get_List_Processing_Time(RELIABLE_SEND_LIST));
  850. sprintf(text, "c rrcv");
  851. List_Size_Graph(p_text_drawer, p_graph_drawer,
  852. text, bar_length,
  853. Get_Client_Rhost()->Get_List_Max(RELIABLE_RCV_LIST),
  854. Get_Client_Rhost()->Get_List_Processing_Time(RELIABLE_RCV_LIST));
  855. sprintf(text, "c usnd");
  856. List_Size_Graph(p_text_drawer, p_graph_drawer,
  857. text, bar_length,
  858. Get_Client_Rhost()->Get_List_Max(UNRELIABLE_SEND_LIST),
  859. Get_Client_Rhost()->Get_List_Processing_Time(UNRELIABLE_SEND_LIST));
  860. */
  861. /* broken
  862. sprintf(text, "c urcv");
  863. List_Packet_Size_Graph(p_text_drawer, p_graph_drawer,
  864. text, bar_length,
  865. Get_Client_Rhost()->Get_List_Packet_Size(UNRELIABLE_RCV_LIST));
  866. }
  867. */
  868. /*
  869. if (I_Am_Server()) {
  870. for (int i = 0; i < MAX_RHOSTS; i++) {
  871. if (Get_Server_Rhost(i) != NULL) {
  872. sprintf(text, "s rsnd %d", i);
  873. List_Size_Graph(p_text_drawer, p_graph_drawer,
  874. text, bar_length,
  875. Get_Server_Rhost(i)->Get_List_Max(RELIABLE_SEND_LIST),
  876. Get_Server_Rhost(i)->Get_List_Processing_Time(RELIABLE_SEND_LIST));
  877. sprintf(text, "s rrcv %d", i);
  878. List_Size_Graph(p_text_drawer, p_graph_drawer,
  879. text, bar_length,
  880. Get_Server_Rhost(i)->Get_List_Max(RELIABLE_RCV_LIST),
  881. Get_Server_Rhost(i)->Get_List_Processing_Time(RELIABLE_RCV_LIST));
  882. sprintf(text, "s usnd %d", i);
  883. List_Size_Graph(p_text_drawer, p_graph_drawer,
  884. text, bar_length,
  885. Get_Server_Rhost(i)->Get_List_Max(UNRELIABLE_SEND_LIST),
  886. Get_Server_Rhost(i)->Get_List_Processing_Time(UNRELIABLE_SEND_LIST));
  887. sprintf(text, "s urcv %d", i);
  888. List_Size_Graph(p_text_drawer, p_graph_drawer,
  889. text, bar_length,
  890. Get_Server_Rhost(i)->Get_List_Max(UNRELIABLE_RCV_LIST),
  891. Get_Server_Rhost(i)->Get_List_Processing_Time(UNRELIABLE_RCV_LIST));
  892. }
  893. }
  894. }
  895. */
  896. }
  897. //-----------------------------------------------------------------------------
  898. void cNetwork::Simulation_Warnings(Render2DTextClass * renderer)
  899. {
  900. WWASSERT(renderer != NULL);
  901. static int color_cycle = 0;
  902. int color = (++color_cycle & 64) ? COLOR_WHITE : COLOR_GREEN;
  903. char message[300];
  904. #ifdef WWDEBUG
  905. renderer->Set_Location( Vector2( 3, 360 ) );
  906. if (cDevOptions::DesiredFrameSleepMs.Get() > 0) {
  907. sprintf(message, "SLEEP: %d ms\n", cDevOptions::DesiredFrameSleepMs.Get());
  908. renderer->Draw_Text( message, color );
  909. }
  910. if (cDevOptions::SimulatedPacketLossPc.Get() > MISCUTIL_EPSILON) {
  911. sprintf(message, "SIM. PACKETLOSS = %5.2f %%\n", (float) cDevOptions::SimulatedPacketLossPc.Get());
  912. renderer->Draw_Text( message, color );
  913. }
  914. if (cDevOptions::SimulatedPacketDuplicationPc.Get() > MISCUTIL_EPSILON) {
  915. sprintf(message, "SIM. PACKET DUP. = %5.2f %%\n", (float) cDevOptions::SimulatedPacketDuplicationPc.Get());
  916. renderer->Draw_Text( message, color );
  917. }
  918. if (cDevOptions::SpamCount.Get() > 0) {
  919. sprintf(message, "SPAM COUNT = %d\n", cDevOptions::SpamCount.Get());
  920. renderer->Draw_Text( message, color );
  921. }
  922. int minimum_latency_ms;
  923. int maximum_latency_ms;
  924. Get_Simulated_Latency_Range_Ms(minimum_latency_ms, maximum_latency_ms);
  925. if (minimum_latency_ms > 0 || maximum_latency_ms > 0) {
  926. sprintf(message, "SIM. LATENCY = (%d, %d)\n", minimum_latency_ms, maximum_latency_ms);
  927. renderer->Draw_Text( message, color );
  928. }
  929. #endif //WWDEBUG
  930. }
  931. /*
  932. //-----------------------------------------------------------------------------
  933. void cNetwork::Priorities_Graph(Render2DTextClass * renderer
  934. {
  935. WWASSERT(p_text_drawer != NULL);
  936. WWASSERT(p_graph_drawer != NULL);
  937. if (cDevOptions::ShowPriorities.Is_False()) {
  938. return;
  939. }
  940. cRemoteHost * p_rhost = NULL;
  941. int rhost_index;
  942. if (cNetwork::I_Am_Client_Server()) {
  943. p_rhost = cNetwork::Get_Server_Rhost(2);
  944. rhost_index = 2;
  945. } else if (cNetwork::I_Am_Only_Server()) {
  946. p_rhost = cNetwork::Get_Server_Rhost(1);
  947. rhost_index = 1;
  948. } else if (cNetwork::I_Am_Client()) {
  949. p_rhost = cNetwork::Get_Client_Rhost();
  950. rhost_index = 0;
  951. }
  952. if (p_rhost != NULL) {
  953. p_graph_drawer->Set_Shader(ShaderClass::_PresetOpaqueSolidShader);
  954. float priority;
  955. float x1;
  956. float x2;
  957. float y1;
  958. float y2;
  959. const float blob_size = 0.004f;
  960. const float blob_size_2 = blob_size / 2.0f;
  961. y1 = 0;
  962. x1 = priority - blob_size_2;
  963. x2 = x1 + blob_size;
  964. y2 = y1 + blob_size;
  965. p_graph_drawer->Set_Vertex_Color();
  966. p_graph_drawer->Quad(x1, y1, x2, y2);
  967. y1 += blob_size_2;
  968. }
  969. }
  970. */
  971. #endif // WWDEBUG
  972. //const float graph_separation = 9;
  973. /*
  974. //-----------------------------------------------------------------------------
  975. void cNetwork::Watch_Bandwidth_Budget_Out(Render2DTextClass * renderer)
  976. {
  977. WWASSERT(renderer != NULL);
  978. return;
  979. if (cDevOptions::ShowBandwidthBudgetOut.Is_False() || !I_Am_Server()) {
  980. return;
  981. }
  982. char text[200];
  983. WWASSERT(PServerConnection != NULL);
  984. sprintf(text, "BBO: %d bps", PServerConnection->Get_Bandwidth_Budget_Out());
  985. renderer->Set_Location(Vector2(2, 25));
  986. renderer->Draw_Text(text);
  987. }
  988. */