-
Notifications
You must be signed in to change notification settings - Fork 0
/
D_MAIN.C
1557 lines (1306 loc) · 40.3 KB
/
D_MAIN.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// d_main.c :
// DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
// plus functions to determine game mode (shareware, registered),
// parse command line parameters, configure game parameters (turbo),
// and call the startup functions.
#ifndef __WIN32__
#include <unistd.h> // for access
#endif
#include <fcntl.h>
#ifdef __WIN32__
#include <direct.h> //for mkdir
#endif
#include "doomdef.h"
#include "command.h"
#include "console.h"
#include "doomstat.h"
#include "am_map.h"
#include "d_net.h"
#include "d_netcmd.h"
#include "dehacked.h"
#include "dstrings.h"
#include "f_wipe.h"
#include "f_finale.h"
#include "g_game.h"
#include "g_input.h"
#include "hu_stuff.h"
#include "i_sound.h"
#include "i_system.h"
#include "i_video.h"
#include "m_argv.h"
#include "m_menu.h"
#include "m_misc.h"
#include "p_setup.h"
#include "p_fab.h"
#include "r_main.h"
#include "r_local.h"
#include "s_sound.h"
#include "st_stuff.h"
#include "v_video.h"
#include "wi_stuff.h"
#include "w_wad.h"
#include "z_zone.h"
#include "d_main.h"
#ifdef __WIN32__
#include "win32/hwr_main.h" // GLIDE View Rendering
#include "win32/win_main.h" // GLIDE View Rendering
#endif
#define BGCOLOR 7
#define FGCOLOR 8
extern int mb_used; // base memory allocation, changeable by -mb parm.
// note: TEMPORARY hack, check D_DoomMain.
//
// DEMO LOOP
//
int demosequence;
int pagetic;
char *pagename;
// PROTOS
void D_DoomLoop (void);
void D_PageDrawer (char* lumpname);
void D_AdvanceDemo (void);
char* startupwadfiles[MAX_WADFILES];
boolean devparm; // started game with -devparm
boolean nomonsters; // checkparm of -nomonsters
boolean singletics = false; // debug flag to cancel adaptiveness
boolean nomusic; //Boris stuff
boolean nosound;
extern boolean inhelpscreens;
boolean advancedemo;
char wadfile[1024]; // primary wad file
char mapdir[1024]; // directory of development maps
//
// EVENT HANDLING
//
// Events are asynchronous inputs generally generated by the game user.
// Events can be discarded if no responder claims them
//
event_t events[MAXEVENTS];
int eventhead;
int eventtail;
//
// D_PostEvent
// Called by the I/O functions when input is detected
//
void D_PostEvent (event_t* ev)
{
events[eventhead] = *ev;
eventhead = (++eventhead)&(MAXEVENTS-1);
}
// just for lock this function
#ifdef PC_DOS
void D_PostEvent_end(void) {};
#endif
//
// D_ProcessEvents
// Send all the events of the given timestamp down the responder chain
//
void D_ProcessEvents (void)
{
event_t* ev;
//added:12-02-98: doing a W_CheckNumForName() is a bit clumsy here...
// IF STORE DEMO, DO NOT ACCEPT INPUT
//if ( ( gamemode == commercial )
// && (W_CheckNumForName("map01")<0) )
// return;
for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )
{
ev = &events[eventtail];
// Menu input
if (M_Responder (ev))
continue; // menu ate the event
// console input
if (CON_Responder (ev))
continue; // ate the event
G_Responder (ev);
}
}
//
// D_Display
// draw current display, possibly wiping it from the previous
//
extern boolean playerdeadview; //hack from P_DeathThink()
#ifdef __WIN32__
extern int glide_view;
void I_DoStartupMouse (void); //win_sys.c
void HWR_RenderPlayerView (int viewnumber, player_t* player);
#endif
// tyest the clientprediction
boolean gostview;
// wipegamestate can be set to -1 to force a wipe on the next draw
// added comment : there is a wipe eatch change of the gamestate
gamestate_t wipegamestate = GS_DEMOSCREEN;
void D_Display (void)
{
static boolean viewactivestate = false;
static boolean menuactivestate = false;
static boolean inhelpscreensstate = false;
static boolean fullscreen = false;
static gamestate_t oldgamestate = -1;
static int borderdrawcount;
int nowtime;
int tics;
int wipestart;
int y;
boolean done;
boolean wipe;
boolean redrawsbar;
if (nodrawers)
return; // for comparative timing / profiling
redrawsbar = false;
//added:21-01-98: check for change of screen size (video mode)
if (setmodeneeded)
{
SCR_SetMode(); // change video mode
}
if (vid.recalc)
{
//added:26-01-98: NOTE! setsizeneeded is set by SCR_Recalc()
SCR_Recalc();
}
// change the view size if needed
if (setsizeneeded || scr_viewsize!=cv_viewsize.value)
{
R_ExecuteSetViewSize ();
oldgamestate = -1; // force background redraw
borderdrawcount = 3;
}
// save the current screen if about to wipe
if (gamestate != wipegamestate &&
rendermode == render_soft)
{
wipe = true;
wipe_StartScreen(0, 0, vid.width, vid.height);
}
else
wipe = false;
if (gamestate == GS_LEVEL && gametic)
{
HU_Erase();
}
// do buffered drawing
switch (gamestate)
{
case GS_LEVEL:
if (!gametic)
break;
if (automapactive)
AM_Drawer ();
if (wipe || ((viewheight != vid.height) && fullscreen) )
redrawsbar = true;
if (inhelpscreensstate && !inhelpscreens)
redrawsbar = true; // just put away the help screen
if (vid.recalc) //redraw (& recalc widgets) when vidmode change
redrawsbar = true;
if (menuactivestate) // redraw stbar because menu fades down the
redrawsbar = true; // screen
ST_Drawer (viewheight == vid.height, redrawsbar );
fullscreen = (viewheight == vid.height);
break;
case GS_INTERMISSION:
WI_Drawer ();
break;
case GS_FINALE:
F_Drawer ();
break;
case GS_DEDICATEDSERVER:
case GS_DEMOSCREEN:
D_PageDrawer (pagename);
break;
case GS_WAITINGPLAYERS:
// console is always draw
break;
}
// draw buffered stuff to screen
I_UpdateNoBlit ();
// draw the view directly
if (gamestate == GS_LEVEL)
{
if( !automapactive )
{
gostview=true;
if ( rendermode == render_soft )
R_RenderPlayerView (&players[displayplayer]);
#ifdef __WIN32__
else //if (rendermode != render_soft)
HWR_RenderPlayerView (0, &players[displayplayer]);
#endif
// added 16-6-98: render the second screen
if( cv_splitscreen.value )
{
gostview = false;
if ( rendermode == render_soft )
{
//faB: Boris hack :P !!
viewwindowy = vid.height/2;
memcpy(ylookup,ylookup2,viewheight*sizeof(ylookup[0]));
R_RenderPlayerView (&players[secondarydisplayplayer]);
viewwindowy = 0;
memcpy(ylookup,ylookup1,viewheight*sizeof(ylookup[0]));
}
#ifdef __WIN32__
else //if (rendermode != render_soft)
HWR_RenderPlayerView (1, &players[secondarydisplayplayer]);
#endif
}
}
HU_Drawer ();
// fullscreen with overlay
if (st_overlay && !automapactive &&
(!playerdeadview || cv_splitscreen.value)) //Fab: full clear view when dead
{
ST_overlayDrawer ();
if(cv_splitscreen.value)
{
player_t *p;
extern player_t *plyr;
p=plyr;
plyr=&players[secondarydisplayplayer];
ST_overlayDrawer ();
plyr=p;
}
}
}
// change gamma if needed
if ((scr_gamma!=cv_usegamma.value) ||
(gamestate != oldgamestate && gamestate != GS_LEVEL) )
{
scr_gamma = cv_usegamma.value;
I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));
}
// clean up border stuff
// see if the border needs to be initially drawn
if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL)
{
viewactivestate = false; // view was not active
R_FillBackScreen (); // draw the pattern into the back screen
}
// see if the border needs to be updated to the screen
if( gamestate==GS_LEVEL && !automapactive &&
(scaledviewwidth!=vid.width) )
{
// the menu may draw over parts out of the view window,
// which are refreshed only when needed
if (menuactive || menuactivestate || !viewactivestate)
borderdrawcount = 3;
if (borderdrawcount)
{
if (rendermode == render_soft)
R_DrawViewBorder (); // erase old menu stuff
#ifdef __WIN32__
else
HWR_DrawViewBorder (0);
#endif
borderdrawcount--;
}
}
menuactivestate = menuactive;
viewactivestate = viewactive;
inhelpscreensstate = inhelpscreens;
oldgamestate = wipegamestate = gamestate;
// draw pause pic
if (paused && (!menuactive || netgame))
{
patch_t* patch;
if (automapactive)
y = 4;
else
y = viewwindowy+4;
patch = W_CachePatchName ("M_PAUSE", PU_CACHE);
V_DrawScaledPatch(viewwindowx+(BASEVIDWIDTH - patch->width)/2,
y,0,patch);
}
//added:24-01-98:vid size change is now finished if it was on...
vid.recalc = 0;
//FIXME: draw either console or menu, not the two
CON_Drawer ();
// menus go directly to the screen
M_Drawer (); // menu is drawn even on top of everything
NetUpdate (); // send out any new accumulation
//
// normal update
//
if (!wipe)
{
//added:12-02-98: tilt view when marine dies... just for fun
if (gamestate == GS_LEVEL &&
cv_tiltview.value &&
players[displayplayer].playerstate==PST_DEAD )
{
V_DrawTiltView (screens[0]);
}
#ifdef PERSPCORRECT
else if (gamestate == GS_LEVEL &&
cv_perspcorr.value )
{
V_DrawPerspView (screens[0], players[displayplayer].aiming);
}
#endif
else
{
//I_BeginProfile();
I_FinishUpdate (); // page flip or blit buffer
//CONS_Printf ("last frame update took %d\n", I_EndProfile());
}
return;
}
//
// wipe update
//
wipe_EndScreen(0, 0, vid.width, vid.height);
wipestart = I_GetTime () - 1;
do
{
do
{
nowtime = I_GetTime ();
tics = nowtime - wipestart;
} while (!tics);
wipestart = nowtime;
done = wipe_ScreenWipe (wipe_Melt
, 0, 0, vid.width, vid.height, tics);
I_UpdateNoBlit ();
M_Drawer (); // menu is drawn even on top of wipes
I_FinishUpdate (); // page flip or blit buffer
} while (!done);
}
// =========================================================================
// D_DoomLoop
// =========================================================================
extern boolean demorecording;
static ULONG oldentertics;
static ULONG lastrendered;
ULONG rendergametic;
// note: the win32 version returns from this routine !
void D_DoomLoop (void)
{
if (demorecording)
G_BeginRecording ();
// user settings
COM_BufAddText ("exec autoexec.cfg\n");
// game startup finished
if ( gamestate!=GS_WAITINGPLAYERS )
{
CON_ToggleOff (); // will be done at the end of map command
}
// end of loading screen: CONS_Printf() will no more call FinishUpdate()
con_startup = false;
rendergametic = -1;
oldentertics = I_GetTime ();
#ifndef LINUX
#ifdef __WIN32__
if ( hWndMain!=NULL )
{
SetFocus(hWndMain);
ShowWindow(hWndMain, SW_SHOW);
UpdateWindow(hWndMain);
}
#endif
//faB: make sure the app window has the focus or
// DirectInput acquire keyboard won't work
CONS_Printf ("I_StartupKeyboard...\n");
I_StartupKeyboard ();
#endif
#ifdef __WIN32__
CONS_Printf ("I_StartupMouse...\n");
I_DoStartupMouse ();
#endif
#ifndef __WIN32__
while (1)
D_DoomInnerLoop ();
#endif
}
// the DOS version can run an infinite loop
// the windows version calls this from win_main.c usual windows message loop
void D_DoomInnerLoop (void)
{
int entertic,realtics;
// get real tics
entertic = I_GetTime ();
realtics = entertic - oldentertics;
oldentertics = entertic;
// frame syncronous IO operations
// UNUSED for the moment (18/12/98)
I_StartFrame ();
// process tics (but maybe not if realtic==0)
TryRunTics (realtics);
if(singletics || (/*realtics && */gametic>rendergametic))
{
rendergametic=gametic;
lastrendered=I_GetTime();
//added:16-01-98:consoleplayer -> displayplayer (hear sounds from viewpoint)
S_UpdateSounds (); // move positional sounds
// Update display, next frame, with current state.
D_Display ();
}
else
if(lastrendered+2<I_GetTime()) // in case the server hang or netsplit
D_Display ();
// Win32 exe uses DirectSound..
#ifndef __WIN32__
//
//Other implementations might need to update the sound here.
//
#ifndef SNDSERV
// Sound mixing for the buffer is snychronous.
I_UpdateSound();
#endif
// Synchronous sound output is explicitly called.
#ifndef SNDINTR
// Update sound output.
I_SubmitSound();
#endif
#endif //__WIN32__
// check for media change, loop music..
I_UpdateCD ();
}
// =========================================================================
// D_AdvanceDemo
// =========================================================================
//
// D_PageTicker
// Handles timing for warped projection
//
void D_PageTicker (void)
{
if (--pagetic < 0)
D_AdvanceDemo ();
}
//
// D_PageDrawer : draw a patch supposed to fill the screen,
// fill the borders with a background pattern (a flat)
// if the patch doesn't fit all the screen.
//
void D_PageDrawer (char* lumpname)
{
byte* src;
byte* dest;
int x;
int y;
// software mode which uses generally lower resolutions doesn't look
// good when the pic is scaled, so it fills space aorund with a pattern,
// and the pic is only scaled to integer multiples (x2, x3...)
if (rendermode==render_soft)
{
if( (vid.width>BASEVIDWIDTH) || (vid.height>BASEVIDHEIGHT) )
{
src = scr_borderpatch;
dest = screens[0];
for (y=0; y<vid.height; y++)
{
for (x=0; x<vid.width/64; x++)
{
memcpy(dest, src+((y&63)<<6), 64);
dest += 64;
}
if (vid.width&63)
{
memcpy(dest, src+((y&63)<<6), vid.width&63);
dest += (vid.width&63);
}
}
}
}
V_DrawScaledPatch(0,0, 0, W_CachePatchName(lumpname, PU_CACHE) );
//added:08-01-98:if you wanna centre the pages it's here.
// I think it's not so beautiful to have the pic centered,
// so I leave it in the upper-left corner for now...
//V_DrawPatch (0,0, 0, W_CachePatchName(pagename, PU_CACHE));
}
//
// D_AdvanceDemo
// Called after each demo or intro demosequence finishes
//
void D_AdvanceDemo (void)
{
advancedemo = true;
}
//
// This cycles through the demo sequences.
// FIXME - version dependend demo numbers?
//
void D_DoAdvanceDemo (void)
{
players[consoleplayer].playerstate = PST_LIVE; // not reborn
advancedemo = false;
usergame = false; // no save / end game here
paused = false;
gameaction = ga_nothing;
if ( gamemode == retail )
demosequence = (demosequence+1)%7;
else
demosequence = (demosequence+1)%6;
switch (demosequence)
{
case 0:
gamestate = GS_DEMOSCREEN;
if ( gamemode == commercial )
pagetic = TICRATE * 15; // Changed by Tails: 9-14-99
else
pagetic = 200;
pagename = "TITLEPIC";
if ( gamemode == commercial )
S_StartMusic(mus_dm2ttl);
else
S_StartMusic (mus_intro);
break;
case 1:
G_DeferedPlayDemo ("demo1");
break;
case 2:
pagetic = 200;
gamestate = GS_DEMOSCREEN;
pagename = "CREDIT";
break;
case 3:
G_DeferedPlayDemo ("demo1");
break;
case 4:
gamestate = GS_DEMOSCREEN;
if ( gamemode == commercial)
{
pagetic = TICRATE * 11;
pagename = "TITLEPIC";
S_StartMusic(mus_dm2ttl);
}
else
{
pagetic = 200;
if ( gamemode == retail )
pagename = text[CREDIT_NUM];
else
pagename = text[HELP2_NUM];
}
break;
case 5:
G_DeferedPlayDemo ("demo1");
break;
// THE DEFINITIVE DOOM Special Edition demo
case 6:
G_DeferedPlayDemo ("demo4");
break;
}
}
// =========================================================================
// D_DoomMain
// =========================================================================
//
// D_StartTitle
//
void D_StartTitle (void)
{
gameaction = ga_nothing;
demosequence = -1;
D_AdvanceDemo ();
}
//
// D_AddFile
//
void D_AddFile (char *file)
{
int numwadfiles;
char *newfile;
for (numwadfiles = 0 ; startupwadfiles[numwadfiles] ; numwadfiles++)
;
newfile = malloc (strlen(file)+1);
strcpy (newfile, file);
startupwadfiles[numwadfiles] = newfile;
}
#ifdef __WIN32__
#define R_OK 0 //faB: win32 does not have R_OK in includes..
#else
#define _MAX_PATH MAX_WADPATH //use djgpp's PATH_MAX
#endif
// ==========================================================================
// Identify the Doom version, and IWAD file to use.
// Sets 'gamemode' to determine whether registered/commmercial features are
// available (notable loading PWAD files).
// ==========================================================================
// return gamemode for Doom or Ultimate Doom, use size to detect which one
gamemode_t GetDoomVersion (char* wadfile)
{
struct stat sbuf;
// and if I patch my main wad and the size gets
// bigger ? uh?
stat (wadfile, &sbuf);
if (sbuf.st_size<12408292)
return registered;
else
return retail; // Ultimate
}
void IdentifyVersion (void)
{
char* doom1wad;
char* doomwad;
char* doomuwad;
char* doom2wad;
char* plutoniawad;
char* tntwad;
char* legacywad;
char pathtemp[_MAX_PATH];
char pathiwad[_MAX_PATH+16];
int p,i;
//Fab:25-04-98:unused now
// char* doom2fwad;
#ifdef LINUX
char *home;
#endif
char *doomwaddir;
doomwaddir = getenv("DOOMWADDIR");
if (!doomwaddir)
{
// get the current directory (possible problem on NT with "." as current dir)
if ( getcwd(pathtemp, _MAX_PATH) != NULL )
doomwaddir = pathtemp;
else
doomwaddir = ".";
}
// Commercial.
doom2wad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(doom2wad, "%s/%s", doomwaddir, text[DOOM2WAD_NUM]);
// Retail.
doomuwad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(doomuwad, "%s/%s", doomwaddir, text[DOOMUWAD_NUM]);
// Registered.
doomwad = malloc(strlen(doomwaddir)+1+8+1);
sprintf(doomwad, "%s/%s", doomwaddir, text[DOOMWAD_NUM]);
// Shareware.
doom1wad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(doom1wad, "%s/%s", doomwaddir, text[DOOM1WAD_NUM]);
// and... Doom LEGACY !!! :)
legacywad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(legacywad, "%s/doom3.wad", doomwaddir);
// FinalDoom : Plutonia
plutoniawad = malloc(strlen(doomwaddir)+1+12+1);
sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir);
// FinalDoom : Tnt Evilution
tntwad = malloc(strlen(doomwaddir)+1+7+1);
sprintf(tntwad, "%s/tnt.wad", doomwaddir);
/* French stuff.
doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);*/
#ifdef LINUX
home = getenv("HOME");
if (!home)
I_Error("Please set $HOME to your home directory");
sprintf(configfile, "%s/"CONFIGFILENAME, home);
#else
sprintf(configfile, "%s/"CONFIGFILENAME, doomwaddir);
#endif
if (M_CheckParm ("-shdev"))
{
gamemode = shareware;
devparm = true;
D_AddFile (DEVDATA"doom1.wad");
D_AddFile (DEVMAPS"data_se/texture1.lmp");
D_AddFile (DEVMAPS"data_se/pnames.lmp");
strcpy (configfile,DEVDATA CONFIGFILENAME);
}
else
if (M_CheckParm ("-regdev"))
{
gamemode = registered;
devparm = true;
D_AddFile (DEVDATA"doom.wad");
D_AddFile (DEVMAPS"data_se/texture1.lmp");
D_AddFile (DEVMAPS"data_se/texture2.lmp");
D_AddFile (DEVMAPS"data_se/pnames.lmp");
strcpy (configfile,DEVDATA CONFIGFILENAME);
return;
}
else
if (M_CheckParm ("-comdev"))
{
gamemode = commercial;
devparm = true;
/* I don't bother
if(plutonia)
D_AddFile (DEVDATA"plutonia.wad");
else if(tnt)
D_AddFile (DEVDATA"tnt.wad");
else*/
D_AddFile (DEVDATA"doom2.wad");
D_AddFile (DEVMAPS"cdata/texture1.lmp");
D_AddFile (DEVMAPS"cdata/pnames.lmp");
strcpy (configfile,DEVDATA CONFIGFILENAME);
return;
}
else
// specify the name of the IWAD file to use, so we can have several IWAD's
// in the same directory, and/or have legacy.exe only once in a different location
if ( (p = M_CheckParm ("-iwad")) && p < myargc-1 )
{
sprintf (pathiwad, "%s/%s", doomwaddir, myargv[p+1]);
D_AddFile (pathiwad);
// point to start of filename only
for (i=strlen(pathiwad)-1; i>=0; i--)
if (pathiwad[i]=='\\' || pathiwad[i]=='/' || pathiwad[i]==':')
break;
i++;
// find gamemode
if (!stricmp("plutonia.wad",pathiwad+i))
gamemode = commercial;
else if (!stricmp("tnt.wad",pathiwad+i))
gamemode = commercial;
else if (!stricmp(text[DOOM2WAD_NUM] ,pathiwad+i))
gamemode = commercial;
else if (!stricmp(text[DOOMUWAD_NUM] ,pathiwad+i))
gamemode = retail;
else if (!stricmp(text[DOOMWAD_NUM] ,pathiwad+i))
gamemode = GetDoomVersion (pathiwad);
else if (!stricmp(text[DOOM1WAD_NUM] ,pathiwad+i))
gamemode = shareware;
else {
gamemode = commercial;
}
}
else
/*
if ( !access (doom2fwad,R_OK) )
{
gamemode = commercial;
// C'est ridicule!
// Let's handle languages in config files, okay?
language = french;
CONS_Printf("French version\n");
D_AddFile (doom2fwad);
}
else*/
if ( !access (doom2wad,R_OK) )
{
gamemode = commercial;
D_AddFile (doom2wad);
}
else
if ( !access (doomuwad,R_OK) )
{
gamemode = retail;
D_AddFile (doomuwad);
}
else
if ( !access (doomwad,R_OK) )
{
gamemode = GetDoomVersion (doomwad);
D_AddFile (doomwad);
}
else
if ( !access (doom1wad,R_OK) )
{
gamemode = shareware;
D_AddFile (doom1wad);
}
else
if ( !access (plutoniawad, R_OK ) )
{
gamemode = commercial;
D_AddFile (plutoniawad);
}
else
if ( !access ( tntwad, R_OK ) )
{
gamemode = commercial;
D_AddFile (tntwad);
}
else
{
I_Error ("Main WAD file not found !\n");
// unused code : I_ERROR never return
gamemode = indetermined;
}
D_AddFile(legacywad);
}
//
// Find a Response File
//
void FindResponseFile (void)
{
int i;
#define MAXARGVS 256
for (i = 1;i < myargc;i++)
if (myargv[i][0] == '@')
{
FILE * handle;
int size;
int k;
int index;
int indexinfile;
char *infile;
char *file;
char *moreargs[20];
char *firstargv;
// READ THE RESPONSE FILE INTO MEMORY
handle = fopen (&myargv[i][1],"rb");
if (!handle)
{
CONS_Printf ("\nNo such response file!");
exit(1);
}
CONS_Printf("Found response file %s!\n",&myargv[i][1]);
fseek (handle,0,SEEK_END);