Ejemplo n.º 1
0
void I_InitAudio(void)
{ 
	sysaudio.obtained.freq = sysaudio.desired.freq =
		SAMPLERATE;
	sysaudio.obtained.format = sysaudio.desired.format =
		AUDIO_S16SYS;
	sysaudio.obtained.channels = sysaudio.desired.channels =
		2;
	sysaudio.obtained.samples = sysaudio.desired.samples =
		SAMPLECOUNT;
	sysaudio.obtained.size = sysaudio.desired.size =
		(SAMPLECOUNT*sysaudio.obtained.channels*((sysaudio.obtained.format&0xff)>>3));

	if (!sysaudio.enabled)
		return;

#ifdef ENABLE_SDLMIXER
	{
		int freq, channels;
		Uint16 format;

		if (Mix_OpenAudio(sysaudio.desired.freq, sysaudio.desired.format,
			sysaudio.desired.channels, sysaudio.desired.samples)<0) {
			I_Error("Could not open audio: %s\n", SDL_GetError());
		}

		if (!Mix_QuerySpec(&freq, &format, &channels)) {
			I_Error("Could not open audio: %s\n", SDL_GetError());
		}

		sysaudio.obtained.freq = freq;
		sysaudio.obtained.channels = channels;
		sysaudio.obtained.format = format;
		sysaudio.obtained.size = (SAMPLECOUNT*channels*((format&0xff)>>3));

		I_InitMusic();
		I_InitSound();

		Mix_SetPostMix(I_UpdateSound, NULL);
/*		Mix_ReserveChannels(NUM_CHANNELS);*/
	}
#else
	sysaudio.desired.callback = I_UpdateAudio;
	sysaudio.desired.userdata = NULL;

	if (SDL_OpenAudio(&sysaudio.desired, &sysaudio.obtained)<0) {
		I_Error("Could not open audio: %s\n", SDL_GetError());
	}

	I_InitMusic();
	I_InitSound();

	SDL_PauseAudio(0);
#endif
}
Ejemplo n.º 2
0
void I_InitSound()
{ 
  int i;
  
  fprintf( stderr, "I_InitSound: ");
  SDL_Init(SDL_INIT_AUDIO);
  I_InitMusic();
  Mix_AllocateChannels(NUM_CHANNELS);
  Mix_ReserveChannels(3);

  // Initialize external data (all sounds) at start, keep static.
 
  for (i=1 ; i<NUMSFX ; i++)
  { 
    // Alias? Example is the chaingun sound linked to pistol.
    if (!S_sfx[i].link)
    {
      // Load data from WAD file.
      S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );

      // Samples now 16bit LE stereo, upsampled to double length and padded
      S_sfx[i].chunk = Mix_QuickLoad_RAW( S_sfx[i].data, lengths[i] );
    }	
    else
    {
      // Previously loaded already?
      S_sfx[i].data = S_sfx[i].link->data;
      lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)];
      S_sfx[i].chunk = Mix_QuickLoad_RAW( S_sfx[i].data, lengths[i] );
    }
  }

  fprintf( stderr, " pre-cached all sound data\n");
  
  // Finished initialization.
  fprintf(stderr, "I_InitSound: sound module ready\n");
  SDL_PauseAudio(0);
}
Ejemplo n.º 3
0
void I_PlaySong(byte* data, size_t length, bool loop)
{
	if (!musicsystem)
		return;

	MusicSystemType newtype = I_SelectMusicSystem(data, length);
	if (newtype != current_musicsystem_type)
	{	
		if (musicsystem)
		{	
			I_ShutdownMusic();
			S_StopMusic();
		}
		I_InitMusic(newtype);
	}
		
	musicsystem->startSong(data, length, loop);
	
	// Hack for problems with Windows Vista/7 & SDL_Mixer
	// See comment for I_ResetMidiVolume().
	I_ResetMidiVolume();
	
	I_SetMusicVolume(snd_musicvolume);
}
Ejemplo n.º 4
0
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
    INT32 p;
    char srb2[82]; // srb2 title banner
    char title[82];

    INT32 pstartmap = 1;
    boolean autostart = false;

    // keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
    if (setvbuf(stderr, NULL, _IOFBF, 1000))
        I_OutputMsg("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
    // initialise locale code
    M_StartupLocale();
#endif

    // get parameters from a response file (eg: srb2 @parms.txt)
    M_FindResponseFile();

    // MAINCFG is now taken care of where "OBJCTCFG" is handled
    G_LoadGameSettings();

    // Test Dehacked lists
    DEH_Check();

    // identify the main IWAD file to use
    IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
    setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
    devparm = !M_CheckParm("-nodebug");
#else
    devparm = M_CheckParm("-debug");
#endif

    // for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
    dedicated = M_CheckParm("-dedicated") != 0;
#endif

    strcpy(title, "Sonic Robo Blast 2");
    strcpy(srb2, "Sonic Robo Blast 2");
    D_MakeTitleString(srb2);

#ifdef PC_DOS
    D_Titlebar(srb2, title);
#endif

#if defined (__OS2__) && !defined (SDL)
    // set PM window title
    snprintf(pmData->title, sizeof (pmData->title),
             "Sonic Robo Blast 2" VERSIONSTRING ": %s",
             title);
    pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

    if (devparm)
        CONS_Printf(M_GetText("Development mode ON.\n"));

    // default savegame
    strcpy(savegamename, SAVEGAMENAME"%u.ssg");

    {
        const char *userhome = D_Home(); //Alam: path to home

        if (!userhome)
        {
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
            I_Error("Please set $HOME to your home directory\n");
#elif defined (_WIN32_WCE) && 0
            if (dedicated)
                snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
            else
                snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
            if (dedicated)
                snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
            else
                snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
        }
        else
        {
            // use user specific config file
#ifdef DEFAULTDIR
            snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
            snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
            if (dedicated)
                snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
            else
                snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

            // can't use sprintf since there is %u in savegamename
            strcatbf(savegamename, srb2home, PATHSEP);

            I_mkdir(srb2home, 0700);
#else
            snprintf(srb2home, sizeof srb2home, "%s", userhome);
            snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
            if (dedicated)
                snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
            else
                snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

            // can't use sprintf since there is %u in savegamename
            strcatbf(savegamename, userhome, PATHSEP);
#endif
        }

        configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
        strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
    }

    // rand() needs seeded regardless of password
    srand((unsigned int)time(NULL));

    if (M_CheckParm("-password") && M_IsNextParm())
        D_SetPassword(M_GetNextParm());
    else
    {
        size_t z;
        char junkpw[25];
        for (z = 0; z < 24; z++)
            junkpw[z] = (char)(rand() & 64)+32;
        junkpw[24] = '\0';
        D_SetPassword(junkpw);
    }

    // add any files specified on the command line with -file wadfile
    // to the wad list
    if (!(M_CheckParm("-connect")))
    {
        if (M_CheckParm("-file"))
        {
            // the parms after p are wadfile/lump names,
            // until end of parms or another - preceded parm
            while (M_IsNextParm())
            {
                const char *s = M_GetNextParm();

                if (s) // Check for NULL?
                {
                    if (!W_VerifyNMUSlumps(s))
                        G_SetGameModified(true);
                    D_AddFile(s);
                }
            }
        }
    }

    // get map from parms

    if (M_CheckParm("-server") || dedicated)
        netgame = server = true;

    if (M_CheckParm("-warp") && M_IsNextParm())
    {
        const char *word = M_GetNextParm();
        if (fastncmp(word, "MAP", 3))
            pstartmap = M_MapNumber(word[3], word[4]);
        else
            pstartmap = atoi(word);
        // Don't check if lump exists just yet because the wads haven't been loaded!
        // Just do a basic range check here.
        if (pstartmap < 1 || pstartmap > NUMMAPS)
            I_Error("Cannot warp to map %d (out of range)\n", pstartmap);
        else
        {
            if (!M_CheckParm("-server"))
                G_SetGameModified(true);
            autostart = true;
        }
    }

    CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
    Z_Init();

    // adapt tables to SRB2's needs, including extra slots for dehacked file support
    P_PatchInfoTables();

    //---------------------------------------------------- READY TIME
    // we need to check for dedicated before initialization of some subsystems

    CONS_Printf("I_StartupTimer()...\n");
    I_StartupTimer();

    // Make backups of some SOCcable tables.
    P_BackupTables();

    // Setup default unlockable conditions
    M_SetupDefaultConditionSets();

    // load wad, including the main wad file
    CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
    if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
        CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#else
        I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#endif
    D_CleanFile();

#if 1 // md5s last updated 3/15/14
    // Yes, you read that right, that's the day of release.
    // Aren't we batshit insane?

    // Check MD5s of autoloaded files
    W_VerifyFileMD5(0, "ac309fb3c7d4b5b685e2cd26beccf0e8"); // srb2.srb/srb2.wad
    W_VerifyFileMD5(1, "a894044b555dfcc71865cee16a996e88"); // zones.dta
    W_VerifyFileMD5(2, "4c410c1de6e0440cc5b2858dcca80c3e"); // player.dta
    W_VerifyFileMD5(3, "85901ad4bf94637e5753d2ac2c03ea26"); // rings.dta
    W_VerifyFileMD5(4, "c529930ee5aed6dbe33625dc8075520b"); // patch.dta

    // don't check music.dta because people like to modify it, and it doesn't matter if they do
    // ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
#endif

    mainwads = 5; // there are 5 wads not to unload

    cht_Init();

    //---------------------------------------------------- READY SCREEN
    // we need to check for dedicated before initialization of some subsystems

    CONS_Printf("I_StartupGraphics()...\n");
    I_StartupGraphics();

    //--------------------------------------------------------- CONSOLE
    // setup loading screen
    SCR_Startup();

    // we need the font of the console
    CONS_Printf("HU_Init(): Setting up heads up display.\n");
    HU_Init();

    COM_Init();
    // libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
    CON_Init();
#else
    CON_InitWii();
#endif

    D_RegisterServerCommands();
    D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
    R_RegisterEngineStuff();
    S_RegisterSoundStuff();

    I_RegisterSysCommands();

    //--------------------------------------------------------- CONFIG.CFG
    M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

    G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
    VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

    // set user default mode or mode set at cmdline
    SCR_CheckDefaultMode();

    wipegamestate = gamestate;

    P_InitMapHeaders();
    savedata.lives = 0; // flag this as not-used

    //------------------------------------------------ COMMAND LINE PARAMS

    // Initialize CD-Audio
    if (M_CheckParm("-usecd") && !dedicated)
        I_InitCD();

    if (M_CheckParm("-noupload"))
        COM_BufAddText("downloading 0\n");

    CONS_Printf("M_Init(): Init miscellaneous info.\n");
    M_Init();

    CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
    R_Init();

    // setting up sound
    CONS_Printf("S_Init(): Setting up sound.\n");
    if (M_CheckParm("-nosound"))
        nosound = true;
    if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
        nomidimusic = nodigimusic = true;
    else
    {
        if (M_CheckParm("-nomidimusic"))
            nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
        if (M_CheckParm("-nodigmusic"))
            nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
    }
    I_StartupSound();
    I_InitMusic();
    S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

    CONS_Printf("ST_Init(): Init status bar.\n");
    ST_Init();

    if (M_CheckParm("-room"))
    {
        if (!M_IsNextParm())
            I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");

#ifdef UPDATE_ALERT
        GetMODVersion_Console();
#endif

        ms_RoomId = atoi(M_GetNextParm());
    }

    // init all NETWORK
    CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
    if (D_CheckNetGame())
        autostart = true;

    // check for a driver that wants intermission stats
    // start the apropriate game based on parms
    if (M_CheckParm("-metal"))
    {
        G_RecordMetal();
        autostart = true;
    }
    else if (M_CheckParm("-record") && M_IsNextParm())
    {
        G_RecordDemo(M_GetNextParm());
        autostart = true;
    }

    // user settings come before "+" parameters.
    if (dedicated)
        COM_ImmedExecute(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home));
    else
        COM_ImmedExecute(va("exec \"%s"PATHSEP"autoexec.cfg\" -noerror\n", srb2home));

    if (!autostart)
        M_PushSpecialParameters(); // push all "+" parameters at the command buffer

    // demo doesn't need anymore to be added with D_AddFile()
    p = M_CheckParm("-playdemo");
    if (!p)
        p = M_CheckParm("-timedemo");
    if (p && M_IsNextParm())
    {
        char tmp[MAX_WADPATH];
        // add .lmp to identify the EXTERNAL demo file
        // it is NOT possible to play an internal demo using -playdemo,
        // rather push a playdemo command.. to do.

        strcpy(tmp, M_GetNextParm());
        // get spaced filename or directory
        while (M_IsNextParm())
        {
            strcat(tmp, " ");
            strcat(tmp, M_GetNextParm());
        }

        FIL_DefaultExtension(tmp, ".lmp");

        CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

        if (M_CheckParm("-playdemo"))
        {
            singledemo = true; // quit after one demo
            G_DeferedPlayDemo(tmp);
        }
        else
            G_TimeDemo(tmp);

        G_SetGamestate(GS_NULL);
        wipegamestate = GS_NULL;
        return;
    }

    if (M_CheckParm("-ultimatemode"))
    {
        autostart = true;
        ultimatemode = true;
    }

    if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
    {
        gameaction = ga_nothing;

        CV_ClearChangedFlags();

        // Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
        // as having been modified for the first game.
        M_PushSpecialParameters(); // push all "+" parameter at the command buffer

        if (M_CheckParm("-gametype") && M_IsNextParm())
        {
            // from Command_Map_f
            INT32 j;
            INT16 newgametype = -1;
            const char *sgametype = M_GetNextParm();

            for (j = 0; gametype_cons_t[j].strvalue; j++)
                if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
                {
                    newgametype = (INT16)gametype_cons_t[j].value;
                    break;
                }
            if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
            {
                j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
                if (j >= 0 && j < NUMGAMETYPES)
                    newgametype = (INT16)j;
            }

            if (newgametype != -1)
            {
                j = gametype;
                gametype = newgametype;
                D_GameTypeChanged(j);
            }
        }

        if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
                && !M_CheckParm("-connect"))
        {
            // Prevent warping to nonexistent levels
            if (W_CheckNumForName(G_BuildMapName(pstartmap)) == LUMPERROR)
                I_Error("Could not warp to %s (map not found)\n", G_BuildMapName(pstartmap));
            // Prevent warping to locked levels
            // ... unless you're in a dedicated server.  Yes, technically this means you can view any level by
            // running a dedicated server and joining it yourself, but that's better than making dedicated server's
            // lives hell.
            else if (!dedicated && M_MapLocked(pstartmap))
                I_Error("You need to unlock this level before you can warp to it!\n");
            else
                D_MapChange(pstartmap, gametype, ultimatemode, true, 0, false, false);
        }
    }
    else if (M_CheckParm("-skipintro"))
    {
        CON_ToggleOff();
        CON_ClearHUD();
        F_StartTitleScreen();
    }
    else
        F_StartIntro(); // Tails 03-03-2002

    if (dedicated && server)
    {
        pagename = "TITLESKY";
        levelstarttic = gametic;
        G_SetGamestate(GS_LEVEL);
        if (!P_SetupLevel(false))
            I_Quit(); // fail so reset game stuff
    }
}
Ejemplo n.º 5
0
//
// D_DoomMain
//
void D_DoomMain (void)
{
    int p;
    char file[256];
    char demolumpname[9];
    int numiwadlumps;

    I_AtExit(D_Endoom, false);

    // print banner

    I_PrintBanner(PACKAGE_STRING);

    DEH_printf("Z_Init: Init zone memory allocation daemon. \n");
    Z_Init ();

#ifdef FEATURE_MULTIPLAYER
    //!
    // @category net
    //
    // Start a dedicated server, routing packets but not participating
    // in the game itself.
    //

    if (M_CheckParm("-dedicated") > 0)
    {
        printf("Dedicated server mode.\n");
        NET_DedicatedServer();

        // Never returns
    }

    //!
    // @category net
    //
    // Query the Internet master server for a global list of active
    // servers.
    //

    if (M_CheckParm("-search"))
    {
        NET_MasterQuery();
        exit(0);
    }

    //!
    // @arg <address>
    // @category net
    //
    // Query the status of the server running on the given IP
    // address.
    //

    p = M_CheckParmWithArgs("-query", 1);

    if (p)
    {
        NET_QueryAddress(myargv[p+1]);
        exit(0);
    }

    //!
    // @category net
    //
    // Search the local LAN for running servers.
    //

    if (M_CheckParm("-localsearch"))
    {
        NET_LANQuery();
        exit(0);
    }

#endif

    //!
    // @vanilla
    //
    // Disable monsters.
    //
	
    nomonsters = M_CheckParm ("-nomonsters");

    //!
    // @vanilla
    //
    // Monsters respawn after being killed.
    //

    respawnparm = M_CheckParm ("-respawn");

    //!
    // @vanilla
    //
    // Monsters move faster.
    //

    fastparm = M_CheckParm ("-fast");

    //! 
    // @vanilla
    //
    // Developer mode.  F1 saves a screenshot in the current working
    // directory.
    //

    devparm = M_CheckParm ("-devparm");

    I_DisplayFPSDots(devparm);

    //!
    // @category net
    // @vanilla
    //
    // Start a deathmatch game.
    //

    if (M_CheckParm ("-deathmatch"))
	deathmatch = 1;

    //!
    // @category net
    // @vanilla
    //
    // Start a deathmatch 2.0 game.  Weapons do not stay in place and
    // all items respawn after 30 seconds.
    //

    if (M_CheckParm ("-altdeath"))
	deathmatch = 2;

    if (devparm)
	DEH_printf(D_DEVSTR);
    
    // find which dir to use for config files

#ifdef _WIN32

    //!
    // @platform windows
    // @vanilla
    //
    // Save configuration data and savegames in c:\doomdata,
    // allowing play from CD.
    //

    if (M_ParmExists("-cdrom"))
    {
        printf(D_CDROM);

        M_SetConfigDir("c:\\doomdata\\");
    }
    else
#endif
    {
        // Auto-detect the configuration dir.

        M_SetConfigDir(NULL);
    }

    //!
    // @arg <x>
    // @vanilla
    //
    // Turbo mode.  The player's speed is multiplied by x%.  If unspecified,
    // x defaults to 200.  Values are rounded up to 10 and down to 400.
    //

    if ( (p=M_CheckParm ("-turbo")) )
    {
	int     scale = 200;
	extern int forwardmove[2];
	extern int sidemove[2];
	
	if (p<myargc-1)
	    scale = atoi (myargv[p+1]);
	if (scale < 10)
	    scale = 10;
	if (scale > 400)
	    scale = 400;
        DEH_printf("turbo scale: %i%%\n", scale);
	forwardmove[0] = forwardmove[0]*scale/100;
	forwardmove[1] = forwardmove[1]*scale/100;
	sidemove[0] = sidemove[0]*scale/100;
	sidemove[1] = sidemove[1]*scale/100;
    }
    
    // init subsystems
    DEH_printf("V_Init: allocate screens.\n");
    V_Init ();

    // Load configuration files before initialising other subsystems.
    DEH_printf("M_LoadDefaults: Load system defaults.\n");
    M_SetConfigFilenames("default.cfg", PROGRAM_PREFIX "doom.cfg");
    D_BindVariables();
    M_LoadDefaults();

    // Save configuration at exit.
    I_AtExit(M_SaveDefaults, false);

    // Find main IWAD file and load it.
    iwadfile = D_FindIWAD(IWAD_MASK_DOOM, &gamemission);

    // None found?

    if (iwadfile == NULL)
    {
        I_Error("Game mode indeterminate.  No IWAD file was found.  Try\n"
                "specifying one with the '-iwad' command line parameter.\n");
    }

    modifiedgame = false;

    DEH_printf("W_Init: Init WADfiles.\n");
    D_AddFile(iwadfile);
    numiwadlumps = numlumps;

    W_CheckCorrectIWAD(doom);

    // Now that we've loaded the IWAD, we can figure out what gamemission
    // we're playing and which version of Vanilla Doom we need to emulate.
    D_IdentifyVersion();
    InitGameVersion();

    //!
    // @category mod
    //
    // Disable automatic loading of Dehacked patches for certain
    // IWAD files.
    //
    if (!M_ParmExists("-nodeh"))
    {
        // Some IWADs have dehacked patches that need to be loaded for
        // them to be played properly.
        LoadIwadDeh();
    }

    // Doom 3: BFG Edition includes modified versions of the classic
    // IWADs which can be identified by an additional DMENUPIC lump.
    // Furthermore, the M_GDHIGH lumps have been modified in a way that
    // makes them incompatible to Vanilla Doom and the modified version
    // of doom2.wad is missing the TITLEPIC lump.
    // We specifically check for DMENUPIC here, before PWADs have been
    // loaded which could probably include a lump of that name.

    if (W_CheckNumForName("dmenupic") >= 0)
    {
        printf("BFG Edition: Using workarounds as needed.\n");
        bfgedition = true;

        // BFG Edition changes the names of the secret levels to
        // censor the Wolfenstein references. It also has an extra
        // secret level (MAP33). In Vanilla Doom (meaning the DOS
        // version), MAP33 overflows into the Plutonia level names
        // array, so HUSTR_33 is actually PHUSTR_1.

        DEH_AddStringReplacement(HUSTR_31, "level 31: idkfa");
        DEH_AddStringReplacement(HUSTR_32, "level 32: keen");
        DEH_AddStringReplacement(PHUSTR_1, "level 33: betray");

        // The BFG edition doesn't have the "low detail" menu option (fair
        // enough). But bizarrely, it reuses the M_GDHIGH patch as a label
        // for the options menu (says "Fullscreen:"). Why the perpetrators
        // couldn't just add a new graphic lump and had to reuse this one,
        // I don't know.
        //
        // The end result is that M_GDHIGH is too wide and causes the game
        // to crash. As a workaround to get a minimum level of support for
        // the BFG edition IWADs, use the "ON"/"OFF" graphics instead.

        DEH_AddStringReplacement("M_GDHIGH", "M_MSGON");
        DEH_AddStringReplacement("M_GDLOW", "M_MSGOFF");
    }

#ifdef FEATURE_DEHACKED
    // Load Dehacked patches specified on the command line with -deh.
    // Note that there's a very careful and deliberate ordering to how
    // Dehacked patches are loaded. The order we use is:
    //  1. IWAD dehacked patches.
    //  2. Command line dehacked patches specified with -deh.
    //  3. PWAD dehacked patches in DEHACKED lumps.
    DEH_ParseCommandLine();
#endif

    // Load PWAD files.
    modifiedgame = W_ParseCommandLine();

    // Debug:
//    W_PrintDirectory();

    //!
    // @arg <demo>
    // @category demo
    // @vanilla
    //
    // Play back the demo named demo.lmp.
    //

    p = M_CheckParmWithArgs ("-playdemo", 1);

    if (!p)
    {
        //!
        // @arg <demo>
        // @category demo
        // @vanilla
        //
        // Play back the demo named demo.lmp, determining the framerate
        // of the screen.
        //
	p = M_CheckParmWithArgs("-timedemo", 1);

    }

    if (p)
    {
        char *uc_filename = strdup(myargv[p + 1]);
        M_ForceUppercase(uc_filename);

        // With Vanilla you have to specify the file without extension,
        // but make that optional.
        if (M_StringEndsWith(uc_filename, ".LMP"))
        {
            M_StringCopy(file, myargv[p + 1], sizeof(file));
        }
        else
        {
            DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
        }

        free(uc_filename);

        if (D_AddFile(file))
        {
            M_StringCopy(demolumpname, lumpinfo[numlumps - 1]->name,
                         sizeof(demolumpname));
        }
        else
        {
            // If file failed to load, still continue trying to play
            // the demo in the same way as Vanilla Doom.  This makes
            // tricks like "-playdemo demo1" possible.

            M_StringCopy(demolumpname, myargv[p + 1], sizeof(demolumpname));
        }

        printf("Playing demo %s.\n", file);
    }

    I_AtExit(G_CheckDemoStatusAtExit, true);

    // Generate the WAD hash table.  Speed things up a bit.
    W_GenerateHashTable();

    // Load DEHACKED lumps from WAD files - but only if we give the right
    // command line parameter.

    //!
    // @category mod
    //
    // Load Dehacked patches from DEHACKED lumps contained in one of the
    // loaded PWAD files.
    //
    if (M_ParmExists("-dehlump"))
    {
        int i, loaded = 0;

        for (i = numiwadlumps; i < numlumps; ++i)
        {
            if (!strncmp(lumpinfo[i]->name, "DEHACKED", 8))
            {
                DEH_LoadLump(i, false, false);
                loaded++;
            }
        }

        printf("  loaded %i DEHACKED lumps from PWAD files.\n", loaded);
    }

    // Set the gamedescription string. This is only possible now that
    // we've finished loading Dehacked patches.
    D_SetGameDescription();

#ifdef _WIN32
    // In -cdrom mode, we write savegames to c:\doomdata as well as configs.
    if (M_ParmExists("-cdrom"))
    {
        savegamedir = configdir;
    }
    else
#endif
    {
        savegamedir = M_GetSaveGameDir(D_SaveGameIWADName(gamemission));
    }

    // Check for -file in shareware
    if (modifiedgame)
    {
	// These are the lumps that will be checked in IWAD,
	// if any one is not present, execution will be aborted.
	char name[23][8]=
	{
	    "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
	    "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
	    "dphoof","bfgga0","heada1","cybra1","spida1d1"
	};
	int i;
	
	if ( gamemode == shareware)
	    I_Error(DEH_String("\nYou cannot -file with the shareware "
			       "version. Register!"));

	// Check for fake IWAD with right name,
	// but w/o all the lumps of the registered version. 
	if (gamemode == registered)
	    for (i = 0;i < 23; i++)
		if (W_CheckNumForName(name[i])<0)
		    I_Error(DEH_String("\nThis is not the registered version."));
    }

    if (W_CheckNumForName("SS_START") >= 0
     || W_CheckNumForName("FF_END") >= 0)
    {
        I_PrintDivider();
        printf(" WARNING: The loaded WAD file contains modified sprites or\n"
               " floor textures.  You may want to use the '-merge' command\n"
               " line option instead of '-file'.\n");
    }

    I_PrintStartupBanner(gamedescription);
    PrintDehackedBanners();

    // Freedoom's IWADs are Boom-compatible, which means they usually
    // don't work in Vanilla (though FreeDM is okay). Show a warning
    // message and give a link to the website.
    if (W_CheckNumForName("FREEDOOM") >= 0 && W_CheckNumForName("FREEDM") < 0)
    {
        printf(" WARNING: You are playing using one of the Freedoom IWAD\n"
               " files, which might not work in this port. See this page\n"
               " for more information on how to play using Freedoom:\n"
               "   http://www.chocolate-doom.org/wiki/index.php/Freedoom\n");
        I_PrintDivider();
    }

    DEH_printf("I_Init: Setting up machine state.\n");
    I_CheckIsScreensaver();
    I_InitTimer();
    I_InitJoystick();
    I_InitSound(true);
    I_InitMusic();

#ifdef FEATURE_MULTIPLAYER
    printf ("NET_Init: Init network subsystem.\n");
    NET_Init ();
#endif

    // Initial netgame startup. Connect to server etc.
    D_ConnectNetGame();

    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 1;
    autostart = false;

    //!
    // @arg <skill>
    // @vanilla
    //
    // Set the game skill, 1-5 (1: easiest, 5: hardest).  A skill of
    // 0 disables all monsters.
    //

    p = M_CheckParmWithArgs("-skill", 1);

    if (p)
    {
	startskill = myargv[p+1][0]-'1';
	autostart = true;
    }

    //!
    // @arg <n>
    // @vanilla
    //
    // Start playing on episode n (1-4)
    //

    p = M_CheckParmWithArgs("-episode", 1);

    if (p)
    {
	startepisode = myargv[p+1][0]-'0';
	startmap = 1;
	autostart = true;
    }
	
    timelimit = 0;

    //! 
    // @arg <n>
    // @category net
    // @vanilla
    //
    // For multiplayer games: exit each level after n minutes.
    //

    p = M_CheckParmWithArgs("-timer", 1);

    if (p)
    {
	timelimit = atoi(myargv[p+1]);
    }

    //!
    // @category net
    // @vanilla
    //
    // Austin Virtual Gaming: end levels after 20 minutes.
    //

    p = M_CheckParm ("-avg");

    if (p)
    {
	timelimit = 20;
    }

    //!
    // @arg [<x> <y> | <xy>]
    // @vanilla
    //
    // Start a game immediately, warping to ExMy (Doom 1) or MAPxy
    // (Doom 2)
    //

    p = M_CheckParmWithArgs("-warp", 1);

    if (p)
    {
        if (gamemode == commercial)
            startmap = atoi (myargv[p+1]);
        else
        {
            startepisode = myargv[p+1][0]-'0';

            if (p + 2 < myargc)
            {
                startmap = myargv[p+2][0]-'0';
            }
            else
            {
                startmap = 1;
            }
        }
        autostart = true;
    }

    // Undocumented:
    // Invoked by setup to test the controls.

    p = M_CheckParm("-testcontrols");

    if (p > 0)
    {
        startepisode = 1;
        startmap = 1;
        autostart = true;
        testcontrols = true;
    }

    // Check for load game parameter
    // We do this here and save the slot number, so that the network code
    // can override it or send the load slot to other players.

    //!
    // @arg <s>
    // @vanilla
    //
    // Load the game in slot s.
    //

    p = M_CheckParmWithArgs("-loadgame", 1);
    
    if (p)
    {
        startloadgame = atoi(myargv[p+1]);
    }
    else
    {
        // Not loading a game
        startloadgame = -1;
    }

    DEH_printf("M_Init: Init miscellaneous info.\n");
    M_Init ();

    DEH_printf("R_Init: Init DOOM refresh daemon - ");
    R_Init ();

    DEH_printf("\nP_Init: Init Playloop state.\n");
    P_Init ();

    DEH_printf("S_Init: Setting up sound.\n");
    S_Init (sfxVolume * 8, musicVolume * 8);

    DEH_printf("D_CheckNetGame: Checking network game status.\n");
    D_CheckNetGame ();

    PrintGameVersion();

    DEH_printf("HU_Init: Setting up heads up display.\n");
    HU_Init ();

    DEH_printf("ST_Init: Init status bar.\n");
    ST_Init ();

    // If Doom II without a MAP01 lump, this is a store demo.
    // Moved this here so that MAP01 isn't constantly looked up
    // in the main loop.

    if (gamemode == commercial && W_CheckNumForName("map01") < 0)
        storedemo = true;

    if (M_CheckParmWithArgs("-statdump", 1))
    {
        I_AtExit(StatDump, true);
        DEH_printf("External statistics registered.\n");
    }

    //!
    // @arg <x>
    // @category demo
    // @vanilla
    //
    // Record a demo named x.lmp.
    //

    p = M_CheckParmWithArgs("-record", 1);

    if (p)
    {
	G_RecordDemo (myargv[p+1]);
	autostart = true;
    }

    p = M_CheckParmWithArgs("-playdemo", 1);
    if (p)
    {
	singledemo = true;              // quit after one demo
	G_DeferedPlayDemo (demolumpname);
	D_DoomLoop ();  // never returns
    }
	
    p = M_CheckParmWithArgs("-timedemo", 1);
    if (p)
    {
	G_TimeDemo (demolumpname);
	D_DoomLoop ();  // never returns
    }
	
    if (startloadgame >= 0)
    {
        M_StringCopy(file, P_SaveGameFile(startloadgame), sizeof(file));
	G_LoadGame(file);
    }
	
    if (gameaction != ga_loadgame )
    {
	if (autostart || netgame)
	    G_InitNew (startskill, startepisode, startmap);
	else
	    D_StartTitle ();                // start up intro loop
    }

    D_DoomLoop ();  // never returns
}
Ejemplo n.º 6
0
void I_InitSound(void)
{
// proff 07/04/98: Added for CYGWIN32 compatibility
#ifdef HAVE_LIBDSOUND
  HRESULT error;
  int c;
  int i;
#endif // HAVE_LIBDSOUND
  
  // proff 07/01/98: Added I_InitMusic
  if (!nomusicparm)
    I_InitMusic();
  if (nosfxparm)
    return;
  // proff 07/04/98: Added for CYGWIN32 compatibility
#ifdef HAVE_LIBDSOUND
  // proff 11/21/98: Added DirectSound device selection
  i = M_CheckParm ("-dsounddevice");
  if ((i) || (snd_dsounddevice))
    {
      printf("I_InitSound: Sound Devices\n");
      DirectSoundEnumerate(&DSEnumCallback,NULL);
      DSoundDevice=snd_dsounddevice;
      if (i)
	DSoundDevice=atoi(myargv[i+1]);
      DSoundDevice=
	(DSoundDevice < 0) ? 0 : 
	(DSoundDevice >= DSDeviceCount) ? 0 : DSoundDevice;
    }

  printf("I_InitSound: ");
  error = DirectSoundCreate(DSDeviceGUIDs[DSoundDevice], &lpDS, NULL);
  // proff 11/21/98: End of additions and changes
  if (error == DSERR_NODRIVER)
    {
      lpDS = NULL;
      printf("no sounddevice found\n");
      noDSound = true;
      return;
    }
  noDSound = false;
  if (error != DS_OK)
    {
      noDSound = true;
      return;
    }

  // open the hidden sound window we use to play sounds through

  OpenSoundWnd();

  printf("created DirectSound. Selected Device: %i\n", DSoundDevice);
  atexit(I_ShutdownSound); 
  error = IDirectSound_SetCooperativeLevel(lpDS, soundWnd , DSSCL_EXCLUSIVE);
  if (error != DS_OK)
    {
      noDSound = true;
      return;
    }
  printf("I_InitSound: ");
  printf("CooperativeLevel set\n");
  printf("I_InitSound: ");

  // error is returned but it works ... ??

  error = CreatePrimaryBuffer();
  //  if (error != DS_OK)
  //    {
  //      printf("ERROR: Couldnt create primary buffer\n");
  //      noDSound = true;
  //      return;
  //    }

  numChannels = default_numChannels;
  lpSecondaryDSB = malloc(sizeof(LPDIRECTSOUNDBUFFER)*numChannels);
  if (lpSecondaryDSB)
    {
      memset(lpSecondaryDSB, 0, sizeof(LPDIRECTSOUNDBUFFER) * numChannels);
      printf ("Channels : %i\n", numChannels);
    }
  else
    {
      noDSound = true;
      return;
    }
  ChannelInfo = malloc(sizeof(channel_info_t)*numChannels);

  if (ChannelInfo)
    {
      // proff 11/09/98: Added for security

      memset(ChannelInfo, 0, sizeof(channel_info_t) * numChannels);
    }
  else
    {
      noDSound = true;
      return;
    }

  for (c=0; c<numChannels; c++)
    {
      error = CreateSecondaryBuffer(&lpSecondaryDSB[c], 65535);
      if (error != DS_OK)
	{
	  noDSound = true;
	  return;
	}
    }

  printf("DirectSound initialised ok!\n");

#endif // HAVE_LIBDSOUND
}
Ejemplo n.º 7
0
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
	INT32 p;
	char srb2[82]; // srb2 title banner
	char title[82];

	INT32 pstartmap = 1;
	boolean autostart = false;

	// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	if (setvbuf(stderr, NULL, _IOFBF, 1000))
		DEBPRINT("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
	// initialise locale code
	M_StartupLocale();
#endif

	// get parameters from a response file (eg: srb2 @parms.txt)
	M_FindResponseFile();

	// MAINCFG is now taken care of where "OBJCTCFG" is handled
	G_LoadGameSettings();

	// identify the main IWAD file to use
	IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
	devparm = !M_CheckParm("-nodebug");
#else
	devparm = M_CheckParm("-debug");
#endif

	// for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
	dedicated = M_CheckParm("-dedicated") != 0;
#endif

	strcpy(title, "Sonic Robo Blast 2");
	strcpy(srb2, "Sonic Robo Blast 2");
	D_MakeTitleString(srb2);

#ifdef PC_DOS
	D_Titlebar(srb2, title);
#else
	CONS_Printf("SRB2"VERSIONSTRING"\n");
#endif

#if defined (__OS2__) && !defined (SDL)
	// set PM window title
	snprintf(pmData->title, sizeof (pmData->title),
		"Sonic Robo Blast 2" VERSIONSTRING ": %s",
		title);
	pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

	if (devparm)
		CONS_Printf("%s", M_GetText("Development mode ON.\n"));

	// default savegame
	strcpy(savegamename, SAVEGAMENAME"%u.ssg");

	{
		const char *userhome = D_Home(); //Alam: path to home

		if (!userhome)
		{
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
			I_Error("%s", M_GetText("Please set $HOME to your home directory\n"));
#elif defined (_WIN32_WCE) && 0
			if (dedicated)
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
			if (dedicated)
				snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
		}
		else
		{
			// use user specific config file
#ifdef DEFAULTDIR
			snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, srb2home, PATHSEP);

			I_mkdir(srb2home, 0700);
#else
			snprintf(srb2home, sizeof srb2home, "%s", userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, userhome, PATHSEP);
#endif
		}

		configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
	strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
	}

	if (M_CheckParm("-password") && M_IsNextParm())
	{
		const char *pw = M_GetNextParm();
		strncpy(adminpassword, pw, 8);
		if (strlen(pw) < 8)
		{
			size_t z;
			for (z = strlen(pw); z < 8; z++)
				adminpassword[z] = 'a';
		}
	}
	else
	{
		size_t z;
		srand((unsigned int)time(NULL));
		for (z = 0; z < 8; z++)
			adminpassword[z] = (char)(rand() & 127);
	}
	adminpassword[8] = '\0';

	// add any files specified on the command line with -file wadfile
	// to the wad list
	if (!(M_CheckParm("-connect")))
	{
		if (M_CheckParm("-file"))
		{
			// the parms after p are wadfile/lump names,
			// until end of parms or another - preceded parm
			while (M_IsNextParm())
			{
				const char *s = M_GetNextParm();

				if (s) // Check for NULL?
				{
					if (!W_VerifyNMUSlumps(s))
						modifiedgame = true;
					D_AddFile(s);
				}
			}
		}
	}

	// get map from parms

	if (M_CheckParm("-server") || dedicated)
		netgame = server = true;

	if (M_CheckParm("-warp") && M_IsNextParm())
	{
		pstartmap = atoi(M_GetNextParm());
		if (!M_CheckParm("-server"))
			modifiedgame = true;
		autostart = true;
		savemoddata = false;
	}

	CONS_Printf("%s", M_GetText("Z_Init: Init zone memory allocation daemon. \n"));
	Z_Init();

	// adapt tables to SRB2's needs, including extra slots for dehacked file support
	P_PatchInfoTables();

	CONS_Printf("%s", M_GetText("W_Init: Init WADfiles.\n"));

	//---------------------------------------------------- READY TIME
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupTimer...\n");
	I_StartupTimer();

	// Make backups of some SOCcable tables.
	P_BackupTables();

	// load wad, including the main wad file
	if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
		CONS_Error(M_GetText("A WAD file was not found or not valid\n"));
