DEBUG.CPP 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053
  1. /*
  2. ** Command & Conquer Red Alert(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. ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Virtual Monopoly *
  23. * *
  24. * File Name : DEBUG.CPP *
  25. * *
  26. * Programmer : Michael Legg *
  27. * *
  28. * Start Date : November 22, 1994 *
  29. * *
  30. * Last Update : May 30, 1995 [ML] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * Get_And_Display_Windows_Debug -- GetWinDebugInfo() called for checking*
  35. * Debug_Mono_Message -- Post a line to the monochrome monitor *
  36. * Debug_Window_Message -- One of many ways to pop up a debug msg window *
  37. * Debug_Show_Palette -- Display the current 256 color palette *
  38. * Debug_Draw_Line_Test -- Tests Westwood library Draw_Line() *
  39. * Debug_Put_Pixel_Test -- Tests the Westwood library Put_Pixel() *
  40. * Debug_Shape_Test -- Tests the Westwood Library Draw_Shape() *
  41. * Debug_Print_Game_Stats -- Code to display player stats w/ text *
  42. * Debug_Rig_Roll -- Pops up dialog to fix the next dice roll *
  43. * Debug_Adjust_Players_Cash -- Changes the current players money *
  44. * Debug_Rig_Roll_Dialog_Procedure -- Handles commands to dialog *
  45. * Debug_Adjust_Cash_Dialog_Proc -- Handles dialog messages for this *
  46. * Debug_Mono_Print_Whose_Turn -- Displays current turn on MONO display *
  47. * Build_Debug_Log_File_Name -- Based on the date and time of system *
  48. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  49. #include "function.h"
  50. #include "debug.rh"
  51. #include "strings.rh"
  52. #if( RIG_ROLL_FOR_PLAYTEST )
  53. VOID Debug_Rig_Roll( WindowHandle window_handle );
  54. PRIVATE BOOL Debug_Rig_Roll_Dialog_Procedure( WindowHandle window_handle,
  55. UINT message,
  56. WPARAM w_param,
  57. LPARAM l_param );
  58. #endif
  59. #if( DEBUG_CODE )
  60. /*
  61. public functions
  62. */
  63. VOID Get_And_Display_Windows_Debug_Info( BYTE *command_line_string );
  64. VOID Debug_Mono_Message( BYTE *message );
  65. //VOID Debug_Window_Message( BYTE *message );
  66. VOID Debug_Show_Palette( VOID );
  67. VOID Debug_Draw_Line_Test( VOID );
  68. VOID Debug_Put_Pixel_Test( VOID );
  69. VOID Debug_Shape_Test( VOID );
  70. VOID Debug_Print_Game_Stats( VOID );
  71. VOID Debug_Adjust_Players_Cash( WindowHandle window_handle );
  72. VOID Debug_Mono_Print_Whose_Turn( PlayerType player );
  73. VOID Build_Debug_Log_File_Name( BYTE *name_string );
  74. /*
  75. private functions
  76. */
  77. PRIVATE BOOL Debug_Adjust_Cash_Dialog_Procedure( WindowHandle window_handle,
  78. UINT message,
  79. WPARAM w_param,
  80. LPARAM l_param );
  81. #endif
  82. #if( DEBUG_CHECKSUM_ALL_SITES_DATA )
  83. PRIVATE VOID Give_To_The_Mikes( VOID );
  84. #endif
  85. #if( DEBUG_CODE )
  86. /*
  87. code begins...
  88. */
  89. /***************************************************************************
  90. * DEBUG_MONO_MESSAGE -- Post a line to the monochrome monitor *
  91. * *
  92. * INPUT: the message to print *
  93. * *
  94. * OUTPUT: a message on the monochrome monitor display *
  95. * *
  96. * WARNINGS: try to end messages with \r\n! *
  97. * *
  98. * HISTORY: see PVCS log *
  99. *=========================================================================*/
  100. #pragma argsused
  101. VOID Debug_Mono_Message( BYTE *message )
  102. {
  103. #if( DEBUG_LOG_TO_MONO_DISPLAY )
  104. BYTE *temp_string;
  105. BYTE *temp_null_position;
  106. BYTE temp_char;
  107. INT length_left;
  108. #endif
  109. #if( DEBUG_LOG_TO_FILE )
  110. INT fh;
  111. static BOOL _errored_once = FALSE;
  112. BYTE name_path_string[ _MAX_PATH ];
  113. BOOL danger;
  114. #endif
  115. #if( DEBUG_LOG_TO_FILE )
  116. danger = Danger_Test_Hard_Drive_Space();
  117. if ( ! _errored_once && ! danger ) {
  118. if ( *(Executable_Path+0) != '\0' ) {
  119. sprintf( name_path_string,
  120. "%s%s",
  121. Executable_Path,
  122. Debug_Log_File_Name );
  123. fh = Open_File( name_path_string, READ|WRITE );
  124. if ( fh == FILEOPENERROR || fh == -1 ) {
  125. sprintf( Text_String,
  126. "Unable to open %s for WRITE.\r\n",
  127. Debug_Log_File_Name );
  128. #if( DEBUG_CODE )
  129. Debug_Error_Window_Message( Text_String );
  130. #endif
  131. _errored_once = TRUE;
  132. }
  133. else {
  134. Seek_File( fh, 0, SEEK_END );
  135. Write_File( (INT)fh, (BYTE *)message, (ULONG)(strlen(message)) );
  136. Close_File( fh );
  137. }
  138. }
  139. }
  140. #endif
  141. #if( DEBUG_LOG_TO_MONO_DISPLAY )
  142. if ( ! Debug_Mono_Messages ) {
  143. return;
  144. }
  145. if ( ! Windows_95_Detected_Flag ) {
  146. OutputDebugString( "." );
  147. }
  148. // else {
  149. // Monochrome_Output( "> " );
  150. // }
  151. length_left = strlen( message );
  152. temp_null_position = message;
  153. while ( length_left > 80 ) {
  154. temp_string = temp_null_position;
  155. temp_null_position += 80;
  156. temp_char = *temp_null_position;
  157. temp_null_position[ 0 ] = '\0';
  158. if ( Windows_95_Detected_Flag ) {
  159. Monochrome_Output( temp_string );
  160. }
  161. else {
  162. OutputDebugString( temp_string );
  163. }
  164. *temp_null_position = temp_char;
  165. length_left -= 80;
  166. }
  167. temp_string = temp_null_position;
  168. if ( Windows_95_Detected_Flag ) {
  169. Monochrome_Output( temp_string );
  170. }
  171. else {
  172. OutputDebugString( temp_string );
  173. }
  174. #endif
  175. }
  176. /***************************************************************************
  177. * DEBUG_SHOW_PALETTE -- Display the current 256 color palette *
  178. * *
  179. * INPUT: none *
  180. * *
  181. * OUTPUT: none *
  182. * *
  183. * WARNINGS: none *
  184. * *
  185. * HISTORY: see PVCS log *
  186. *=========================================================================*/
  187. VOID Debug_Show_Palette( VOID )
  188. {
  189. #define PIXEL_SIZE 19
  190. INT i, j, x, y;
  191. UBYTE color;
  192. DeviceContextHandle screen_dc;
  193. if ( Game_Is_Now_Currently_Interrupted ) {
  194. Standard_Window_Message( "Game_Is_Now_Currently_Interrupted = TRUE", "X" );
  195. if ( Current_Interrupting_Player > NO_PLAYER ) {
  196. sprintf( Text_String,
  197. "Current_Interrupting_Player = %s\r\n",
  198. Players[ Current_Interrupting_Player ].Get_Name() );
  199. }
  200. else {
  201. sprintf( Text_String,
  202. "Current_Interrupting_Player = unknown\r\n" );
  203. }
  204. Standard_Window_Message( Text_String, "X" );
  205. }
  206. else {
  207. Standard_Window_Message( "Game_Is_Now_Currently_Interrupted = FALSE", "X" );
  208. }
  209. color = 0;
  210. for ( i = 0; i < 16; i ++ ) {
  211. for ( j = 0; j < 16; j ++ ) {
  212. x = VQ_MOVIE_X + (j * PIXEL_SIZE);
  213. y = VQ_MOVIE_Y + (i * PIXEL_SIZE);
  214. Monopoly_Fill_Rect( x, y, x+PIXEL_SIZE-1, y+PIXEL_SIZE-1, COLOR_BLACK );
  215. Monopoly_Fill_Rect( x+1, y+1, x+PIXEL_SIZE-2, y+PIXEL_SIZE-2, color++ );
  216. }
  217. }
  218. screen_dc = GetDC( Main_Window_Handle );
  219. // WinGBitBlt( Screen_DC,
  220. WinGBitBlt( screen_dc,
  221. VQ_MOVIE_X, VQ_MOVIE_Y,
  222. VQ_MOVIE_WIDTH,
  223. VQ_MOVIE_HEIGHT,
  224. WinG_DC,
  225. VQ_MOVIE_X, VQ_MOVIE_Y );
  226. ReleaseDC( Main_Window_Handle, screen_dc );
  227. }
  228. /***************************************************************************
  229. * DEBUG_DRAW_LINE_TEST -- Tests Westwood library Draw_Line() *
  230. * *
  231. * INPUT: none *
  232. * *
  233. * OUTPUT: none *
  234. * *
  235. * WARNINGS: make sure WinG buffer is active! *
  236. * *
  237. * HISTORY: see PVCS log *
  238. *=========================================================================*/
  239. VOID Debug_Draw_Line_Test( VOID )
  240. {
  241. #if( 0 )
  242. // INT x1=0, y1=0, x2=638, y2=438;
  243. INT x1, y1=0, x2=638, y2=438;
  244. for ( x1=0; x1<=638; x1+=10 ) {
  245. HidBuff_Class_Ptr->Draw_Line( x1,y1,x2,y2,255 );
  246. WinGBitBlt( Screen_DC,
  247. min(x1,x2), min(y1,y2),
  248. abs(x2-x1)+1,
  249. abs(y2-y1)+1,
  250. WinG_DC,
  251. min(x1,x2), min(y1,y2) );
  252. x2-=10;
  253. }
  254. x1=0;
  255. // y1=0;
  256. x2=638;
  257. y2=438;
  258. for ( y1=0; y1<=438; y1+=10 ) {
  259. HidBuff_Class_Ptr->Draw_Line( x1,y1,x2,y2,255 );
  260. WinGBitBlt( Screen_DC,
  261. min(x1,x2), min(y1,y2),
  262. abs(x2-x1)+1,
  263. abs(y2-y1)+1,
  264. WinG_DC,
  265. min(x1,x2), min(y1,y2) );
  266. y2-=10;
  267. }
  268. #endif
  269. }
  270. /***************************************************************************
  271. * DEBUG_PUT_PIXEL_TEST -- Tests the Westwood library Put_Pixel() *
  272. * *
  273. * INPUT: none *
  274. * *
  275. * OUTPUT: none *
  276. * *
  277. * WARNINGS: Make sure WinG buffer is active *
  278. * *
  279. * HISTORY: see PVCS log *
  280. *=========================================================================*/
  281. VOID Debug_Put_Pixel_Test( VOID )
  282. {
  283. #if( 0 )
  284. INT x = random( 640 );
  285. INT y = random( 440 );
  286. INT xweight=1; int yweight=1;
  287. LONG i;
  288. static UBYTE color = 0;
  289. color++;
  290. for ( i=0; i<100000; i ++ ) {
  291. HidBuff_Class_Ptr->Put_Pixel( x, y, color );
  292. WinGBitBlt( Screen_DC,
  293. x, y,
  294. 1,
  295. 1,
  296. WinG_DC,
  297. x, y );
  298. if ( x <= 0 ) {
  299. x = 0;
  300. xweight = 1;
  301. }
  302. if ( y <= 0 ) {
  303. y = 0;
  304. yweight = 1;
  305. }
  306. if ( x >= WING_BITMAP_WIDTH-1 ) {
  307. x = WING_BITMAP_WIDTH-1;
  308. xweight = -1;
  309. }
  310. if ( y >= WING_BITMAP_HEIGHT-1 ) {
  311. y = WING_BITMAP_HEIGHT-1;
  312. yweight = -1;
  313. }
  314. if ( xweight > 0 ) {
  315. /* 0-9 */
  316. /* 0-9 */
  317. if ( random( 10 ) <= 4 ) {
  318. x ++;
  319. }
  320. else { /* 0 */
  321. x --;
  322. }
  323. }
  324. else {
  325. /* 0-9 */
  326. if ( random( 10 ) <= 4 ) {
  327. x --;
  328. }
  329. else { /* 0 */
  330. x ++;
  331. }
  332. }
  333. if ( yweight > 0 ) {
  334. /* 0-9 */
  335. if ( random( 10 ) <= 4 ) {
  336. y ++;
  337. }
  338. else { /* 0 */
  339. y --;
  340. }
  341. }
  342. else {
  343. /* 0-9 */
  344. if ( random( 10 ) <= 4 ) {
  345. y --;
  346. }
  347. else { /* 0 */
  348. y ++;
  349. }
  350. }
  351. }
  352. #endif
  353. }
  354. /***************************************************************************
  355. * DEBUG_SHAPE_TEST -- Tests the Westwood Library Draw_Shape() *
  356. * *
  357. * INPUT: none *
  358. * *
  359. * OUTPUT: none *
  360. * *
  361. * WARNINGS: Make sure the WinG buffer is active! *
  362. * *
  363. * HISTORY: see PVCS log *
  364. *=========================================================================*/
  365. VOID Debug_Shape_Test( VOID )
  366. {
  367. #if( 0 )
  368. BYTE *shapebuf, *shapes;
  369. LONG fsize;
  370. CHAR *shape_ptr[ 37 ];
  371. INT i, j, x;
  372. INT wwfh;
  373. Debug_Mono_Message( "------------------------------------------\r\n" );
  374. sprintf( Text_String, "Mem before shape buff alloc(5000): %ld\r\n", Ram_Free( MEM_NORMAL ) );
  375. Debug_Mono_Message( Text_String );
  376. shapebuf = (char *) Alloc( 5000, MEM_NORMAL );
  377. sprintf( Text_String, "Mem after shape buff alloc(5000): %ld\r\n", Ram_Free( MEM_NORMAL ) );
  378. Debug_Mono_Message( Text_String );
  379. if ( shapebuf == NULL ) {
  380. Debug_Mono_Message("shapebuf alloc failed.\n");
  381. }
  382. Set_Shape_Buffer (shapebuf,5000);
  383. wwfh = Open_File( "MSW00.SHP", READ );
  384. sprintf( Text_String, "File opened with wwfh %d\r\n", wwfh );
  385. Debug_Mono_Message( Text_String );
  386. if( wwfh == -1 ) {
  387. Debug_Mono_Message("File not found\n");
  388. }
  389. fsize = File_Size( wwfh );
  390. sprintf( Text_String, "File_Size( %d ) = %d\r\n", wwfh, fsize );
  391. Debug_Mono_Message( Text_String );
  392. if ( fsize > 0 ) {
  393. shapes = (char *) Alloc( fsize, MEM_NORMAL );
  394. if( shapes == NULL) {
  395. Debug_Mono_Message("shapes alloc failed\n");
  396. }
  397. Read_File( wwfh, shapes, fsize );
  398. Close_File( wwfh );
  399. }
  400. sprintf( Text_String, "Mem after shapedata alloc: %ld\r\n", Ram_Free( MEM_NORMAL ) );
  401. Debug_Mono_Message( Text_String );
  402. for( i = 0; i <= 36; i++ ) {
  403. shape_ptr[ i ] = Get_Shape( shapes, i );
  404. }
  405. sprintf( Text_String, "Mem after all shapes alloc: %ld\r\n", Ram_Free( MEM_NORMAL ) );
  406. Debug_Mono_Message( Text_String );
  407. Free( shapes );
  408. x = -64;
  409. for ( j = 0; j < 20; j ++ ) {
  410. for ( i = 21; i <= 28; i ++ ) {
  411. Refresh_Board_BMP_On_Hid();
  412. if ( shape_ptr[ i ] ) {
  413. // Draw_Shape( HidBuff_Class_Ptr, shape_ptr[ i ], x, 71, SHAPE_NORMAL );
  414. Draw_Shape( HidBuff_Class_Ptr, shape_ptr[ i ], x, 0, SHAPE_SCALING, 340, 340 );
  415. HidBuff_Class_Ptr->Put_Pixel( x, 100, 3 );
  416. WinGBitBlt( Screen_DC,
  417. x, 0,
  418. 200, 200,
  419. WinG_DC,
  420. x, 0 );
  421. }
  422. x += 4;
  423. }
  424. }
  425. if ( shape_ptr[ 0 ] ) {
  426. Refresh_Board_BMP_On_Hid();
  427. // Draw_Shape( HidBuff_Class_Ptr, shape_ptr[ 0 ], x, 71, SHAPE_NORMAL );
  428. Draw_Shape( HidBuff_Class_Ptr, shape_ptr[ 0 ], x, 0, SHAPE_SCALING, 340, 340 );
  429. HidBuff_Class_Ptr->Put_Pixel( x, 100, 3 );
  430. WinGBitBlt( Screen_DC,
  431. x, 0,
  432. 200, 200,
  433. WinG_DC,
  434. x, 0 );
  435. }
  436. for( i = 0; i <= 36; i++ ) {
  437. Free( shape_ptr[ i ] );
  438. }
  439. Free( shapebuf );
  440. sprintf( Text_String, "Mem when all done: %ld\r\n", Ram_Free( MEM_NORMAL ) );
  441. Debug_Mono_Message( Text_String );
  442. Debug_Mono_Message( "------------------------------------------\r\n" );
  443. #endif
  444. }
  445. #if( 0 )
  446. #define DEBUG_TEXT_X 4
  447. #define DEBUG_TEXT_Y 12
  448. #define DEBUG_TEXT_SPACING 13
  449. /***************************************************************************
  450. * DEBUG_PRINT_GAME_STATS -- Code to display player stats w/ text *
  451. * *
  452. * INPUT: none *
  453. * *
  454. * OUTPUT: none *
  455. * *
  456. * WARNINGS: none *
  457. * *
  458. * HISTORY: see PVCS log *
  459. *=========================================================================*/
  460. VOID Debug_Print_Game_Stats( VOID )
  461. {
  462. INT i;
  463. INT x;
  464. INT y;
  465. PlayerType whos_turn;
  466. BYTE temp_token_string[ 50 ];
  467. BYTE temp_ai_string[ 50 ];
  468. BYTE temp_string[ 50 ];
  469. /*
  470. no game, no stats
  471. */
  472. if ( ! Game_Status.Is_Game_In_Progress() ) {
  473. return;
  474. }
  475. x = DEBUG_TEXT_X;
  476. y = DEBUG_TEXT_Y;
  477. whos_turn = Game_Status.Get_Whos_Turn_Is_It_Now();
  478. SetTextAlign( Screen_DC, TA_LEFT );
  479. SelectObject( Screen_DC, GetStockObject( ANSI_VAR_FONT ) );
  480. SetTextCharacterExtra( Screen_DC, 0 );
  481. for ( i = PLAYER_1; i < TOTAL_PLAYERS; i ++ ) {
  482. if ( Players[ i ].Is_Active() ) {
  483. if ( whos_turn == i ) {
  484. strcpy( Text_String_2, "*" );
  485. rgb_vals = PALETTERGB( 0, 0, 255 );
  486. }
  487. else {
  488. strcpy( Text_String_2, " " );
  489. rgb_vals = WHITE_RGB_COLOR_REF;
  490. }
  491. sprintf( temp_string, "%d: ", i+1 );
  492. strcat( Text_String_2, temp_string );
  493. // grab token name
  494. if ( Players[ i ].Get_Token() >= TOKEN_FIRST ) {
  495. LoadString( Global_Instance_Handle,
  496. STRING_TOKEN_FIRST + Players[ i ].Get_Token(),
  497. temp_token_string,
  498. 50 );
  499. }
  500. else {
  501. *temp_token_string = '\0';
  502. }
  503. // grab ai name
  504. if ( Players[ i ].Get_AI_Type() >= AI_FIRST ) {
  505. LoadString( Global_Instance_Handle,
  506. STRING_AI_FIRST + Players[ i ].Get_AI_Type(),
  507. temp_ai_string,
  508. 50 );
  509. }
  510. else {
  511. *temp_ai_string = '\0';
  512. }
  513. sprintf( Text_String,
  514. "%s%s, $%d, %s ",
  515. Text_String_2,
  516. Players[ i ].Get_Name(),
  517. Players[ i ].Get_Cash(),
  518. temp_token_string );
  519. SetTextColor( Screen_DC, rgb_vals );
  520. TextOut( Screen_DC,
  521. x,
  522. y,
  523. Text_String,
  524. strlen( Text_String ) );
  525. /*
  526. now print liquid assets, available assets, tradable assets,
  527. total assets and monopolies...
  528. */
  529. y += DEBUG_TEXT_SPACING;
  530. sprintf( Text_String, " AI: $%s ", temp_ai_string );
  531. TextOut( Screen_DC,
  532. x,
  533. y,
  534. Text_String,
  535. strlen( Text_String ) );
  536. y += DEBUG_TEXT_SPACING;
  537. sprintf( Text_String, " Liquid Assets: $%u ", Players[ i ].Get_Liquid_Assets() );
  538. TextOut( Screen_DC,
  539. x,
  540. y,
  541. Text_String,
  542. strlen( Text_String ) );
  543. y += DEBUG_TEXT_SPACING;
  544. sprintf( Text_String, " Available Assets: $%u ", Players[ i ].Get_Available_Assets() );
  545. TextOut( Screen_DC,
  546. x,
  547. y,
  548. Text_String,
  549. strlen( Text_String ) );
  550. // y += DEBUG_TEXT_SPACING;
  551. // sprintf( Text_String, " Tradable Assets: $%u ", Players[ i ].Get_Tradable_Assets() );
  552. // TextOut( Screen_DC,
  553. // x,
  554. // y,
  555. // Text_String,
  556. // strlen( Text_String ) );
  557. y += DEBUG_TEXT_SPACING;
  558. sprintf( Text_String, " Total Assets: $%u ", Players[ i ].Get_Total_Assets( FALSE ) );
  559. TextOut( Screen_DC,
  560. x,
  561. y,
  562. Text_String,
  563. strlen( Text_String ) );
  564. y += DEBUG_TEXT_SPACING;
  565. // sprintf( Text_String, " Monopolies: %u ", Players[ i ].Get_Monopolies() );
  566. // TextOut( Screen_DC,
  567. // x,
  568. // y,
  569. // Text_String,
  570. // strlen( Text_String ) );
  571. // y += DEBUG_TEXT_SPACING;
  572. }
  573. }
  574. /*
  575. Free parking!
  576. */
  577. y += DEBUG_TEXT_SPACING;
  578. if ( Game_Status.Does_Free_Parking_Collect_Cash() ) {
  579. strcpy( Text_String_2, "Active" );
  580. }
  581. else {
  582. strcpy( Text_String_2, "Inactive" );
  583. }
  584. sprintf( Text_String,
  585. "Free Parking: $%d, %s ",
  586. Game_Status.Get_Free_Parking_Money(),
  587. Text_String_2 );
  588. rgb_vals = BLACK_RGB_COLOR_REF;
  589. SetTextColor( Screen_DC, rgb_vals );
  590. TextOut( Screen_DC,
  591. x,
  592. y,
  593. Text_String,
  594. strlen( Text_String ) );
  595. /*
  596. Bank
  597. */
  598. y += DEBUG_TEXT_SPACING;
  599. sprintf( Text_String,
  600. "Bank: %d houses, %d hotels, $infinite ",
  601. Bank.Get_Houses(),
  602. Bank.Get_Hotels() );
  603. TextOut( Screen_DC,
  604. x,
  605. y,
  606. Text_String,
  607. strlen( Text_String ) );
  608. }
  609. #endif
  610. /***************************************************************************
  611. * DEBUG_ADJUST_PLAYERS_CASH -- Changes the current players money *
  612. * *
  613. * INPUT: parent window handle *
  614. * *
  615. * OUTPUT: none *
  616. * *
  617. * WARNINGS: none *
  618. * *
  619. * HISTORY: see PVCS log *
  620. *=========================================================================*/
  621. VOID Debug_Adjust_Players_Cash( WindowHandle window_handle )
  622. {
  623. if ( ! Game_Status.Is_Game_In_Progress() ) {
  624. Debug_Error_Window_Message( "Game not in progress!" );
  625. return;
  626. }
  627. DialogBox( Global_Instance_Handle,
  628. "DebugSetCashDlgBox",
  629. window_handle,
  630. (DLGPROC) Debug_Adjust_Cash_Dialog_Procedure );
  631. }
  632. #pragma argsused
  633. /***************************************************************************
  634. * DEBUG_ADJUST_CASH_DIALOG_PROC -- Handles dialog messages for this *
  635. * *
  636. * INPUT: standard windows dialog command parameters *
  637. * *
  638. * OUTPUT: TRUE if cash modified, FALSE if not *
  639. * *
  640. * WARNINGS: none *
  641. * *
  642. * HISTORY: see PVCS log *
  643. *=========================================================================*/
  644. PRIVATE BOOL Debug_Adjust_Cash_Dialog_Procedure( WindowHandle window_handle,
  645. UINT message,
  646. WPARAM w_param,
  647. LPARAM l_param )
  648. {
  649. INT cash;
  650. PlayerType player;
  651. switch( message ) {
  652. case WM_COMMAND:
  653. if ( LOWORD( w_param ) == IDOK ) {
  654. GetDlgItemText( window_handle,
  655. CASH_EDIT1,
  656. Text_String,
  657. SIZE_OF_TEXT_STRING );
  658. cash = atoi( Text_String );
  659. if ( cash < 0 ) {
  660. cash = 0;
  661. }
  662. if ( cash > 100000 ) {
  663. cash = 100000;
  664. }
  665. player = Game_Status.Get_Whos_Turn_Is_It_Now();
  666. // Players[ player ].Set_Money( cash );
  667. // FALSE = not incoming, so outgoing to other systems
  668. Send_Game_Command( FALSE, CMD_SET_CASH, player, cash );
  669. sprintf( Text_String,
  670. "%s now has $%d.\r\n",
  671. Players[ player ].Get_Name(), cash );
  672. Debug_Mono_Message( Text_String );
  673. Refresh_Player_Interface( player, TRUE );
  674. EndDialog( window_handle, IDOK );
  675. return( TRUE );
  676. }
  677. break;
  678. case WM_INITDIALOG:
  679. /*
  680. Default cash for player
  681. */
  682. player = Game_Status.Get_Whos_Turn_Is_It_Now();
  683. itoa( Players[ player ].Get_Cash(), Text_String, 10 );
  684. SetDlgItemText( window_handle,
  685. CASH_EDIT1,
  686. Text_String );
  687. SendDlgItemMessage( window_handle,
  688. CASH_EDIT1,
  689. EM_SETSEL,
  690. (WPARAM) 0,
  691. (LPARAM) -1 );
  692. return( TRUE );
  693. default: break;
  694. }
  695. return( FALSE );
  696. }
  697. // TC
  698. extern BYTE *Debug_Chance_Card_Text[];
  699. VOID Debug_Show_Chance_Deck( VOID )
  700. {
  701. ChanceCardType card;
  702. INT i;
  703. for ( i = 0; i < TOTAL_CHANCE_CARDS_IN_MAX_DECK; i ++ ) {
  704. card = Game_Cards.Query_Chance_Card( i );
  705. if ( card > CHANCE_NO_CARD ) {
  706. sprintf( Text_String,
  707. "Chance card[ %d ] = %s\r\n",
  708. i,
  709. Debug_Chance_Card_Text[ card ] );
  710. }
  711. else {
  712. sprintf( Text_String,
  713. "Chance card[ %d ] = -1\r\n",
  714. i );
  715. }
  716. Debug_Mono_Message( Text_String );
  717. }
  718. }
  719. // TC
  720. extern BYTE *Debug_CC_Card_Text[];
  721. VOID Debug_Show_CC_Deck( VOID )
  722. {
  723. CommunityChestCardType card;
  724. INT i;
  725. for ( i = 0; i < TOTAL_COMMUNITY_CHEST_CARDS_IN_MAX_DECK; i ++ ) {
  726. card = Game_Cards.Query_CC_Card( i );
  727. if ( card > CC_NO_CARD ) {
  728. sprintf( Text_String,
  729. "C. Chest card[ %d ] = %s\r\n",
  730. i,
  731. Debug_CC_Card_Text[ card ] );
  732. }
  733. else {
  734. sprintf( Text_String,
  735. "C. Chest card[ %d ] = -1\r\n",
  736. i );
  737. }
  738. Debug_Mono_Message( Text_String );
  739. }
  740. }
  741. /***************************************************************************
  742. * DEBUG_MONO_PRINT_WHOSE_TURN -- Displays current turn on MONO display *
  743. * *
  744. * INPUT: player whos turn it is *
  745. * *
  746. * OUTPUT: a message to the MONO display *
  747. * *
  748. * WARNINGS: none *
  749. * *
  750. * HISTORY: see PVCS log *
  751. *=========================================================================*/
  752. VOID Debug_Mono_Print_Whose_Turn( PlayerType player )
  753. {
  754. Debug_Mono_Message( "--------------------------------------------------------------------------\r\n" );
  755. sprintf( Text_String, "--- %s's turn...\r\n", Players[ player ].Get_Name() );
  756. Debug_Mono_Message( Text_String );
  757. Debug_Mono_Message( "--------------------------------------------------------------------------\r\n" );
  758. }
  759. VOID Debug_Display_Bank_Status( VOID )
  760. {
  761. sprintf( Text_String,
  762. "Hotels in bank = %d, Houses in bank = %d",
  763. Bank.Get_Hotels(),
  764. Bank.Get_Houses() );
  765. Standard_Window_Message( Text_String, "DEBUG" );
  766. }
  767. VOID Debug_Show_Player_Info( VOID )
  768. {
  769. BYTE *tokens[ TOTAL_TOKENS ] = {
  770. "CANNON ",
  771. "CAR ",
  772. "DOG ",
  773. "HAT ",
  774. "IRON ",
  775. "HORSE ",
  776. "SHIP ",
  777. "SHOE ",
  778. "THIMBLE",
  779. "WBARROW",
  780. };
  781. BYTE *ais[ TOTAL_AI_TYPES ] = {
  782. "LOCAL HUMAN ",
  783. "LOCAL AI ",
  784. "REMOTE HUMAN",
  785. "REMOTE AI ",
  786. };
  787. BYTE *status[ TOTAL_ACTIVE_STATUSES ] = {
  788. "INACTIVE",
  789. "ACTIVE ",
  790. "BANKRUPT",
  791. };
  792. INT i;
  793. Debug_Mono_Message( "****************************************************\r\n" );
  794. sprintf( Text_String,
  795. "Game_Is_Now_Currently_Interrupted = %d\r\n",
  796. Game_Is_Now_Currently_Interrupted );
  797. Debug_Mono_Message( Text_String );
  798. for ( i = FIRST_PLAYER; i <= LAST_PLAYER; i ++ ) {
  799. if ( Players[ i ].Get_Active_Status() != PLAYER_INACTIVE ) {
  800. sprintf( Text_String,
  801. "Player[ %d ] - %s | %s | %s | %s | %s\r\n",
  802. i,
  803. tokens[ Players[ i ].Get_Token() ],
  804. ais[ Players[ i ].Get_AI_Type() ],
  805. Players[ i ].Get_IP_Address(),
  806. status[ Players[ i ].Get_Active_Status() ],
  807. Players[ i ].Get_Name() );
  808. }
  809. else {
  810. sprintf( Text_String,
  811. "Player[ %d ] INACTIVE\r\n",
  812. i );
  813. }
  814. Debug_Mono_Message( Text_String );
  815. }
  816. Debug_Mono_Message( "****************************************************\r\n" );
  817. }
  818. VOID Debug_Give_All_Properties( PlayerType player )
  819. {
  820. INT i;
  821. if ( player >= FIRST_PLAYER ) {
  822. for ( i = PROP_FIRST; i <= PROP_LAST; i ++ ) {
  823. // Property_Data[ i ].Set_Owner( player );
  824. Send_Game_Command( FALSE, CMD_SET_OWNER, player, i );
  825. }
  826. // Refresh_Player_Interface( player, TRUE );
  827. Send_Game_Command( FALSE, CMD_FULLY_REFRESH_SCREEN );
  828. }
  829. }
  830. #endif /* DEBUG_CODE */
  831. #if( DEBUG_CHECKSUM_ALL_SITES_DATA )
  832. #if( COMPILE_WINSOCK )
  833. VOID Debug_Broadcast_Save_Game_Checksum_Other_Sites( VOID )
  834. {
  835. ULONG file_size;
  836. INT fh;
  837. INT i;
  838. ULONG check_sum;
  839. BYTE *buffer;
  840. // SOCKET temp_socket;
  841. // INT status;
  842. INT low_int;
  843. INT high_int;
  844. UBYTE add_byte;
  845. BYTE *file_name;
  846. /*
  847. don't do this unless we are multi-site
  848. */
  849. if ( ! Multiple_Site_Game_In_Progress ) {
  850. return;
  851. }
  852. file_name = Text_String_3;
  853. sprintf( file_name,
  854. "%s%s",
  855. Executable_Path,
  856. "TEMPSEND.TMP" );
  857. /*
  858. first save out the current game data
  859. */
  860. DOS_Save_A_Game( file_name, TRUE ); // TRUE = site-to-site verification
  861. /*
  862. now allocate a buffer and load the save data back up
  863. */
  864. fh = Open_File( file_name, READ );
  865. if ( fh != -1 ) {
  866. file_size = File_Size( fh );
  867. buffer = (BYTE *) Alloc( (ULONG) file_size + 10, MEM_NORMAL );
  868. if ( buffer == NULL ) {
  869. Close_File( fh );
  870. #if ( DEBUG_CODE )
  871. Debug_Error_Window_Message( "Unable to alloc buffer in Debug_Broadcast_Save_Game_Data_To_Other_Sites()" );
  872. #endif
  873. return;
  874. }
  875. Read_File( fh, buffer, file_size );
  876. Close_File( fh );
  877. }
  878. /*
  879. now checksum the buffer
  880. */
  881. check_sum = 0L;
  882. for ( i = 0; i < file_size; i ++ ) {
  883. add_byte = (UBYTE) *(buffer + i);
  884. check_sum += (add_byte * (i+1));
  885. }
  886. low_int = LOWORD( check_sum );
  887. high_int = HIWORD( check_sum );
  888. #if( DEBUG_CODE )
  889. sprintf( Text_String,
  890. "Local checksum of %s is %ld, sending %d (low) & %d (high)...\r\n",
  891. file_name,
  892. check_sum,
  893. low_int,
  894. high_int );
  895. Debug_Mono_Message( Text_String );
  896. #endif
  897. /*
  898. send a system command with the checksum game data
  899. */
  900. WinSock_Broadcast_Command( CMD_SENDING_CHECKSUM_DATA, 3, (INT) file_size, low_int, high_int );
  901. if ( buffer ) {
  902. Free( buffer );
  903. // buffer = NULL;
  904. }
  905. // Delete_File( file_name );
  906. }
  907. #endif
  908. #endif
  909. #if( DEBUG_CHECKSUM_ALL_SITES_DATA )
  910. #if( COMPILE_WINSOCK )
  911. VOID Debug_Compare_Local_Checksum_With_Received_Checksum( INT received_file_size, INT low_int, INT high_int )
  912. {
  913. INT fh;
  914. ULONG received_check_sum;
  915. ULONG local_check_sum;
  916. BYTE *buffer = NULL;
  917. INT local_file_size;
  918. INT i;
  919. UBYTE add_byte;
  920. BYTE *file_name;
  921. static BOOL _errored_already = FALSE;
  922. if ( _errored_already ) {
  923. return;
  924. }
  925. /*
  926. don't do this unless we are multi-site
  927. */
  928. if ( ! Multiple_Site_Game_In_Progress ) {
  929. return;
  930. }
  931. received_check_sum = high_int;
  932. received_check_sum <<= 16;
  933. received_check_sum += low_int;
  934. #if( DEBUG_CODE )
  935. sprintf( Text_String,
  936. "Getting ready to compare other sites file, size = %d, checksum = %ld\r\n",
  937. received_file_size,
  938. received_check_sum );
  939. Debug_Mono_Message( Text_String );
  940. #endif
  941. file_name = Text_String_3;
  942. sprintf( file_name,
  943. "%s%s",
  944. Executable_Path,
  945. "TEMPSAVE.TMP" );
  946. /*
  947. save out out current game right now!
  948. */
  949. DOS_Save_A_Game( file_name, TRUE ); // TRUE = site-to-site verification
  950. /*
  951. now load it, and check sum it
  952. */
  953. /*
  954. now allocate a buffer and load the save data back up
  955. */
  956. fh = Open_File( file_name, READ );
  957. if ( fh != -1 ) {
  958. local_file_size = File_Size( fh );
  959. buffer = (BYTE *) Alloc( (ULONG) local_file_size + 10, MEM_NORMAL );
  960. if ( buffer == NULL ) {
  961. Close_File( fh );
  962. #if ( DEBUG_CODE )
  963. Debug_Error_Window_Message( "Unable to alloc buffer in Debug_Broadcast_Save_Game_Data_To_Other_Sites()" );
  964. #endif
  965. return;
  966. }
  967. Read_File( fh, buffer, local_file_size );
  968. Close_File( fh );
  969. }
  970. /*
  971. now checksum the buffer
  972. */
  973. local_check_sum = 0L;
  974. for ( i = 0; i < local_file_size; i ++ ) {
  975. add_byte = (UBYTE) *(buffer + i);
  976. local_check_sum += (add_byte * (i+1));
  977. }
  978. /*
  979. free the buffer
  980. */
  981. if( buffer ) {
  982. Free( buffer );
  983. }
  984. /*
  985. now compare files sizes and check sum!
  986. */
  987. if ( local_file_size != received_file_size ) {
  988. sprintf( Text_String,
  989. "ERROR! TEMPSAVE.TMP (local, %d) & TEMPSEND.TMP (remote, %d) file sizes don't match!\r\n",
  990. local_file_size, received_file_size );
  991. #if( DEBUG_CODE )
  992. Debug_Mono_Message( Text_String );
  993. // don't post anything!
  994. Debug_Error_Window_Message( Text_String );
  995. #endif
  996. return;
  997. }
  998. if ( local_check_sum != received_check_sum ) {
  999. LOCAL_RESET_SITE_OPTION( SITE_OPTION_COMPUTER_ROLLS_FOR_ITSELF );
  1000. Send_Game_Command( FALSE, CMD_SET_GAME_OVER_FLAG, TRUE );
  1001. _errored_already = TRUE;
  1002. #if( DEBUG_CODE )
  1003. sprintf( Text_String,
  1004. "ERROR! TEMPSAVE.TMP (local, %ld) & TEMPSEND.TMP (remote, %ld) checksums don't match!\r\n",
  1005. local_check_sum, received_check_sum );
  1006. // Give_To_The_Mikes();
  1007. Debug_Mono_Message( Text_String );
  1008. Debug_Error_Window_Message( Text_String );
  1009. #endif
  1010. return;
  1011. }
  1012. /*
  1013. okay! everything matches!
  1014. */
  1015. #if( DEBUG_CODE )
  1016. sprintf( Text_String,
  1017. "TEMPSAVE.TMP (local, %ld) & TEMPSEND.TMP (remote, %ld) checksums match!\r\n",
  1018. local_check_sum, received_check_sum );
  1019. Debug_Mono_Message( Text_String );
  1020. #endif
  1021. }
  1022. #endif
  1023. #endif
  1024. #if( DEBUG_CHECKSUM_ALL_SITES_DATA )
  1025. PRIVATE VOID Give_To_The_Mikes( VOID )
  1026. {
  1027. Real_Error_Window_Message( "Put TEMPSAVE.TMP from your system on a floppy..." );
  1028. Real_Error_Window_Message( "and put TEMPSEND.TMP from your oppenent systems on the floppy..." );
  1029. Real_Error_Window_Message( "...and then give it to the Mike's for error checking!" );
  1030. }
  1031. #endif
  1032. #if( DEBUG_WRITE_IDS_IN_SAVES )
  1033. LONG Debug_Write_ID_Save_Game_File( INT file_handle, BYTE *three_byte_id )
  1034. {
  1035. LONG bytes_read_or_written = 0L;
  1036. if ( file_handle > -1 ) {
  1037. bytes_read_or_written += Write_File( file_handle, three_byte_id, 3 );
  1038. }
  1039. return( bytes_read_or_written );
  1040. }
  1041. #endif
  1042. #if( DEBUG_WRITE_IDS_IN_SAVES )
  1043. LONG Debug_Read_ID_Save_Game_File( INT file_handle )
  1044. {
  1045. LONG bytes_read_or_written = 0L;
  1046. BYTE junk[ 4 ];
  1047. if ( file_handle > -1 ) {
  1048. bytes_read_or_written += Read_File( file_handle, &junk, 3 );
  1049. }
  1050. return( bytes_read_or_written );
  1051. }
  1052. #endif
  1053. #if( DEBUG_WRITE_IDS_IN_SAVES )
  1054. LONG Debug_Write_ID_Save_Game_Memory( MemorySaveBufferType buffer_num, BYTE *three_byte_id )
  1055. {
  1056. LONG bytes_read_or_written = 0L;
  1057. bytes_read_or_written += Memory_Save_Games[ buffer_num ].Write_Data( (UBYTE *) three_byte_id, 3 );
  1058. return( bytes_read_or_written );
  1059. }
  1060. #endif
  1061. #if( DEBUG_WRITE_IDS_IN_SAVES )
  1062. LONG Debug_Read_ID_Save_Game_Memory( MemorySaveBufferType buffer_num )
  1063. {
  1064. LONG bytes_read_or_written = 0L;
  1065. BYTE junk[ 4 ];
  1066. bytes_read_or_written += Memory_Save_Games[ buffer_num ].Read_Data( (UBYTE *) &junk, 3 );
  1067. return( bytes_read_or_written );
  1068. }
  1069. #endif
  1070. /***************************************************************************
  1071. * BUILD_DEBUG_LOG_FILE_NAME -- Based on the date and time of system *
  1072. * *
  1073. * INPUT: buffer to put file name in *
  1074. * *
  1075. * OUTPUT: none *
  1076. * *
  1077. * WARNINGS: the buffer had better be at least 13 characters for filename *
  1078. * *
  1079. * HISTORY: see PVCS log *
  1080. *=========================================================================*/
  1081. #if( DEBUG_LOG_TO_FILE )
  1082. VOID Build_Debug_Log_File_Name( BYTE *name_string_buffer, BYTE *system_id_string_buffer )
  1083. {
  1084. SYSTEMTIME data;
  1085. BYTE *ptr;
  1086. INT fh;
  1087. BYTE *file_name;
  1088. /*
  1089. build file in following format:
  1090. AA BB CC DD . 0EE -> AABBCCDD.0EE
  1091. AA = month 01-12
  1092. BB = day 01-31
  1093. CC = hour 00-23
  1094. DD = minute 00-59
  1095. EE = second 00-59
  1096. */
  1097. /*
  1098. get system time and data information and build a file name
  1099. */
  1100. GetSystemTime( &data );
  1101. // sprintf( name_string,
  1102. // "%2d%2d%2d%2d.%2d",
  1103. // data.wMonth,
  1104. // data.wDay,
  1105. // data.wHour,
  1106. // data.wMinute,
  1107. // data.wSecond );
  1108. sprintf( name_string_buffer,
  1109. "%2d%2d%2d%2d.%3d",
  1110. data.wMonth,
  1111. data.wDay,
  1112. data.wHour,
  1113. data.wMinute,
  1114. 0 );
  1115. /*
  1116. replace spaces w/ 0's in file name
  1117. */
  1118. ptr = name_string_buffer;
  1119. while ( *ptr != '\0' ) {
  1120. if ( *ptr == ' ' ) {
  1121. *ptr = '0';
  1122. }
  1123. ptr ++;
  1124. }
  1125. // #if( DEBUG_CODE )
  1126. // sprintf( Text_String,
  1127. // "Log file name for this session: %s\r\n",
  1128. // name_string );
  1129. // Debug_Mono_Message( Text_String );
  1130. // #endif
  1131. /*
  1132. build .INI file name (with directory path) in Text_String_2
  1133. */
  1134. sprintf( Text_String_2,
  1135. "%sMONOPOLY.INI",
  1136. Executable_Path );
  1137. /*
  1138. now get the system id from "monopoly.ini" in Text_String_3, error if not in there
  1139. */
  1140. if ( ! Find_File( Text_String_2 ) ) {
  1141. sprintf( Text_String,
  1142. "%s not found!",
  1143. Text_String_2 );
  1144. Debug_Error_Window_Message( Text_String );
  1145. return;
  1146. }
  1147. /*
  1148. get the DebugSystemName in Text_String_3
  1149. */
  1150. GetPrivateProfileString( "Monopoly",
  1151. "DebugSystemName",
  1152. "No DebugSystemName found!",
  1153. Text_String_3,
  1154. SIZE_OF_TEXT_STRING,
  1155. Text_String_2 );
  1156. /*
  1157. Now store the system name
  1158. */
  1159. if( strlen( Text_String_3 ) >= SIZE_OF_DEBUG_SYSTEM_ID_NAME ) {
  1160. *( Text_String_3 + SIZE_OF_DEBUG_SYSTEM_ID_NAME - 1 ) = '\0';
  1161. }
  1162. strcpy( system_id_string_buffer, Text_String_3 );
  1163. // #if( DEBUG_CODE )
  1164. // sprintf( Text_String,
  1165. // "Legal DebugSystemName for this session: %s\r\n",
  1166. // Text_String_3 );
  1167. // Debug_Mono_Message( Text_String );
  1168. // #endif
  1169. /*
  1170. open and write header to the log file
  1171. */
  1172. strcpy( Text_String_2,
  1173. "----------------------------------------------------------------\r\n" );
  1174. sprintf( Text_String,
  1175. "---File: %s \r\n---Running on %02d/%02d/%02d at %02d:%02d \r\n---System: %s \r\n",
  1176. name_string_buffer,
  1177. data.wMonth, data.wDay, data.wYear,
  1178. data.wHour, data.wMinute,
  1179. Text_String_3 );
  1180. // #if( DEBUG_CODE )
  1181. // Debug_Mono_Message( Text_String );
  1182. // #endif
  1183. /*
  1184. open the file and write out the header info!
  1185. */
  1186. file_name = Text_String_3;
  1187. sprintf( file_name,
  1188. "%s%s",
  1189. Executable_Path,
  1190. name_string_buffer );
  1191. fh = Open_File( file_name, WRITE );
  1192. Write_File( (INT)fh, (BYTE *)Text_String_2, (ULONG)(strlen(Text_String_2)) );
  1193. Write_File( (INT)fh, (BYTE *)Text_String, (ULONG)(strlen(Text_String)) );
  1194. Write_File( (INT)fh, (BYTE *)Text_String_2, (ULONG)(strlen(Text_String_2)) );
  1195. Close_File( fh );
  1196. }
  1197. #endif
  1198. #if( DEBUG_LOG_TO_FILE )
  1199. VOID Debug_Print_Log_File_Name_On_Board_Hid( VOID )
  1200. {
  1201. #if( 0 )
  1202. SetTextAlign( WinG_DC, TA_LEFT );
  1203. SelectObject( WinG_DC, GetStockObject( ANSI_VAR_FONT ) );
  1204. SetTextColor( WinG_DC, BLACK_RGB_COLOR_REF );
  1205. SetTextCharacterExtra( WinG_DC, 0 );
  1206. SetBkMode( WinG_DC, TRANSPARENT );
  1207. sprintf( Text_String,
  1208. "Debug file: %s",
  1209. Debug_Log_File_Name );
  1210. TextOut( WinG_DC,
  1211. VQ_MOVIE_X+2,
  1212. VQ_MOVIE_Y-2,
  1213. Text_String,
  1214. strlen( Text_String ) );
  1215. sprintf( Text_String,
  1216. "System name: %s",
  1217. Debug_System_ID_Name );
  1218. TextOut( WinG_DC,
  1219. VQ_MOVIE_X+2,
  1220. VQ_MOVIE_Y-2+10,
  1221. Text_String,
  1222. strlen( Text_String ) );
  1223. sprintf( Text_String,
  1224. "Vers: %s",
  1225. VERSION_NUMBER_STRING );
  1226. TextOut( WinG_DC,
  1227. VQ_MOVIE_X+2,
  1228. VQ_MOVIE_Y-2+20,
  1229. Text_String,
  1230. strlen( Text_String ) );
  1231. #endif
  1232. }
  1233. #endif // DEBUG_CODE
  1234. /*
  1235. This needs to be outside DEBUG_CODE
  1236. */
  1237. /***************************************************************************
  1238. * GET_AND_DISPLAY_WINDOWS_DEBUG -- GetWinDebugInfo() is called for checkin*
  1239. * *
  1240. * INPUT: none *
  1241. * *
  1242. * OUTPUT: none *
  1243. * *
  1244. * WARNINGS: avoid the raptor pit on Jurassic Park *
  1245. * *
  1246. * HISTORY: see PVCS log *
  1247. *=========================================================================*/
  1248. BOOL Get_Windows_System_Info( VOID )
  1249. {
  1250. OSVERSIONINFO version_info;
  1251. DWORD major;
  1252. DWORD minor;
  1253. FLOAT float_version;
  1254. //#if( 0 )
  1255. // WINDEBUGINFO current_windows_debug_info;
  1256. // GetWinDebugInfo( &current_windows_debug_info,
  1257. // WDI_OPTIONS | WDI_FILTER | WDI_ALLOC_BREAK );
  1258. // sprintf( Text_String,
  1259. // "Debug info:\r\nflags = %d, options = %d, filter = %d, alloc module = %s, \r\nalloc break = %ld, alloc count = %ld.\r\n",
  1260. // current_windows_debug_info.flags,
  1261. // current_windows_debug_info.dwOptions,
  1262. // current_windows_debug_info.dwFilter,
  1263. // current_windows_debug_info.achAllocModule,
  1264. // current_windows_debug_info.dwAllocBreak,
  1265. // current_windows_debug_info.dwAllocCount );
  1266. // Debug_Mono_Message( Text_String );
  1267. //#endif
  1268. /*------------------------------------------------------------------------*/
  1269. Windows_95_Detected_Flag = FALSE;
  1270. version_info.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
  1271. if ( GetVersionEx( &version_info ) ) {
  1272. sprintf( Text_String,
  1273. "Windows OS version: %ld.%ld, build #%ld, %s\r\n",
  1274. version_info.dwMajorVersion,
  1275. version_info.dwMinorVersion,
  1276. version_info.dwBuildNumber,
  1277. version_info.szCSDVersion );
  1278. Debug_Mono_Message( Text_String );
  1279. if ( version_info.dwPlatformId == VER_PLATFORM_WIN32s ) { // 0
  1280. #if( DEBUG_CODE )
  1281. Debug_Mono_Message( "Windows OS Platform: Win32s on Windows 3.1\r\n" );
  1282. #endif
  1283. Windows_95_Detected_Flag = FALSE;
  1284. /*
  1285. if Win32s, make sure that we have version 1.25 or greater
  1286. */
  1287. major = version_info.dwMajorVersion;
  1288. minor = version_info.dwMinorVersion;
  1289. sprintf( Text_String,
  1290. "%ld.%ld",
  1291. major, minor );
  1292. sscanf( Text_String, "%f", &float_version );
  1293. // if ( major < REQUIRED_WIN32S_MAJOR_VERSION ||
  1294. // ( major == REQUIRED_WIN32S_MAJOR_VERSION && minor < REQUIRED_WIN32S_MINOR_VERSION ) ) {
  1295. // Real_Error_Window_Message( "Win32s version 1.25 or greater is required. Run SETUP.EXE from the Monopoly CD-ROM CD." );
  1296. // return( FALSE );
  1297. // }
  1298. if ( float_version < REQUIRED_WIN32S_FLOAT_VERSION ) {
  1299. /*
  1300. do both in case TRR not set up
  1301. */
  1302. Real_Error_Window_Message_String( "Win32s version 1.25 or greater is required. Run SETUP.EXE from the Monopoly CD-ROM CD." );
  1303. Real_Error_Window_Message( STR_TRR_SYSTEM_ERROR_76 );
  1304. return( FALSE );
  1305. }
  1306. }
  1307. // else if ( version_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { // 1
  1308. else if ( version_info.dwPlatformId == 1 ) { // 1
  1309. #if( DEBUG_CODE )
  1310. Debug_Mono_Message( "Windows OS Platform: Win32 on Chicago\r\n" );
  1311. #endif
  1312. Windows_95_Detected_Flag = TRUE;
  1313. }
  1314. else if ( version_info.dwPlatformId == VER_PLATFORM_WIN32_NT ) { // 2
  1315. #if( DEBUG_CODE )
  1316. Debug_Mono_Message( "Windows OS Platform: Win32 NT\r\n" );
  1317. #endif
  1318. Windows_95_Detected_Flag = FALSE;
  1319. }
  1320. else {
  1321. #if( DEBUG_CODE )
  1322. Debug_Mono_Message( "Windows OS Platform: Unknown!\r\n" );
  1323. #endif
  1324. Windows_95_Detected_Flag = TRUE; // just to be safe! future versions!
  1325. }
  1326. }
  1327. else {
  1328. Debug_Mono_Message( "Unable to GetVersionEx()!\r\n" );
  1329. }
  1330. /*------------------------------------------------------------------------*/
  1331. // /*
  1332. // display command line string, if any
  1333. // */
  1334. // sprintf( Text_String,
  1335. // "WinMain() command line string = %s\r\n",
  1336. // command_line_string );
  1337. // Debug_Mono_Message( Text_String );
  1338. /*
  1339. Show the current directory
  1340. */
  1341. // GetCurrentDirectory( SIZE_OF_TEXT_STRING, Text_String_3 );
  1342. // sprintf( Text_String,
  1343. // "GetCurrentDirectory() = %s\r\n",
  1344. // Text_String_3 );
  1345. // Debug_Mono_Message( Text_String );
  1346. sprintf( Text_String,
  1347. "Executable_Path[] = %s\r\n",
  1348. Executable_Path );
  1349. Debug_Mono_Message( Text_String );
  1350. sprintf( Text_String,
  1351. "CD_Root_Path[] = %s\r\n",
  1352. CD_Root_Path );
  1353. Debug_Mono_Message( Text_String );
  1354. /*
  1355. display argv arguments
  1356. */
  1357. // for ( i = 0; i < _argc; i ++ ) {
  1358. // sprintf( Text_String,
  1359. // "WinMain() argv[ %d ] = %s\r\n",
  1360. // i,
  1361. // _argv[ i ] );
  1362. // Debug_Mono_Message( Text_String );
  1363. // }
  1364. return( TRUE );
  1365. }
  1366. //#if( DEBUG_VERIFY_ALL_SITES_DATA )
  1367. //VOID Debug_Broadcast_Save_Game_Data_To_Other_Sites( VOID )
  1368. //{
  1369. // BYTE *file_name = "TEMPSEND.TMP";
  1370. // ULONG file_size;
  1371. // INT fh;
  1372. // INT i;
  1373. // BYTE *buffer;
  1374. // SOCKET temp_socket;
  1375. // INT status;
  1376. //
  1377. // /*
  1378. // first save out the current game data
  1379. // */
  1380. // DOS_Save_Game( file_name, TRUE ); // TRUE = site-to-site verification
  1381. // /*
  1382. // now allocate a buffer and load the save data back up
  1383. // */
  1384. // fh = Open_File( file_name, READ );
  1385. // if ( fh != -1 ) {
  1386. // file_size = File_Size( fh );
  1387. // buffer = (BYTE *) Alloc( (ULONG) file_size + 10, MEM_NORMAL );
  1388. // if ( buffer == NULL ) {
  1389. // Close_File( fh );
  1390. // Generic_Window_Message( "Unable to alloc buffer in Debug_Broadcast_Save_Game_Data_To_Other_Sites()", " " );
  1391. // return;
  1392. // }
  1393. // Read_File( fh, buffer, file_size );
  1394. // Close_File( fh );
  1395. // }
  1396. //
  1397. // #if( COMPILE_WINSOCK )
  1398. // /*
  1399. // send a system command that the save game data is coming over
  1400. // */
  1401. // WinSock_Broadcast_Command( CMD_HERE_COMES_MY_GAME_STATUS_BUFFER, 1, (INT) file_size );
  1402. // /*
  1403. // now blast the data over!
  1404. // */
  1405. // /* if this system was the original host */
  1406. // if ( Waiting_Socket_Index > -1 ) {
  1407. // /* send the command to all the "waiter links" */
  1408. // for ( i = 0; i <= Waiting_Socket_Index; i ++ ) {
  1409. // temp_socket = Hosts_Waiting_Sockets[ i ].accepted_connection_waiting_socket;
  1410. // if ( temp_socket != INVALID_SOCKET ) {
  1411. // status = WINSOCK_SEND( temp_socket, buffer, file_size, 0 );
  1412. // if ( status == SOCKET_ERROR ) {
  1413. // Generic_Window_Message( "Bad send() of save game data", " " );
  1414. // }
  1415. // else {
  1416. // sprintf( Text_String, "%d size save game data buffer sent\r\n", status );
  1417. // Debug_Mono_Message( Text_String );
  1418. // }
  1419. // }
  1420. // }
  1421. // }
  1422. // /* else this system is a webbee */
  1423. // else {
  1424. // /* send the command to the original host */
  1425. // if ( WC_Temp_Waiter_Socket != INVALID_SOCKET ) {
  1426. // status = WINSOCK_SEND( WC_Temp_Waiter_Socket, buffer, file_size, 0 );
  1427. // if ( status == SOCKET_ERROR ) {
  1428. // Generic_Window_Message( "Bad send() of save game data", " " );
  1429. // }
  1430. // else {
  1431. // sprintf( Text_String, "%d size save game data buffer sent\r\n", status );
  1432. // Debug_Mono_Message( Text_String );
  1433. // }
  1434. // }
  1435. // /* then send the command to all other connected webbees */
  1436. // for ( i = 0; i <= Web_Accepted_Socket_Index; i ++ ) {
  1437. // temp_socket = Web_Accepted_Sockets[ i ];
  1438. // if ( temp_socket != INVALID_SOCKET ) {
  1439. // status = WINSOCK_SEND( temp_socket, buffer, file_size, 0 );
  1440. // if ( status == SOCKET_ERROR ) {
  1441. // Generic_Window_Message( "Bad send() of save game data", " " );
  1442. // }
  1443. // else {
  1444. // sprintf( Text_String, "%d size save game data buffer sent\r\n", status );
  1445. // Debug_Mono_Message( Text_String );
  1446. // }
  1447. // }
  1448. // }
  1449. // }
  1450. // #endif
  1451. //
  1452. // if ( buffer ) {
  1453. // Free( buffer );
  1454. //// buffer = NULL;
  1455. // }
  1456. //// Delete_File( file_name );
  1457. //}
  1458. //#endif /* DEBUG_VERIFY_ALL_SITE_DATA */
  1459. //#if( DEBUG_VERIFY_ALL_SITES_DATA )
  1460. //VOID Debug_Prepare_To_Receive_Other_Site_Save_Game_Data( INT buffer_size )
  1461. //{
  1462. // if ( Incoming_Save_Game_Data ) {
  1463. // Generic_Window_Message( "Incoming_Save_Game_Data already allocated!", " " );
  1464. // Free( Incoming_Save_Game_Data );
  1465. // Incoming_Save_Game_Data = NULL;
  1466. // }
  1467. //
  1468. // Incoming_Save_Game_Data = (BYTE *) Alloc( (buffer_size) + 10, MEM_NORMAL );
  1469. // Incoming_Save_Game_Data_Size = buffer_size;
  1470. // if ( ! Incoming_Save_Game_Data ) {
  1471. // Generic_Window_Message( "Unable to allocate Incoming_Save_Game_Data\r\n", " " );
  1472. // Incoming_Save_Game_Data_Size = 0;
  1473. // }
  1474. // else {
  1475. // Debug_Mono_Message( "Incoming_Save_Game_Data allocated and ready for receive...\r\n" );
  1476. // }
  1477. //}
  1478. //#endif /* DEBUG_VERIFY_ALL_SITE_DATA */
  1479. //
  1480. //#if( DEBUG_VERIFY_ALL_SITES_DATA )
  1481. //VOID Debug_Verify_Incoming_Save_Data( INT bytes_actually_received )
  1482. //{
  1483. // INT fh;
  1484. // BYTE *buffer = NULL;
  1485. // BYTE *file_name = "TEMPSAVE.TMP";
  1486. // LONG file_compare;
  1487. //
  1488. // if ( ! Incoming_Save_Game_Data || ! Incoming_Save_Game_Data_Size ) {
  1489. // return;
  1490. // }
  1491. //
  1492. // sprintf( Text_String,
  1493. // "Save game data rec'd for verify, expected %d, actual %d\r\n",
  1494. // Incoming_Save_Game_Data_Size,
  1495. // bytes_actually_received );
  1496. // Debug_Mono_Message( Text_String );
  1497. //
  1498. // /*
  1499. // temp save the "just received save game" buffer out
  1500. // */
  1501. // fh = Open_File( "TEMPRECV.MNO", WRITE );
  1502. // if ( fh != -1 ) {
  1503. // Write_File( fh, (BYTE *) Incoming_Save_Game_Data, Incoming_Save_Game_Data_Size );
  1504. // Close_File( fh );
  1505. // }
  1506. // else {
  1507. // Generic_Window_Message( "Unable to save out temporary rec'd save game", " " );
  1508. // }
  1509. //
  1510. // /*
  1511. // now compare the data just rec'd with our current save game
  1512. // */
  1513. // /*
  1514. // first save out the local current game data on this system
  1515. // */
  1516. // DOS_Save_Game( file_name, TRUE ); // TRUE = site-to-site verification
  1517. //
  1518. // /*
  1519. // do file compare here between file_name (local) and
  1520. // temprecv.mno (rec'd from remote)
  1521. // */
  1522. // file_compare = Debug_Compare_Two_Files( file_name, "TEMPRECV.MNO" );
  1523. // switch( file_compare ) {
  1524. // case -4L: Debug_Mono_Message( "Received game status data fine!\r\n" ); break;
  1525. // case -3L: Debug_Mono_Message( "Memory error occured w/ file compare!\r\n" ); break;
  1526. // case -2L: Debug_Mono_Message( "File error occured w/ file compare!\r\n" ); break;
  1527. // case -1L: Generic_Window_Message( "Error! Data verification file sizes different!", " " );
  1528. // default:
  1529. // sprintf( Text_String,
  1530. // "Error! Data verification files differ at byte %ld",
  1531. // file_compare );
  1532. // Generic_Window_Message( Text_String, " " );
  1533. // sprintf( Text_String,
  1534. // "Compare %s (our system) and TEMPRECV.MNO (rec'd)!",
  1535. // file_name );
  1536. // Generic_Window_Message( Text_String, " " );
  1537. // }
  1538. //
  1539. // /*
  1540. // free the temporary buffer
  1541. // */
  1542. // if( buffer ) {
  1543. // Free( buffer );
  1544. //// buffer = NULL;
  1545. // }
  1546. // /*
  1547. // free it all up for next time
  1548. // */
  1549. // if( Incoming_Save_Game_Data ) {
  1550. // Free( Incoming_Save_Game_Data );
  1551. // Incoming_Save_Game_Data = NULL;
  1552. // }
  1553. // Incoming_Save_Game_Data_Size = 0;
  1554. //}
  1555. //#endif /* DEBUG_VERIFY_ALL_SITE_DATA */
  1556. ///*
  1557. // 0+ = different at byte 0+
  1558. // -1 = size different
  1559. // -2 = file / DOS error
  1560. // -3 = allocation / memory error
  1561. // -4 = files are the same!
  1562. //*/
  1563. //#if( DEBUG_VERIFY_ALL_SITES_DATA )
  1564. //LONG Debug_Compare_Two_Files( BYTE *file_name_1, BYTE *file_name_2 )
  1565. //{
  1566. // INT fh_1;
  1567. // INT fh_2;
  1568. // LONG file_size_1;
  1569. // LONG file_size_2;
  1570. // UBYTE *buffer_1;
  1571. // UBYTE *buffer_2;
  1572. // UBYTE *ptr_1;
  1573. // UBYTE *ptr_2;
  1574. // LONG bytes_read_1;
  1575. // LONG bytes_read_2;
  1576. // LONG i;
  1577. // LONG error_byte_index;
  1578. //
  1579. // fh_1 = Open_File( file_name_1, READ );
  1580. // if ( fh_1 == -1 ) {
  1581. // sprintf( Text_String,
  1582. // "File %s could not be opened\r\n",
  1583. // file_name_1 );
  1584. // Debug_Mono_Message( Text_String );
  1585. // return( -2L ); // ERROR!
  1586. //
  1587. // }
  1588. // fh_2 = Open_File( file_name_2, READ );
  1589. // if ( fh_2 == -1 ) {
  1590. // sprintf( Text_String,
  1591. // "File %s could not be opened\r\n",
  1592. // file_name_2 );
  1593. // Debug_Mono_Message( Text_String );
  1594. // Close_File( fh_1 );
  1595. // return( -2L ); // ERROR!
  1596. //
  1597. // }
  1598. //
  1599. // file_size_1 = File_Size( fh_1 );
  1600. // file_size_2 = File_Size( fh_2 );
  1601. //// file_size_1 = 662;
  1602. //// file_size_2 = 662;
  1603. //
  1604. // sprintf( Text_String,
  1605. // "File_Size() of %s = %d bytes, File_Size() of %s = %d bytes\r\n",
  1606. // file_name_1,
  1607. // file_size_1,
  1608. // file_name_2,
  1609. // file_size_2 );
  1610. // Debug_Mono_Message( Text_String );
  1611. //
  1612. // if ( file_size_1 != file_size_2 ) {
  1613. //// Debug_Mono_Message( "About to call Close_File()\r\n" );
  1614. // Close_File( fh_1 );
  1615. //// Debug_Mono_Message( "About to call Close_File()\r\n" );
  1616. // Close_File( fh_2 );
  1617. // return( -1L ); // ERROR!
  1618. // }
  1619. //
  1620. //// Debug_Mono_Message( "About to call Alloc()\r\n" );
  1621. // buffer_1 = (UBYTE *) Alloc( (ULONG) (file_size_1 + 10L), MEM_NORMAL );
  1622. //// Debug_Mono_Message( "About to call Alloc()\r\n" );
  1623. // buffer_2 = (UBYTE *) Alloc( (ULONG) (file_size_2 + 10L), MEM_NORMAL );
  1624. // if ( ! buffer_1 || ! buffer_2 ) {
  1625. // if ( buffer_1 ) {
  1626. //// Debug_Mono_Message( "error, About to call Free()\r\n" );
  1627. // Free( buffer_1 );
  1628. // }
  1629. // if ( buffer_2 ) {
  1630. //// Debug_Mono_Message( "error, About to call Free()\r\n" );
  1631. // Free( buffer_2 );
  1632. // }
  1633. //// Debug_Mono_Message( "error, About to call Close_File()\r\n" );
  1634. // Close_File( fh_1 );
  1635. //// Debug_Mono_Message( "error, About to call Close_File()\r\n" );
  1636. // Close_File( fh_2 );
  1637. // return( -3L ); // ERROR!
  1638. // }
  1639. //
  1640. //// Debug_Mono_Message( "About to call Read_File()\r\n" );
  1641. // bytes_read_1 = Read_File( fh_1, buffer_1, file_size_1 );
  1642. //// Debug_Mono_Message( "About to call Read_File()\r\n" );
  1643. // bytes_read_2 = Read_File( fh_2, buffer_2, file_size_2 );
  1644. //// Debug_Mono_Message( "About to call Close_File()\r\n" );
  1645. // Close_File( fh_1 );
  1646. //// Debug_Mono_Message( "About to call Close_File()\r\n" );
  1647. // Close_File( fh_2 );
  1648. //
  1649. // sprintf( Text_String,
  1650. // "Bytes read of %s = %d bytes, bytes read of %s = %d bytes\r\n",
  1651. // file_name_1,
  1652. // bytes_read_1,
  1653. // file_name_2,
  1654. // bytes_read_2 );
  1655. // Debug_Mono_Message( Text_String );
  1656. //
  1657. // if ( bytes_read_1 != bytes_read_2 ) {
  1658. //// Debug_Mono_Message( "Error, About to call Free()\r\n" );
  1659. // Free( buffer_1 );
  1660. //// Debug_Mono_Message( "Error, About to call Free()\r\n" );
  1661. // Free( buffer_2 );
  1662. // return( -2L ); // ERROR!
  1663. // }
  1664. //
  1665. //// Debug_Mono_Message( "About to call memcmp()\r\n" );
  1666. // if ( memcmp( buffer_1, buffer_2, file_size_1 ) ) {
  1667. //
  1668. // Debug_Mono_Message( "Error: Files are different\r\n" );
  1669. //
  1670. // ptr_1 = (UBYTE *) buffer_1;
  1671. // ptr_2 = (UBYTE *) buffer_2;
  1672. // /*
  1673. // scan the data and find which byte # the error occured on
  1674. // */
  1675. // error_byte_index = 0L;
  1676. // for ( i = 0; i < file_size_1; i ++ ) {
  1677. // if ( *ptr_1 != *ptr_2 ) {
  1678. // error_byte_index = i;
  1679. // i = file_size_1;
  1680. // }
  1681. // ptr_1 += 1;
  1682. // ptr_2 += 1;
  1683. // }
  1684. //
  1685. //// Debug_Mono_Message( "Error, About to call Free()\r\n" );
  1686. // Free( buffer_1 );
  1687. //// Debug_Mono_Message( "Error, About to call Free()\r\n" );
  1688. // Free( buffer_2 );
  1689. //
  1690. // sprintf( Text_String,
  1691. // "Error, files are different at byte #%d\r\n",
  1692. // error_byte_index );
  1693. // Debug_Mono_Message( Text_String );
  1694. //
  1695. // return( (LONG) error_byte_index ); // ERROR!
  1696. // }
  1697. //
  1698. //// Debug_Mono_Message( "About to call Free()\r\n" );
  1699. // Free( buffer_1 );
  1700. //// Debug_Mono_Message( "About to call Free()\r\n" );
  1701. // Free( buffer_2 );
  1702. //
  1703. // Debug_Mono_Message( "Both files match!\r\n" );
  1704. // return( -4L ); // SUCCESS!
  1705. //}
  1706. //#endif
  1707. BYTE *Debug_Get_Time_String( VOID )
  1708. {
  1709. SYSTEMTIME data;
  1710. static BYTE _time_string[ 20 ];
  1711. /*
  1712. build file in following format:
  1713. AA BB CC DD . 0EE -> AABBCCDD.0EE
  1714. AA = month 01-12
  1715. BB = day 01-31
  1716. CC = hour 00-23
  1717. DD = minute 00-59
  1718. EE = second 00-59
  1719. */
  1720. /*
  1721. get system time and data information and build a file name
  1722. */
  1723. GetSystemTime( &data );
  1724. // sprintf( _time_string,
  1725. // "%2d%2d%2d%2d.%2d",
  1726. // data.wMonth,
  1727. // data.wDay,
  1728. // data.wHour,
  1729. // data.wMinute,
  1730. // data.wSecond );
  1731. sprintf( _time_string,
  1732. "%2d:%2d",
  1733. data.wHour,
  1734. data.wMinute );
  1735. return( _time_string );
  1736. }
  1737. VOID Check_For_Duplicate_Tokens_Bug( VOID )
  1738. {
  1739. #if( DEBUG_CODE )
  1740. INT i, j;
  1741. GameTokenType token;
  1742. for ( i = FIRST_PLAYER; i < Game_Status.Get_Total_Players(); i ++ ) {
  1743. token = Players[ i ].Get_Token();
  1744. for ( j = FIRST_PLAYER; j < Game_Status.Get_Total_Players(); j ++ ) {
  1745. if ( j != i ) {
  1746. if ( Players[ j ].Get_Token() == token ) {
  1747. /*
  1748. Sound the alarm!
  1749. */
  1750. Play_Sound( SND_GOTOJAIL, PLAY_KILL_PREVIOUS_SOUND, BROADCAST_SOUND );
  1751. Debug_Error_Window_Message( "Emergency! The annoying Double-token bug has been encountered!\r\n" );
  1752. Debug_Error_Window_Message( "Give the .000 log file from this system/game to the Mikes!" );
  1753. Debug_Error_Window_Message( "Get the .000 log files from the other systems in this game, too." );
  1754. Debug_Error_Window_Message( "Other data may be hosed, so this game is probably now invalid." );
  1755. Debug_Error_Window_Message( "With the log file, we should be able to find the stinkin' bug." );
  1756. Debug_Error_Window_Message( "Excellent work, Mr. Bond!" );
  1757. }
  1758. }
  1759. }
  1760. }
  1761. #endif
  1762. }
  1763. #if( RIG_ROLL_FOR_PLAYTEST )
  1764. /***************************************************************************
  1765. * DEBUG_RIG_ROLL -- Pops up dialog to fix the next dice roll *
  1766. * *
  1767. * INPUT: parent window handle *
  1768. * *
  1769. * OUTPUT: none *
  1770. * *
  1771. * WARNINGS: none *
  1772. * *
  1773. * HISTORY: see PVCS log *
  1774. *=========================================================================*/
  1775. VOID Debug_Rig_Roll( WindowHandle window_handle )
  1776. {
  1777. if ( ! Game_Status.Is_Game_In_Progress() ) {
  1778. #if( DEBUG_CODE )
  1779. Debug_Error_Window_Message( "Game not in progress!" );
  1780. #endif
  1781. return;
  1782. }
  1783. DialogBox( Global_Instance_Handle,
  1784. "DebugDiceDlgBox",
  1785. window_handle,
  1786. (DLGPROC) Debug_Rig_Roll_Dialog_Procedure );
  1787. #if( DEBUG_CODE )
  1788. Debug_Mono_Message( "***** The next roll has been rigged! *****\r\n" );
  1789. #endif
  1790. #if( COMPILE_WINSOCK )
  1791. // if ( Multiple_Site_Game_In_Progress ) {
  1792. // WinSock_Broadcast_Cmd_String( CMD_SEND_YELL_MESSAGE_STRING,
  1793. // Game_Status.Get_Whos_Turn_Is_It_Now(),
  1794. // "The next dice roll has been rigged!\r\n" );
  1795. // }
  1796. #endif
  1797. }
  1798. #pragma argsused
  1799. /***************************************************************************
  1800. * DEBUG_RIG_ROLL_DIALOG_PROCEDURE -- Handles commands to dialog *
  1801. * *
  1802. * INPUT: standard windows dialog command parameters *
  1803. * *
  1804. * OUTPUT: TRUE if dice rigged, FALSE if not *
  1805. * *
  1806. * WARNINGS: none *
  1807. * *
  1808. * HISTORY: see PVCS log *
  1809. *=========================================================================*/
  1810. PRIVATE BOOL Debug_Rig_Roll_Dialog_Procedure( WindowHandle window_handle,
  1811. UINT message,
  1812. WPARAM w_param,
  1813. LPARAM l_param )
  1814. {
  1815. INT die1, die2;
  1816. switch( message ) {
  1817. case WM_COMMAND:
  1818. if ( LOWORD( w_param ) == IDOK ) {
  1819. GetDlgItemText( window_handle,
  1820. DIE_EDIT1,
  1821. Text_String,
  1822. SIZE_OF_TEXT_STRING );
  1823. die1 = atoi( Text_String );
  1824. GetDlgItemText( window_handle,
  1825. DIE_EDIT2,
  1826. Text_String,
  1827. SIZE_OF_TEXT_STRING );
  1828. die2 = atoi( Text_String );
  1829. if ( die1 < 1 || die1 > 6 || die2 < 1 || die2 > 6 ) {
  1830. #if( DEBUG_CODE )
  1831. Debug_Error_Window_Message( "Illegal values, defaulting to 1 & 1.\r\n" );
  1832. #endif
  1833. die1 = 1;
  1834. die2 = 1;
  1835. }
  1836. Dice.Set_Debug_Die( 1, die1 );
  1837. Dice.Set_Debug_Die( 2, die2 );
  1838. sprintf( Text_String,
  1839. "The next dice roll is rigged for a %d and a %d.\r\n",
  1840. die1, die2 );
  1841. Debug_Mono_Message( Text_String );
  1842. EndDialog( window_handle, TRUE );
  1843. return( TRUE );
  1844. }
  1845. break;
  1846. default: break;
  1847. }
  1848. return( FALSE );
  1849. }
  1850. #endif