void G_DoLoadLevel (void) { int i; for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; players[i].frags = 0; } /* */ /* set the sky map for the episode */ /* */ if (gamemap < 9) skytexture = R_TextureNumForName ("SKY1"); else if (gamemap < 18) skytexture = R_TextureNumForName ("SKY2"); else skytexture = R_TextureNumForName ("SKY3"); skytexturep = &textures[skytexture]; P_SetupLevel (gamemap, gameskill); displayplayer = consoleplayer; /* view the guy you are playing */ gameaction = ga_nothing; /* S_StartSong(1, 0); */ /* Added CEF */ Z_CheckHeap (mainzone); /* DEBUG */ }
void G_DoLoadLevel(void) { int i; levelstarttic = gametic; // for time calculation gamestate = GS_LEVEL; for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; memset(players[i].frags, 0, sizeof(players[i].frags)); } P_SetupLevel(gameepisode, gamemap, 0, gameskill); displayplayer = consoleplayer; // view the guy you are playing gameaction = ga_nothing; Z_CheckHeap(); // // clear cmd building stuff // memset(gamekeydown, 0, sizeof(gamekeydown)); joyxmove = joyymove = joystrafemove = 0; mousex = mousey = 0; sendpause = sendsave = paused = false; memset(mousearray, 0, sizeof(mousearray)); memset(joyarray, 0, sizeof(joyarray)); if (testcontrols) { P_SetMessage(&players[consoleplayer], "PRESS ESCAPE TO QUIT.", false); } }
// // 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 } }
// // 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 } }
void G_DoLoadLevel (int position, bool autosave) { static int lastposition = 0; gamestate_t oldgs = gamestate; int i; if (NextSkill >= 0) { UCVarValue val; val.Int = NextSkill; gameskill.ForceSet (val, CVAR_Int); NextSkill = -1; } if (position == -1) position = lastposition; else lastposition = position; G_InitLevelLocals (); StatusBar->DetachAllMessages (); // Force 'teamplay' to 'true' if need be. if (level.flags2 & LEVEL2_FORCETEAMPLAYON) teamplay = true; // Force 'teamplay' to 'false' if need be. if (level.flags2 & LEVEL2_FORCETEAMPLAYOFF) teamplay = false; Printf ( "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" "\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" TEXTCOLOR_BOLD "%s - %s\n\n", level.MapName.GetChars(), level.LevelName.GetChars()); if (wipegamestate == GS_LEVEL) wipegamestate = GS_FORCEWIPE; if (gamestate != GS_TITLELEVEL) { gamestate = GS_LEVEL; } // Set the sky map. // First thing, we have a dummy sky texture name, // a flat. The data is in the WAD only because // we look for an actual index, instead of simply // setting one. skyflatnum = TexMan.GetTexture (gameinfo.SkyFlatName, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); // DOOM determines the sky texture to be used // depending on the current episode and the game version. // [RH] Fetch sky parameters from FLevelLocals. sky1texture = level.skytexture1; sky2texture = level.skytexture2; // [RH] Set up details about sky rendering R_InitSkyMap (); for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && (deathmatch || players[i].playerstate == PST_DEAD)) players[i].playerstate = PST_ENTER; // [BC] memset (players[i].frags,0,sizeof(players[i].frags)); if (!(dmflags2 & DF2_YES_KEEPFRAGS) && (alwaysapplydmflags || deathmatch)) players[i].fragcount = 0; } if (changeflags & CHANGELEVEL_NOMONSTERS) { level.flags2 |= LEVEL2_NOMONSTERS; } else { level.flags2 &= ~LEVEL2_NOMONSTERS; } if (changeflags & CHANGELEVEL_PRERAISEWEAPON) { level.flags2 |= LEVEL2_PRERAISEWEAPON; } level.maptime = 0; P_SetupLevel (level.MapName, position); AM_LevelInit(); // [RH] Start lightning, if MAPINFO tells us to if (level.flags & LEVEL_STARTLIGHTNING) { P_StartLightning (); } gameaction = ga_nothing; // clear cmd building stuff ResetButtonStates (); SendItemUse = NULL; SendItemDrop = NULL; mousex = mousey = 0; sendpause = sendsave = sendturn180 = SendLand = false; LocalViewAngle = 0; LocalViewPitch = 0; paused = 0; //Added by MC: Initialize bots. if (deathmatch) { bglobal.Init (); } if (timingdemo) { static bool firstTime = true; if (firstTime) { starttime = I_GetTime (false); firstTime = false; } } level.starttime = gametic; G_UnSnapshotLevel (!savegamerestore); // [RH] Restore the state of the level. G_FinishTravel (); // For each player, if they are viewing through a player, make sure it is themselves. for (int ii = 0; ii < MAXPLAYERS; ++ii) { if (playeringame[ii] && (players[ii].camera == NULL || players[ii].camera->player != NULL)) { players[ii].camera = players[ii].mo; } } StatusBar->AttachToPlayer (&players[consoleplayer]); P_DoDeferedScripts (); // [RH] Do script actions that were triggered on another map. if (demoplayback || oldgs == GS_STARTUP || oldgs == GS_TITLELEVEL) C_HideConsole (); C_FlushDisplay (); // [RH] Always save the game when entering a new level. if (autosave && !savegamerestore && disableautosave < 1) { DAutosaver GCCNOWARN *dummy = new DAutosaver; } }
void G_DoLoadLevel(void) { int i; mapdef_t* map; for(i = 0; i < MAXPLAYERS; i++) { if(playeringame[i] && players[i].playerstate == PST_DEAD) { players[i].playerstate = PST_REBORN; } dmemset(players[i].frags, 0, sizeof(players[i].frags)); } basetic = gametic; // update settings from server cvar if(!netgame) { gameskill = (int)sv_skill.value; respawnparm = (int)sv_respawn.value; respawnitem = (int)sv_respawnitems.value; fastparm = (int)sv_fastmonsters.value; nomonsters = (int)sv_nomonsters.value; } map = P_GetMapInfo(gamemap); if(map == NULL) { // boot out to main menu gameaction = ga_title; return; } forcecollision = map->oldcollision; forcejump = map->allowjump; forcefreelook = map->allowfreelook; // This was quite messy with SPECIAL and commented parts. // Supposedly hacks to make the latest edition work. // It might not work properly. G_SetFastParms(fastparm || gameskill == sk_nightmare); // killough 4/10/98 if(gameskill == sk_nightmare || respawnparm) { respawnmonsters = true; } else { respawnmonsters = false; } if(respawnitem) { respawnspecials = true; } else { respawnspecials = false; } P_SetupLevel(gamemap, 0, gameskill); displayplayer = consoleplayer; // view the guy you are playing starttime = I_GetTime(); gameaction = ga_nothing; // clear cmd building stuff G_ClearInput(); sendpause = sendsave = paused = false; }