#else
		I_Error("%s", M_GetText("A WAD file was not found or not valid\n"));
#endif
	D_CleanFile();

	// Check MD5s of autoloaded files
	W_VerifyFileMD5(0, "1f698dd35bcedb04631568a84a97d72b"); // srb2.srb
	W_VerifyFileMD5(1, "86ae3f9179c64358d1c88060e41bd415"); // zones.dta
	W_VerifyFileMD5(2, "f699d4702b9b505db621e5ad5af4f352"); // sonic.plr
	W_VerifyFileMD5(3, "dfbbc38080485c70a84a57bb734ceee9"); // tails.plr
	W_VerifyFileMD5(4, "1ea958e2aee87b6995226a120ba3eaac"); // knux.plr
	W_VerifyFileMD5(5, "8f702416c15060cd3c53c71b91116914"); // rings.wpn
	W_VerifyFileMD5(6, "6b1cf9b41e41a46ac58606dc6e7c9e05"); // drill.dta
	W_VerifyFileMD5(7, "8d080c050ecf03691562aa7b60156fec"); // soar.dta

	// don't check music.dta because people like to modify it, and it doesn't matter if they do
	// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.


	mainwads = 8; // there are 8 wads not to unload

/* TODO: incorporate this!
	CONS_Printf("%s", "===========================================================================\n"
	"                       Sonic Robo Blast II!\n"
	"                       by Sonic Team Junior\n"
	"                       http://www.srb2.org\n"
	"      This is a modified version. Go to our site for the original.\n"
	"===========================================================================\n");
*/

	// Check and print which version is executed.
	CONS_Printf("%s", "===========================================================================\n"
	"                   We hope you enjoy this game as\n"
	"                     much as we did making it!\n"
	"                            ...wait. =P\n"
	"===========================================================================\n");

	cht_Init();

	//---------------------------------------------------- READY SCREEN
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupGraphics...\n");
	I_StartupGraphics();

	//--------------------------------------------------------- CONSOLE
	// setup loading screen
	SCR_Startup();

	// we need the font of the console
	CONS_Printf("%s", M_GetText("HU_Init: Setting up heads up display.\n"));
	HU_Init();

	COM_Init();
	// libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
	CON_Init();
