]> icculus.org git repositories - btb/d2x.git/blob - main/inferno.c
enable logo screens for shareware/oem
[btb/d2x.git] / main / inferno.c
1 /* $Id: inferno.c,v 1.92 2004-11-27 11:55:10 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * inferno.c: Entry point of program (main procedure)
18  *
19  * After main initializes everything, most of the time is spent in the loop
20  * while (Function_mode != FMODE_EXIT)
21  * In this loop, the main menu is brought up first.
22  *
23  * main() for Inferno
24  *
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include <conf.h>
29 #endif
30
31 char copyright[] = "DESCENT II  COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPORATION";
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <limits.h>
37
38 #ifdef __unix__
39 #include <unistd.h>
40 #include <sys/stat.h>
41 #include <sys/types.h>
42 #endif
43
44 #include "pstypes.h"
45 #include "strutil.h"
46 #include "console.h"
47 #include "pa_enabl.h"       //$$POLY_ACC
48 #include "gr.h"
49 #include "fix.h"
50 #include "vecmat.h"
51 #include "mono.h"
52 #include "key.h"
53 #include "timer.h"
54 #include "3d.h"
55 #include "bm.h"
56 #include "inferno.h"
57 #include "error.h"
58 #include "game.h"
59 #include "segment.h"            //for Side_to_verts
60 #include "u_mem.h"
61 #include "segpoint.h"
62 #include "screens.h"
63 #include "texmap.h"
64 #include "texmerge.h"
65 #include "menu.h"
66 #include "wall.h"
67 #include "polyobj.h"
68 #include "effects.h"
69 #include "digi.h"
70 #include "iff.h"
71 #include "pcx.h"
72 #include "palette.h"
73 #include "args.h"
74 #include "sounds.h"
75 #include "titles.h"
76 #include "player.h"
77 #include "text.h"
78 #include "newdemo.h"
79 #ifdef NETWORK
80 #include "network.h"
81 #include "modem.h"
82 #endif
83 #include "gamefont.h"
84 #include "kconfig.h"
85 #include "mouse.h"
86 #include "joy.h"
87 #include "newmenu.h"
88 #include "desc_id.h"
89 #include "config.h"
90 #include "joydefs.h"
91 #include "multi.h"
92 #include "songs.h"
93 #include "cfile.h"
94 #include "gameseq.h"
95 #include "gamepal.h"
96 #include "mission.h"
97 #include "movie.h"
98 #include "d_io.h"
99
100 // #  include "3dfx_des.h"
101
102 //added on 9/30/98 by Matt Mueller for selectable automap modes
103 #include "automap.h"
104 //end addition -MM
105
106 #include "../texmap/scanline.h" //for select_tmap -MM
107
108 #if defined(POLY_ACC)
109 #include "poly_acc.h"
110 extern int Current_display_mode;        //$$ there's got to be a better way than hacking this.
111 #endif
112
113 #ifdef EDITOR
114 #include "editor/editor.h"
115 #include "editor/kdefs.h"
116 #include "ui.h"
117 #endif
118
119 #ifndef __MSDOS__
120 #include <SDL.h>
121 #endif
122
123 #include "vers_id.h"
124
125 void mem_init(void);
126 void arch_init(void);
127 void arch_init_start(void);
128
129 //Current version number
130
131 ubyte Version_major = 1;                //FULL VERSION
132 ubyte Version_minor = 2;
133
134 //static const char desc_id_checksum_str[] = DESC_ID_CHKSUM_TAG "0000"; // 4-byte checksum
135 char desc_id_exit_num = 0;
136
137 int Function_mode=FMODE_MENU;           //game or editor?
138 int Screen_mode=-1;                                     //game screen or editor screen?
139
140 //--unused-- grs_bitmap Inferno_bitmap_title;
141
142 int WVIDEO_running=0;           //debugger can set to 1 if running
143
144 #ifdef EDITOR
145 int Inferno_is_800x600_available = 0;
146 #endif
147
148 //--unused-- int Cyberman_installed=0;                  // SWIFT device present
149 ubyte CybermouseActive=0;
150
151 int __far descent_critical_error_handler( unsigned deverr, unsigned errcode, unsigned __far * devhdr );
152
153 void check_joystick_calibration(void);
154
155 void show_order_form(void);
156
157 //--------------------------------------------------------------------------
158
159 extern int piggy_low_memory;
160
161
162 int descent_critical_error = 0;
163 unsigned descent_critical_deverror = 0;
164 unsigned descent_critical_errcode = 0;
165
166 extern int Network_allow_socket_changes;
167
168 extern void vfx_set_palette_sub(ubyte *);
169
170 extern int VR_low_res;
171
172 extern int Config_vr_type;
173 extern int Config_vr_resolution;
174 extern int Config_vr_tracking;
175
176 #define LINE_LEN        100
177
178 //read help from a file & print to screen
179 void print_commandline_help()
180 {
181         CFILE *ifile;
182         int have_binary=0;
183         char line[LINE_LEN];
184
185         ifile = cfopen("help.tex","rb");
186         if (!ifile) {
187                 ifile = cfopen("help.txb","rb");
188                 if (!ifile)
189                         Warning("Cannot load help text file.");
190                 have_binary = 1;
191         }
192
193         if (ifile)
194         {
195         char *end;
196         
197                 while ((end = cfgets(line,LINE_LEN,ifile))) {
198
199             // This is the only use of cfgets that needs the CR
200             *end++ = '\n';
201                         if (have_binary)
202                                 decode_text_line (line);
203
204                         if (line[0] == ';')
205                                 continue;               //don't show comments
206
207                         printf("%s",line);
208
209                 }
210
211                 cfclose(ifile);
212
213         }
214
215 //      printf( " Diagnostic:\n\n");
216 //      printf( "  -emul           %s\n", "Certain video cards need this option in order to run game");
217 //      printf( "  -ddemul         %s\n", "If -emul doesn't work, use this option");
218 //      printf( "\n");
219 #ifdef EDITOR
220         printf( " Editor Options:\n\n");
221         printf( "  -autoload <file>%s\n", "Autoload a level in the editor");
222         printf( "  -hoarddata      %s\n","FIXME: Undocumented");
223 //      printf( "  -nobm           %s\n","FIXME: Undocumented");
224         printf( "\n");
225 #endif
226         printf( " D2X Options:\n\n");
227         printf( "  -noredundancy   %s\n", "Do not send messages when picking up redundant items in multi");
228         printf( "  -shortpackets   %s\n", "Set shortpackets to default as on");
229 #ifdef OGL // currently only does anything on ogl build, so don't advertise othewise.
230         printf("  -renderstats    %s\n", "Enable renderstats info by default");
231 #endif
232         printf( "  -maxfps <n>     %s\n", "Set maximum framerate (1-100)");
233         printf( "  -notitles       %s\n", "Do not show titlescreens on startup");
234         printf( "  -hogdir <dir>   %s\n", "set shared data directory to <dir>");
235 #ifdef __unix__
236         printf( "  -nohogdir       %s\n", "don't try to use shared data directory");
237         printf( "  -userdir <dir>  %s\n", "set user dir to <dir> instead of $HOME/.d2x");
238 #endif
239         printf( "  -ini <file>     %s\n", "option file (alternate to command line), defaults to d2x.ini");
240         printf( "  -autodemo       %s\n", "Start in demo mode");
241         printf( "  -bigpig         %s\n","FIXME: Undocumented");
242         printf( "  -bspgen         %s\n","FIXME: Undocumented");
243 //      printf( "  -cdproxy        %s\n","FIXME: Undocumented");
244 #ifndef NDEBUG
245         printf( "  -checktime      %s\n","FIXME: Undocumented");
246         printf( "  -showmeminfo    %s\n","FIXME: Undocumented");
247 #endif
248 //      printf( "  -codereadonly   %s\n","FIXME: Undocumented");
249 //      printf( "  -cyberimpact    %s\n","FIXME: Undocumented");
250         printf( "  -debug          %s\n","Enable very verbose output");
251 //      printf( "  -debugmode      %s\n","FIXME: Undocumented");
252 //      printf( "  -disallowgfx    %s\n","FIXME: Undocumented");
253 //      printf( "  -disallowreboot %s\n","FIXME: Undocumented");
254 //      printf( "  -dynamicsockets %s\n","FIXME: Undocumented");
255 //      printf( "  -forcegfx       %s\n","FIXME: Undocumented");
256 #ifdef SDL_INPUT
257         printf( "  -grabmouse      %s\n","Keeps the mouse from wandering out of the window");
258 #endif
259 //      printf( "  -hw_3dacc       %s\n","FIXME: Undocumented");
260 #ifndef RELEASE
261         printf( "  -invulnerability %s\n","Make yourself invulnerable");
262 #endif
263         printf( "  -ipxnetwork <num> %s\n","Use IPX network number <num>");
264         printf( "  -jasen          %s\n","FIXME: Undocumented");
265         printf( "  -joyslow        %s\n","FIXME: Undocumented");
266 #ifdef NETWORK
267         printf( "  -kali           %s\n","use Kali for networking");
268 #endif
269 //      printf( "  -logfile        %s\n","FIXME: Undocumented");
270         printf( "  -lowresmovies   %s\n","Play low resolution movies if available (for slow machines)");
271 #if defined(EDITOR) || !defined(MACDATA)
272         printf( "  -macdata        %s\n","Read (and, for editor, write) mac data files (swap colors)");
273 #endif
274 //      printf( "  -memdbg         %s\n","FIXME: Undocumented");
275 //      printf( "  -monodebug      %s\n","FIXME: Undocumented");
276         printf( "  -nocdrom        %s\n","FIXME: Undocumented");
277 #ifdef __DJGPP__
278         printf( "  -nocyberman     %s\n","FIXME: Undocumented");
279 #endif
280 #ifndef NDEBUG
281         printf( "  -nofade         %s\n","Disable fades");
282 #endif
283 #ifdef NETWORK
284         printf( "  -nomatrixcheat  %s\n","FIXME: Undocumented");
285         printf( "  -norankings     %s\n","Disable multiplayer ranking system");
286         printf( "  -packets <num>  %s\n","Specifies the number of packets per second\n");
287 //      printf( "  -showaddress    %s\n","FIXME: Undocumented");
288         printf( "  -socket         %s\n","FIXME: Undocumented");
289 #endif
290 #if !defined(MACINTOSH) && !defined(WINDOWS)
291         printf( "  -nomixer        %s\n","Don't crank music volume");
292 //      printf( "  -superhires     %s\n","Allow higher-resolution modes");
293 #endif
294 //      printf( "  -nomodex        %s\n","FIXME: Undocumented");
295 #ifndef RELEASE
296         printf( "  -nomovies       %s\n","Don't play movies");
297         printf( "  -noscreens      %s\n","Skip briefing screens");
298 #endif
299 #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) )
300         printf( "  -noredbook      %s\n","Disable redbook audio");
301 #endif
302         printf( "  -norun          %s\n","Bail out after initialization");
303 //      printf( "  -ordinaljoy     %s\n","FIXME: Undocumented");
304 //      printf( "  -rtscts         %s\n","Same as -ctsrts");
305 //      printf( "  -semiwin        %s\n","Use non-fullscreen mode");
306 //      printf( "  -specialdevice  %s\n","FIXME: Undocumented");
307 #ifdef TACTILE
308         printf( "  -stickmag       %s\n","FIXME: Undocumented");
309 #endif
310 //      printf( "  -stopwatch      %s\n","FIXME: Undocumented");
311         printf( "  -subtitles      %s\n","Turn on movie subtitles (English-only)");
312 //      printf( "  -sysram         %s\n","FIXME: Undocumented");
313         printf( "  -text <file>    %s\n","Specify alternate .tex file");
314 //      printf( "  -tsengdebug1    %s\n","FIXME: Undocumented");
315 //      printf( "  -tsengdebug2    %s\n","FIXME: Undocumented");
316 //      printf( "  -tsengdebug3    %s\n","FIXME: Undocumented");
317 //      printf( "  -vidram         %s\n","FIXME: Undocumented");
318         printf( "  -xcontrol       %s\n","FIXME: Undocumented");
319         printf( "  -xname          %s\n","FIXME: Undocumented");
320         printf( "  -xver           %s\n","FIXME: Undocumented");
321         printf( "  -tmap <t>       %s\n","select texmapper to use (c,fp,i386,pent,ppro)");
322 #ifdef __MSDOS__
323         printf( "  -<X>x<Y>        %s\n", "Change screen resolution. Options:");
324         printf( "                     320x100;320x200;320x240;320x400;640x400;640x480;800x600;1024x768\n");
325 #else
326         printf( "  -<X>x<Y>        %s\n", "Change screen resolution to <X> by <Y>");
327 #endif
328         printf("  -niceautomap    %s\n", "Free cpu while doing automap");
329         printf( "  -automap<X>x<Y> %s\n","Set automap resolution to <X> by <Y>");
330         printf( "  -automap_gameres %s\n","Set automap to use the same resolution as in game");
331 //      printf( "  -menu<X>x<Y>    %s\n","Set menu resolution to <X> by <Y>");
332 //      printf( "  -menu_gameres   %s\n","Set menus to use the same resolution as in game");
333         printf("  -rearviewtime t %s\n", "time holding rearview key to use toggle mode (default 0.0625 seconds)");
334         printf( "\n");
335
336         printf( "D2X System Options:\n\n");
337 #ifdef __MSDOS__
338         printf("  -ihaveabrokenmouse %s\n", "try to make mouse work if it is not currently");
339         printf( "  -joy209         %s\n", "Use alternate port 209 for joystick");
340 #endif
341 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
342         printf( "  -fullscreen     %s\n", "Use fullscreen mode if available");
343 #endif
344 #ifdef OGL
345         printf( "  -gl_texmagfilt <f> %s\n","set GL_TEXTURE_MAG_FILTER (see readme.d1x)");
346         printf( "  -gl_texminfilt <f> %s\n","set GL_TEXTURE_MIN_FILTER (see readme.d1x)");
347         printf("  -gl_mipmap      %s\n", "set gl texture filters to \"standard\" (bilinear) mipmapping");
348         printf("  -gl_trilinear   %s\n", "set gl texture filters to trilinear mipmapping");
349         printf( "  -gl_simple      %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)");
350         printf("  -gl_anisotropy <f> %s\n", "set maximum degree of anisotropy to <f>");
351         printf( "  -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)");
352         printf( "  -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster");
353 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
354         printf( "  -gl_voodoo      %s\n","force fullscreen mode only");
355 #endif
356         printf( "  -gl_16bittextures %s\n","attempt to use 16bit textures");
357         printf("  -gl_16bpp       %s\n", "attempt to use 16bit screen mode");
358         printf( "  -gl_reticle <r> %s\n","use OGL reticle 0=never 1=above 320x* 2=always");
359         printf( "  -gl_intensity4_ok %s\n","FIXME: Undocumented");
360         printf( "  -gl_luminance4_alpha4_ok %s\n","FIXME: Undocumented");
361         printf( "  -gl_readpixels_ok %s\n","FIXME: Undocumented");
362         printf( "  -gl_rgba2_ok    %s\n","FIXME: Undocumented");
363 //      printf( "  -gl_test1       %s\n","FIXME: Undocumented");
364         printf( "  -gl_test2       %s\n","FIXME: Undocumented");
365         printf( "  -gl_vidmem      %s\n","FIXME: Undocumented");
366 #ifdef OGL_RUNTIME_LOAD
367         printf( "  -gl_library <l> %s\n","use alternate opengl library");
368 #endif
369 #ifdef WGL_VIDEO
370         printf("  -gl_refresh <r> %s\n", "set refresh rate (in fullscreen mode)");
371 #endif
372 #endif
373 #ifdef SDL_VIDEO
374         printf( "  -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch");
375         printf( "  -hwsurface      %s\n","FIXME: Undocumented");
376 #endif
377 #ifdef NETWORK
378         printf("  -udp            %s\n", "Specify options for udp/ip:");
379         printf("    @<shift>      %s\n", "  shift udp port base offset");
380         printf("    =<HOST_LIST>  %s\n", "  broadcast both local and to HOST_LIST");
381         printf("    +<HOST_LIST>  %s\n", "  broadcast only to HOST_LIST");
382         printf("                  %s\n", "   HOSTS can be any IP or hostname")
383                 ;
384         printf("                  %s\n", "   HOSTS can also be in the form of <address>:<shift>");
385         printf("                  %s\n", "   separate multiple HOSTS with a ,");
386 #endif
387 #ifdef __unix__
388         printf( "  -serialdevice <s> %s\n", "Set serial/modem device to <s>");
389         printf( "  -serialread <r> %s\n", "Set serial/modem to read from <r>");
390 #endif
391         printf( "\n Help:\n\n");
392         printf( "  -help, -h, -?, ? %s\n", "View this help screen");
393         printf( "\n");
394 }
395
396 void do_joystick_init()
397 {
398
399         if (!FindArg( "-nojoystick" ))  {
400                 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6);
401                 joy_init();
402                 if ( FindArg( "-joyslow" ))     {
403                         con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_7);
404                         joy_set_slow_reading(JOY_SLOW_READINGS);
405                 }
406                 if ( FindArg( "-joypolled" ))   {
407                         con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_8);
408                         joy_set_slow_reading(JOY_POLLED_READINGS);
409                 }
410                 if ( FindArg( "-joybios" ))     {
411                         con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_9);
412                         joy_set_slow_reading(JOY_BIOS_READINGS);
413                 }
414
415         //      Added from Descent v1.5 by John.  Adapted by Samir.
416         } else {
417                 con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_10);
418         }
419 }
420
421 //set this to force game to run in low res
422 int disable_high_res=0;
423
424 void do_register_player(ubyte *title_pal)
425 {
426         Players[Player_num].callsign[0] = '\0';
427
428         if (!Auto_demo)         {
429
430                 key_flush();
431
432                 //now, before we bring up the register player menu, we need to
433                 //do some stuff to make sure the palette is ok.  First, we need to
434                 //get our current palette into the 2d's array, so the remapping will
435                 //work.  Second, we need to remap the fonts.  Third, we need to fill
436                 //in part of the fade tables so the darkening of the menu edges works
437
438                 memcpy(gr_palette,title_pal,sizeof(gr_palette));
439                 remap_fonts_and_menus(1);
440                 RegisterPlayer();               //get player's name
441         }
442
443 }
444
445 #define PROGNAME argv[0]
446
447 extern char Language[];
448
449 //can we do highres menus?
450 extern int MenuHiresAvailable;
451
452 int intro_played = 0;
453
454 int Inferno_verbose = 0;
455
456 //added on 11/18/98 by Victor Rachels to add -mission and -startgame
457 int start_net_immediately = 0;
458 //int start_with_mission = 0;
459 //char *start_with_mission_name;
460 //end this section addition
461
462 int open_movie_file(char *filename,int must_have);
463
464 #if defined(POLY_ACC)
465 #define MENU_HIRES_MODE SM_640x480x15xPA
466 #else
467 #define MENU_HIRES_MODE SM(640,480)
468 #endif
469
470 //      DESCENT II by Parallax Software
471 //              Descent Main
472
473 //extern ubyte gr_current_pal[];
474
475 #ifdef  EDITOR
476 int     Auto_exit = 0;
477 char    Auto_file[128] = "";
478 #endif
479
480 int main(int argc, char *argv[])
481 {
482         int i, t;
483         ubyte title_pal[768];
484
485         con_init();  // Initialise the console
486         mem_init();
487
488         error_init(NULL, NULL);
489
490         InitArgs( argc,argv );
491
492 #ifdef __unix__
493         {
494                 char *home = getenv("HOME");
495
496                 if ((t = FindArg("-userdir")))
497                         chdir(Args[t+1]);
498
499                 else if (home) {
500                         char buf[PATH_MAX + 5];
501
502                         strcpy(buf, home);
503                         strcat(buf, "/.d2x");
504                         if (chdir(buf)) {
505                                 mkdir(buf, 0755);
506                                 if (chdir(buf))
507                                         fprintf(stderr, "Cannot change to $HOME/.d2x\n");
508                         }
509                 }
510         }
511 #endif
512
513         if (FindArg("-debug"))
514                 con_threshold.value = (float)2;
515         else if (FindArg("-verbose"))
516                 con_threshold.value = (float)1;
517
518         //tell cfile where hogdir is
519         if ((t=FindArg("-hogdir")))
520                 cfile_use_alternate_hogdir(Args[t+1]);
521 #ifdef __unix__
522         else if (!FindArg("-nohogdir"))
523                 cfile_use_alternate_hogdir(SHAREPATH);
524 #endif
525
526         //tell cfile about our counter
527         cfile_set_critical_error_counter_ptr(&descent_critical_error);
528
529         if (! cfile_init("descent2.hog"))
530                 if (! cfile_init("d2demo.hog"))
531                         Warning("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n"
532 #ifdef __unix__
533                               "\t$HOME/.d2x\n"
534                               "\t" SHAREPATH "\n"
535 #else
536                                   "\tCurrent directory\n"
537 #endif
538                                   "Or use the -hogdir option to specify an alternate location.");
539         load_text();
540
541         //print out the banner title
542         con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor);
543         #ifdef VERSION_NAME
544         con_printf(CON_NORMAL, "  %s", VERSION_NAME);
545         #endif
546         if (cfexist(MISSION_DIR "d2x.hog"))
547                 con_printf(CON_NORMAL, "  Vertigo Enhanced");
548
549         con_printf(CON_NORMAL, "  %s %s\n", __DATE__,__TIME__);
550         con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
551         con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n");
552         con_printf(CON_NORMAL, "                                         Copyright (c) 2002 Bradley Bell\n");
553
554
555         if (FindArg( "-?" ) || FindArg( "-help" ) || FindArg( "?" ) || FindArg( "-h" ) ) {
556                 print_commandline_help();
557                 set_exit_message("");
558 #ifdef __MINGW32__
559                 exit(0);  /* mingw hangs on this return.  dunno why */
560 #endif
561                 return(0);
562         }
563
564         con_printf(CON_NORMAL, "\n");
565         con_printf(CON_NORMAL, TXT_HELP, PROGNAME);             //help message has %s for program name
566         con_printf(CON_NORMAL, "\n");
567
568         //(re)added Mar 30, 2003 Micah Lieske - Allow use of 22K sound samples again.
569         if(FindArg("-sound22k"))
570         {
571                 digi_sample_rate = SAMPLE_RATE_22K;
572         }
573
574         if(FindArg("-sound11k"))
575         {
576                 digi_sample_rate = SAMPLE_RATE_11K;
577         }
578
579         arch_init_start();
580
581         arch_init();
582
583         //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM");
584
585         if ((t = FindArg("-rearviewtime")))
586         {
587                 float f = atof(Args[t + 1]);
588                 Rear_view_leave_time = f * f1_0;
589         }
590         con_printf(CON_VERBOSE, "Rear_view_leave_time=0x%x (%f sec)\n", Rear_view_leave_time, Rear_view_leave_time / (float)f1_0);
591
592         //added/edited 8/18/98 by Victor Rachels to set maximum fps <= 100
593         if ((t = FindArg( "-maxfps" ))) {
594                 t=atoi(Args[t+1]);
595                 if (t>0&&t<=80)
596                         maxfps=t;
597         }
598         //end addition - Victor Rachels
599
600 #ifdef SUPPORTS_NICEFPS
601         if (FindArg("-nicefps"))
602                 use_nice_fps = 1;
603         if (FindArg("-niceautomap"))
604                 nice_automap = 1;
605 #endif
606
607         if (FindArg("-renderstats"))
608                 gr_renderstats = 1;
609
610         if ( FindArg( "-autodemo" ))
611                 Auto_demo = 1;
612
613 #ifndef RELEASE
614         if ( FindArg( "-noscreens" ) )
615                 Skip_briefing_screens = 1;
616 #endif
617
618         if ((t=FindArg("-tmap"))){
619                 select_tmap(Args[t+1]);
620         }else
621                 select_tmap(NULL);
622
623         Lighting_on = 1;
624
625 //      if (init_graphics()) return 1;
626
627         #ifdef EDITOR
628         if (!Inferno_is_800x600_available)      {
629                 con_printf(CON_NORMAL, "The editor will not be available, press any key to start game...\n" );
630                 Function_mode = FMODE_MENU;
631         }
632         #endif
633
634         if (!WVIDEO_running)
635                 con_printf(CON_DEBUG,"WVIDEO_running = %d\n",WVIDEO_running);
636
637         con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1);
638         ReadConfigFile();
639
640         do_joystick_init();
641
642 #if defined(POLY_ACC)
643     Current_display_mode = -1;
644     game_init_render_buffers(SM_640x480x15xPA, 640, 480, VR_NONE, VRF_COMPATIBLE_MENUS+VRF_ALLOW_COCKPIT );
645 #else
646
647         if (!VR_offscreen_buffer)       //if hasn't been initialied (by headset init)
648                 set_display_mode(0);            //..then set default display mode
649 #endif
650
651         {
652                 int screen_width = 640;
653                 int screen_height = 480;
654                 int vr_mode = VR_NONE;
655                 int screen_flags = VRF_USE_PAGING;
656
657                 if (FindResArg("", &screen_width, &screen_height))
658                 {
659                         /* stuff below mirrors values from display_mode_info in
660                          * menu.c which is used by set_display_mode. In fact,
661                          * set_display_mode should probably be rewritten to allow
662                          * arbitrary resolutions, and then we get rid of this
663                          * stuff here.
664                          */
665                         switch (SM(screen_width, screen_height))
666                         {
667                         case SM(320, 200):
668                         case SM(640, 480):
669                                 screen_flags = VRF_ALLOW_COCKPIT + VRF_COMPATIBLE_MENUS;
670                                 break;
671                         case SM(320, 400):
672                                 screen_flags = VRF_USE_PAGING;
673                                 break;
674                         case SM(640, 400):
675                         case SM(800, 600):
676                         case SM(1024, 768):
677                         case SM(1280, 1024):
678                                 screen_flags = VRF_COMPATIBLE_MENUS;
679                                 break;
680                         }
681
682                         con_printf(CON_VERBOSE, "Using %ix%i ...\n", screen_width, screen_height);
683                 }
684
685 // added ifdef on 9/30/98 by Matt Mueller to fix high res in linux
686 #ifdef __MSDOS__
687                 if (FindArg("-nodoublebuffer"))
688 #endif
689 // end addition -MM
690                 {
691                         con_printf(CON_VERBOSE, "Double-buffering disabled...\n");
692                         screen_flags &= ~VRF_USE_PAGING;
693                 }
694
695                 // added 3/24/99 by Owen Evans for screen res changing
696                 Game_screen_mode = SM(screen_width, screen_height);
697                 // end added -OE
698                 game_init_render_buffers(Game_screen_mode, screen_width, screen_height, vr_mode, screen_flags);
699
700         }
701         {
702 // added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args
703                 int i, argnum = INT_MAX, w, h;
704 // added on 9/30/98 by Matt Mueller for selectable automap modes - edited 11/21/99 whee, more fun with defines. - edited 03/31/02 to use new FindResArg.
705 #define SMODE(V,VV,VG) if ((i=FindResArg(#V, &w, &h)) && (i < argnum)) { argnum = i; VV = SM(w, h); VG = 0; }
706 #define SMODE_GR(V,VG) if ((i=FindArg("-" #V "_gameres"))){if (i<argnum) VG=1;}
707 #define SMODE_PRINT(V,VV,VG) if (VG) con_printf(CON_VERBOSE, #V " using game resolution ...\n"); else con_printf(CON_VERBOSE, #V " using %ix%i ...\n",SM_W(VV),SM_H(VV) );
708 // aren't #defines great? :)
709 // end addition/edit -MM
710 #define S_MODE(V,VV,VG) argnum = INT_MAX; SMODE(V, VV, VG); SMODE_GR(V, VG); SMODE_PRINT(V, VV, VG);
711
712                 S_MODE(automap,automap_mode,automap_use_game_res);
713 //              S_MODE(menu,menu_screen_mode,menu_use_game_res);
714          }
715 //end addition -MM
716
717         i = FindArg( "-xcontrol" );
718         if ( i > 0 )    {
719                 kconfig_init_external_controls( strtol(Args[i+1], NULL, 0), strtol(Args[i+2], NULL, 0) );
720         }
721
722         con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS);
723         if (FindArg("-nofade"))
724                 grd_fades_disabled=1;
725
726         //determine whether we're using high-res menus & movies
727 #if !defined(POLY_ACC)
728         if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res)
729                 MovieHires = MenuHires = MenuHiresAvailable = 0;
730         else
731 #endif
732                 //NOTE LINK TO ABOVE!
733                 MenuHires = MenuHiresAvailable = 1;
734
735         if (FindArg( "-lowresmovies" ))
736                 MovieHires = 0;
737
738         if ((t=gr_init())!=0)                           //doesn't do much
739                 Error(TXT_CANT_INIT_GFX,t);
740
741    #ifdef _3DFX
742    _3dfx_Init();
743    #endif
744
745         // Load the palette stuff. Returns non-zero if error.
746         con_printf(CON_DEBUG, "Initializing palette system...\n" );
747         gr_use_palette_table(DEFAULT_PALETTE );
748
749         con_printf(CON_DEBUG, "Initializing font system...\n" );
750         gamefont_init();        // must load after palette data loaded.
751
752         con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
753         init_movies();          //init movie libraries
754
755 #if 0
756         con_printf(CON_VERBOSE, "Going into graphics mode...\n");
757 #if defined(POLY_ACC)
758         gr_set_mode(SM_640x480x15xPA);
759 #else
760         gr_set_mode(MovieHires?SM(640,480):SM(320,200));
761 #endif
762 #endif
763
764         #ifndef RELEASE
765         if ( FindArg( "-notitles" ) )
766                 songs_play_song( SONG_TITLE, 1);
767         else
768         #endif
769         {       //NOTE LINK TO ABOVE!
770 #ifndef SHAREWARE
771                 int played=MOVIE_NOT_PLAYED;    //default is not played
772 #endif
773                 int song_playing = 0;
774
775                 #ifdef D2_OEM
776                 #define MOVIE_REQUIRED 0
777                 #else
778                 #define MOVIE_REQUIRED 1
779                 #endif
780
781                 {       //show bundler screens
782                         char filename[FILENAME_LEN];
783
784                         played=MOVIE_NOT_PLAYED;        //default is not played
785
786             played = PlayMovie("pre_i.mve",0);
787
788                         if (!played) {
789                 strcpy(filename,MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
790
791                                 while (cfexist(filename))
792                                 {
793                                         show_title_screen( filename, 1, 0 );
794                     filename[5]++;
795                                 }
796                         }
797                 }
798
799                 #ifndef SHAREWARE
800                         init_subtitles("intro.tex");
801                         played = PlayMovie("intro.mve",MOVIE_REQUIRED);
802                         close_subtitles();
803                 #endif
804
805                 if (played != MOVIE_NOT_PLAYED)
806                         intro_played = 1;
807                 else {                                          //didn't get intro movie, try titles
808
809                         played = PlayMovie("titles.mve",MOVIE_REQUIRED);
810
811                         if (played == MOVIE_NOT_PLAYED)
812                         {
813                                 char filename[FILENAME_LEN];
814
815 #if defined(POLY_ACC)
816                                 gr_set_mode(SM_640x480x15xPA);
817 #else
818                                 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
819 #endif
820 #ifdef OGL
821                                 set_screen_mode(SCREEN_MENU);
822 #endif
823                                 con_printf( CON_DEBUG, "\nPlaying title song..." );
824                                 songs_play_song( SONG_TITLE, 1);
825                                 song_playing = 1;
826                                 con_printf( CON_DEBUG, "\nShowing logo screens..." );
827
828                                 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
829                                 if (! cfexist(filename))
830                                         strcpy(filename, "iplogo1.pcx"); // SHAREWARE
831                                 if (! cfexist(filename))
832                                         strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
833                                 show_title_screen(filename, 1, 1 );
834
835                                 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
836                                 if (! cfexist(filename))
837                                         strcpy(filename, "logo.pcx"); // SHAREWARE
838                                 if (! cfexist(filename))
839                                         strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
840                                 show_title_screen(filename, 1, 1 );
841                         }
842                 }
843
844                 {       //show bundler movie or screens
845
846                         char filename[FILENAME_LEN];
847                         int movie_handle;
848
849                         played=MOVIE_NOT_PLAYED;        //default is not played
850
851                         //check if OEM movie exists, so we don't stop the music if it doesn't
852                         movie_handle = open_movie_file("oem.mve",0);
853                         if (movie_handle != -1) {
854                                 close(movie_handle);
855                                 played = PlayMovie("oem.mve",0);
856                                 song_playing = 0;               //movie will kill sound
857                         }
858
859                         if (!played) {
860                                 strcpy(filename,MenuHires?"oem1b.pcx":"oem1.pcx");
861
862                                 while (cfexist(filename))
863                                 {
864                                         show_title_screen( filename, 1, 0 );
865                                         filename[3]++;
866                                 }
867                         }
868                 }
869
870                 if (!song_playing)
871                         songs_play_song( SONG_TITLE, 1);
872                         
873         }
874
875         PA_DFX (pa_splash());
876
877         con_printf( CON_DEBUG, "\nShowing loading screen..." );
878         {
879                 //grs_bitmap title_bm;
880                 int pcx_error;
881                 char filename[14];
882
883                 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
884                 if (! cfexist(filename))
885                         strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
886                 if (! cfexist(filename))
887                         strcpy(filename, "descentd.pcx"); // SHAREWARE
888                 if (! cfexist(filename))
889                         strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
890
891 #if defined(POLY_ACC)
892                 gr_set_mode(SM_640x480x15xPA);
893 #else
894                 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
895 #endif
896 #ifdef OGL
897                 set_screen_mode(SCREEN_MENU);
898 #endif
899
900                 FontHires = FontHiresAvailable && MenuHires;
901
902                 if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE)        {
903                         //vfx_set_palette_sub( title_pal );
904                         gr_palette_clear();
905                         gr_palette_fade_in( title_pal, 32, 0 );
906                 } else
907                         Error( "Couldn't load pcx file '%s', PCX load error: %s\n",filename, pcx_errormsg(pcx_error));
908         }
909
910         con_printf( CON_DEBUG , "\nDoing bm_init..." );
911         #ifdef EDITOR
912                 bm_init_use_tbl();
913         #else
914                 bm_init();
915         #endif
916
917         #ifdef EDITOR
918         if (FindArg("-hoarddata") != 0) {
919                 #define MAX_BITMAPS_PER_BRUSH 30
920                 grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
921                 grs_bitmap icon;
922                 int nframes;
923                 short nframes_short;
924                 ubyte palette[256*3];
925                 FILE *ofile;
926                 int iff_error,i;
927                 char *sounds[] = {"selforb.raw","selforb.r22",          //SOUND_YOU_GOT_ORB                     
928                                                                 "teamorb.raw","teamorb.r22",            //SOUND_FRIEND_GOT_ORB                  
929                                                                 "enemyorb.raw","enemyorb.r22",  //SOUND_OPPONENT_GOT_ORB        
930                                                                 "OPSCORE1.raw","OPSCORE1.r22"}; //SOUND_OPPONENT_HAS_SCORED
931
932                 ofile = fopen("hoard.ham","wb");
933
934            iff_error = iff_read_animbrush("orb.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
935                 Assert(iff_error == IFF_NO_ERROR);
936                 nframes_short = nframes;
937                 fwrite(&nframes_short,sizeof(nframes_short),1,ofile);
938                 fwrite(&bm[0]->bm_w,sizeof(short),1,ofile);
939                 fwrite(&bm[0]->bm_h,sizeof(short),1,ofile);
940                 fwrite(palette,3,256,ofile);
941                 for (i=0;i<nframes;i++)
942                         fwrite(bm[i]->bm_data,1,bm[i]->bm_w*bm[i]->bm_h,ofile);
943
944                 iff_error = iff_read_animbrush("orbgoal.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
945                 Assert(iff_error == IFF_NO_ERROR);
946                 Assert(bm[0]->bm_w == 64 && bm[0]->bm_h == 64);
947                 nframes_short = nframes;
948                 fwrite(&nframes_short,sizeof(nframes_short),1,ofile);
949                 fwrite(palette,3,256,ofile);
950                 for (i=0;i<nframes;i++)
951                         fwrite(bm[i]->bm_data,1,bm[i]->bm_w*bm[i]->bm_h,ofile);
952
953                 for (i=0;i<2;i++) {
954                         iff_error = iff_read_bitmap(i?"orbb.bbm":"orb.bbm",&icon,BM_LINEAR,palette);
955                         Assert(iff_error == IFF_NO_ERROR);
956                         fwrite(&icon.bm_w,sizeof(short),1,ofile);
957                         fwrite(&icon.bm_h,sizeof(short),1,ofile);
958                         fwrite(palette,3,256,ofile);
959                         fwrite(icon.bm_data,1,icon.bm_w*icon.bm_h,ofile);
960                 }
961
962                 for (i=0;i<sizeof(sounds)/sizeof(*sounds);i++) {
963                         FILE *ifile;
964                         int size;
965                         ubyte *buf;
966                         ifile = fopen(sounds[i],"rb");
967                         Assert(ifile != NULL);
968                         size = ffilelength(ifile);
969                         buf = d_malloc(size);
970                         fread(buf,1,size,ifile);
971                         fwrite(&size,sizeof(size),1,ofile);
972                         fwrite(buf,1,size,ofile);
973                         d_free(buf);
974                         fclose(ifile);
975                 }
976
977                 fclose(ofile);
978
979                 exit(1);
980         }
981         #endif
982
983         //the bitmap loading code changes gr_palette, so restore it
984         memcpy(gr_palette,title_pal,sizeof(gr_palette));
985
986         if ( FindArg( "-norun" ) )
987                 return(0);
988
989         con_printf( CON_DEBUG, "\nInitializing 3d system..." );
990         g3_init();
991
992         con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
993         texmerge_init( 10 );            // 10 cache bitmaps
994
995         con_printf( CON_DEBUG, "\nRunning game...\n" );
996         set_screen_mode(SCREEN_MENU);
997
998         init_game();
999
1000         //      If built with editor, option to auto-load a level and quit game
1001         //      to write certain data.
1002         #ifdef  EDITOR
1003         {       int t;
1004         if ( (t = FindArg( "-autoload" )) ) {
1005                 Auto_exit = 1;
1006                 strcpy(Auto_file, Args[t+1]);
1007         }
1008                 
1009         }
1010
1011         if (Auto_exit) {
1012                 strcpy(Players[0].callsign, "dummy");
1013         } else
1014         #endif
1015                 do_register_player(title_pal);
1016
1017         gr_palette_fade_out( title_pal, 32, 0 );
1018
1019         Game_mode = GM_GAME_OVER;
1020
1021         if (Auto_demo)  {
1022                 newdemo_start_playback("descent.dem");          
1023                 if (Newdemo_state == ND_STATE_PLAYBACK )
1024                         Function_mode = FMODE_GAME;
1025         }
1026
1027         //do this here because the demo code can do a longjmp when trying to
1028         //autostart a demo from the main menu, never having gone into the game
1029         setjmp(LeaveGame);
1030
1031         while (Function_mode != FMODE_EXIT)
1032         {
1033                 switch( Function_mode ) {
1034                 case FMODE_MENU:
1035                         set_screen_mode(SCREEN_MENU);
1036                         if ( Auto_demo )        {
1037                                 newdemo_start_playback(NULL);           // Randomly pick a file
1038                                 if (Newdemo_state != ND_STATE_PLAYBACK) 
1039                                         Error("No demo files were found for autodemo mode!");
1040                         } else {
1041                                 #ifdef EDITOR
1042                                 if (Auto_exit) {
1043                                         strcpy((char *)&Level_names[0], Auto_file);
1044                                         LoadLevel(1, 1);
1045                                         Function_mode = FMODE_EXIT;
1046                                         break;
1047                                 }
1048                                 #endif
1049
1050                                 check_joystick_calibration();
1051                                 gr_palette_clear();             //I'm not sure why we need this, but we do
1052                                 DoMenu();                                                                               
1053                                 #ifdef EDITOR
1054                                 if ( Function_mode == FMODE_EDITOR )    {
1055                                         create_new_mine();
1056                                         SetPlayerFromCurseg();
1057                                         load_palette(NULL,1,0);
1058                                 }
1059                                 #endif
1060                         }
1061                         break;
1062                 case FMODE_GAME:
1063                         #ifdef EDITOR
1064                                 keyd_editor_mode = 0;
1065                         #endif
1066
1067 #ifdef SDL_INPUT
1068                         /* keep the mouse from wandering in SDL */
1069                         if (FindArg("-grabmouse"))
1070                             SDL_WM_GrabInput(SDL_GRAB_ON);
1071 #endif
1072
1073                         game();
1074
1075 #ifdef SDL_INPUT
1076                         /* give control back to the WM */
1077                         if (FindArg("-grabmouse"))
1078                             SDL_WM_GrabInput(SDL_GRAB_OFF);
1079 #endif
1080
1081                         if ( Function_mode == FMODE_MENU )
1082                                 songs_play_song( SONG_TITLE, 1 );
1083                         break;
1084                 #ifdef EDITOR
1085                 case FMODE_EDITOR:
1086                         keyd_editor_mode = 1;
1087                         editor();
1088 #ifdef __WATCOMC__
1089                         _harderr( (void*)descent_critical_error_handler );              // Reinstall game error handler
1090 #endif
1091                         if ( Function_mode == FMODE_GAME ) {
1092                                 Game_mode = GM_EDITOR;
1093                                 editor_reset_stuff_on_level();
1094                                 N_players = 1;
1095                         }
1096                         break;
1097                 #endif
1098                 default:
1099                         Error("Invalid function mode %d",Function_mode);
1100                 }
1101         }
1102
1103         WriteConfigFile();
1104
1105         #ifndef RELEASE
1106         if (!FindArg( "-notitles" ))
1107         #endif
1108                 show_order_form();
1109
1110         #ifndef NDEBUG
1111         if ( FindArg( "-showmeminfo" ) )
1112                 show_mem_info = 1;              // Make memory statistics show
1113         #endif
1114
1115         return(0);              //presumably successful exit
1116 }
1117
1118
1119 void check_joystick_calibration()       {
1120         int x1, y1, x2, y2, c;
1121         fix t1;
1122
1123         if ( (Config_control_type!=CONTROL_JOYSTICK) &&
1124                   (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) &&
1125                   (Config_control_type!=CONTROL_THRUSTMASTER_FCS) &&
1126                   (Config_control_type!=CONTROL_GRAVIS_GAMEPAD)
1127                 ) return;
1128
1129         joy_get_pos( &x1, &y1 );
1130
1131         t1 = timer_get_fixed_seconds();
1132         while( timer_get_fixed_seconds() < t1 + F1_0/100 )
1133                 ;
1134
1135         joy_get_pos( &x2, &y2 );
1136
1137         // If joystick hasn't moved...
1138         if ( (abs(x2-x1)<30) &&  (abs(y2-y1)<30) )      {
1139                 if ( (abs(x1)>30) || (abs(x2)>30) ||  (abs(y1)>30) || (abs(y2)>30) )    {
1140                         c = nm_messagebox( NULL, 2, TXT_CALIBRATE, TXT_SKIP, TXT_JOYSTICK_NOT_CEN );
1141                         if ( c==0 )     {
1142                                 joydefs_calibrate();
1143                         }
1144                 }
1145         }
1146
1147 }
1148
1149 void show_order_form()
1150 {
1151 #ifndef EDITOR
1152
1153         int pcx_error;
1154         unsigned char title_pal[768];
1155         char    exit_screen[16];
1156
1157         gr_set_current_canvas( NULL );
1158         gr_palette_clear();
1159
1160         key_flush();
1161
1162         strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1163         if (! cfexist(exit_screen))
1164                 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1165         if (! cfexist(exit_screen))
1166                 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1167         if (! cfexist(exit_screen))
1168                 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1169         if (! cfexist(exit_screen))
1170                 return; // D2 registered
1171
1172         if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) {
1173                 //vfx_set_palette_sub( title_pal );
1174                 gr_palette_fade_in( title_pal, 32, 0 );
1175                 gr_update();
1176                 while (!key_inkey() && !mouse_button_state(0)) {} //key_getch();
1177                 gr_palette_fade_out( title_pal, 32, 0 );
1178         }
1179         else
1180                 Int3();         //can't load order screen
1181
1182         key_flush();
1183
1184 #endif
1185 }
1186
1187 void quit_request()
1188 {
1189 #ifdef NETWORK
1190 //      void network_abort_game();
1191 //      if(Network_status)
1192 //              network_abort_game();
1193 #endif
1194         exit(0);
1195 }