d_main.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "Precompiled.h"
  21. #include "globaldata.h"
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <fcntl.h>
  27. #include "doomdef.h"
  28. #include "doomstat.h"
  29. #include "dstrings.h"
  30. #include "sounds.h"
  31. #include "z_zone.h"
  32. #include "w_wad.h"
  33. #include "s_sound.h"
  34. #include "v_video.h"
  35. #include "f_finale.h"
  36. #include "f_wipe.h"
  37. #include "m_argv.h"
  38. #include "m_misc.h"
  39. #include "m_menu.h"
  40. #include "i_system.h"
  41. #include "i_sound.h"
  42. #include "i_video.h"
  43. #include "g_game.h"
  44. #include "hu_stuff.h"
  45. #include "wi_stuff.h"
  46. #include "st_stuff.h"
  47. #include "am_map.h"
  48. #include "p_setup.h"
  49. #include "r_local.h"
  50. #include "d_main.h"
  51. //#include "../idLib/precompiled.h"
  52. //#include "../Main/PlayerProfile.h"
  53. //#include "../Main/PSN/PS3_Session.h"
  54. #include "d3xp/Game_local.h"
  55. //
  56. // D-DoomLoop()
  57. // Not a globally visible function,
  58. // just included for source reference,
  59. // called by D_DoomMain, never exits.
  60. // Manages timing and IO,
  61. // calls all ?_Responder, ?_Ticker, and ?_Drawer,
  62. // calls I_GetTime, I_StartFrame, and I_StartTic
  63. //
  64. void D_DoomLoop (void);
  65. void R_ExecuteSetViewSize (void);
  66. void D_CheckNetGame (void);
  67. bool D_PollNetworkStart();
  68. void D_ProcessEvents (void);
  69. void D_DoAdvanceDemo (void);
  70. const char* wadfiles[MAXWADFILES] =
  71. {
  72. 0
  73. };
  74. const char* extraWad = 0;
  75. //
  76. // EVENT HANDLING
  77. //
  78. // Events are asynchronous inputs generally generated by the game user.
  79. // Events can be discarded if no responder claims them
  80. //
  81. //
  82. // D_PostEvent
  83. // Called by the I/O functions when input is detected
  84. //
  85. void D_PostEvent (event_t* ev)
  86. {
  87. ::g->events[::g->eventhead] = *ev;
  88. ::g->eventhead = (++::g->eventhead)&(MAXEVENTS-1);
  89. }
  90. //
  91. // D_ProcessEvents
  92. // Send all the ::g->events of the given timestamp down the responder chain
  93. //
  94. void D_ProcessEvents (void)
  95. {
  96. event_t* ev;
  97. // IF STORE DEMO, DO NOT ACCEPT INPUT
  98. if ( ( ::g->gamemode == commercial )
  99. && (W_CheckNumForName("map01")<0) )
  100. return;
  101. for ( ; ::g->eventtail != ::g->eventhead ; ::g->eventtail = (++::g->eventtail)&(MAXEVENTS-1) )
  102. {
  103. ev = &::g->events[::g->eventtail];
  104. if (M_Responder (ev))
  105. continue; // menu ate the event
  106. G_Responder (ev);
  107. }
  108. }
  109. //
  110. // D_Display
  111. // draw current display, possibly wiping it from the previous
  112. //
  113. // ::g->wipegamestate can be set to -1 to force a ::g->wipe on the next draw
  114. extern bool waitingForWipe;
  115. void D_Wipe()
  116. {
  117. int nowtime, tics;
  118. nowtime = I_GetTime();
  119. tics = nowtime - ::g->wipestart;
  120. if (tics != 0)
  121. {
  122. ::g->wipestart = nowtime;
  123. ::g->wipedone = wipe_ScreenWipe( 0, 0, SCREENWIDTH, SCREENHEIGHT, tics );
  124. // DHM - Nerve :: Demo recording :: Stop large hitch on first frame after the wipe
  125. if ( ::g->wipedone ) {
  126. ::g->oldtrt_entertics = nowtime / ::g->ticdup;
  127. ::g->gametime = nowtime;
  128. ::g->wipe = false;
  129. waitingForWipe = false;
  130. }
  131. }
  132. }
  133. void D_Display (void)
  134. {
  135. qboolean redrawsbar;
  136. if (::g->nodrawers)
  137. return; // for comparative timing / profiling
  138. redrawsbar = false;
  139. // change the view size if needed
  140. if (::g->setsizeneeded)
  141. {
  142. R_ExecuteSetViewSize();
  143. ::g->oldgamestate = (gamestate_t)-1; // force background redraw
  144. ::g->borderdrawcount = 3;
  145. }
  146. // save the current screen if about to ::g->wipe
  147. if (::g->gamestate != ::g->wipegamestate)
  148. {
  149. ::g->wipe = true;
  150. wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
  151. }
  152. else
  153. ::g->wipe = false;
  154. if (::g->gamestate == GS_LEVEL && ::g->gametic)
  155. HU_Erase();
  156. // do buffered drawing
  157. switch (::g->gamestate)
  158. {
  159. case GS_LEVEL:
  160. if (!::g->gametic)
  161. break;
  162. if (::g->automapactive)
  163. AM_Drawer ();
  164. if (::g->wipe || (::g->viewheight != 200 * GLOBAL_IMAGE_SCALER && ::g->fullscreen) )
  165. redrawsbar = true;
  166. if (::g->inhelpscreensstate && !::g->inhelpscreens)
  167. redrawsbar = true; // just put away the help screen
  168. ST_Drawer ( ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER, redrawsbar );
  169. ::g->fullscreen = ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER;
  170. break;
  171. case GS_INTERMISSION:
  172. WI_Drawer ();
  173. break;
  174. case GS_FINALE:
  175. F_Drawer ();
  176. break;
  177. case GS_DEMOSCREEN:
  178. D_PageDrawer ();
  179. break;
  180. }
  181. // draw buffered stuff to screen
  182. I_UpdateNoBlit ();
  183. // draw the view directly
  184. if (::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->gametic)
  185. R_RenderPlayerView (&::g->players[::g->displayplayer]);
  186. if (::g->gamestate == GS_LEVEL && ::g->gametic)
  187. HU_Drawer ();
  188. // clean up border stuff
  189. if (::g->gamestate != ::g->oldgamestate && ::g->gamestate != GS_LEVEL)
  190. I_SetPalette ((byte*)W_CacheLumpName ("PLAYPAL",PU_CACHE_SHARED));
  191. // see if the border needs to be initially drawn
  192. if (::g->gamestate == GS_LEVEL && ::g->oldgamestate != GS_LEVEL)
  193. {
  194. ::g->viewactivestate = false; // view was not active
  195. R_FillBackScreen (); // draw the pattern into the back screen
  196. }
  197. // see if the border needs to be updated to the screen
  198. if (::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->scaledviewwidth != (320 * GLOBAL_IMAGE_SCALER) )
  199. {
  200. if (::g->menuactive || ::g->menuactivestate || !::g->viewactivestate)
  201. ::g->borderdrawcount = 3;
  202. if (::g->borderdrawcount)
  203. {
  204. R_DrawViewBorder (); // erase old menu stuff
  205. ::g->borderdrawcount--;
  206. }
  207. }
  208. ::g->menuactivestate = ::g->menuactive;
  209. ::g->viewactivestate = ::g->viewactive;
  210. ::g->inhelpscreensstate = ::g->inhelpscreens;
  211. ::g->oldgamestate = ::g->wipegamestate = ::g->gamestate;
  212. // draw pause pic
  213. /*
  214. if (::g->paused)
  215. {
  216. if (::g->automapactive)
  217. y = 4;
  218. else
  219. y = ::g->viewwindowy+4;
  220. V_DrawPatchDirect(::g->viewwindowx+(ORIGINAL_WIDTH-68)/2,
  221. y,0,(patch_t*)W_CacheLumpName ("M_PAUSE", PU_CACHE_SHARED));
  222. }
  223. */
  224. // menus go directly to the screen
  225. M_Drawer (); // menu is drawn even on top of everything
  226. NetUpdate ( NULL ); // send out any new accumulation
  227. // normal update
  228. if (!::g->wipe)
  229. {
  230. I_FinishUpdate (); // page flip or blit buffer
  231. return;
  232. }
  233. // \ update
  234. wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
  235. ::g->wipestart = I_GetTime () - 1;
  236. D_Wipe(); // initialize g->wipedone
  237. }
  238. void D_RunFrame( bool Sounds )
  239. {
  240. if (Sounds) {
  241. // move positional sounds
  242. S_UpdateSounds (::g->players[::g->consoleplayer].mo);
  243. }
  244. // Update display, next frame, with current state.
  245. D_Display ();
  246. if (Sounds) {
  247. // Update sound output.
  248. I_SubmitSound();
  249. }
  250. }
  251. //
  252. // D_DoomLoop
  253. //
  254. void D_DoomLoop (void)
  255. {
  256. // DHM - Not used
  257. /*
  258. if (M_CheckParm ("-debugfile"))
  259. {
  260. char filename[20];
  261. sprintf (filename,"debug%i.txt",::g->consoleplayer);
  262. I_Printf ("debug output to: %s\n",filename);
  263. ::g->debugfile = f o p e n(filename,"w");
  264. }
  265. I_InitGraphics ();
  266. while (1)
  267. {
  268. TryRunTics();
  269. D_RunFrame( true );
  270. }
  271. */
  272. }
  273. //
  274. // DEMO LOOP
  275. //
  276. //
  277. // D_PageTicker
  278. // Handles timing for warped ::g->projection
  279. //
  280. void D_PageTicker (void)
  281. {
  282. if (--::g->pagetic < 0)
  283. D_AdvanceDemo ();
  284. }
  285. //
  286. // D_PageDrawer
  287. //
  288. void D_PageDrawer (void)
  289. {
  290. V_DrawPatch (0,0, 0, (patch_t*)W_CacheLumpName(::g->pagename, PU_CACHE_SHARED));
  291. }
  292. //
  293. // D_AdvanceDemo
  294. // Called after each demo or intro ::g->demosequence finishes
  295. //
  296. void D_AdvanceDemo (void)
  297. {
  298. ::g->advancedemo = true;
  299. }
  300. //
  301. // This cycles through the demo sequences.
  302. // FIXME - version dependend demo numbers?
  303. //
  304. void D_DoAdvanceDemo (void)
  305. {
  306. ::g->players[::g->consoleplayer].playerstate = PST_LIVE; // not reborn
  307. ::g->advancedemo = false;
  308. ::g->usergame = false; // no save / end game here
  309. ::g->paused = false;
  310. ::g->gameaction = ga_nothing;
  311. if ( ::g->gamemode == retail )
  312. ::g->demosequence = (::g->demosequence+1)%8;
  313. else
  314. ::g->demosequence = (::g->demosequence+1)%6;
  315. switch (::g->demosequence)
  316. {
  317. case 0:
  318. if ( ::g->gamemode == commercial )
  319. ::g->pagetic = 35 * 11;
  320. else
  321. ::g->pagetic = 8 * TICRATE;
  322. ::g->gamestate = GS_DEMOSCREEN;
  323. ::g->pagename = "INTERPIC";
  324. if ( ::g->gamemode == commercial )
  325. S_StartMusic(mus_dm2ttl);
  326. else
  327. S_StartMusic (mus_intro);
  328. break;
  329. case 1:
  330. G_DeferedPlayDemo ("demo1");
  331. break;
  332. case 2:
  333. ::g->pagetic = 3 * TICRATE;
  334. ::g->gamestate = GS_DEMOSCREEN;
  335. ::g->pagename = "INTERPIC";
  336. break;
  337. case 3:
  338. G_DeferedPlayDemo ("demo2");
  339. break;
  340. case 4:
  341. ::g->pagetic = 3 * TICRATE;
  342. ::g->gamestate = GS_DEMOSCREEN;
  343. ::g->pagename = "INTERPIC";
  344. break;
  345. case 5:
  346. G_DeferedPlayDemo ("demo3");
  347. break;
  348. // THE DEFINITIVE DOOM Special Edition demo
  349. case 6:
  350. ::g->pagetic = 3 * TICRATE;
  351. ::g->gamestate = GS_DEMOSCREEN;
  352. ::g->pagename = "INTERPIC";
  353. break;
  354. case 7:
  355. G_DeferedPlayDemo ("demo4");
  356. break;
  357. }
  358. }
  359. //
  360. // D_StartTitle
  361. //
  362. void D_StartTitle (void)
  363. {
  364. ::g->gameaction = ga_nothing;
  365. ::g->demosequence = -1;
  366. D_AdvanceDemo ();
  367. }
  368. // print ::g->title for every printed line
  369. //
  370. // D_AddExtraWadFile
  371. //
  372. void D_SetExtraWadFile( const char *file ) {
  373. extraWad = file;
  374. }
  375. //
  376. // D_AddFile
  377. //
  378. void D_AddFile (const char *file)
  379. {
  380. int numwadfiles;
  381. for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)
  382. if (file == wadfiles[numwadfiles])
  383. return;
  384. ;
  385. wadfiles[numwadfiles] = file;
  386. }
  387. //
  388. // IdentifyVersion
  389. // Checks availability of IWAD files by name,
  390. // to determine whether registered/commercial features
  391. // should be executed (notably loading PWAD's).
  392. //
  393. void IdentifyVersion (void)
  394. {
  395. W_FreeWadFiles();
  396. const ExpansionData * expansion = DoomLib::GetCurrentExpansion();
  397. ::g->gamemode = expansion->gameMode;
  398. ::g->gamemission = expansion->pack_type;
  399. if( expansion->type == ExpansionData::PWAD ) {
  400. D_AddFile( expansion->iWadFilename );
  401. D_AddFile( expansion->pWadFilename );
  402. } else {
  403. D_AddFile( expansion->iWadFilename );
  404. }
  405. }
  406. //
  407. // Find a Response File
  408. //
  409. void FindResponseFile (void)
  410. {
  411. }
  412. //
  413. // D_DoomMain
  414. //
  415. void D_DoomMain (void)
  416. {
  417. int p;
  418. char file[256];
  419. FindResponseFile ();
  420. IdentifyVersion ();
  421. setbuf (stdout, NULL);
  422. ::g->modifiedgame = false;
  423. // TODO: Networking
  424. //const bool isDeathmatch = gameLocal->GetMatchParms().GetGameType() == GAME_TYPE_PVP;
  425. const bool isDeathmatch = false;
  426. ::g->nomonsters = M_CheckParm ("-nomonsters") || isDeathmatch;
  427. ::g->respawnparm = M_CheckParm ("-respawn");
  428. ::g->fastparm = M_CheckParm ("-fast");
  429. ::g->devparm = M_CheckParm ("-devparm");
  430. if (M_CheckParm ("-altdeath") || isDeathmatch)
  431. ::g->deathmatch = 2;
  432. else if (M_CheckParm ("-deathmatch"))
  433. ::g->deathmatch = 1;
  434. switch ( ::g->gamemode )
  435. {
  436. case retail:
  437. sprintf (::g->title,
  438. " "
  439. "The Ultimate DOOM Startup v%i.%i"
  440. " ",
  441. VERSION/100,VERSION%100);
  442. break;
  443. case shareware:
  444. sprintf (::g->title,
  445. " "
  446. "DOOM Shareware Startup v%i.%i"
  447. " ",
  448. VERSION/100,VERSION%100);
  449. break;
  450. case registered:
  451. sprintf (::g->title,
  452. " "
  453. "DOOM Registered Startup v%i.%i"
  454. " ",
  455. VERSION/100,VERSION%100);
  456. break;
  457. case commercial:
  458. sprintf (::g->title,
  459. " "
  460. "DOOM 2: Hell on Earth v%i.%i"
  461. " ",
  462. VERSION/100,VERSION%100);
  463. break;
  464. default:
  465. sprintf (::g->title,
  466. " "
  467. "Public DOOM - v%i.%i"
  468. " ",
  469. VERSION/100,VERSION%100);
  470. break;
  471. }
  472. I_Printf ("%s\n",::g->title);
  473. if (::g->devparm)
  474. I_Printf(D_DEVSTR);
  475. if (M_CheckParm("-cdrom"))
  476. {
  477. I_Printf(D_CDROM);
  478. //c++ mkdir("c:\\doomdata",0);
  479. strcpy (::g->basedefault,"c:/doomdata/default.cfg");
  480. }
  481. // add any files specified on the command line with -file ::g->wadfile
  482. // to the wad list
  483. //
  484. p = M_CheckParm ("-file");
  485. if (p)
  486. {
  487. // the parms after p are ::g->wadfile/lump names,
  488. // until end of parms or another - preceded parm
  489. ::g->modifiedgame = true; // homebrew levels
  490. while (++p != ::g->myargc && ::g->myargv[p][0] != '-')
  491. D_AddFile (::g->myargv[p]);
  492. }
  493. p = M_CheckParm ("-playdemo");
  494. if (!p)
  495. p = M_CheckParm ("-timedemo");
  496. if (p && p < ::g->myargc-1)
  497. {
  498. sprintf (file,"d:\\%s.lmp", ::g->myargv[p+1]);
  499. D_AddFile (file);
  500. I_Printf("Playing demo %s.lmp.\n",::g->myargv[p+1]);
  501. }
  502. // get skill / episode / map from defaults
  503. ::g->startskill = sk_medium;
  504. ::g->startepisode = 1;
  505. ::g->startmap = 1;
  506. ::g->autostart = false;
  507. if ( DoomLib::matchParms.gameEpisode != GAME_EPISODE_UNKNOWN ) {
  508. ::g->startepisode = DoomLib::matchParms.gameEpisode;
  509. ::g->autostart = 1;
  510. }
  511. if ( DoomLib::matchParms.gameMap != -1 ) {
  512. ::g->startmap = DoomLib::matchParms.gameMap;
  513. ::g->autostart = 1;
  514. }
  515. if ( DoomLib::matchParms.gameSkill != -1) {
  516. ::g->startskill = (skill_t)DoomLib::matchParms.gameSkill;
  517. }
  518. // get skill / episode / map from cmdline
  519. p = M_CheckParm ("-skill");
  520. if (p && p < ::g->myargc-1)
  521. {
  522. ::g->startskill = (skill_t)(::g->myargv[p+1][0]-'1');
  523. ::g->autostart = true;
  524. }
  525. p = M_CheckParm ("-episode");
  526. if (p && p < ::g->myargc-1)
  527. {
  528. ::g->startepisode = ::g->myargv[p+1][0]-'0';
  529. ::g->startmap = 1;
  530. ::g->autostart = true;
  531. }
  532. /*p = M_CheckParm ("-timer");
  533. if (p && p < ::g->myargc-1 && ::g->deathmatch)
  534. {*/
  535. // TODO: Networking
  536. //const int timeLimit = gameLocal->GetMatchParms().GetTimeLimit();
  537. const int timeLimit = 0;
  538. if (timeLimit != 0 && ::g->deathmatch)
  539. {
  540. int time;
  541. //time = atoi(::g->myargv[p+1]);
  542. time = timeLimit;
  543. I_Printf("Levels will end after %d minute",time);
  544. if (time>1)
  545. I_Printf("s");
  546. I_Printf(".\n");
  547. }
  548. p = M_CheckParm ("-avg");
  549. if (p && p < ::g->myargc-1 && ::g->deathmatch)
  550. I_Printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
  551. p = M_CheckParm ("-warp");
  552. if (p && p < ::g->myargc-1)
  553. {
  554. if (::g->gamemode == commercial)
  555. ::g->startmap = atoi (::g->myargv[p+1]);
  556. else
  557. {
  558. ::g->startepisode = ::g->myargv[p+1][0]-'0';
  559. ::g->startmap = ::g->myargv[p+2][0]-'0';
  560. }
  561. ::g->autostart = true;
  562. }
  563. I_Printf ("Z_Init: Init zone memory allocation daemon. \n");
  564. Z_Init ();
  565. // init subsystems
  566. I_Printf ("V_Init: allocate ::g->screens.\n");
  567. V_Init ();
  568. I_Printf ("M_LoadDefaults: Load system defaults.\n");
  569. M_LoadDefaults (); // load before initing other systems
  570. I_Printf ("W_Init: Init WADfiles.\n");
  571. W_InitMultipleFiles (wadfiles);
  572. // Check for -file in shareware
  573. if (::g->modifiedgame)
  574. {
  575. // These are the lumps that will be checked in IWAD,
  576. // if any one is not present, execution will be aborted.
  577. char name[23][16]=
  578. {
  579. "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
  580. "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
  581. "dphoof","bfgga0","heada1","cybra1","spida1d1"
  582. };
  583. int i;
  584. if ( ::g->gamemode == shareware)
  585. I_Error("\nYou cannot -file with the shareware "
  586. "version. Register!");
  587. // Check for fake IWAD with right name,
  588. // but w/o all the lumps of the registered version.
  589. if (::g->gamemode == registered)
  590. for (i = 0;i < 23; i++)
  591. if (W_CheckNumForName(name[i])<0)
  592. I_Error("\nThis is not the registered version.");
  593. }
  594. // Iff additonal PWAD files are used, print modified banner
  595. if (::g->modifiedgame)
  596. {
  597. /*m*/I_Printf (
  598. "===========================================================================\n"
  599. "ATTENTION: This version of DOOM has been modified. If you would like to\n"
  600. "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
  601. " You will not receive technical support for modified games.\n"
  602. " press enter to continue\n"
  603. "===========================================================================\n"
  604. );
  605. getchar ();
  606. }
  607. // Check and print which version is executed.
  608. switch ( ::g->gamemode )
  609. {
  610. case shareware:
  611. case indetermined:
  612. I_Printf (
  613. "===========================================================================\n"
  614. " Shareware!\n"
  615. "===========================================================================\n"
  616. );
  617. break;
  618. case registered:
  619. case retail:
  620. case commercial:
  621. I_Printf (
  622. "===========================================================================\n"
  623. " Commercial product - do not distribute!\n"
  624. " Please report software piracy to the SPA: 1-800-388-PIR8\n"
  625. "===========================================================================\n"
  626. );
  627. break;
  628. default:
  629. // Ouch.
  630. break;
  631. }
  632. I_Printf ("M_Init: Init miscellaneous info.\n");
  633. M_Init ();
  634. I_Printf ("R_Init: Init DOOM refresh daemon - ");
  635. R_Init ();
  636. I_Printf ("\nP_Init: Init Playloop state.\n");
  637. P_Init ();
  638. I_Printf ("I_Init: Setting up machine state.\n");
  639. I_Init ();
  640. I_Printf ("D_CheckNetGame: Checking network game status.\n");
  641. D_CheckNetGame ();
  642. }
  643. bool D_DoomMainPoll(void)
  644. {
  645. int p;
  646. char file[256];
  647. if (D_PollNetworkStart() == false)
  648. return false;
  649. I_Printf( "S_Init: Setting up sound.\n" );
  650. S_Init( s_volume_sound.GetInteger(), s_volume_midi.GetInteger() );
  651. I_Printf ("HU_Init: Setting up heads up display.\n");
  652. HU_Init ();
  653. I_Printf ("ST_Init: Init status bar.\n");
  654. ST_Init ();
  655. // start the apropriate game based on parms
  656. p = M_CheckParm ("-record");
  657. if (p && p < ::g->myargc-1)
  658. {
  659. G_RecordDemo (::g->myargv[p+1]);
  660. ::g->autostart = true;
  661. }
  662. p = M_CheckParm ("-playdemo");
  663. if (p && p < ::g->myargc-1)
  664. {
  665. //::g->singledemo = true; // quit after one demo
  666. G_DeferedPlayDemo (::g->myargv[p+1]);
  667. //D_DoomLoop (); // never returns
  668. }
  669. p = M_CheckParm ("-timedemo");
  670. if (p && p < ::g->myargc-1)
  671. {
  672. G_TimeDemo ("nukage1");//::g->myargv[p+1]);
  673. D_DoomLoop (); // never returns
  674. }
  675. p = M_CheckParm ("-loadgame");
  676. if (p && p < ::g->myargc-1)
  677. {
  678. if (M_CheckParm("-cdrom"))
  679. sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",::g->myargv[p+1][0]);
  680. else
  681. sprintf(file, SAVEGAMENAME"%c.dsg",::g->myargv[p+1][0]);
  682. G_LoadGame (file);
  683. }
  684. if ( ::g->gameaction != ga_loadgame && ::g->gameaction != ga_playdemo )
  685. {
  686. if (::g->autostart || ::g->netgame ) {
  687. G_InitNew (::g->startskill, ::g->startepisode, ::g->startmap );
  688. } else if( ::g->gameaction != ga_newgame) {
  689. D_StartTitle (); // start up intro loop
  690. }
  691. }
  692. return true;
  693. }