#else
	CON_InitWii();
#endif

	D_RegisterServerCommands();
	D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
	R_RegisterEngineStuff();
	S_RegisterSoundStuff();

	I_RegisterSysCommands();

	//--------------------------------------------------------- CONFIG.CFG
	M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

	if (!M_CheckParm("-resetdata"))
		G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
	VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

	// set user default mode or mode set at cmdline
	SCR_CheckDefaultMode();

	wipegamestate = gamestate;

	P_InitMapHeaders();
	savedata.lives = 0; // flag this as not-used

	//------------------------------------------------ COMMAND LINE PARAMS

	// Initialize CD-Audio
	if (M_CheckParm("-usecd") && !dedicated)
		I_InitCD();

	if (M_CheckParm("-nodownloading"))
		COM_BufAddText("downloading 0\n");

	CONS_Printf("%s", M_GetText("M_Init: Init miscellaneous info.\n"));
	M_Init();

	CONS_Printf("%s", M_GetText("R_Init: Init SRB2 refresh daemon - "));
	R_Init();

	// setting up sound
	CONS_Printf("%s", M_GetText("S_Init: Setting up sound.\n"));
	if (M_CheckParm("-nosound"))
		nosound = true;
	if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
		nomidimusic = nodigimusic = true;
	else
	{
		if (M_CheckParm("-nomidimusic"))
			nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
		if (M_CheckParm("-nodigmusic"))
			nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
	}
	I_StartupSound();
	I_InitMusic();
	S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

	CONS_Printf("%s", M_GetText("ST_Init: Init status bar.\n"));
	ST_Init();

	if (M_CheckParm("-internetserver"))
		CV_SetValue(&cv_internetserver, 1);

	// init all NETWORK
	CONS_Printf("%s", M_GetText("D_CheckNetGame: Checking network game status.\n"));
	if (D_CheckNetGame())
		autostart = true;

	// check for a driver that wants intermission stats
	// start the apropriate game based on parms
	if (M_CheckParm("-record") && M_IsNextParm())
	{
		G_RecordDemo(M_GetNextParm());
		autostart = true;
	}

	p = M_CheckParm("-timetic");
	if (p)
		CV_Set(&cv_timetic, "On");

	if (!autostart)
		M_PushSpecialParameters(); // push all "+" parameters at the command buffer

	// demo doesn't need anymore to be added with D_AddFile()
	p = M_CheckParm("-playdemo");
	if (!p)
		p = M_CheckParm("-timedemo");
	if (p && M_IsNextParm())
	{
		char tmp[MAX_WADPATH];
		// add .lmp to identify the EXTERNAL demo file
		// it is NOT possible to play an internal demo using -playdemo,
		// rather push a playdemo command.. to do.

		strcpy(tmp, M_GetNextParm());
		// get spaced filename or directory
		while (M_IsNextParm())
		{
			strcat(tmp, " ");
			strcat(tmp, M_GetNextParm());
		}

		FIL_DefaultExtension(tmp, ".lmp");

		CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

		if (M_CheckParm("-playdemo"))
		{
			singledemo = true; // quit after one demo
			G_DeferedPlayDemo(tmp);
		}
		else
			G_TimeDemo(tmp);

		G_SetGamestate(GS_NULL);
		wipegamestate = GS_NULL;
		return;
	}

	if (M_CheckParm("-ultimatemode"))
	{
		autostart = true;
		ultimatemode = true;
	}

	if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
	{
		gameaction = ga_nothing;

		CV_ClearChangedFlags();

		// Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
		// as having been modified for the first game.
		M_PushSpecialParameters(); // push all "+" parameter at the command buffer

		if (M_CheckParm("-gametype") && M_IsNextParm())
		{
			// from Command_Map_f
			INT32 j;
			INT16 newgametype = -1;
			const char *sgametype = M_GetNextParm();

			for (j = 0; gametype_cons_t[j].strvalue; j++)
				if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
				{
					if (gametype_cons_t[j].value == GTF_TEAMMATCH)
					{
						newgametype = GT_MATCH;
						CV_SetValue(&cv_matchtype, 1);
					}
					else if (gametype_cons_t[j].value == GTF_CLASSICRACE)
					{
						newgametype = GT_RACE;
						CV_SetValue(&cv_racetype, 1);
					}
					else if (gametype_cons_t[j].value == GTF_HIDEANDSEEK)
					{
						newgametype = GT_TAG;
						CV_SetValue(&cv_tagtype, 1);
					}
					else
						newgametype = (INT16)gametype_cons_t[j].value;

					break;
				}
			if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
			{
				j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
				if (j >= 0 && j < NUMGAMETYPES)
					newgametype = (INT16)j;
			}

			if (newgametype != -1)
			{
				j = gametype;
				gametype = newgametype;
				D_GameTypeChanged(j);
			}
		}

		if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
			&& !M_CheckParm("-connect"))
		{
			D_MapChange(pstartmap, gametype, ultimatemode, 1, 0, false, false);
		}
	}
	else
		F_StartIntro(); // Tails 03-03-2002

	if (dedicated && server)
	{
		pagename = "TITLESKY";
		levelstarttic = gametic;
		G_SetGamestate(GS_LEVEL);
		if (!P_SetupLevel(gamemap, false))
			I_Quit(); // fail so reset game stuff
	}
}
Ejemplo n.º 8
0
//
// I_Init
//
void I_Init(void)
{
    I_InitSound();
    I_InitMusic();
}
Ejemplo n.º 9
0
void D_DoomMain(void)
{
    GameMission_t gamemission;
    int p;

    I_AtExit(D_HexenQuitMessage, false);
    startepisode = 1;
    autostart = false;
    startskill = sk_medium;
    startmap = 1;
    gamemode = commercial;

    I_PrintBanner(PACKAGE_STRING);

    // Initialize subsystems

    ST_Message("V_Init: allocate screens.\n");
    V_Init();

    // Load defaults before initing other systems
    ST_Message("M_LoadDefaults: Load system defaults.\n");
    D_BindVariables();

#ifdef _WIN32

    //!
    // @platform windows
    // @vanilla
    //
    // Save configuration data and savegames in c:\hexndata,
    // allowing play from CD.
    //

    cdrom = M_ParmExists("-cdrom");
#endif

    if (cdrom)
    {
        M_SetConfigDir("c:\\hexndata\\");
    }
    else
    {
        M_SetConfigDir(NULL);
    }

    D_SetDefaultSavePath();
    M_SetConfigFilenames("hexen.cfg", PROGRAM_PREFIX "hexen.cfg");
    M_LoadDefaults();

    I_AtExit(M_SaveDefaults, false);


    // Now that the savedir is loaded from .CFG, make sure it exists
    CreateSavePath();

    ST_Message("Z_Init: Init zone memory allocation daemon.\n");
    Z_Init();

    // haleyjd: removed WATCOMC

    ST_Message("W_Init: Init WADfiles.\n");

    iwadfile = D_FindIWAD(IWAD_MASK_HEXEN, &gamemission);

    if (iwadfile == NULL)
    {
        I_Error("Game mode indeterminate. No IWAD was found. Try specifying\n"
                "one with the '-iwad' command line parameter.");
    }

    D_AddFile(iwadfile);
    W_CheckCorrectIWAD(hexen);
    D_IdentifyVersion();
    D_SetGameDescription();
    AdjustForMacIWAD();

    HandleArgs();

    I_PrintStartupBanner(gamedescription);

    ST_Message("MN_Init: Init menu system.\n");
    MN_Init();

    ST_Message("CT_Init: Init chat mode data.\n");
    CT_Init();

    InitMapMusicInfo();         // Init music fields in mapinfo

    ST_Message("S_InitScript\n");
    S_InitScript();

    ST_Message("SN_InitSequenceScript: Registering sound sequences.\n");
    SN_InitSequenceScript();
    ST_Message("I_Init: Setting up machine state.\n");
    I_CheckIsScreensaver();
    I_InitTimer();
    I_InitJoystick();
    I_InitSound(false);
    I_InitMusic();

#ifdef FEATURE_MULTIPLAYER
    ST_Message("NET_Init: Init networking subsystem.\n");
    NET_Init();
#endif
    D_ConnectNetGame();

    S_Init();
    S_Start();

    ST_Message("ST_Init: Init startup screen.\n");
    ST_Init();

    // Show version message now, so it's visible during R_Init()
    ST_Message("R_Init: Init Hexen refresh daemon");
    R_Init();
    ST_Message("\n");

    //if (M_CheckParm("-net"))
    //    ST_NetProgress();       // Console player found

    ST_Message("P_Init: Init Playloop state.\n");
    P_Init();

    // Check for command line warping. Follows P_Init() because the
    // MAPINFO.TXT script must be already processed.
    WarpCheck();

    ST_Message("D_CheckNetGame: Checking network game status.\n");
    D_CheckNetGame();

    ST_Message("SB_Init: Loading patches.\n");
    SB_Init();

    ST_Done();

    if (autostart)
    {
        ST_Message("Warp to Map %d (\"%s\":%d), Skill %d\n",
                   WarpMap, P_GetMapName(startmap), startmap, startskill + 1);
    }

    CheckRecordFrom();

    p = M_CheckParm("-record");
    if (p && p < myargc - 1)
    {
        G_RecordDemo(startskill, 1, startepisode, startmap, myargv[p + 1]);
        H2_GameLoop();          // Never returns
    }

    p = M_CheckParmWithArgs("-playdemo", 1);
    if (p)
    {
        singledemo = true;      // Quit after one demo
        G_DeferedPlayDemo(demolumpname);
        H2_GameLoop();          // Never returns
    }

    p = M_CheckParmWithArgs("-timedemo", 1);
    if (p)
    {
        G_TimeDemo(demolumpname);
        H2_GameLoop();          // Never returns
    }

    //!
    // @arg <s>
    // @vanilla
    //
    // Load the game in savegame slot s.
    //

    p = M_CheckParmWithArgs("-loadgame", 1);
    if (p)
    {
        G_LoadGame(atoi(myargv[p + 1]));
    }

    if (gameaction != ga_loadgame)
    {
        UpdateState |= I_FULLSCRN;
        BorderNeedRefresh = true;
        if (autostart || netgame)
        {
            G_StartNewInit();
            G_InitNew(startskill, startepisode, startmap);
        }
        else
        {
            H2_StartTitle();
        }
    }
    H2_GameLoop();              // Never returns
}
Ejemplo n.º 10
0
//
// D_DoomMain
//
void D_DoomMain (void)
{
    int             p;
    char            file[256];
    char            demolumpname[9];

    I_AtExit(D_Endoom, false);

    // haleyjd 20110206 [STRIFE]: -nograph parameter

    //!
    // @vanilla
    //
    // Disable graphical introduction sequence
    //

    if (M_ParmExists("-nograph"))
        showintro = false;

    // Undocumented:
    // Invoked by setup to test the controls.

    if (M_ParmExists("-testcontrols"))
    {
        testcontrols = true;
        showintro = false;
    }

    // haleyjd 20110206: Moved up -devparm for max visibility

    //!
    // @vanilla
    //
    // Developer mode. Implies -nograph.
    //

    devparm = M_CheckParm ("-devparm");

    // print banner

    I_PrintBanner(PACKAGE_STRING);

    //DEH_printf("Z_Init: Init zone memory allocation daemon. \n"); [STRIFE] removed
    Z_Init ();

#ifdef FEATURE_MULTIPLAYER
    //!
    // @category net
    //
    // Start a dedicated server, routing packets but not participating
    // in the game itself.
    //

    if (M_CheckParm("-dedicated") > 0)
    {
        printf("Dedicated server mode.\n");
        NET_DedicatedServer();

        // Never returns
    }

    //!
    // @category net
    //
    // Query the Internet master server for a global list of active
    // servers.
    //

    if (M_CheckParm("-search"))
    {
        NET_MasterQuery();
        exit(0);
    }

    //!
    // @arg <address>
    // @category net
    //
    // Query the status of the server running on the given IP
    // address.
    //

    p = M_CheckParmWithArgs("-query", 1);

    if (p)
    {
        NET_QueryAddress(myargv[p+1]);
        exit(0);
    }

    //!
    // @category net
    //
    // Search the local LAN for running servers.
    //

    if (M_CheckParm("-localsearch"))
    {
        NET_LANQuery();
        exit(0);
    }

#endif
            
#ifdef FEATURE_DEHACKED
    if(devparm)
        printf("DEH_Init: Init Dehacked support.\n");
    DEH_Init();
#endif

    //!
    // @vanilla
    //
    // Disable monsters.
    //

    nomonsters = M_CheckParm ("-nomonsters");

    //!
    // @vanilla
    //
    // Set Rogue playtesting mode (godmode, noclip toggled by backspace)
    //

    workparm = M_CheckParm ("-work");

    //!
    // @vanilla
    //
    // Flip player gun sprites (broken).
    //

    flipparm = M_CheckParm ("-flip");

    //!
    // @vanilla
    //
    // Respawn monsters after they are killed.
    //

    respawnparm = M_CheckParm ("-respawn");

    //!
    // @vanilla
    //
    // Items respawn at random locations
    //

    randomparm = M_CheckParm ("-random");

    //!
    // @vanilla
    //
    // Monsters move faster.
    //

    fastparm = M_CheckParm ("-fast");

    I_DisplayFPSDots(devparm);

    // haleyjd 20110206 [STRIFE]: -devparm implies -nograph
    if(devparm)
        showintro = false;

    // Note: Vanilla Strife does not understand the -deathmatch command
    // line parameter. deathmatch=1 is the default behavior when
    // playing a netgame.

    //!
    // @category net
    // @vanilla
    //
    // Start a deathmatch game.  Weapons do not stay in place and
    // all items respawn after 30 seconds.
    //

    if (M_CheckParm ("-altdeath"))
        deathmatch = 2;

    if (devparm)
        DEH_printf(D_DEVSTR);
    
    // find which dir to use for config files

#ifdef _WIN32

    //!
    // @platform windows
    // @vanilla
    //
    // Save configuration data and savegames in c:\strife.cd,
    // allowing play from CD.
    //

    if (M_CheckParm("-cdrom") > 0)
    {
        printf(D_CDROM);

        // haleyjd 08/22/2010: [STRIFE] Use strife.cd folder for -cdrom
        M_SetConfigDir("c:\\strife.cd\\");
    }
    else
#endif
    {
        // Auto-detect the configuration dir.

        M_SetConfigDir(NULL);
    }
    
    //!
    // @arg <x>
    // @vanilla
    //
    // Turbo mode.  The player's speed is multiplied by x%.  If unspecified,
    // x defaults to 200.  Values are rounded up to 10 and down to 400.
    //

    if ( (p=M_CheckParm ("-turbo")) )
    {
        int     scale = 200;
        extern int forwardmove[2];
        extern int sidemove[2];

        if (p<myargc-1)
            scale = atoi (myargv[p+1]);
        if (scale < 10)
            scale = 10;
        if (scale > 400)
            scale = 400;
        DEH_printf("turbo scale: %i%%\n", scale);
        forwardmove[0] = forwardmove[0]*scale/100;
        forwardmove[1] = forwardmove[1]*scale/100;
        sidemove[0] = sidemove[0]*scale/100;
        sidemove[1] = sidemove[1]*scale/100;
    }
    
    // init subsystems
    // DEH_printf("V_Init: allocate screens.\n"); [STRIFE] removed
    V_Init ();

    // Load configuration files before initialising other subsystems.
    // haleyjd 08/22/2010: [STRIFE] - use strife.cfg
    // DEH_printf("M_LoadDefaults: Load system defaults.\n"); [STRIFE] removed
    M_SetConfigFilenames("strife.cfg", PROGRAM_PREFIX "strife.cfg");
    D_BindVariables();
    M_LoadDefaults();

    if (!graphical_startup)
    {
        showintro = false;
    }

    // Save configuration at exit.
    I_AtExit(M_SaveDefaults, false);

    // Find the main IWAD file and load it.
    iwadfile = D_FindIWAD(IWAD_MASK_STRIFE, &gamemission);

    // None found?
    if (iwadfile == NULL)
    {
        I_Error("Game mode indeterminate.  No IWAD file was found.  Try\n"
                "specifying one with the '-iwad' command line parameter.\n");
    }

    modifiedgame = false;

    if(devparm) // [STRIFE] Devparm only
        DEH_printf("W_Init: Init WADfiles.\n");
    D_AddFile(iwadfile);
    W_CheckCorrectIWAD(strife);
    modifiedgame = W_ParseCommandLine();

    // [STRIFE] serial number output
    if(devparm)
    {
        char msgbuf[80];
        char *serial  = W_CacheLumpName("SERIAL", PU_CACHE);
        int serialnum = atoi(serial);

        DEH_snprintf(msgbuf, sizeof(msgbuf), "Wad Serial Number: %d:", serialnum);
        printf("%s\n", msgbuf);
    }

    // add any files specified on the command line with -file wadfile
    // to the wad list
    //

    // Debug:
//    W_PrintDirectory();

    //!
    // @arg <demo>
    // @category demo
    // @vanilla
    //
    // Play back the demo named demo.lmp.
    //

    p = M_CheckParmWithArgs ("-playdemo", 1);

    if (!p)
    {
        //!
        // @arg <demo>
        // @category demo
        // @vanilla
        //
        // Play back the demo named demo.lmp, determining the framerate
        // of the screen.
        //
	p = M_CheckParmWithArgs("-timedemo", 1);

    }

    if (p)
    {
        // With Vanilla you have to specify the file without extension,
        // but make that optional.
        if (M_StringEndsWith(myargv[p + 1], ".lmp"))
        {
            M_StringCopy(file, myargv[p + 1], sizeof(file));
        }
        else
        {
            DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
        }

        if (D_AddFile (file))
        {
            M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name,
                         sizeof(demolumpname));
        }
        else
        {
            // If file failed to load, still continue trying to play
            // the demo in the same way as Vanilla Doom.  This makes
            // tricks like "-playdemo demo1" possible.

            M_StringCopy(demolumpname, myargv[p + 1], sizeof(demolumpname));
        }

        printf("Playing demo %s.\n", file);
    }

    I_AtExit((atexit_func_t) G_CheckDemoStatus, true);

    // Generate the WAD hash table.  Speed things up a bit.

    W_GenerateHashTable();
    
    D_IdentifyVersion();
    InitGameVersion();
    D_SetGameDescription();
    savegamedir = M_GetSaveGameDir("strife1.wad");

    // fraggle 20130405: I_InitTimer is needed here for the netgame
    // startup. Start low-level sound init here too.
    I_InitTimer();
    I_InitSound(true);
    I_InitMusic();

