console.cpp 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781
  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/console.cpp $*
  25. * *
  26. * $Author:: Jani_p $*
  27. * *
  28. * $Modtime:: 3/14/02 4:07p $*
  29. * *
  30. * $Revision:: 138 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "console.h"
  36. #include "consolefunction.h"
  37. #include "textdisplay.h"
  38. #include "assets.h"
  39. #include "font3d.h"
  40. #include "debug.h"
  41. #include "timemgr.h"
  42. #include "input.h"
  43. #include "miscutil.h"
  44. #include "cnetwork.h"
  45. #include "teammanager.h"
  46. #include "scene.h"
  47. #include "ww3d.h"
  48. #include <stdio.h>
  49. #include "wwaudio.h"
  50. #include "audiblesound.H"
  51. //#include "gamesettings.h"
  52. #include "gamedata.h"
  53. #include "overlay.h"
  54. #include "combat.h"
  55. #include "camera.h"
  56. #include "ccamera.h"
  57. #include "gameobjmanager.h"
  58. #include "smartgameobj.h"
  59. #include "playermanager.h"
  60. #include "_globals.h"
  61. #include "registry.h"
  62. #include "phys3.h"
  63. #include "wolgmode.h"
  64. #include "devoptions.h"
  65. #include "playertype.h"
  66. #include "pscene.h"
  67. #include "translatedb.h"
  68. #include "string_ids.h"
  69. #include "vehicle.h"
  70. #include "wheelvehicle.h"
  71. #include "wwprofile.h"
  72. #include "wwmemlog.h"
  73. #include "wheel.h"
  74. #include "statistics.h"
  75. #include "meshmdl.h"
  76. #include "w3d_file.h" // for SURFACE_TYPE_STRINGS
  77. #include "colors.h"
  78. #include "chatshre.h"
  79. #include "dx8renderer.h"
  80. #include "dx8wrapper.h"
  81. #include "umbrasupport.h"
  82. #include "render2d.h"
  83. #include "sortingrenderer.h"
  84. #include "sctextobj.h"
  85. #include "textdisplay.h"
  86. #include "trackedvehicle.h"
  87. #include "dx8rendererdebugger.h"
  88. #include "fastallocator.h"
  89. #include <WWOnline\WOLSession.h>
  90. #include "consolemode.h"
  91. //#include "dlgmpingamechat.h"
  92. #if (_MSC_VER >= 1200)
  93. #pragma warning(push,1)
  94. #endif
  95. #include <sstream>
  96. #if (_MSC_VER >= 1200)
  97. #pragma warning(pop)
  98. #endif
  99. static bool profile_log_active;
  100. static StringClass* profile_log_names;
  101. //
  102. // ConsoleGameModeClass statics
  103. //
  104. ConsoleGameModeClass * ConsoleGameModeClass::Instance = NULL;
  105. const float ConsoleGameModeClass::LeftMargin = 0.02f;
  106. /*
  107. ** called each time through the main loop
  108. */
  109. void ConsoleGameModeClass::Init()
  110. {
  111. ConsoleFunctionManager::Init();
  112. WWASSERT( ConsoleGameModeClass::Instance == NULL );
  113. ConsoleGameModeClass::Instance = this;
  114. InputActive = false;
  115. InputLine[0] = 0;
  116. Clear_Suggestion();
  117. // FPSActive = false;
  118. FPSFrames = 0;
  119. FPSTime = 0.0f;
  120. FPSLastTime = 0.0f;
  121. FPS = 0.0f;
  122. // ShowPlayerPosition = false;
  123. PerformanceSamplingActive = false;
  124. Load_Registry_Keys();
  125. ProfileIterator = NULL;
  126. }
  127. /*
  128. ** called each time through the main loop
  129. */
  130. void ConsoleGameModeClass::Shutdown()
  131. {
  132. Save_Registry_Keys();
  133. WWASSERT( ConsoleGameModeClass::Instance == this );
  134. ConsoleGameModeClass::Instance = NULL;
  135. ConsoleFunctionManager::Shutdown();
  136. }
  137. void ConsoleGameModeClass::Load_Registry_Keys(void)
  138. {
  139. // Debug_Say(( "CombatGameModeClass::Load_Registry_Keys...\n" ));
  140. RegistryClass * registry = new RegistryClass( APPLICATION_SUB_KEY_NAME_OPTIONS );
  141. WWASSERT( registry );
  142. if ( registry->Is_Valid() ) {
  143. WW3D::Set_Screen_UV_Bias( registry->Get_Int( "ScreenUVBias", 1 ) != 0 );
  144. Get_Console()->Set_FPS_Active( registry->Get_Int( "FPS", 1 ) != 0 );
  145. }
  146. delete registry;
  147. }
  148. void ConsoleGameModeClass::Save_Registry_Keys(void)
  149. {
  150. // Debug_Say(( "CombatGameModeClass::Save_Registry_Keys...\n"));
  151. RegistryClass * registry = new RegistryClass( APPLICATION_SUB_KEY_NAME_OPTIONS );
  152. WWASSERT( registry );
  153. if ( registry->Is_Valid() ) {
  154. registry->Set_Int( "ScreenUVBias", WW3D::Is_Screen_UV_Biased() );
  155. // registry->Set_Int( "TextureReduction", WW3D::Get_Texture_Reduction() );
  156. // registry->Set_Int( "TextureThumbnail", WW3D::Get_Texture_Thumbnail_Mode() );
  157. // registry->Set_Int( "TextureCompression", WW3D::Get_Texture_Compression_Mode() );
  158. // registry->Set_Int( "NPatchesLevel", WW3D::Get_NPatches_Level() );
  159. registry->Set_Int( "FPS", Get_Console()->Is_FPS_Active() );
  160. }
  161. delete registry;
  162. }
  163. #define BACKSPACE_KEY 8
  164. #define ESC_KEY 27
  165. #define ENTER_KEY 13
  166. #define TAB_KEY 0x09
  167. #define SPACE_KEY 0x20
  168. /*
  169. ** called each time through the main loop
  170. */
  171. void ConsoleGameModeClass::Think()
  172. {
  173. WWPROFILE( "Console Think" );
  174. /*
  175. //
  176. // TSS092501 - disabling this because it is fatal.
  177. // If you want it, you'll have to fix it!
  178. //
  179. if (Input::Get_State(INPUT_FUNCTION_VERBOSE_HELP)) {
  180. ConsoleFunctionManager::Next_Verbose_Help_Screen();
  181. }
  182. */
  183. //cNetwork::Watch_Wol_Location(Drawer, Font);
  184. if ( !InputActive ) {
  185. bool enable_console = false;
  186. #pragma message("TODO: relocate and provide UI for player communication.")
  187. // HACK: Disable console in ATI demo
  188. //#ifndef ATI_DEMO_HACK
  189. if (Input::Get_State(INPUT_FUNCTION_BEGIN_CONSOLE)) {
  190. enable_console = true;
  191. ConsoleInputType = INPUT_FUNCTION_BEGIN_CONSOLE;
  192. strcpy(InputLine, "Command >");
  193. }
  194. //#endif
  195. if (enable_console) {
  196. InputActive = true;
  197. PromptLength = strlen(InputLine);
  198. Input::Console_Enable();
  199. Clear_Suggestion();
  200. }
  201. }
  202. /*
  203. ** Handle Console Input
  204. */
  205. if ( InputActive ) {
  206. WWPROFILE( "Input Active" );
  207. int key = Input::Console_Get_Key();
  208. while ( key ) {
  209. int len = strlen( InputLine ) ;
  210. switch( key ) {
  211. case ENTER_KEY:
  212. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  213. Accept_Suggestion(InputLine + PromptLength);
  214. len = strlen(InputLine);
  215. Clear_Suggestion();
  216. }
  217. //Parse_Input( InputLine );
  218. Parse_Input( InputLine + PromptLength );
  219. case ESC_KEY:
  220. InputActive = false;
  221. Input::Console_Disable();
  222. break;
  223. case BACKSPACE_KEY:
  224. //if ( len > 0 ) {
  225. if ( len > PromptLength ) {
  226. InputLine[ --len ] = 0;
  227. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  228. Update_Suggestion(InputLine + PromptLength,true);
  229. }
  230. } else {
  231. //DebugManager::Display();
  232. }
  233. break;
  234. case TAB_KEY:
  235. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  236. Update_Suggestion(InputLine + PromptLength,true);
  237. }
  238. break;
  239. case SPACE_KEY:
  240. // Accept any suggested command line completion and fall through to default
  241. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  242. Accept_Suggestion(InputLine + PromptLength);
  243. len = strlen(InputLine);
  244. }
  245. default:
  246. if ( len + 1 < MAX_INPUT_LINE_LENGTH) {
  247. InputLine[ len++ ] = key;
  248. InputLine[ len ] = 0;
  249. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  250. Update_Suggestion(InputLine + PromptLength,false);
  251. }
  252. } else {
  253. //DebugManager::Display();
  254. }
  255. break;
  256. }
  257. key = Input::Console_Get_Key();
  258. }
  259. /*
  260. ** Console Input Output
  261. */
  262. char mess[MAX_INPUT_LINE_LENGTH+2];
  263. strcpy( mess, InputLine );
  264. static int flash = 0;
  265. if ( (int)(TimeManager::Get_Seconds()*4) & 1 ) {
  266. strcat( mess, "|" );
  267. }
  268. strcat( mess, "\n" );
  269. Vector3 color(1.0f,1.0f,1.0f);
  270. switch (ConsoleInputType) {
  271. /*
  272. case INPUT_FUNCTION_BEGIN_PUBLIC_MESSAGE :
  273. color = COLOR_PUBLIC_TEXT;
  274. break;
  275. case INPUT_FUNCTION_BEGIN_TEAM_MESSAGE :
  276. color = cNetwork::Get_My_Color();
  277. break;
  278. case INPUT_FUNCTION_BEGIN_PRIVATE_MESSAGE :
  279. color = COLOR_PRIVATE_TEXT;
  280. break;
  281. */
  282. case INPUT_FUNCTION_BEGIN_CONSOLE :
  283. color = COLOR_CONSOLE_TEXT;
  284. break;
  285. default :
  286. DIE;
  287. break;
  288. }
  289. if (Get_Text_Display()) {
  290. WWASSERT( Get_Text_Display() );
  291. Get_Text_Display()->Set_Input_Text( mess );
  292. Get_Text_Display()->Set_Help_Text( HelpLine );
  293. }
  294. } else {
  295. if (Get_Text_Display()) {
  296. WWASSERT( Get_Text_Display() );
  297. Vector3 color(1,1,1);
  298. Get_Text_Display()->Set_Input_Text( "" );
  299. Get_Text_Display()->Set_Help_Text( "" );
  300. }
  301. }
  302. /****************************************************************************************
  303. **
  304. ** Vis Warning, In debug and profile mode, always display a warning if vis is missing
  305. **
  306. ****************************************************************************************/
  307. #ifdef WWDEBUG
  308. { WWPROFILE( "Vis Check" );
  309. if (Get_Text_Display()) {
  310. PhysicsSceneClass * scene = PhysicsSceneClass::Get_Instance();
  311. Get_Text_Display()->Display_Vis_Warning( scene && scene->Is_Vis_Sector_Missing() );
  312. }
  313. }
  314. #endif
  315. // Note: As you add more stats, also add to the stats help command.
  316. /****************************************************************************************
  317. **
  318. ** Frame-Rate Stats. Activate with 'stats fps'
  319. **
  320. ****************************************************************************************/
  321. if (Get_Text_Display()) {
  322. // Update text if it's visible
  323. if (StatisticsDisplayManager::Is_Current_Display("histogram")) {
  324. StringClass working_string(true);
  325. StringClass message(true);
  326. float cur_time = TimeManager::Get_Seconds();
  327. FPSTime += cur_time - FPSLastTime;
  328. FPSLastTime = cur_time;
  329. FPSFrames++;
  330. if ( FPSTime >= 1.0f ) {
  331. FPS = (float)FPSFrames/FPSTime;
  332. FPSTime = 0.0f;
  333. FPSFrames = 0;
  334. }
  335. working_string.Format("%2.0f fps\n\n",FPS);
  336. message += working_string;
  337. unsigned slot_count=TimeManager::Peek_Frame_Time_Histogram().Get_Slot_Count();
  338. if (slot_count) {
  339. unsigned char* slots=new unsigned char[slot_count];
  340. TimeManager::Peek_Frame_Time_Histogram().Get_Packed_Report(slots);
  341. unsigned i;
  342. for (i=0;i<slot_count;++i) {
  343. working_string.Format("%d: %d\n",
  344. unsigned(TimeManager::Peek_Frame_Time_Histogram().Get_Step()*float(i)),
  345. slots[i]);
  346. message+=working_string;
  347. }
  348. delete[] slots;
  349. }
  350. StatisticsDisplayManager::Set_Stat( "histogram", message );
  351. }
  352. // Update text if it's visible
  353. if (StatisticsDisplayManager::Is_Current_Display("fps")) {
  354. StringClass working_string(true);
  355. StringClass message(true);
  356. float cur_time = TimeManager::Get_Seconds();
  357. FPSTime += cur_time - FPSLastTime;
  358. FPSLastTime = cur_time;
  359. FPSFrames++;
  360. if ( FPSTime >= 1.0f ) {
  361. FPS = (float)FPSFrames/FPSTime;
  362. FPSTime = 0.0f;
  363. FPSFrames = 0;
  364. }
  365. working_string.Format("%2.0f fps\n",FPS);
  366. message += working_string;
  367. #ifdef ATI_DEMO_HACK
  368. if (WW3D::Get_NPatches_Level()>1) {
  369. working_string.Format(
  370. "\nNPATCH level: %d\n",
  371. WW3D::Get_NPatches_Level());
  372. }
  373. else {
  374. working_string.Format("\nNPATCH OFF\n");
  375. }
  376. message += working_string;
  377. #endif
  378. working_string.Format(
  379. "\npolys/frame: %7d\npolys/second %4dk\n",
  380. WW3D::Get_Last_Frame_Poly_Count(),
  381. int(WW3D::Get_Last_Frame_Poly_Count()*FPS/1000));
  382. message += working_string;
  383. unsigned ffheap=FastAllocatorGeneral::Get_Allocator()->Get_Total_Heap_Size();
  384. unsigned ffuse=FastAllocatorGeneral::Get_Allocator()->Get_Total_Allocated_Size();
  385. unsigned actualuse=FastAllocatorGeneral::Get_Allocator()->Get_Total_Actual_Memory_Usage();
  386. unsigned count=FastAllocatorGeneral::Get_Allocator()->Get_Total_Allocation_Count();
  387. working_string.Format(
  388. "\nMalloc count: %d\n"
  389. "Free count: %d\n"
  390. "FF Heap: %d.%3.3d.%3.3d (%d Mb)\n"
  391. "FF Use: %d.%3.3d.%3.3d (%d Mb)\n"
  392. "Actual Use: %d.%3.3d.%3.3d (%d Mb)\n"
  393. "FF Count: %d\n"
  394. ,
  395. WW3D::Get_Last_Frame_Memory_Allocation_Count(),
  396. WW3D::Get_Last_Frame_Memory_Free_Count(),
  397. ffheap/(1000*1000),(ffheap/1000)%1000,ffheap%1000, ffheap/(1024*1024),
  398. ffuse/(1000*1000),(ffuse/10000)%1000,ffuse%1000, ffuse/(1024*1024),
  399. actualuse/(1000*1000),(actualuse/1000)%1000,actualuse%1000, actualuse/(1024*1024),
  400. count);
  401. message += working_string;
  402. #ifndef ATI_DEMO_HACK
  403. working_string.Format("verts/frame: %7d v/p ratio: %2.2f\n",
  404. WW3D::Get_Last_Frame_Vertex_Count(),
  405. float(WW3D::Get_Last_Frame_Vertex_Count())/float(WW3D::Get_Last_Frame_Poly_Count()));
  406. message += working_string;
  407. #endif
  408. int texture_reduction = WW3D::Get_Texture_Reduction();
  409. if (texture_reduction > 0) {
  410. working_string.Format("Tex. Red. %d\n\n", texture_reduction);
  411. message += working_string;
  412. }
  413. // Only display texture and vertex processor statistics if texture statistics recording is enabled
  414. if (Debug_Statistics::Get_Record_Texture_Mode()!=Debug_Statistics::RECORD_TEXTURE_NONE) {
  415. // Texture usage
  416. int red_size=Debug_Statistics::Get_Record_Texture_Size();
  417. int lightmap_size=Debug_Statistics::Get_Record_Lightmap_Texture_Size();
  418. int procedural_size=Debug_Statistics::Get_Record_Procedural_Texture_Size();
  419. working_string.Format(
  420. "\n"
  421. "textures/frame: %5d\n"
  422. "tex memory used: %d.%dMb\n"
  423. "texture changes: %d\n"
  424. ,
  425. Debug_Statistics::Get_Record_Texture_Count(),
  426. red_size>>20,
  427. (10*(red_size>>10)>>10)%10,
  428. Debug_Statistics::Get_Record_Texture_Change_Count());
  429. message += working_string;
  430. // Lightmap info
  431. working_string.Format(
  432. "\n"
  433. "lightmaps/frame: %5d\n"
  434. "lightmap memory used: %d.%dMb\n"
  435. ,
  436. Debug_Statistics::Get_Record_Lightmap_Texture_Count(),
  437. lightmap_size>>20,
  438. (10*(lightmap_size>>10)>>10)%10);
  439. message += working_string;
  440. // Procedural texture info
  441. working_string.Format(
  442. "\n"
  443. "procedural textures/frame: %5d\n"
  444. "procedural memory used: %d.%dMb\n\n"
  445. ,
  446. Debug_Statistics::Get_Record_Procedural_Texture_Count(),
  447. procedural_size>>20,
  448. (10*(procedural_size>>10)>>10)%10);
  449. message += working_string;
  450. // Texture info
  451. red_size=TextureClass::_Get_Total_Texture_Size();
  452. lightmap_size=TextureClass::_Get_Total_Lightmap_Texture_Size();
  453. procedural_size=TextureClass::_Get_Total_Procedural_Texture_Size();
  454. working_string.Format(
  455. "\n"
  456. "total tex loaded: %5d\n"
  457. "total size of textures: %d.%dMb\n"
  458. "\n"
  459. "total lightmaps: %5d\n"
  460. "total size of lightmaps: %dMb\n"
  461. "\n"
  462. "total procedural textures: %5d\n"
  463. "total size of procedural textures: %dMb\n"
  464. ,
  465. TextureClass::_Get_Total_Texture_Count(),
  466. red_size>>20,
  467. (10*(red_size>>10)>>10)%10,
  468. TextureClass::_Get_Total_Lightmap_Texture_Count(),
  469. lightmap_size>>20,
  470. (10*(lightmap_size>>10)>>10)%10,
  471. TextureClass::_Get_Total_Procedural_Texture_Count(),
  472. procedural_size>>20,
  473. (10*(procedural_size>>10)>>10)%10);
  474. message += working_string;
  475. // Thumbnail info
  476. red_size=TextureClass::_Get_Total_Locked_Surface_Size();
  477. working_string.Format(
  478. "total thumbnails: %5d\n"
  479. "total size of thumbnails: %d.%dMb\n"
  480. ,
  481. TextureClass::_Get_Total_Locked_Surface_Count(),
  482. red_size>>20,
  483. (10*(red_size>>10)>>10)%10);
  484. message += working_string;
  485. if (Debug_Statistics::Get_Record_Texture_Mode()==Debug_Statistics::RECORD_TEXTURE_DETAILS) {
  486. message+="\n"
  487. "<F9 + F5> Scroll up\n"
  488. "<F9 + F6> Scroll down\n"
  489. "\n";
  490. message+=Debug_Statistics::Get_Record_Texture_String();
  491. }
  492. }
  493. if (Debug_Statistics::Get_Record_Texture_Mode()==Debug_Statistics::RECORD_TEXTURE_DETAILS) {
  494. StatisticsDisplayManager::Set_Stat( "fps", message, 0xffffffcf );
  495. }
  496. else {
  497. StatisticsDisplayManager::Set_Stat( "fps", message );
  498. }
  499. }
  500. /****************************************************************************************
  501. **
  502. ** Meshmodel Stats. Activate with 'stats dx8'
  503. **
  504. ****************************************************************************************/
  505. // Update text if it's visible
  506. if (StatisticsDisplayManager::Is_Current_Display("dx8")) {
  507. StringClass working_string(true);
  508. StringClass message(true);
  509. float cur_time = TimeManager::Get_Seconds();
  510. FPSTime += cur_time - FPSLastTime;
  511. FPSLastTime = cur_time;
  512. FPSFrames++;
  513. if ( FPSTime >= 1.0f ) {
  514. FPS = (float)FPSFrames/FPSTime;
  515. FPSTime = 0.0f;
  516. FPSFrames = 0;
  517. }
  518. message.Format("%2.0f fps\n",FPS);
  519. working_string.Format(
  520. "Total DX8 calls: %d\n"
  521. "Total Polys: %d\n"
  522. "Total Verts: %d\n"
  523. "Skins rendered: %d\n"
  524. "(Total Polys in skins: %d)\n"
  525. "(Total Verts in skins: %d)\n"
  526. "Matrix changes: %d\n"
  527. "Texture changes: %d\n"
  528. "Material changes: %d\n"
  529. "VB changes: %d\n"
  530. "IB changes: %d\n"
  531. "Light changes: %d\n\n"
  532. "Sorted polys: %d\n"
  533. "Sorted verts: %d\n",
  534. DX8Wrapper::Get_Last_Frame_DX8_Calls(),
  535. Debug_Statistics::Get_DX8_Polygons(),
  536. Debug_Statistics::Get_DX8_Vertices(),
  537. Debug_Statistics::Get_DX8_Skin_Renders(),
  538. Debug_Statistics::Get_DX8_Skin_Polygons(),
  539. Debug_Statistics::Get_DX8_Skin_Vertices(),
  540. DX8Wrapper::Get_Last_Frame_Matrix_Changes(),
  541. Debug_Statistics::Get_Record_Texture_Count(),
  542. DX8Wrapper::Get_Last_Frame_Material_Changes(),
  543. DX8Wrapper::Get_Last_Frame_Vertex_Buffer_Changes(),
  544. DX8Wrapper::Get_Last_Frame_Index_Buffer_Changes(),
  545. DX8Wrapper::Get_Last_Frame_Light_Changes(),
  546. Debug_Statistics::Get_Sorting_Polygons(),
  547. Debug_Statistics::Get_Sorting_Vertices());
  548. message+=working_string;
  549. // DX8MeshRendererContainerClass* n=DX8MeshRendererContainerClass::Head();
  550. // int cont=0;
  551. // while (n) {
  552. // First check if container it empty
  553. /* bool empty=true;
  554. for (int a=0;a<DX8MeshRendererContainerClass::RENDER_CLASS_MAX;++a) {
  555. DX8MeshRendererClass* renderer=n->render_class_types[a].Get_Renderer_Head();
  556. if (renderer) {
  557. empty=false;
  558. break;
  559. }
  560. }
  561. // Log stats only if container is not empty
  562. if (empty) {
  563. working_string.Format("Container: %d EMPTY\n",cont);
  564. message+=working_string;
  565. }
  566. else {
  567. working_string.Format("Container: %d\n",cont);
  568. message+=working_string;
  569. for (int a=0;a<DX8MeshRendererContainerClass::RENDER_CLASS_MAX;++a) {
  570. working_string.Format("Class: %s",
  571. DX8MeshRendererContainerClass::Get_Render_Class_Name(a));
  572. message+=working_string;
  573. DX8MeshRendererClass* renderer=n->render_class_types[a].Get_Renderer_Head();
  574. if (!renderer) {
  575. message+=" No registered renderers!\n";
  576. }
  577. else {
  578. message+="\n";
  579. }
  580. while (renderer) {
  581. if (renderer->stats_last_frame_add_calls || renderer->stats_last_frame_count) {
  582. working_string.Format("%24s Add: %3d Render: %3d Polys: %3d\n",
  583. renderer->name,
  584. renderer->stats_last_frame_add_calls,
  585. renderer->stats_last_frame_count,
  586. renderer->stats_last_frame_polys);
  587. message+=working_string;
  588. }
  589. renderer=renderer->Succ();
  590. }
  591. }
  592. }
  593. */
  594. // n=n->Succ();
  595. // cont++;
  596. // }
  597. /* working_string.Format("Total add renders: %d\n",DX8MeshRendererClass::Get_Last_Frame_Render_Stats());
  598. message+=working_string;
  599. for (int ridx=0;ridx<DX8MeshRendererContainerClass::RENDER_CLASS_MAX;++ridx) {
  600. working_string.Format("Class: %s\nObjects: %d\nPolys: %d\n\n",
  601. DX8MeshRendererContainerClass::Get_Render_Class_Name(ridx),
  602. DX8MeshRendererClass::Get_Last_Frame_Render_Stats(ridx).count,
  603. DX8MeshRendererClass::Get_Last_Frame_Render_Stats(ridx).polys);
  604. message+=working_string;
  605. }
  606. */ StatisticsDisplayManager::Set_Stat( "dx8", message, 0xffffffff );
  607. }
  608. /****************************************************************************************
  609. **
  610. ** Audio Stats. Activate with 'stats audio'
  611. **
  612. ****************************************************************************************/
  613. // Update text if it's visible
  614. if (StatisticsDisplayManager::Is_Current_Display("audio")) {
  615. StringClass message (true);
  616. StringClass temp_string (true);
  617. int count_2d = WWAudioClass::Get_Instance ()->Get_2D_Sample_Count ();
  618. int count_3d = WWAudioClass::Get_Instance ()->Get_3D_Sample_Count ();
  619. message = "2D or Pseudo-3D Sounds:\n";
  620. //
  621. // Add all the 2D sounds to the message
  622. //
  623. for (int sample_index = 0; sample_index < count_2d; sample_index ++) {
  624. temp_string.Format (" %d.", sample_index + 1);
  625. message += temp_string;
  626. AudibleSoundClass *sound_obj = WWAudioClass::Get_Instance ()->Peek_2D_Sample (sample_index);
  627. if (sound_obj != NULL) {
  628. if (sound_obj->Get_Type () == AudibleSoundClass::TYPE_MUSIC) {
  629. message += "(M)";
  630. } else if (sound_obj->Get_Type () == AudibleSoundClass::TYPE_SOUND_EFFECT) {
  631. message += "(S)";
  632. } else if (sound_obj->Get_Type () == AudibleSoundClass::TYPE_DIALOG) {
  633. message += "(D)";
  634. }
  635. StringClass filename = sound_obj->Get_Filename ();
  636. message += filename;
  637. message += "\n";
  638. Vector3 curr_pos = sound_obj->Get_Position ();
  639. PhysicsSceneClass::Get_Instance ()->Add_Debug_AABox (AABoxClass (curr_pos, Vector3 (0.25F,0.25F,0.25F)), Vector3 (1, 0, 0));
  640. } else {
  641. message += " --\n";
  642. }
  643. }
  644. message += "\n3D Sounds:\n";
  645. //
  646. // Add all the 2D sounds to the message
  647. //
  648. for (sample_index = 0; sample_index < count_3d; sample_index ++) {
  649. temp_string.Format (" %d.", sample_index + 1);
  650. message += temp_string;
  651. AudibleSoundClass *sound_obj = WWAudioClass::Get_Instance ()->Peek_3D_Sample (sample_index);
  652. if (sound_obj != NULL) {
  653. if (sound_obj->Get_Type () == AudibleSoundClass::TYPE_MUSIC) {
  654. message += "(M)";
  655. } else if (sound_obj->Get_Type () == AudibleSoundClass::TYPE_SOUND_EFFECT) {
  656. message += "(S)";
  657. } else if (sound_obj->Get_Type () == AudibleSoundClass::TYPE_DIALOG) {
  658. message += "(D)";
  659. }
  660. StringClass filename = sound_obj->Get_Filename ();
  661. message += filename;
  662. message += "\n";
  663. Vector3 curr_pos = sound_obj->Get_Position ();
  664. PhysicsSceneClass::Get_Instance ()->Add_Debug_AABox (AABoxClass (curr_pos, Vector3 (0.25F,0.25F,0.25F)), Vector3 (0, 0, 1));
  665. } else {
  666. message += " --\n";
  667. }
  668. }
  669. StatisticsDisplayManager::Set_Stat( "audio", message, 0xffffffff );
  670. }
  671. /****************************************************************************************
  672. **
  673. ** Mesh rendering debug display page. Activate with 'stats mesh'
  674. **
  675. ****************************************************************************************/
  676. if (StatisticsDisplayManager::Is_Current_Display("mesh")) {
  677. StringClass message;
  678. DX8RendererDebugger::Enable(true); // The first frame will not have any information...
  679. DX8RendererDebugger::Get_String(message);
  680. StatisticsDisplayManager::Set_Stat( "star", message );
  681. Vector2 pos = Render2DClass::Get_Screen_Resolution().Upper_Left();
  682. StatisticsDisplayManager::Set_Stat( "mesh", message, 0xffffffff, pos );
  683. }
  684. /****************************************************************************************
  685. **
  686. ** Star Stats Page. Activate with 'stats star'
  687. **
  688. ****************************************************************************************/
  689. if (StatisticsDisplayManager::Is_Current_Display("star")) {
  690. StringClass working_string(true);
  691. StringClass message(true);
  692. working_string.Format("Star (%1.1f, %1.1f, %1.1f) %1.1f\n",
  693. PlayerPosition.X, PlayerPosition.Y, PlayerPosition.Z, RAD_TO_DEGF(PlayerFacing) );
  694. message = working_string;
  695. if (COMBAT_STAR) {
  696. Phys3Class * pobj = COMBAT_STAR->Peek_Physical_Object()->As_Phys3Class();
  697. if (pobj) {
  698. Vector3 vel;
  699. pobj->Get_Velocity(&vel);
  700. working_string.Format("Vel (%1.1f, %1.1f, %1.1f)\n",vel.X,vel.Y,vel.Z);
  701. message += working_string;
  702. }
  703. }
  704. if ( COMBAT_CAMERA ) {
  705. working_string.Format("Range %1.1f\n", COMBAT_CAMERA->Get_Sniper_Distance() );
  706. message += working_string;
  707. }
  708. StatisticsDisplayManager::Set_Stat( "star", message );
  709. }
  710. /****************************************************************************************
  711. **
  712. ** Collision Detection Stats Page. Activate with 'stats collision'
  713. **
  714. ****************************************************************************************/
  715. if (StatisticsDisplayManager::Is_Current_Display("collision")) {
  716. StringClass working_string(true);
  717. StringClass message(true);
  718. const CollisionMath::ColmathStatsStruct & stats = CollisionMath::Get_Current_Stats();
  719. working_string.Format("Collision Stats\n");
  720. message = working_string;
  721. working_string.Format("Tests: %d\n",stats.TotalCollisionCount);
  722. message += working_string;
  723. working_string.Format("Hits: %d\n",stats.TotalCollisionHitCount);
  724. message += working_string;
  725. working_string.Format("Ray-Tri Tests: %d\n",stats.CollisionRayTriCount);
  726. message += working_string;
  727. working_string.Format("Ray-Tri Hits: %d\n",stats.CollisionRayTriHitCount);
  728. message += working_string;
  729. working_string.Format("AAB-Tri Tests: %d\n",stats.CollisionAABoxTriCount);
  730. message += working_string;
  731. working_string.Format("AAB-Tri Hits: %d\n",stats.CollisionAABoxTriHitCount);
  732. message += working_string;
  733. working_string.Format("OBB-Tri Tests: %d\n",stats.CollisionOBBoxTriCount);
  734. message += working_string;
  735. working_string.Format("OBB-Tri Hits: %d\n",stats.CollisionOBBoxTriHitCount);
  736. message += working_string;
  737. StatisticsDisplayManager::Set_Stat( "collision", message );
  738. }
  739. CollisionMath::Reset_Stats();
  740. /****************************************************************************************
  741. **
  742. ** Culling Stats Page. Activate with 'stats culling'
  743. **
  744. ****************************************************************************************/
  745. if (StatisticsDisplayManager::Is_Current_Display("culling")) {
  746. StringClass working_string(true);
  747. StringClass message(true);
  748. PhysicsSceneClass * the_scene = PhysicsSceneClass::Get_Instance();
  749. working_string.Format("Culling Stats\n");
  750. message = working_string;
  751. if (the_scene != NULL) {
  752. const PhysicsSceneClass::StatsStruct & stats = the_scene->Get_Statistics();
  753. if (stats.FrameCount > 0) {
  754. working_string.Format("Frames: %d\n",stats.FrameCount);
  755. message += working_string;
  756. working_string.Format("Node Count: %d\n",stats.CullNodeCount);
  757. message += working_string;
  758. working_string.Format("Accepted: %d %10.3f pf\n",stats.CullNodesAccepted,(float)stats.CullNodesAccepted / (float)stats.FrameCount);
  759. message += working_string;
  760. working_string.Format("Triv Accepted: %d %10.3f pf\n",stats.CullNodesTriviallyAccepted,(float)stats.CullNodesTriviallyAccepted / (float)stats.FrameCount);
  761. message += working_string;
  762. working_string.Format("Rejected: %d %10.3f pf\n",stats.CullNodesRejected,(float)stats.CullNodesRejected / (float)stats.FrameCount);
  763. message += working_string;
  764. }
  765. }
  766. StatisticsDisplayManager::Set_Stat( "culling", message );
  767. }
  768. /****************************************************************************************
  769. **
  770. ** Physics Stats Page. Activate with 'stats physics'
  771. **
  772. ****************************************************************************************/
  773. if (StatisticsDisplayManager::Is_Current_Display("physics")) {
  774. StringClass working_string(true);
  775. StringClass message(true);
  776. PhysicsSceneClass * the_scene = PhysicsSceneClass::Get_Instance();
  777. working_string.Format("Physics Stats\n");
  778. message = working_string;
  779. if (the_scene != NULL) {
  780. int phys3_count = 0;
  781. int phys3_active_count = 0;
  782. int human_count = 0;
  783. int rbody_count = 0;
  784. int rbody_active_count = 0;
  785. int wheeled_count = 0;
  786. int tracked_count = 0;
  787. int vtol_count = 0;
  788. int projectile_count = 0;
  789. int decoration_count = 0;
  790. int light_count = 0;
  791. int rendobj_count = 0;
  792. int other_count = 0;
  793. RefPhysListIterator iterator = the_scene->Get_Dynamic_Object_Iterator();
  794. for (iterator.First(); !iterator.Is_Done(); iterator.Next()) {
  795. PhysClass * obj = iterator.Peek_Obj();
  796. WWASSERT(obj != NULL);
  797. if (obj->As_Phys3Class()) {
  798. phys3_count++;
  799. if (!obj->Is_Asleep()) {
  800. phys3_active_count++;
  801. }
  802. if (obj->As_HumanPhysClass()) {
  803. human_count++;
  804. }
  805. } else if (obj->As_RigidBodyClass()) {
  806. rbody_count++;
  807. bool is_active = true;
  808. if (obj->Is_Asleep()) {
  809. is_active = false;
  810. }
  811. if ((obj->As_VehiclePhysClass()) && (obj->As_VehiclePhysClass()->Get_VehiclePhysDef()->Is_Fake() == true)) {
  812. is_active = false;
  813. }
  814. if (is_active) {
  815. rbody_active_count++;
  816. }
  817. if (obj->As_WheeledVehicleClass()) {
  818. wheeled_count++;
  819. } else if (obj->As_TrackedVehicleClass()) {
  820. tracked_count++;
  821. } else if (obj->As_VTOLVehicleClass()) {
  822. vtol_count++;
  823. }
  824. } else if (obj->As_LightPhysClass()) {
  825. light_count++;
  826. } else if (obj->As_DecorationPhysClass()) {
  827. decoration_count++;
  828. } else if (obj->As_ProjectileClass()) {
  829. projectile_count++;
  830. } else if (obj->As_RenderObjPhysClass()) {
  831. rendobj_count++;
  832. } else {
  833. other_count++;
  834. }
  835. }
  836. working_string.Format("Phys3 Objects: %d (active: %d)\n",phys3_count,phys3_active_count);
  837. message += working_string;
  838. working_string.Format(" Human Objects: %d\n\n",human_count);
  839. message += working_string;
  840. working_string.Format("RBody Objects: %d (active: %d)\n",rbody_count,rbody_active_count);
  841. message += working_string;
  842. working_string.Format(" WheeledVehicle Objects: %d\n",wheeled_count);
  843. message += working_string;
  844. working_string.Format(" TrackedVehicle Objects: %d\n",tracked_count);
  845. message += working_string;
  846. working_string.Format(" VTOLVehicle Objects: %d\n\n",vtol_count);
  847. message += working_string;
  848. working_string.Format("Static Lights: %d\n",light_count);
  849. message += working_string;
  850. working_string.Format("Decoration Objects: %d\n",decoration_count);
  851. message += working_string;
  852. working_string.Format("Projectile Objects: %d\n",projectile_count);
  853. message += working_string;
  854. working_string.Format("Render Object Wrappers: %d\n",rendobj_count);
  855. message += working_string;
  856. working_string.Format("Other Objects: %d\n",other_count);
  857. message += working_string;
  858. int static_obj_count = 0;
  859. int static_anim_count = 0;
  860. iterator = the_scene->Get_Static_Object_Iterator();
  861. for (iterator.First(); !iterator.Is_Done(); iterator.Next()) {
  862. PhysClass * obj = iterator.Peek_Obj();
  863. WWASSERT(obj != NULL);
  864. if (obj->As_StaticPhysClass()) static_obj_count++;
  865. if (obj->As_StaticAnimPhysClass()) static_anim_count++;
  866. }
  867. working_string.Format("Static objects: %d\n",static_obj_count);
  868. message += working_string;
  869. working_string.Format(" Static Anim Objects: %d\n",static_anim_count);
  870. message += working_string;
  871. StatisticsDisplayManager::Set_Stat("physics", message);
  872. }
  873. }
  874. /****************************************************************************************
  875. **
  876. ** Vehicle Debug Stats Page. Activate with 'stats vehicle'
  877. ** This will dump stats about any vehicle the player is currently controlling.
  878. **
  879. ****************************************************************************************/
  880. if (StatisticsDisplayManager::Is_Current_Display("vehicle")) {
  881. StringClass working_string(true);
  882. StringClass message(true);
  883. working_string.Format("Vehicle Debug Stats\n");
  884. message = working_string;
  885. if ((COMBAT_STAR != NULL) && (((PhysicalGameObj *) COMBAT_STAR)->As_SoldierGameObj() != NULL)) {
  886. VehicleGameObj * vehicle_game_obj = ((PhysicalGameObj *)COMBAT_STAR)->As_SoldierGameObj()->Get_Vehicle();
  887. if ((vehicle_game_obj != NULL) && (vehicle_game_obj->Peek_Physical_Object() != NULL)) {
  888. VehiclePhysClass * vehicle = vehicle_game_obj->Peek_Physical_Object()->As_VehiclePhysClass();
  889. if (vehicle != NULL) {
  890. Vector3 vel;
  891. vehicle->Get_Velocity(&vel);
  892. float meters_per_sec = vel.Length();
  893. float miles_per_hour = meters_per_sec * 60.0f * 60.0f * (1/1609.0f);
  894. working_string.Format("Current Velocity: %10.2f m/s (%10.2f mph)\r\n",meters_per_sec,miles_per_hour);
  895. message += working_string;
  896. WheeledVehicleClass * wv = vehicle->As_WheeledVehicleClass();
  897. if (wv != NULL) {
  898. working_string.Format("Current Gear: %d\n", wv->Get_Current_Gear());
  899. message += working_string;
  900. working_string.Format("Engine avel: %10.3f\n", wv->Get_Engine_Angular_Velocity());
  901. message += working_string;
  902. working_string.Format("Engine rpm: %10.3f\n", RADS_TO_RPM(wv->Get_Engine_Angular_Velocity()));
  903. message += working_string;
  904. working_string.Format("Axle rpm: %10.3f\n", RADS_TO_RPM(wv->Get_Axle_Angular_Velocity()));
  905. message += working_string;
  906. working_string.Format("Engine torque: %10.3f\n", wv->Get_Engine_Torque());
  907. message += working_string;
  908. working_string.Format("Axle torque: %10.3f\n", wv->Get_Axle_Torque());
  909. message += working_string;
  910. working_string.Format("Max Engine torque: %10.3f\n", wv->Get_Max_Engine_Torque());
  911. message += working_string;
  912. }
  913. TrackedVehicleClass * tv = vehicle->As_TrackedVehicleClass();
  914. if (tv != NULL) {
  915. const TrackedVehicleDefClass * def = tv->Get_TrackedVehicleDef();
  916. if (def != NULL) {
  917. working_string.Format("Max Engine Torque: %10.3f\n", def->Get_Max_Engine_Torque());
  918. message += working_string;
  919. working_string.Format("Turn Torque Scale Factor: %10.3f\n", def->Get_Turn_Torque_Scale_Factor());
  920. message += working_string;
  921. }
  922. }
  923. }
  924. }
  925. }
  926. StatisticsDisplayManager::Set_Stat("vehicle", message, 0xffffffff );
  927. }
  928. /****************************************************************************************
  929. **
  930. ** Collision Detection Stats Page. Activate with 'stats collision'
  931. **
  932. ****************************************************************************************/
  933. if (StatisticsDisplayManager::Is_Current_Display("ai")) {
  934. StringClass working_string(true);
  935. StringClass message(true);
  936. working_string.Format("AI Stats\n");
  937. message = working_string;
  938. extern int _ActionActCalls;
  939. working_string.Format("%d Action Act Calls\n",_ActionActCalls);
  940. message += working_string;
  941. _ActionActCalls = 0;
  942. extern int _ActionCodeChanges;
  943. working_string.Format("%d Action Code Changes\n", _ActionCodeChanges);
  944. message += working_string;
  945. _ActionCodeChanges = 0;
  946. extern int _AwakeSoldiers;
  947. working_string.Format("%d Awake Soldiers\n", _AwakeSoldiers);
  948. message += working_string;
  949. _AwakeSoldiers = 0;
  950. extern int _HibernatingSoldiers;
  951. working_string.Format("%d Hibernating Soldiers\n", _HibernatingSoldiers);
  952. message += working_string;
  953. _HibernatingSoldiers = 0;
  954. SLNode<BaseGameObj> *objnode;
  955. for ( objnode = GameObjManager::Get_Game_Obj_List()->Head(); objnode; objnode = objnode->Next()) {
  956. if ( !objnode->Data()->Is_Hibernating() ) {
  957. if ( objnode->Data()->As_SmartGameObj() ) {
  958. if ( objnode->Data()->As_SmartGameObj()->As_SoldierGameObj() ) {
  959. Vector3 pos;
  960. objnode->Data()->As_SmartGameObj()->Get_Position( &pos );
  961. pos -= COMBAT_CAMERA->Get_Transform().Get_Translation();
  962. float distance = pos.Length();
  963. working_string.Format("ID %d awake (%1.1fm)\n", objnode->Data()->Get_ID(), distance );
  964. message += working_string;
  965. }
  966. }
  967. }
  968. }
  969. StatisticsDisplayManager::Set_Stat( "ai", message );
  970. }
  971. #ifdef WWDEBUG
  972. /*
  973. ** WOL location diagnostic
  974. */
  975. #if(0) // obsolete
  976. if (StatisticsDisplayManager::Is_Current_Display("wol")) {
  977. char string[200];
  978. if (GameModeManager::Find("WOL")->Is_Active()) {
  979. WWASSERT(PWC != NULL);
  980. //sprintf(string, "WOL location: %s", PWC->Translate_Location());
  981. sprintf(string, "WOL location: %s", Translate_Location(PWC->Get_Current_Location()));
  982. } else {
  983. sprintf(string, "WOL is not active.");
  984. }
  985. StatisticsDisplayManager::Set_Stat( "wol", string );
  986. }
  987. #endif // obsolete
  988. #endif // WWDEBUG
  989. }
  990. if ( Input::Get_State( INPUT_FUNCTION_CNC )) {
  991. ConsoleFunctionManager::Parse_Input( "CNC" );
  992. }
  993. // Note: As you add more stats, also add to the stats help command.
  994. Update_Profile();
  995. Update_Memory_Log();
  996. }
  997. /*
  998. **
  999. */
  1000. void ConsoleGameModeClass::Parse_Input( char * string )
  1001. {
  1002. WWASSERT(Get_Console() != NULL);
  1003. if ( ConsoleInputType == INPUT_FUNCTION_BEGIN_PUBLIC_MESSAGE ||
  1004. ConsoleInputType == INPUT_FUNCTION_BEGIN_TEAM_MESSAGE ||
  1005. ConsoleInputType == INPUT_FUNCTION_BEGIN_PRIVATE_MESSAGE ) {
  1006. if (GameModeManager::Find("Combat")->Is_Active()) {
  1007. /*
  1008. if (cNetwork::I_Am_Client()) {
  1009. cNetwork::Send_Client_Text_Message(string, ConsoleInputType);
  1010. } else {
  1011. WWASSERT(ConsoleInputType == INPUT_FUNCTION_BEGIN_PUBLIC_MESSAGE);
  1012. WideStringClass text;
  1013. text.Convert_From(string);
  1014. if (!text.Is_Empty()) {
  1015. cScTextObj * p_test_obj = new cScTextObj;
  1016. p_test_obj->Init(text, TEXT_MESSAGE_PUBLIC, HOST_TEXT_SENDER);
  1017. }
  1018. }
  1019. */
  1020. } else if (GameModeManager::Find("WOL")->Is_Active()) {
  1021. RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
  1022. if (wolSession.IsValid()) {
  1023. wolSession->SendPublicMessage(string);
  1024. }
  1025. }
  1026. } else {
  1027. ConsoleFunctionManager::Parse_Input( string );
  1028. }
  1029. }
  1030. void ConsoleGameModeClass::Clear_Suggestion(void)
  1031. {
  1032. memset(Suggestion,0,sizeof(Suggestion));
  1033. memset(HelpLine,0,sizeof(HelpLine));
  1034. }
  1035. void ConsoleGameModeClass::Accept_Suggestion(char * cmd)
  1036. {
  1037. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  1038. // If a space has already been entered or there is no suggestion, do nothing
  1039. if ((strchr(cmd,' ') == NULL) && (strlen(Suggestion) > 0)) {
  1040. strcpy(cmd,Suggestion);
  1041. }
  1042. }
  1043. }
  1044. void ConsoleGameModeClass::Update_Suggestion(char * cmd,bool go_to_next)
  1045. {
  1046. if (ConsoleInputType == INPUT_FUNCTION_BEGIN_CONSOLE) {
  1047. // If a space has already been entered don't update so that the help stays up
  1048. if ((strlen(cmd) > 0) && (strchr(cmd,' ') == NULL)) {
  1049. char * cur_suggestion = NULL;
  1050. if ((go_to_next) && (strlen(Suggestion) > 0)) {
  1051. cur_suggestion = &(Suggestion[0]);
  1052. }
  1053. bool gotone = ConsoleFunctionManager::Get_Command_Suggestion(cmd,cur_suggestion,Suggestion,HelpLine,sizeof(Suggestion));
  1054. if (!gotone) {
  1055. Clear_Suggestion();
  1056. }
  1057. }
  1058. }
  1059. }
  1060. void ConsoleGameModeClass::Profile_Command( const char * command )
  1061. {
  1062. if ( ProfileIterator != NULL ) {
  1063. if ( stricmp( command, "log" ) == 0 ) {
  1064. if (profile_log_active) End_Profile_Log();
  1065. else Begin_Profile_Log();
  1066. } else if ( stricmp( command, "off" ) == 0 ) {
  1067. WWProfileManager::Release_Iterator( ProfileIterator );
  1068. ProfileIterator = NULL;
  1069. } else if ( stricmp( command, "reset" ) == 0 ) {
  1070. WWProfileManager::Reset();
  1071. } else if ( stricmp( command, "up" ) == 0 ) {
  1072. ProfileIterator->Enter_Parent();
  1073. } else {
  1074. int index = atoi( command );
  1075. if ( index > -1 ) {
  1076. ProfileIterator->Enter_Child( index );
  1077. }
  1078. }
  1079. }
  1080. if ( ProfileIterator == NULL ) {
  1081. if ( stricmp( command, "on" ) == 0 ) {
  1082. ProfileIterator = WWProfileManager::Get_Iterator();
  1083. }
  1084. }
  1085. }
  1086. StringClass profile_string;
  1087. StringClass working_string;
  1088. void ConsoleGameModeClass::Update_Profile( void )
  1089. {
  1090. WWPROFILE( "Update Profile" );
  1091. #ifdef ATI_DEMO_HACK
  1092. // HACK
  1093. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD0)) WW3D::Set_NPatches_Level(0);
  1094. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD1)) WW3D::Set_NPatches_Level(1);
  1095. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD2)) WW3D::Set_NPatches_Level(2);
  1096. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD3)) WW3D::Set_NPatches_Level(3);
  1097. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD4)) WW3D::Set_NPatches_Level(4);
  1098. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD5)) WW3D::Set_NPatches_Level(5);
  1099. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD6)) WW3D::Set_NPatches_Level(6);
  1100. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD7)) WW3D::Set_NPatches_Level(7);
  1101. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD8)) WW3D::Set_NPatches_Level(8);
  1102. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_PARENT)) {
  1103. if (COMBAT_SCENE->Get_Polygon_Mode()==SceneClass::LINE) {
  1104. COMBAT_SCENE->Set_Polygon_Mode(SceneClass::FILL);
  1105. }
  1106. else {
  1107. COMBAT_SCENE->Set_Polygon_Mode(SceneClass::LINE);
  1108. }
  1109. }
  1110. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD9)) {
  1111. unsigned i=(unsigned)WW3D::Get_NPatches_Gap_Filling_Mode();
  1112. i&=1;
  1113. i^=1;
  1114. WW3D::Set_NPatches_Gap_Filling_Mode( (WW3D::NPatchesGapFillingModeEnum) i);
  1115. }
  1116. #endif
  1117. if (!StatisticsDisplayManager::Is_Current_Display("profile")) return;
  1118. if (profile_log_active) {
  1119. Process_Profile_Log();
  1120. Vector2 pos = (Render2DClass::Get_Screen_Resolution().Upper_Left() + Render2DClass::Get_Screen_Resolution().Lower_Left()) * 0.5f;
  1121. StatisticsDisplayManager::Set_Stat( "profile", "LOG IN PROGRESS", 0xffffffff, pos );
  1122. return;
  1123. }
  1124. // It costs to allocate these, lets just skip strings that grow.
  1125. // StringClass profile_string( 2000, true );
  1126. // StringClass working_string( 200, true );
  1127. if ( ProfileIterator ) {
  1128. /*
  1129. ** Handle user input. When the profiler is active, the numeric keypad can be used to
  1130. ** traverse the profile tree.
  1131. ** '1'-'9' enter profile node 1-9
  1132. ** '.' go to parent node
  1133. ** '*' reset the profile data
  1134. */
  1135. #ifndef ATI_DEMO_HACK
  1136. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD0)) { Profile_Command("0"); }
  1137. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD1)) { Profile_Command("1"); }
  1138. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD2)) { Profile_Command("2"); }
  1139. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD3)) { Profile_Command("3"); }
  1140. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD4)) { Profile_Command("4"); }
  1141. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD5)) { Profile_Command("5"); }
  1142. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD6)) { Profile_Command("6"); }
  1143. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD7)) { Profile_Command("7"); }
  1144. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD8)) { Profile_Command("8"); }
  1145. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_CHILD9)) { Profile_Command("9"); }
  1146. if (Input::Get_State(INPUT_FUNCTION_PROFILE_ENTER_PARENT)) { Profile_Command("up"); }
  1147. if (Input::Get_State(INPUT_FUNCTION_PROFILE_RESET)) { Profile_Command("reset"); }
  1148. #endif
  1149. // Only update every 1/4 second
  1150. static float timer = 0;
  1151. timer += TimeManager::Get_Frame_Seconds();
  1152. if ( timer < 0.25f ) {
  1153. return;
  1154. }
  1155. timer = 0;
  1156. profile_string = "";
  1157. working_string = "";
  1158. /*
  1159. ** Update the profile display
  1160. */
  1161. const char * parent_name = ProfileIterator->Get_Current_Parent_Name();
  1162. float parent_time = ProfileIterator->Get_Current_Parent_Total_Time();
  1163. profile_string.Format( "PROFILE DATA for %s\n\n", parent_name );
  1164. working_string.Format(
  1165. " Name %%parent %%total ms/f ms/call calls/f\n\n");
  1166. profile_string += working_string;
  1167. int index = 0;
  1168. float total_time = WWProfileManager::Get_Time_Since_Reset();
  1169. int total_frames = WWProfileManager::Get_Frame_Count_Since_Reset();
  1170. float missing_parent_time = parent_time;
  1171. if ((total_frames > 0) && (total_time > 0.0f)) {
  1172. float percent_of_parent;
  1173. float percent_of_total;
  1174. float ms_per_frame;
  1175. float ms_per_call;
  1176. int calls_per_frame;
  1177. /*
  1178. ** Display stats for each child node
  1179. */
  1180. for ( ProfileIterator->First(); !ProfileIterator->Is_Done(); ProfileIterator->Next() ) {
  1181. int calls = ProfileIterator->Get_Current_Total_Calls();
  1182. float time = ProfileIterator->Get_Current_Total_Time();
  1183. const char * name = ProfileIterator->Get_Current_Name();
  1184. missing_parent_time -= time;
  1185. /*
  1186. ** First print the index and name of the profile entry
  1187. */
  1188. working_string.Format("%-2d %-25s",index,name);
  1189. profile_string += working_string;
  1190. /*
  1191. ** Print the percent of the parent and percent of total time.
  1192. ** If there is no parent time, we are at the wrapper of everything and
  1193. ** we simply print that it is 100% of the time and
  1194. */
  1195. percent_of_total = 100.0f * time / total_time;
  1196. if (parent_time != 0.0f) {
  1197. percent_of_parent = 100.0f * time / parent_time;
  1198. working_string.Format(" %-6.2f %-6.2f",percent_of_parent,percent_of_total);
  1199. } else {
  1200. percent_of_parent = 100.0f;
  1201. working_string.Format(" -- %-6.2f",percent_of_total);
  1202. }
  1203. profile_string += working_string;
  1204. /*
  1205. ** Print the ms_per_frame
  1206. */
  1207. ms_per_frame = 1000.0f * time / total_frames;
  1208. working_string.Format(" %-6.2f",ms_per_frame);
  1209. profile_string += working_string;
  1210. /*
  1211. ** Print the ms_per_call and number of calls or '--' if not available
  1212. */
  1213. if (calls > 0) {
  1214. ms_per_call = 1000.0f * time / (float)calls;
  1215. calls_per_frame = calls / total_frames;
  1216. working_string.Format(" %-6.2f %-4d (%4d)\n",ms_per_call, calls_per_frame, calls);
  1217. } else {
  1218. working_string.Format(" -- -- \n");
  1219. }
  1220. profile_string += working_string;
  1221. /*
  1222. ** Increment the index
  1223. */
  1224. index++;
  1225. }
  1226. /*
  1227. ** Display stats for the un-accounted time. Note that there will only be
  1228. ** "missing_parent_time" if there also was "parent_time"...
  1229. */
  1230. if (parent_time > 0.0f) {
  1231. percent_of_parent = 100.0f * missing_parent_time / parent_time;
  1232. percent_of_total = 100.0f * missing_parent_time / total_time;
  1233. ms_per_frame = 1000.0f * missing_parent_time / total_frames;
  1234. working_string.Format(
  1235. " %-25s %-6.2f %-6.2f %-6.2f\n",
  1236. "MISSING TIME",
  1237. percent_of_parent,
  1238. percent_of_total,
  1239. ms_per_frame );
  1240. profile_string += working_string;
  1241. }
  1242. }
  1243. if (ConsoleBox.Is_Exclusive()) {
  1244. ConsoleBox.Update_Profile(profile_string);
  1245. } else {
  1246. Vector2 pos = (Render2DClass::Get_Screen_Resolution().Upper_Left() + Render2DClass::Get_Screen_Resolution().Lower_Left()) * 0.5f;
  1247. StatisticsDisplayManager::Set_Stat( "profile", profile_string, 0xffffffff, pos );
  1248. }
  1249. }
  1250. }
  1251. class ProfileLogNodeClass
  1252. {
  1253. StringClass string;
  1254. ProfileLogNodeClass* succ;
  1255. float* percentages;
  1256. unsigned count;
  1257. public:
  1258. ProfileLogNodeClass(unsigned count);
  1259. ~ProfileLogNodeClass();
  1260. void Set(unsigned index,float value) { WWASSERT(index<count); percentages[index]=value; }
  1261. float Get(unsigned index) const { WWASSERT(index<count); return percentages[index]; }
  1262. void Set_String(const StringClass& string_) { string=string_; }
  1263. const StringClass& Get_String() const { return string; }
  1264. unsigned Get_Count() const { return count; }
  1265. ProfileLogNodeClass* Succ() { return succ; }
  1266. };
  1267. static ProfileLogNodeClass* profile_log_head;
  1268. static ProfileLogNodeClass* profile_log_tail;
  1269. ProfileLogNodeClass::ProfileLogNodeClass(unsigned count_)
  1270. :
  1271. count(count_),
  1272. succ(NULL)
  1273. {
  1274. if (!profile_log_head) {
  1275. profile_log_head=this;
  1276. profile_log_tail=this;
  1277. }
  1278. else {
  1279. profile_log_tail->succ=this;
  1280. profile_log_tail=this;
  1281. }
  1282. percentages=new float[count];
  1283. }
  1284. ProfileLogNodeClass::~ProfileLogNodeClass()
  1285. {
  1286. delete[] percentages;
  1287. if (profile_log_head==this) profile_log_head=succ;
  1288. if (profile_log_tail==this) profile_log_tail=NULL;
  1289. }
  1290. void ConsoleGameModeClass::Begin_Profile_Log()
  1291. {
  1292. if (profile_log_active) return;
  1293. profile_log_active=true;
  1294. }
  1295. void ConsoleGameModeClass::End_Profile_Log()
  1296. {
  1297. if (!profile_log_active) return;
  1298. profile_log_active=false;
  1299. ProfileLogNodeClass* node=profile_log_head;
  1300. if (node && profile_log_names) {
  1301. for (unsigned index=0;index<node->Get_Count();++index) {
  1302. char tmp[8];
  1303. strncpy(tmp,profile_log_names[index],sizeof(tmp));
  1304. tmp[7]='\0';
  1305. WWDEBUG_SAY(("%7s ",tmp));
  1306. }
  1307. WWDEBUG_SAY(("\n"));
  1308. }
  1309. while (node) {
  1310. for (unsigned index=0;index<node->Get_Count();++index) {
  1311. WWDEBUG_SAY(("%2.2f ",node->Get(index)));
  1312. }
  1313. WWDEBUG_SAY(("\n"));
  1314. node=node->Succ();
  1315. }
  1316. WWDEBUG_SAY(("\n\n"));
  1317. node=profile_log_head;
  1318. while (node) {
  1319. WWDEBUG_SAY(("%s\n",node->Get_String()));
  1320. node=node->Succ();
  1321. }
  1322. while (profile_log_head) {
  1323. delete profile_log_head;
  1324. }
  1325. delete[] profile_log_names;
  1326. profile_log_names=NULL;
  1327. }
  1328. void ConsoleGameModeClass::Process_Profile_Log()
  1329. {
  1330. if ( ProfileIterator ) {
  1331. // Only update every 1/4 second
  1332. static float timer = 0;
  1333. timer += TimeManager::Get_Frame_Seconds();
  1334. if ( timer < 0.25f ) {
  1335. return;
  1336. }
  1337. timer = 0;
  1338. profile_string = "";
  1339. working_string = "";
  1340. /*
  1341. ** Update the profile display
  1342. */
  1343. // const char * parent_name = ProfileIterator->Get_Current_Parent_Name();
  1344. // float parent_time = ProfileIterator->Get_Current_Parent_Total_Time();
  1345. //
  1346. float total_time = WWProfileManager::Get_Time_Since_Reset();
  1347. int total_frames = WWProfileManager::Get_Frame_Count_Since_Reset();
  1348. //
  1349. // float missing_parent_time = parent_time;
  1350. if ((total_frames > 0) && (total_time > 0.0f)) {
  1351. // float percent_of_parent;
  1352. float percent_of_total;
  1353. // float ms_per_frame;
  1354. // float ms_per_call;
  1355. // int calls_per_frame;
  1356. unsigned index=0;
  1357. for ( ProfileIterator->First(); !ProfileIterator->Is_Done(); ProfileIterator->Next(),index++ ) {
  1358. }
  1359. delete[] profile_log_names;
  1360. profile_log_names=NULL;
  1361. if (index) {
  1362. profile_log_names=new StringClass[index];
  1363. }
  1364. ProfileLogNodeClass* node=new ProfileLogNodeClass(index);
  1365. /*
  1366. ** Display stats for each child node
  1367. */
  1368. index=0;
  1369. for ( ProfileIterator->First(); !ProfileIterator->Is_Done(); ProfileIterator->Next() ) {
  1370. // int calls = ProfileIterator->Get_Current_Total_Calls();
  1371. float time = ProfileIterator->Get_Current_Total_Time();
  1372. const char * name = ProfileIterator->Get_Current_Name();
  1373. profile_log_names[index]=name;
  1374. // missing_parent_time -= time;
  1375. /*
  1376. ** First print the index and name of the profile entry
  1377. */
  1378. // working_string.Format("%-2d %-25s",index,name);
  1379. // profile_string += working_string;
  1380. /*
  1381. ** Print the percent of the parent and percent of total time.
  1382. ** If there is no parent time, we are at the wrapper of everything and
  1383. ** we simply print that it is 100% of the time and
  1384. */
  1385. percent_of_total = 100.0f * time / total_time;
  1386. // if (parent_time != 0.0f) {
  1387. // percent_of_parent = 100.0f * time / parent_time;
  1388. // working_string.Format(" %-6.2f %-6.2f",percent_of_parent,percent_of_total);
  1389. // } else {
  1390. // percent_of_parent = 100.0f;
  1391. // working_string.Format(" -- %-6.2f",percent_of_total);
  1392. // }
  1393. // profile_string += working_string;
  1394. node->Set(index,percent_of_total);
  1395. /*
  1396. ** Print the ms_per_frame
  1397. */
  1398. // ms_per_frame = 1000.0f * time / total_frames;
  1399. // working_string.Format(" %-6.2f",ms_per_frame);
  1400. // profile_string += working_string;
  1401. /*
  1402. ** Print the ms_per_call and number of calls or '--' if not available
  1403. */
  1404. // if (calls > 0) {
  1405. // ms_per_call = 1000.0f * time / (float)calls;
  1406. // calls_per_frame = calls / total_frames;
  1407. // working_string.Format(" %-6.2f %-4d (%4d)\n",ms_per_call, calls_per_frame, calls);
  1408. // } else {
  1409. // working_string.Format(" -- -- \n");
  1410. // }
  1411. // profile_string += working_string;
  1412. /*
  1413. ** Increment the index
  1414. */
  1415. index++;
  1416. }
  1417. /*
  1418. ** Display stats for the un-accounted time. Note that there will only be
  1419. ** "missing_parent_time" if there also was "parent_time"...
  1420. */
  1421. /* if (parent_time > 0.0f) {
  1422. percent_of_parent = 100.0f * missing_parent_time / parent_time;
  1423. percent_of_total = 100.0f * missing_parent_time / total_time;
  1424. ms_per_frame = 1000.0f * missing_parent_time / total_frames;
  1425. working_string.Format(
  1426. " %-25s %-6.2f %-6.2f %-6.2f\n",
  1427. "MISSING TIME",
  1428. percent_of_parent,
  1429. percent_of_total,
  1430. ms_per_frame );
  1431. profile_string += working_string;
  1432. }
  1433. */
  1434. node->Set_String(profile_string);
  1435. // Vector2 pos = (Render2DClass::Get_Screen_Resolution().Upper_Left() + Render2DClass::Get_Screen_Resolution().Lower_Left()) * 0.5f;
  1436. // StatisticsDisplayManager::Set_Stat( "profile", profile_string, 0xffffffff, pos );
  1437. }
  1438. }
  1439. }
  1440. void ConsoleGameModeClass::Update_Memory_Log( void )
  1441. {
  1442. if (!StatisticsDisplayManager::Is_Current_Display("memory")) return;
  1443. const float MEGABYTE = 1048576.0f;
  1444. const float OOMEGABYTE = 1.0f / MEGABYTE;
  1445. StringClass memory_string(2048);
  1446. StringClass working_string(true);
  1447. memory_string.Format("Memory Category Current(Mb) Peak(Mb)\n");
  1448. int total = 0;
  1449. for (int i=0; i<WWMemoryLogClass::Get_Category_Count(); i++) {
  1450. // (gth) to compute Mb should I divide by the nearest power of two to a million?
  1451. working_string.Format("%-18s %-10.2f %-10.2f\r\n",
  1452. WWMemoryLogClass::Get_Category_Name(i),
  1453. (float)WWMemoryLogClass::Get_Current_Allocated_Memory(i) * OOMEGABYTE,
  1454. (float)WWMemoryLogClass::Get_Peak_Allocated_Memory(i) * OOMEGABYTE);
  1455. memory_string += working_string;
  1456. total += WWMemoryLogClass::Get_Current_Allocated_Memory(i);
  1457. }
  1458. #if (UMBRASUPPORT)
  1459. float umbra_mem = UmbraSupport::Get_Umbra_Memory_Consumption();
  1460. total += umbra_mem;
  1461. working_string.Format("Umbra: %-10.2f\r\n",umbra_mem * OOMEGABYTE);
  1462. memory_string += working_string;
  1463. #endif
  1464. working_string.Format("SUB TOTAL: %-10.2f\r\n\r\n",(float)total * OOMEGABYTE);
  1465. memory_string += working_string;
  1466. // display the estimated space used by textures residing in system ram
  1467. int tex_size=TextureClass::_Get_Total_Texture_Size();
  1468. working_string.Format("%-18s %-10.2f\r\n","Textures(est)",(float)tex_size * OOMEGABYTE);
  1469. memory_string += working_string;
  1470. total+=tex_size;
  1471. // display estimated vertex buffer space
  1472. unsigned vb_size=VertexBufferClass::Get_Total_Allocated_Memory();
  1473. working_string.Format("%-18s %-10.2f\r\n","Vertex Buffers(est)",(float)vb_size * OOMEGABYTE);
  1474. memory_string += working_string;
  1475. total+=vb_size;
  1476. // display estimated index buffer space
  1477. unsigned ib_size=IndexBufferClass::Get_Total_Allocated_Memory();
  1478. working_string.Format("%-18s %-10.2f\r\n","Index Buffers(est)",(float)ib_size * OOMEGABYTE);
  1479. memory_string += working_string;
  1480. total+=ib_size;
  1481. // total!
  1482. working_string.Format("TOTAL: %-10.2f\r\n\r\n",(float)total * OOMEGABYTE);
  1483. memory_string += working_string;
  1484. StatisticsDisplayManager::Set_Stat( "memory", memory_string, 0xffffffff );
  1485. }