// sets the modenum as the new default video mode to be saved in the config file void SCR_SetDefaultMode(void) { // remember the default screen size CV_SetValue(&cv_scr_width, vid.width); CV_SetValue(&cv_scr_height, vid.height); CV_SetValue(&cv_scr_depth, vid.bpp*8); }
// // P_DoTeamscrambling() // // If a team scramble has been started, scramble one person from the // pre-made scramble array. Said array is created in TeamScramble_OnChange() // void P_DoTeamscrambling(void) { changeteam_union NetPacket; UINT16 usvalue; NetPacket.value.l = NetPacket.value.b = 0; // Only do it if we have enough room in the net buffer to send it. // Otherwise, come back next time and try again. if (sizeof(usvalue) > GetFreeXCmdSize()) return; if (scramblecount < scrambletotal) { if (players[scrambleplayers[scramblecount]].ctfteam != scrambleteams[scramblecount]) { NetPacket.packet.newteam = scrambleteams[scramblecount]; NetPacket.packet.playernum = scrambleplayers[scramblecount]; NetPacket.packet.verification = true; NetPacket.packet.scrambled = true; usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } scramblecount++; //Increment, and get to the next player when we come back here next time. } else CV_SetValue(&cv_teamscramble, 0); }
boolean I_SetVolumeCD (INT32 volume) { #ifdef NOSDLCD (void)volume; #else if (volume != cdvolume) { if (volume > 0 && volume < 16) { CV_SetValue(&cd_volume, 31); cdvolume = 31; I_ResumeCD(); } else if (volume > 15 && volume < 31) { CV_SetValue(&cd_volume, 0); cdvolume = 0; I_PauseCD(); } } #endif return 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)) 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 } }
// ======================================================================== // Sets a video mode // ======================================================================== INT32 VID_SetMode(INT32 modenum) { int vstat; vmode_t *pnewmode; if (dedicated) return 0; DEBPRINT(va("VID_SetMode(%d)\n", modenum)); // if mode 0 (windowed) we must not be fullscreen already, // if other mode, check it is not mode 0 and existing if ((modenum >= NUMSPECIALMODES) || bAppFullScreen) { if (modenum > numvidmodes || modenum < NUMSPECIALMODES) { if (!pcurrentmode) modenum = 0; // revert to the default base vid mode else I_Error("Unknown video mode: %d\n", modenum); } } pnewmode = VID_GetModePtr(modenum); // dont switch to the same display mode if (pnewmode == pcurrentmode) return 1; // initialize the new mode pcurrentmode = pnewmode; // initialize vidbuffer size for setmode vid.width = pcurrentmode->width; vid.height = pcurrentmode->height; vid.rowbytes = pcurrentmode->rowbytes; vid.bpp = pcurrentmode->bytesperpixel; if (modenum) // if not 320x200 windowed mode, it's actually a hack { if (rendermode == render_opengl) { // don't accept depth < 16 for OpenGL mode (too much ugly) if (cv_scr_depth.value < 16) CV_SetValue(&cv_scr_depth, 16); vid.bpp = cv_scr_depth.value/8; vid.u.windowed = (bWinParm || !cv_fullscreen.value); pcurrentmode->bytesperpixel = vid.bpp; pcurrentmode->windowed = vid.u.windowed; } } vstat = (*pcurrentmode->setmode)(&vid, pcurrentmode); if (vstat == -1) I_Error("Not enough mem for VID_SetMode\n"); else if (vstat == -2) I_Error("Couldn't set video mode because it failed the test\n"); else if (vstat == -3) I_Error("Couldn't set video mode because it failed the change?\n"); else if (!vstat) I_Error("Couldn't set video mode %d (%dx%d %d bits)\n", modenum, vid.width, vid.height, (vid.bpp*8));// hardware could not setup mode else CONS_Printf(M_GetText("Mode changed to %d (%s)\n"), modenum, pcurrentmode->name); vid.modenum = modenum; // tell game engine to recalc all tables and realloc buffers based on new values vid.recalc = 1; if (modenum < NUMSPECIALMODES) { // we are in startup windowed mode bAppFullScreen = FALSE; bDIBMode = TRUE; } else { // we switch to fullscreen bAppFullScreen = TRUE; bDIBMode = FALSE; #ifdef HWRENDER if (rendermode != render_soft) { // purge all patch graphics stored in software format //Z_FreeTags (PU_PURGELEVEL, PU_PURGELEVEL+100); HWR_Startup(); } #endif } I_RestartSysMouse(); return 1; }