#ifdef FEATURE_MULTIPLAYER
    if(devparm) // [STRIFE]
        printf ("NET_Init: Init network subsystem.\n");
    NET_Init();
#endif
    D_ConnectNetGame();

    // haleyjd 20110210: Create Strife hub save folders
    M_CreateSaveDirs(savegamedir);

    I_GraphicsCheckCommandLine();

    // haleyjd 20110206 [STRIFE] Startup the introduction sequence
    D_InitIntroSequence();

    // haleyjd 20110924: moved S_Init up to here
    if(devparm) // [STRIFE]
        DEH_printf("S_Init: Setting up sound.\n");
    S_Init (sfxVolume * 8, musicVolume * 8, voiceVolume * 8); // [STRIFE]: voice
    D_IntroTick(); // [STRIFE]

    // Check for -file in shareware
    if (modifiedgame)
    {
        // These are the lumps that will be checked in IWAD,
        // if any one is not present, execution will be aborted.
        // haleyjd 08/22/2010: [STRIFE] Check for Strife lumps.
        char name[3][8]=
        {
            "map23", "map30", "ROB3E1"
        };
        int i;

        // haleyjd 08/22/2010: [STRIFE] Changed string to match binary
        // STRIFE-FIXME: Needs to test isdemoversion variable
        if ( gamemode == shareware)
            I_Error(DEH_String("\nYou cannot -file with the demo "
                               "version. You must buy the real game!"));

        // Check for fake IWAD with right name,
        // but w/o all the lumps of the registered version. 
        // STRIFE-FIXME: Needs to test isregistered variable
        if (gamemode == registered)
            for (i = 0; i < 3; i++)
                if (W_CheckNumForName(name[i])<0)
                    I_Error(DEH_String("\nThis is not the registered version."));
    }
    
    D_IntroTick(); // [STRIFE]
    
    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 1;
    autostart = false;

    //!
    // @arg <skill>
    // @vanilla
    //
    // Set the game skill, 1-5 (1: easiest, 5: hardest).  A skill of
    // 0 disables all monsters.
    //

    p = M_CheckParmWithArgs("-skill", 1);

    if (p)
    {
        startskill = myargv[p+1][0]-'1';
        autostart = true;
    }

    // [STRIFE] no such thing in Strife
    //
    // // @arg <n>
    // // @vanilla
    // //
    // // Start playing on episode n (1-4)
    // //

    // p = M_CheckParmWithArgs("-episode", 1);

    // if (p)
    // {
    //     startepisode = myargv[p+1][0]-'0';
    //     startmap = 1;
    //     autostart = true;
    // }

    timelimit = 0;

    //! 
    // @arg <n>
    // @category net
    // @vanilla
    //
    // For multiplayer games: exit each level after n minutes.
    //

    p = M_CheckParmWithArgs("-timer", 1);

    if (p)
    {
        timelimit = atoi(myargv[p+1]);
        printf("timer: %i\n", timelimit);
    }

    //!
    // @category net
    // @vanilla
    //
    // Austin Virtual Gaming: end levels after 20 minutes.
    //

    p = M_CheckParm ("-avg");

    if (p)
    {
        timelimit = 20;
    }

    //!
    // @arg x
    // @vanilla
    //
    // Start a game immediately, warping to level x.
    //

    p = M_CheckParmWithArgs("-warp", 1);

    if (p)
    {
        if (gamemode == commercial)
            startmap = atoi (myargv[p+1]);
        else
        {
            startepisode = myargv[p+1][0]-'0';

            if (p + 2 < myargc)
            {
                startmap = myargv[p+2][0]-'0';
            }
            else
            {
                startmap = 1;
            }
        }
        autostart = true;
    }

    if (testcontrols)
    {
        startepisode = 1;
        startmap = 3;
        autostart = true;
    }

    // Check for load game parameter
    // We do this here and save the slot number, so that the network code
    // can override it or send the load slot to other players.

    //!
    // @arg <s>
    // @vanilla
    //
    // Load the game in slot s.
    //

    p = M_CheckParmWithArgs("-loadgame", 1);
    
    if (p)
    {
        startloadgame = atoi(myargv[p+1]);
    }
    else
    {
        // Not loading a game
        startloadgame = -1;
    }

    if (W_CheckNumForName("SS_START") >= 0
     || W_CheckNumForName("FF_END") >= 0)
    {
        I_PrintDivider();
        printf(" WARNING: The loaded WAD file contains modified sprites or\n"
               " floor textures.  You may want to use the '-merge' command\n"
               " line option instead of '-file'.\n");
    }

    I_PrintStartupBanner(gamedescription);
    PrintDehackedBanners();

    // haleyjd 08/28/10: Init Choco Strife stuff.
    D_InitChocoStrife();

    // haleyjd 08/22/2010: [STRIFE] Modified string to match binary
    if(devparm) // [STRIFE]
       DEH_printf("R_Init: Loading Graphics - ");
    R_Init ();
    D_IntroTick(); // [STRIFE]

    if(devparm) // [STRIFE]
        DEH_printf("\nP_Init: Init Playloop state.\n");
    P_Init ();
    D_IntroTick(); // [STRIFE]

    if(devparm) // [STRIFE]
        DEH_printf("I_Init: Setting up machine state.\n");
    I_CheckIsScreensaver();
    I_InitJoystick();
    D_IntroTick(); // [STRIFE]

    D_IntroTick(); // [STRIFE]

    if(devparm) // [STRIFE]
        DEH_printf("M_Init: Init Menu.\n");
    M_Init ();
    D_IntroTick(); // [STRIFE]

    // haleyjd 20110924: Moved S_Init up.
    D_IntroTick();

    // haleyjd 20110220: This stuff was done in I_StartupSound in vanilla, but 
    // we'll do it here instead so we don't have to modify the low-level shared
    // code with Strife-specific stuff.

    //!
    // @vanilla
    //
    // Disable voice dialog and show dialog as text instead,
    // even if voices.wad can be found.
    //

    if(disable_voices || M_CheckParm("-novoice"))
    {
        dialogshowtext = disable_voices = 1;
    }

    if(devparm)
        DEH_printf("  Play voices = %d\n", disable_voices == 0);

    if(devparm) // [STRIFE]
        DEH_printf("D_CheckNetGame: Checking network game status.\n");
    D_CheckNetGame ();

    PrintGameVersion();

    if(devparm)
        DEH_printf("HU_Init: Setting up heads up display.\n");
    HU_Init ();
    D_IntroTick(); // [STRIFE]

    if(devparm)
        DEH_printf("ST_Init: Init status bar.\n");
    ST_Init ();
    D_IntroTick(); // [STRIFE]

    // haleyjd [STRIFE] -statcopy used to be here...
    D_IntroTick(); // [STRIFE]

    // If Doom II without a MAP01 lump, this is a store demo.  
    // Moved this here so that MAP01 isn't constantly looked up
    // in the main loop.
    // haleyjd 08/23/2010: [STRIFE] There is no storedemo version of Strife
    /*
    if (gamemode == commercial && W_CheckNumForName("map01") < 0)
        storedemo = true;
    */

    //!
    // @arg <x>
    // @category demo
    // @vanilla
    //
    // Record a demo named x.lmp.
    //

    p = M_CheckParmWithArgs("-record", 1);

    if (p)
    {
        G_RecordDemo (myargv[p+1]);
        autostart = true;
    }
    D_IntroTick(); // [STRIFE]

    p = M_CheckParmWithArgs("-playdemo", 1);
    if (p)
    {
        singledemo = true;              // quit after one demo
        G_DeferedPlayDemo (demolumpname);
        D_DoomLoop ();  // never returns
    }
    D_IntroTick(); // [STRIFE]

    p = M_CheckParmWithArgs("-timedemo", 1);
    if (p)
    {
        G_TimeDemo (demolumpname);
        D_DoomLoop ();  // never returns
    }
    D_IntroTick(); // [STRIFE]

    if (startloadgame >= 0)
    {
        // [STRIFE]: different, for hubs
        M_LoadSelect(startloadgame);
    }
    D_IntroTick(); // [STRIFE]


    if (gameaction != ga_loadgame )
    {
        if (autostart || netgame)
            G_InitNew (startskill, startmap);
        else
            D_StartTitle ();                // start up intro loop
    }

    D_DoomLoop ();  // never returns
}
Ejemplo n.º 11
0
void I_InitSound (void)
{
	if(Args.CheckParm("-nosound"))
		return;

	const char *driver = getenv("SDL_AUDIODRIVER");

	if(!driver)
		driver = "default";

	Printf(PRINT_HIGH, "I_InitSound: Initializing SDL's sound subsystem (%s)\n", driver);

	if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
	{
		Printf(PRINT_HIGH, 
               "I_InitSound: Unable to set up sound: %s\n", 
               SDL_GetError());
               
		return;
	}

	const SDL_version *ver = Mix_Linked_Version();

	if(ver->major != MIX_MAJOR_VERSION
		|| ver->minor != MIX_MINOR_VERSION)
	{
		Printf(PRINT_HIGH, "I_InitSound: SDL_mixer version conflict (%d.%d.%d vs %d.%d.%d dll)\n",
			MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL,
			ver->major, ver->minor, ver->patch);
		return;
	}

	if(ver->patch != MIX_PATCHLEVEL)
	{
		Printf(PRINT_HIGH, "I_InitSound: SDL_mixer version warning (%d.%d.%d vs %d.%d.%d dll)\n",
			MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL,
			ver->major, ver->minor, ver->patch);
	}

	Printf(PRINT_HIGH, "I_InitSound: Initializing SDL_mixer\n");

    if (Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 1024) < 0)
	{
		Printf(PRINT_HIGH, 
               "I_InitSound: Error initializing SDL_mixer: %s\n", 
               Mix_GetError());
		return;
	}

    if(!Mix_QuerySpec(&mixer_freq, &mixer_format, &mixer_channels))
	{
		Printf(PRINT_HIGH, 
               "I_InitSound: Error initializing SDL_mixer: %s\n", 
               Mix_GetError());
		return;
	}
	
	Printf(PRINT_HIGH, 
           "I_InitSound: Using %d channels (freq:%d, fmt:%d, chan:%d)\n",
           Mix_AllocateChannels(NUM_CHANNELS),
		   mixer_freq, mixer_format, mixer_channels);

	atterm(I_ShutdownSound);

	sound_initialized = true;

	SDL_PauseAudio(0);

	Printf(PRINT_HIGH, "I_InitSound: sound module ready\n");

	I_InitMusic();

        // Half of fix for stopping wrong sound, these need to be -1
        // to be regarded as empty (they'd be initialised to something weird)
    memset(channel_in_use, -1, sizeof(channel_in_use));
}