void M_LoadDefaults (void) { int i; // check for a custom default file //! // @arg <file> // @vanilla // // Load main configuration from the specified file, instead of the // default. // i = M_CheckParmWithArgs("-config", 1); if (i) { doom_defaults.filename = myargv[i+1]; printf (" default file: %s\n",doom_defaults.filename); } else { doom_defaults.filename = malloc(strlen(configdir) + strlen(default_main_config) + 1); sprintf(doom_defaults.filename, "%s%s", configdir, default_main_config); } printf("saving config in %s\n", doom_defaults.filename); //! // @arg <file> // // Load additional configuration from the specified file, instead of // the default. // i = M_CheckParmWithArgs("-extraconfig", 1); if (i) { extra_defaults.filename = myargv[i+1]; printf(" extra configuration file: %s\n", extra_defaults.filename); } else { extra_defaults.filename = malloc(strlen(configdir) + strlen(default_extra_config) + 1); sprintf(extra_defaults.filename, "%s%s", configdir, default_extra_config); } LoadDefaultCollection(&doom_defaults); LoadDefaultCollection(&extra_defaults); }
// // Startup tasks for the frontend. // static void FE_Init(void) { int p; srand(time(NULL)); frontend_done = false; frontend_state = FE_STATE_MAINMENU; frontend_sgcount = 20; frontend_wipe = true; frontend_waitframe = false; currentFEMenu = &mainMenu; S_ChangeMusic(mus_panthr, 1); FE_InitMerchant(); FE_InitBackgrounds(); FE_LoadSlider(); FE_BindMusicTestVar(); // check for +connect_lobby from the Steam client if((p = M_CheckParmWithArgs("+connect_lobby", 1)) > 0) { frontend_autolobby = true; frontend_lobbyid = myargv[p + 1]; } else FE_EnableLobbyListener(); // can accept invites I_SetShowVisualCursor(true); frontend_running = true; }
byte *I_ZoneBase (int *size) { byte *zonemem; int min_ram, default_ram; int p; //! // @arg <mb> // // Specify the heap size, in MiB (default 16). // p = M_CheckParmWithArgs("-mb", 1); if (p > 0) { default_ram = atoi(myargv[p+1]); min_ram = default_ram; } else { default_ram = DEFAULT_RAM; min_ram = MIN_RAM; } zonemem = AutoAllocMemory(size, default_ram, min_ram); printf("zone memory: %p, %x allocated for zone\n", zonemem, *size); return zonemem; }
static boolean NET_SDL_InitServer(void) { int p; if (initted) return true; p = M_CheckParmWithArgs("-port", 1); if (p > 0) port = atoi(myargv[p+1]); SDLNet_Init(); udpsocket = SDLNet_UDP_Open(port); if (udpsocket == NULL) { I_Error("NET_SDL_InitServer: Unable to bind to port %i", port); } recvpacket = SDLNet_AllocPacket(1500); #ifdef DROP_PACKETS srand(time(NULL)); #endif initted = true; return true; }
void NET_SV_SendQueryResponse(net_addr_t *addr) { net_packet_t *reply; net_querydata_t querydata; int p; // Version querydata.version = PACKAGE_STRING; // Server state querydata.server_state = server_state; // Number of players/maximum players querydata.num_players = NET_SV_NumPlayers(); querydata.max_players = NET_SV_MaxPlayers(); // Game mode/mission querydata.gamemode = sv_gamemode; querydata.gamemission = sv_gamemission; //! // @category net // @arg <name> // // When starting a network server, specify a name for the server. // p = M_CheckParmWithArgs("-servername", 1); if (p > 0) { querydata.description = myargv[p + 1]; } else { querydata.description = "Unnamed server"; } // Send it and we're done. NET_Log("server: sending query response to %s", NET_AddrToString(addr)); reply = NET_NewPacket(64); NET_WriteInt16(reply, NET_PACKET_TYPE_QUERY_RESPONSE); NET_WriteQueryData(reply, &querydata); NET_SendPacket(addr, reply); NET_FreePacket(reply); }
static void InitGameVersion(void) { int p; int i; // haleyjd: we support emulating either the 1.2 or the 1.31 versions of // Strife, which are the most significant. 1.2 is the most mature version // that still has the single saveslot restriction, whereas 1.31 is the // final revision. The differences between the two are barely worth // mentioning aside from that main one. //! // @arg <version> // @category compat // // Emulate a specific version of Strife. Valid values are "1.2" and "1.31". // p = M_CheckParmWithArgs("-gameversion", 1); if (p) { for (i=0; gameversions[i].description != NULL; ++i) { if (!strcmp(myargv[p+1], gameversions[i].cmdline)) { gameversion = gameversions[i].version; break; } } if (gameversions[i].description == NULL) { printf("Supported game versions:\n"); for (i=0; gameversions[i].description != NULL; ++i) { printf("\t%s (%s)\n", gameversions[i].cmdline, gameversions[i].description); } I_Error("Unknown game version '%s'", myargv[p+1]); } } else { gameversion = exe_strife_1_31; } }
// // M_LoadDefaults // void M_LoadDefaults(void) { int i; // check for a custom default file i = M_CheckParmWithArgs("-config", 1); if (i) doom_defaults.filename = myargv[i + 1]; else doom_defaults.filename = PACKAGE_CONFIG; LoadDefaultCollection(&doom_defaults); M_CheckDefaults(); }
char *D_FindIWAD(int mask, GameMission_t *mission) { char *result; char *iwadfile; int iwadparm; int i; // Check for the -iwad parameter //! // Specify an IWAD file to use. // // @arg <file> // iwadparm = M_CheckParmWithArgs("-iwad", 1); if (iwadparm) { // Search through IWAD dirs for an IWAD with the given name. iwadfile = myargv[iwadparm + 1]; result = D_FindWADByName(iwadfile); if (result == NULL) { I_Error("IWAD file '%s' not found!", iwadfile); } *mission = IdentifyIWADByName(result, mask); } else { // Search through the list and look for an IWAD result = NULL; BuildIWADDirList(); for (i=0; result == NULL && i<num_iwad_dirs; ++i) { result = SearchDirectoryForIWAD(iwad_dirs[i], mask, mission); } } return result; }
void StatDump(void) { FILE *dumpfile; int i; //! // @category compat // @arg <filename> // // Dump statistics information to the specified file on the levels // that were played. The output from this option matches the output // from statdump.exe (see ctrlapi.zip in the /idgames archive). // i = M_CheckParmWithArgs("-statdump", 1); if (i > 0) { printf("Statistics captured for %i level(s)\n", num_captured_stats); // We actually know what the real gamemission is, but this has // to match the output from statdump.exe. DiscoverGamemode(captured_stats, num_captured_stats); // Allow "-" as output file, for stdout. if (strcmp(myargv[i + 1], "-") != 0) { dumpfile = fopen(myargv[i + 1], "w"); } else { dumpfile = NULL; } for (i = 0; i < num_captured_stats; ++i) { PrintStats(dumpfile, &captured_stats[i]); } if (dumpfile != NULL) { fclose(dumpfile); } } }
static void ParseCommandLineArgs(void) { int i; //! // @arg <n> // @category net // // Autostart the netgame when n nodes (clients) have joined the server. // i = M_CheckParmWithArgs("-nodes", 1); if (i > 0) { expected_nodes = atoi(myargv[i + 1]); } }
static void InitConnectData(net_connect_data_t *connect_data) { int i; // // Connect data // // Game type fields: connect_data->gamemode = gamemode; connect_data->gamemission = hexen; connect_data->lowres_turn = false; connect_data->drone = false; connect_data->max_players = MAXPLAYERS; //! // @category net // @arg <n> // // Specify player class: 0=fighter, 1=cleric, 2=mage, 3=pig. // i = M_CheckParmWithArgs("-class", 1); if (i > 0) { connect_data->player_class = atoi(myargv[i + 1]); } else { connect_data->player_class = PCLASS_FIGHTER; } // Read checksums of our WAD directory and dehacked information W_Checksum(connect_data->wad_sha1sum); memset(connect_data->deh_sha1sum, 0, sizeof(sha1_digest_t)); connect_data->is_freedoom = 0; }
// // FindIWAD // Checks availability of IWAD files by name, // to determine whether registered/commercial features // should be executed (notably loading PWADs). // char *D_FindIWAD(void) { char *result = NULL; char *iwadfile; int iwadparm = M_CheckParmWithArgs("-iwad", 1); if (iwadparm) { // Search through IWAD dirs for an IWAD with the given name. iwadfile = myargv[iwadparm + 1]; result = D_FindWADByName(iwadfile); if (result == NULL) I_Error("The IWAD file \"%s\" wasn't found!", iwadfile); IdentifyIWADByName(result); } return result; }
static boolean NET_SDL_InitClient(void) { int p; if (initted) return true; //! // @category net // @arg <n> // // Use the specified UDP port for communications, instead of // the default (2342). // p = M_CheckParmWithArgs("-port", 1); if (p > 0) port = atoi(myargv[p+1]); SDLNet_Init(); udpsocket = SDLNet_UDP_Open(0); if (udpsocket == NULL) { I_Error("NET_SDL_InitClient: Unable to open a socket!"); } recvpacket = SDLNet_AllocPacket(1500); #ifdef DROP_PACKETS srand(time(NULL)); #endif initted = true; return true; }
static void DonutOverrun(fixed_t *s3_floorheight, short *s3_floorpic, line_t *line, sector_t *pillar_sector) { static int first = 1; static int tmp_s3_floorheight; static int tmp_s3_floorpic; extern int numflats; if (first) { int p; // This is the first time we have had an overrun. first = 0; // Default values tmp_s3_floorheight = DONUT_FLOORHEIGHT_DEFAULT; tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT; //! // @category compat // @arg <x> <y> // // Use the specified magic values when emulating behavior caused // by memory overruns from improperly constructed donuts. // In Vanilla Doom this can differ depending on the operating // system. The default (if this option is not specified) is to // emulate the behavior when running under Windows 98. p = M_CheckParmWithArgs("-donut", 2); if (p > 0) { // Dump of needed memory: (fixed_t)0000:0000 and (short)0000:0008 // // C:\>debug // -d 0:0 // // DOS 6.22: // 0000:0000 (57 92 19 00) F4 06 70 00-(16 00) // DOS 7.1: // 0000:0000 (9E 0F C9 00) 65 04 70 00-(16 00) // Win98: // 0000:0000 (00 00 00 00) 65 04 70 00-(16 00) // DOSBox under XP: // 0000:0000 (00 00 00 F1) ?? ?? ?? 00-(07 00) M_StrToInt(myargv[p + 1], &tmp_s3_floorheight); M_StrToInt(myargv[p + 2], &tmp_s3_floorpic); if (tmp_s3_floorpic >= numflats) { fprintf(stderr, "DonutOverrun: The second parameter for \"-donut\" " "switch should be greater than 0 and less than number " "of flats (%d). Using default value (%d) instead. \n", numflats, DONUT_FLOORPIC_DEFAULT); tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT; } } } /* fprintf(stderr, "Linedef: %d; Sector: %d; " "New floor height: %d; New floor pic: %d\n", line->iLineID, pillar_sector->iSectorID, tmp_s3_floorheight >> 16, tmp_s3_floorpic); */ *s3_floorheight = (fixed_t) tmp_s3_floorheight; *s3_floorpic = (short) tmp_s3_floorpic; }
int M_CheckParm(char *check) { return M_CheckParmWithArgs(check, 0); }
static void InitGameVersion(void) { byte *demolump; char demolumpname[6]; int demoversion; int p; int i; boolean status; //! // @arg <version> // @category compat // // Emulate a specific version of Doom. Valid values are "1.666", // "1.7", "1.8", "1.9", "ultimate", "final", "final2", "hacx" and // "chex". // p = M_CheckParmWithArgs("-gameversion", 1); if (p) { for (i=0; gameversions[i].description != NULL; ++i) { if (!strcmp(myargv[p+1], gameversions[i].cmdline)) { gameversion = gameversions[i].version; break; } } if (gameversions[i].description == NULL) { printf("Supported game versions:\n"); for (i=0; gameversions[i].description != NULL; ++i) { printf("\t%s (%s)\n", gameversions[i].cmdline, gameversions[i].description); } I_Error("Unknown game version '%s'", myargv[p+1]); } } else { // Determine automatically if (gamemission == pack_chex) { // chex.exe - identified by iwad filename gameversion = exe_chex; } else if (gamemission == pack_hacx) { // hacx.exe: identified by iwad filename gameversion = exe_hacx; } else if (gamemode == shareware || gamemode == registered || (gamemode == commercial && gamemission == doom2)) { // original gameversion = exe_doom_1_9; // Detect version from demo lump for (i = 1; i <= 3; ++i) { M_snprintf(demolumpname, 6, "demo%i", i); if (W_CheckNumForName(demolumpname) > 0) { demolump = W_CacheLumpName(demolumpname, PU_STATIC); demoversion = demolump[0]; W_ReleaseLumpName(demolumpname); status = true; switch (demoversion) { case 106: gameversion = exe_doom_1_666; break; case 107: gameversion = exe_doom_1_7; break; case 108: gameversion = exe_doom_1_8; break; case 109: gameversion = exe_doom_1_9; break; default: status = false; break; } if (status) { break; } } } } else if (gamemode == retail) { gameversion = exe_ultimate; } else if (gamemode == commercial) { // Final Doom: tnt or plutonia // Defaults to emulating the first Final Doom executable, // which has the crash in the demo loop; however, having // this as the default should mean that it plays back // most demos correctly. gameversion = exe_final; } } // The original exe does not support retail - 4th episode not supported if (gameversion < exe_ultimate && gamemode == retail) { gamemode = registered; } // EXEs prior to the Final Doom exes do not support Final Doom. if (gameversion < exe_final && gamemode == commercial && (gamemission == pack_tnt || gamemission == pack_plut)) { gamemission = doom2; } }
void D_IdentifyVersion(void) { // gamemission is set up by the D_FindIWAD function. But if // we specify '-iwad', we have to identify using // IdentifyIWADByName. However, if the iwad does not match // any known IWAD name, we may have a dilemma. Try to // identify by its contents. if (gamemission == none) { unsigned int i; for (i=0; i<numlumps; ++i) { if (!strncasecmp(lumpinfo[i]->name, "MAP01", 8)) { gamemission = doom2; break; } else if (!strncasecmp(lumpinfo[i]->name, "E1M1", 8)) { gamemission = doom; break; } } if (gamemission == none) { // Still no idea. I don't think this is going to work. I_Error("Unknown or invalid IWAD file."); } } // Make sure gamemode is set up correctly if (logical_gamemission == doom) { // Doom 1. But which version? if (W_CheckNumForName("E4M1") > 0) { // Ultimate Doom gamemode = retail; } else if (W_CheckNumForName("E3M1") > 0) { gamemode = registered; } else { gamemode = shareware; } } else { int p; // Doom 2 of some kind. gamemode = commercial; // We can manually override the gamemission that we got from the // IWAD detection code. This allows us to eg. play Plutonia 2 // with Freedoom and get the right level names. //! // @arg <pack> // // Explicitly specify a Doom II "mission pack" to run as, instead of // detecting it based on the filename. Valid values are: "doom2", // "tnt" and "plutonia". // p = M_CheckParmWithArgs("-pack", 1); if (p > 0) { SetMissionForPackName(myargv[p + 1]); } } }
// // 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 }
boolean D_InitNetGame(net_connect_data_t *connect_data) { boolean result = false; net_addr_t *addr = NULL; int i; // Call D_QuitNetGame on exit: I_AtExit(D_QuitNetGame, true); player_class = connect_data->player_class; #ifdef FEATURE_MULTIPLAYER //! // @category net // // Start a multiplayer server, listening for connections. // if (M_CheckParm("-server") > 0 || M_CheckParm("-privateserver") > 0) { NET_SV_Init(); NET_SV_AddModule(&net_loop_server_module); NET_SV_AddModule(&net_sdl_module); NET_SV_RegisterWithMaster(); net_loop_client_module.InitClient(); addr = net_loop_client_module.ResolveAddress(NULL); } else { //! // @category net // // Automatically search the local LAN for a multiplayer // server and join it. // i = M_CheckParm("-autojoin"); if (i > 0) { addr = NET_FindLANServer(); if (addr == NULL) { I_Error("No server found on local LAN"); } } //! // @arg <address> // @category net // // Connect to a multiplayer server running on the given // address. // i = M_CheckParmWithArgs("-connect", 1); if (i > 0) { net_sdl_module.InitClient(); addr = net_sdl_module.ResolveAddress(myargv[i+1]); if (addr == NULL) { I_Error("Unable to resolve '%s'\n", myargv[i+1]); } } } if (addr != NULL) { if (M_CheckParm("-drone") > 0) { connect_data->drone = true; } if (!NET_CL_Connect(addr, connect_data)) { I_Error("D_InitNetGame: Failed to connect to %s\n", NET_AddrToString(addr)); } printf("D_InitNetGame: Connected to %s\n", NET_AddrToString(addr)); // Wait for launch message received from server. NET_WaitForLaunch(); result = true; } #endif return result; }
static void InitGameVersion(void) { int p; int i; //! // @arg <version> // @category compat // // Emulate a specific version of Doom. Valid values are "1.9", // "ultimate", "final", "final2", "hacx" and "chex". // p = M_CheckParmWithArgs("-gameversion", 1); if (p) { for (i=0; gameversions[i].description != NULL; ++i) { if (!strcmp(myargv[p+1], gameversions[i].cmdline)) { gameversion = gameversions[i].version; break; } } if (gameversions[i].description == NULL) { printf("Supported game versions:\n"); for (i=0; gameversions[i].description != NULL; ++i) { printf("\t%s (%s)\n", gameversions[i].cmdline, gameversions[i].description); } I_Error("Unknown game version '%s'", myargv[p+1]); } } else { // Determine automatically if (gameversion == exe_chex || gameversion == exe_hacx) { // Already determined } else if (gamemode == shareware || gamemode == registered) { // original gameversion = exe_doom_1_9; } else if (gamemode == retail) { gameversion = exe_ultimate; } else if (gamemode == commercial) { if (gamemission == doom2) { gameversion = exe_doom_1_9; } else { // Final Doom: tnt or plutonia // Default to the "alt" version of the executable that // fixes the demo loop behavior. gameversion = exe_final2; } } } // The original exe does not support retail - 4th episode not supported if (gameversion < exe_ultimate && gamemode == retail) { gamemode = registered; } // EXEs prior to the Final Doom exes do not support Final Doom. if (gameversion < exe_final && gamemode == commercial) { gamemission = doom2; } }
void I_GraphicsCheckCommandLine(void) { int i; //! // @vanilla // // Disable blitting the screen. // noblit = M_CheckParm ("-noblit"); //! // @category video // // Grab the mouse when running in windowed mode. // if (M_CheckParm("-grabmouse")) { grabmouse = true; } //! // @category video // // Don't grab the mouse when running in windowed mode. // if (M_CheckParm("-nograbmouse")) { grabmouse = false; } // default to fullscreen mode, allow override with command line // nofullscreen because we love prboom //! // @category video // // Run in a window. // if (M_CheckParm("-window") || M_CheckParm("-nofullscreen")) { fullscreen = false; } //! // @category video // // Run in fullscreen mode. // if (M_CheckParm("-fullscreen")) { fullscreen = true; } //! // @category video // // Disable the mouse. // nomouse = M_CheckParm("-nomouse") > 0; //! // @category video // @arg <x> // // Specify the screen width, in pixels. // i = M_CheckParmWithArgs("-width", 1); if (i > 0) { screen_width = atoi(myargv[i + 1]); } //! // @category video // @arg <y> // // Specify the screen height, in pixels. // i = M_CheckParmWithArgs("-height", 1); if (i > 0) { screen_height = atoi(myargv[i + 1]); } //! // @category video // @arg <bpp> // // Specify the color depth of the screen, in bits per pixel. // i = M_CheckParmWithArgs("-bpp", 1); if (i > 0) { screen_bpp = atoi(myargv[i + 1]); } // Because we love Eternity: //! // @category video // // Set the color depth of the screen to 32 bits per pixel. // if (M_CheckParm("-8in32")) { screen_bpp = 32; } //! // @category video // @arg <WxY>[wf] // // Specify the dimensions of the window or fullscreen mode. An // optional letter of w or f appended to the dimensions selects // windowed or fullscreen mode. i = M_CheckParmWithArgs("-geometry", 1); if (i > 0) { int w, h, s; char f; s = sscanf(myargv[i + 1], "%ix%i%1c", &w, &h, &f); if (s == 2 || s == 3) { screen_width = w; screen_height = h; if (s == 3 && f == 'f') { fullscreen = true; } else if (s == 3 && f == 'w') { fullscreen = false; } } } //! // @category video // // Don't scale up the screen. // if (M_CheckParm("-1")) { SetScaleFactor(1); } //! // @category video // // Double up the screen to 2x its normal size. // if (M_CheckParm("-2")) { SetScaleFactor(2); } //! // @category video // // Double up the screen to 3x its normal size. // if (M_CheckParm("-3")) { SetScaleFactor(3); } //! // @category video // // Disable vertical mouse movement. // if (M_CheckParm("-novert")) { novert = true; } //! // @category video // // Enable vertical mouse movement. // if (M_CheckParm("-nonovert")) { novert = false; } }
// // D_DoomMainSetup // // CPhipps - the old contents of D_DoomMain, but moved out of the main // line of execution so its stack space can be freed static void D_DoomMainSetup(void) { int p; char file[256]; int temp; int choseniwad; SDL_Init(0); M_FindResponseFile(); iwadfile = D_FindIWAD(); modifiedgame = false; nomonsters = M_CheckParm("-nomonsters"); respawnparm = M_CheckParm("-respawn"); fastparm = M_CheckParm("-fast"); devparm = M_CheckParm("-devparm"); if (M_CheckParm("-altdeath")) deathmatch = 2; else if (M_CheckParm("-deathmatch")) deathmatch = 1; M_SetConfigDir(); // turbo option p = M_CheckParm("-turbo"); if (p) { 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; 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 V_Init(); // Load configuration files before initialising other subsystems. M_LoadDefaults(); if (!M_FileExists("doomretro.wad")) if (!M_FileExists("doomretro.wad.temp")) I_Error("Can't find doomretro.wad."); if (iwadfile) { if (D_AddFile(iwadfile)) if (runcount < RUNCOUNT_MAX) runcount++; } else { if (!runcount) D_FirstUse(); rename("doomretro.wad", "doomretro.wad.temp"); do { choseniwad = D_ChooseIWAD(); if (choseniwad == -1) { rename("doomretro.wad.temp", "doomretro.wad"); I_Quit(false); } else if (!choseniwad) PlaySound((LPCTSTR)SND_ALIAS_SYSTEMHAND, NULL, SND_ALIAS_ID | SND_ASYNC); } while (!choseniwad); rename("doomretro.wad.temp", "doomretro.wad"); if (runcount < RUNCOUNT_MAX) runcount++; } M_SaveDefaults(); if (!W_MergeFile("doomretro.wad")) if (!W_MergeFile("doomretro.wad.temp")) I_Error("Can't find doomretro.wad."); if (W_CheckNumForName("BLD2A0") < 0 || W_CheckNumForName("MEDBA0") < 0 || W_CheckNumForName("STBAR2") < 0) I_Error("Wrong version of doomretro.wad."); p = M_CheckParmsWithArgs("-file", "-pwad", 1); if (p > 0) { for (p = p + 1; p < myargc && myargv[p][0] != '-'; ++p) { char *filename = uppercase(D_TryFindWADByName(myargv[p])); if (W_MergeFile(filename)) { modifiedgame = true; if (D_CheckFilename(filename, "NERVE.WAD")) nerve = true; } } } if (FREEDOOM && W_CheckNumForName("FREEDM") < 0 && !modifiedgame) I_Error("FREEDOOM requires a BOOM-compatible source port, and is therefore" "unable to be opened by DOOM RETRO."); DMENUPIC = (W_CheckNumForName("DMENUPIC") >= 0); M_DOOM = (W_CheckMultipleLumps("M_DOOM") > 1); M_EPISOD = (W_CheckMultipleLumps("M_EPISOD") > 1); M_GDHIGH = (W_CheckMultipleLumps("M_GDHIGH") > 1); M_GDLOW = (W_CheckMultipleLumps("M_GDLOW") > 1); M_LOADG = (W_CheckMultipleLumps("M_LOADG") > 1); M_LSCNTR = (W_CheckMultipleLumps("M_LSCNTR") > 1); M_MSENS = (W_CheckMultipleLumps("M_MSENS") > 1); M_MSGOFF = (W_CheckMultipleLumps("M_MSGOFF") > 1); M_MSGON = (W_CheckMultipleLumps("M_MSGON") > 1); M_NEWG = (W_CheckMultipleLumps("M_NEWG") > 1); M_NMARE = (W_CheckMultipleLumps("M_NMARE") > 1); M_OPTTTL = (W_CheckMultipleLumps("M_OPTTTL") > 1); M_PAUSE = (W_CheckMultipleLumps("M_PAUSE") > 1); M_SAVEG = (W_CheckMultipleLumps("M_SAVEG") > 1); M_SKILL = (W_CheckMultipleLumps("M_SKILL") > 1); M_SKULL1 = (W_CheckMultipleLumps("M_SKULL1") > 1); M_SVOL = (W_CheckMultipleLumps("M_SVOL") > 1); STARMS = (W_CheckMultipleLumps("STARMS") > 2); STBAR = (W_CheckMultipleLumps("STBAR") > 2); STCFN034 = (W_CheckMultipleLumps("STCFN034") > 1); STCFN039 = (W_CheckMultipleLumps("STCFN039") > 1); STCFN121 = (W_CheckMultipleLumps("STCFN121") > 1); STYSNUM0 = (W_CheckMultipleLumps("STYSNUM0") > 1); TITLEPIC = (W_CheckNumForName("TITLEPIC") >= 0); WISCRT2 = (W_CheckMultipleLumps("WISCRT2") > 1); bfgedition = (DMENUPIC && W_CheckNumForName("M_ACPT") >= 0); // Generate the WAD hash table. Speed things up a bit. W_GenerateHashTable(); D_IdentifyVersion(); InitGameVersion(); D_SetGameDescription(); D_SetSaveGameDir(); // 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][9] = { "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("You cannot use -FILE with the shareware version.\n" "Please purchase the full version."); // 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("This is not the registered version."); } // get skill / episode / map from parms startskill = sk_medium; startepisode = 1; startmap = 1; autostart = false; p = M_CheckParmWithArgs("-skill", 1); if (p) { temp = myargv[p + 1][0] - '1'; if (temp >= sk_baby && temp <= sk_nightmare) { startskill = (skill_t)temp; autostart = true; } } p = M_CheckParmWithArgs("-episode", 1); if (p) { temp = myargv[p + 1][0] - '0'; if ((gamemode == shareware && temp == 1) || (temp >= 1 && ((gamemode == registered && temp <= 3) || (gamemode == retail && temp <= 4)))) { startepisode = temp; startmap = 1; autostart = true; } } p = M_CheckParmWithArgs("-expansion", 1); if (p) { temp = myargv[p + 1][0] - '0'; if (gamemode == commercial && temp <= (nerve ? 2 : 1)) { gamemission = (temp == 1 ? doom2 : pack_nerve); selectedexpansion = temp - 1; startepisode = 1; startmap = 1; autostart = true; } } timelimit = 0; p = M_CheckParmWithArgs("-timer", 1); if (p) timelimit = atoi(myargv[p + 1]); p = M_CheckParm("-avg"); if (p) timelimit = 20; p = M_CheckParmWithArgs("-warp", 1); if (p) { static char lumpname[6]; if (gamemode == commercial) { if (strlen(myargv[p + 1]) == 5 && toupper(myargv[p + 1][0]) == 'M' && toupper(myargv[p + 1][1]) == 'A' && toupper(myargv[p + 1][2]) == 'P') startmap = (myargv[p + 1][3] - '0') * 10 + myargv[p + 1][4] - '0'; else startmap = atoi(myargv[p + 1]); sprintf(lumpname, "MAP%02i", startmap); } else { if (strlen(myargv[p + 1]) == 4 && toupper(myargv[p + 1][0]) == 'E' && toupper(myargv[p + 1][2]) == 'M') { startepisode = myargv[p + 1][1] - '0'; startmap = myargv[p + 1][3] - '0'; } else { startepisode = myargv[p + 1][0] - '0'; if (p + 2 < myargc) startmap = myargv[p + 2][0] - '0'; else startmap = 1; } sprintf(lumpname, "E%iM%i", startepisode, startmap); } if (W_CheckNumForName(lumpname) >= 0) autostart = true; } p = M_CheckParmWithArgs("-loadgame", 1); if (p) startloadgame = atoi(myargv[p + 1]); else startloadgame = -1; if (mouseSensitivity < MOUSESENSITIVITY_MIN || mouseSensitivity > MOUSESENSITIVITY_MAX) mouseSensitivity = MOUSESENSITIVITY_DEFAULT; if (mouseSensitivity == MOUSESENSITIVITY_MIN) mouseSensitivity = -5; gamepadSensitivity = (!mouseSensitivity ? 0.0f : (2.0f + mouseSensitivity / (float)MOUSESENSITIVITY_MAX)); if (sfxVolume < SFXVOLUME_MIN || sfxVolume > SFXVOLUME_MAX) sfxVolume = SFXVOLUME_DEFAULT; if (musicVolume < MUSICVOLUME_MIN || musicVolume > MUSICVOLUME_MAX) musicVolume = MUSICVOLUME_DEFAULT; if (screensize < SCREENSIZE_MIN || screensize > SCREENSIZE_MAX) screensize = SCREENSIZE_DEFAULT; if (widescreen && !fullscreen) { widescreen = false; screensize = SCREENSIZE_MAX; } if (!widescreen) hud = true; if (fullscreen && screensize == SCREENSIZE_MAX) { widescreen = true; screensize = SCREENSIZE_MAX - 1; } if (widescreen) { returntowidescreen = true; widescreen = false; } if (screenwidth && screenheight && (screenwidth < SCREENWIDTH || screenheight < SCREENHEIGHT * 3 / 4)) { screenwidth = SCREENWIDTH; screenheight = SCREENWIDTH * 3 / 4; } if (windowwidth < SCREENWIDTH || windowheight < SCREENWIDTH * 3 / 4) { windowwidth = SCREENWIDTH; windowheight = SCREENWIDTH * 3 / 4; } if (gammalevel < GAMMALEVEL_MIN || gammalevel > GAMMALEVEL_MAX) gammalevel = GAMMALEVEL_DEFAULT; gammalevelindex = 0; while (gammalevelindex < GAMMALEVELS) if (gammalevels[gammalevelindex++] == gammalevel) break; if (gammalevelindex == GAMMALEVELS) { gammalevelindex = 0; while (gammalevels[gammalevelindex++] != GAMMALEVEL_DEFAULT); } gammalevelindex--; if (bloodsplats < BLOODSPLATS_MIN || bloodsplats > BLOODSPLATS_MAX) bloodsplats = BLOODSPLATS_DEFAULT; bloodSplatSpawner = ((bloodsplats == UNLIMITED ? P_SpawnBloodSplat : (bloodsplats ? P_SpawnBloodSplat2 : P_SpawnBloodSplat3))); if (pixelwidth < PIXELWIDTH_MIN || pixelwidth > PIXELWIDTH_MAX) pixelwidth = PIXELWIDTH_DEFAULT; while (SCREENWIDTH % pixelwidth) pixelwidth--; if (pixelheight < PIXELHEIGHT_MIN || pixelheight > PIXELHEIGHT_MAX) pixelheight = PIXELHEIGHT_DEFAULT; while (SCREENHEIGHT % pixelheight) pixelheight--; M_Init(); R_Init(); P_Init(); I_Init(); S_Init((int)(sfxVolume * (127.0f / 15.0f)), (int)(musicVolume * (127.0f / 15.0f))); D_CheckNetGame(); HU_Init(); ST_Init(); AM_Init(); if (startloadgame >= 0) { M_StringCopy(file, P_SaveGameFile(startloadgame), sizeof(file)); G_LoadGame(file); } if (gameaction != ga_loadgame) { if (autostart || netgame) G_DeferredInitNew(startskill, startepisode, startmap); else D_StartTitle(); // start up intro loop } }
boolean I_GetMemoryValue(uint32_t offset, void *value, int32_t size) { static boolean firsttime = true; if (firsttime) { uint32_t p, i, val; firsttime = false; i = 0; //! // @category compat // @arg <version> // // Specify DOS version to emulate for NULL pointer dereference // emulation. Supported versions are: dos622, dos71, dosbox. // The default is to emulate DOS 7.1 (Windows 98). // p = M_CheckParmWithArgs("-setmem", 1); if (p > 0) { if (!strcasecmp(myargv[p + 1], "dos622")) { dos_mem_dump = mem_dump_dos622; } if (!strcasecmp(myargv[p + 1], "dos71")) { dos_mem_dump = mem_dump_win98; } else if (!strcasecmp(myargv[p + 1], "dosbox")) { dos_mem_dump = mem_dump_dosbox; } else { for (i=0; i<DOS_MEM_DUMP_SIZE; ++i) { ++p; if (p >= myargc || myargv[p][0] == '-') { break; } M_StrToInt(myargv[p], &val); mem_dump_custom[i++] = (unsigned char)val; } dos_mem_dump = mem_dump_custom; } } } switch (size) { case 1: *((unsigned char *)value) = dos_mem_dump[offset]; return true; case 2: *((uint16_t *)value) = dos_mem_dump[offset] | (dos_mem_dump[offset + 1] << 8); return true; case 4: *((uint32_t *)value) = dos_mem_dump[offset] | (dos_mem_dump[offset + 1] << 8) | (dos_mem_dump[offset + 2] << 16) | (dos_mem_dump[offset + 3] << 24); return true; } return false; }
void NET_CL_StartGame(void) { net_packet_t *packet; net_gamesettings_t settings; int i; // Fill in game settings structure with appropriate parameters // for the new game settings.deathmatch = deathmatch; settings.episode = startepisode; settings.map = startmap; settings.skill = startskill; settings.loadgame = startloadgame; settings.gameversion = gameversion; settings.nomonsters = nomonsters; settings.fast_monsters = fastparm; settings.respawn_monsters = respawnparm; settings.timelimit = timelimit; //! // @category net // // Use original game sync code. // if (M_CheckParm("-oldsync") > 0) settings.new_sync = 0; else settings.new_sync = 1; //! // @category net // @arg <n> // // Send n extra tics in every packet as insurance against dropped // packets. // i = M_CheckParmWithArgs("-extratics", 1); if (i > 0) settings.extratics = atoi(myargv[i+1]); else settings.extratics = 1; //! // @category net // @arg <n> // // Reduce the resolution of the game by a factor of n, reducing // the amount of network bandwidth needed. // i = M_CheckParmWithArgs("-dup", 1); if (i > 0) settings.ticdup = atoi(myargv[i+1]); else settings.ticdup = 1; // Start from a ticcmd of all zeros memset(&last_ticcmd, 0, sizeof(ticcmd_t)); // Send packet packet = NET_Conn_NewReliable(&client_connection, NET_PACKET_TYPE_GAMESTART); NET_WriteSettings(packet, &settings); }
static void InitGameVersion(void) { int p; int i; //! // @arg <version> // @category compat // // Emulate a specific version of Doom. Valid values are "1.9", // "ultimate", "final", "final2", "hacx" and "chex". // p = M_CheckParmWithArgs("-gameversion", 1); if (p) { for (i=0; gameversions[i].description != NULL; ++i) { if (!strcmp(myargv[p+1], gameversions[i].cmdline)) { gameversion = gameversions[i].version; break; } } if (gameversions[i].description == NULL) { printf("Supported game versions:\n"); for (i=0; gameversions[i].description != NULL; ++i) { printf("\t%s (%s)\n", gameversions[i].cmdline, gameversions[i].description); } I_Error("Unknown game version '%s'", myargv[p+1]); } } else { // Determine automatically if (gamemission == pack_chex) { // chex.exe - identified by iwad filename gameversion = exe_chex; } else if (gamemission == pack_hacx) { // hacx.exe: identified by iwad filename gameversion = exe_hacx; } else if (gamemode == shareware || gamemode == registered) { // original gameversion = exe_doom_1_9; // TODO: Detect IWADs earlier than Doom v1.9. } else if (gamemode == retail) { gameversion = exe_ultimate; } else if (gamemode == commercial) { if (gamemission == doom2) { gameversion = exe_doom_1_9; } else { // Final Doom: tnt or plutonia // Defaults to emulating the first Final Doom executable, // which has the crash in the demo loop; however, having // this as the default should mean that it plays back // most demos correctly. gameversion = exe_final; } } } // The original exe does not support retail - 4th episode not supported if (gameversion < exe_ultimate && gamemode == retail) { gamemode = registered; } // EXEs prior to the Final Doom exes do not support Final Doom. if (gameversion < exe_final && gamemode == commercial && (gamemission == pack_tnt || gamemission == pack_plut)) { gamemission = doom2; } }
// // D_DoomMain // void D_DoomMain (void) { int p; char file[256]; char demolumpname[9]; 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 #ifdef FEATURE_DEHACKED printf("DEH_Init: Init Dehacked support.\n"); DEH_Init(); #endif 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; //! // @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_CheckParm("-cdrom") > 0) { 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); DEH_printf("W_Init: Init WADfiles.\n"); D_AddFile(iwadfile); 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) { if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp")) { strcpy(file, myargv[p + 1]); } else { sprintf (file,"%s.lmp", myargv[p+1]); } if (D_AddFile (file)) { strncpy(demolumpname, lumpinfo[numlumps - 1].name, 8); demolumpname[8] = '\0'; printf("Playing demo %s.\n", file); } 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. strncpy(demolumpname, myargv[p + 1], 8); demolumpname[8] = '\0'; } } I_AtExit((atexit_func_t) G_CheckDemoStatus, true); // Generate the WAD hash table. Speed things up a bit. W_GenerateHashTable(); D_IdentifyVersion(); InitGameVersion(); LoadChexDeh(); LoadHacxDeh(); D_SetGameDescription(); 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(); DEH_printf("I_Init: Setting up machine state.\n"); I_CheckIsScreensaver(); I_InitTimer(); I_InitJoystick(); #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; // Doom 3: BFG Edition includes modified versions of the classic // IWADs. The modified version of doom2.wad does not have a // TITLEPIC lump, so detect this so we can apply a workaround. // We specifically check for TITLEPIC here, after PWADs have been // loaded - this means that we can play with the BFG Edition with // PWADs that change the title screen and still see the modified // titles. if (gamemode == commercial && W_CheckNumForName("titlepic") < 0) { printf("BFG Edition: Using INTERPIC instead of TITLEPIC.\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"); } 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) { strcpy(file, P_SaveGameFile(startloadgame)); 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 }
// // D_DoomMain // void D_DoomMain (void) { int p; char file[256]; char demolumpname[9]; M_FindResponseFile (); // Undocumented "search for IWADs" parameter used by the setup // tool. if (M_CheckParm("-findiwads") > 0) { D_FindInstalledIWADs(); } // print banner 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")) { printf("\nSearching for servers on Internet ...\n"); p = NET_MasterQuery(NET_QueryPrintCallback, NULL); printf("\n%i server(s) found.\n", p); 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")) { printf("\nSearching for servers on local LAN ...\n"); p = NET_LANQuery(NET_QueryPrintCallback, NULL); printf("\n%i server(s) found.\n", p); exit(0); } #endif #ifdef FEATURE_DEHACKED printf("DEH_Init: Init Dehacked support.\n"); DEH_Init(); #endif iwadfile = D_FindIWAD(); // *** PID BEGIN *** psdoom1wad = D_FindWADByName("psdoom1.wad"); psdoom2wad = D_FindWADByName("psdoom2.wad"); // *** PID END *** // 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; //! // @vanilla // // Disable monsters. // nomonsters = M_CheckParm ("-nomonsters"); // This keeps a 'no monsters' that is persistant across new games // and level warps. if ( (nomonstersperiod = M_CheckParm("-nomonsters.") ) ) { nomonsters = true; } // This makes items respawn as in -altdeath (ie. no dropped items, // no invis, no invun) respawnitems = M_CheckParm("-respawnitems"); //! // @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"); //! // @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 M_SetConfigDir(); //! // @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 (); DEH_printf("M_LoadDefaults: Load system defaults.\n"); M_ApplyPlatformDefaults(); M_LoadDefaults (); // load before initing other systems DEH_printf("W_Init: Init WADfiles.\n"); D_AddFile(iwadfile); // *** PID BEGIN *** // If the command-line flag to suppress auto-loading of custom // ps management levels is *not* there, load the appropriate level. p = M_CheckParm ("-nopslev"); if (p) { // Add psdoom1.wad if this is registered (Doom 1) or retail (Ultimite Doom). // If we loaded it, set the flag to true so we can place the monsters in the // correct positions. if ( gamemode == registered || gamemode == retail ){ D_AddFile(iwadfile); ps_level_loaded = true; } // Add psdoom2.wad if this is commercial (Doom 2) and not an add-on pack. // If we loaded it, set the flag to true so we can place the monsters in the // correct positions. if ( gamemode == commercial && gamemission == doom2 ) { D_AddFile(iwadfile); ps_level_loaded = true; } } // *** PID END *** #ifdef FEATURE_WAD_MERGE // Merged PWADs are loaded first, because they are supposed to be // modified IWADs. //! // @arg <files> // @category mod // // Simulates the behavior of deutex's -merge option, merging a PWAD // into the main IWAD. Multiple files may be specified. // p = M_CheckParmWithArgs("-merge", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging %s\n", filename); W_MergeFile(filename); } } // NWT-style merging: // NWT's -merge option: //! // @arg <files> // @category mod // // Simulates the behavior of NWT's -merge option. Multiple files // may be specified. p = M_CheckParmWithArgs("-nwtmerge", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" performing NWT-style merge of %s\n", filename); W_NWTDashMerge(filename); } } // Add flats //! // @arg <files> // @category mod // // Simulates the behavior of NWT's -af option, merging flats into // the main IWAD directory. Multiple files may be specified. // p = M_CheckParmWithArgs("-af", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging flats from %s\n", filename); W_NWTMergeFile(filename, W_NWT_MERGE_FLATS); } } //! // @arg <files> // @category mod // // Simulates the behavior of NWT's -as option, merging sprites // into the main IWAD directory. Multiple files may be specified. // p = M_CheckParmWithArgs("-as", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging sprites from %s\n", filename); W_NWTMergeFile(filename, W_NWT_MERGE_SPRITES); } } //! // @arg <files> // @category mod // // Equivalent to "-af <files> -as <files>". // p = M_CheckParmWithArgs("-aa", 1); if (p > 0) { for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p) { char *filename; filename = D_TryFindWADByName(myargv[p]); printf(" merging sprites and flats from %s\n", filename); W_NWTMergeFile(filename, W_NWT_MERGE_SPRITES | W_NWT_MERGE_FLATS); } } #endif //! // @arg <files> // @vanilla // // Load the specified PWAD files. // p = M_CheckParmWithArgs("-file", 1); if (p) { // the parms after p are wadfile/lump names, // until end of parms or another - preceded parm modifiedgame = true; // homebrew levels while (++p != myargc && myargv[p][0] != '-') { char *filename; filename = D_TryFindWADByName(myargv[p]); D_AddFile(filename); } } // 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) { if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp")) { strcpy(file, myargv[p + 1]); } else { sprintf (file,"%s.lmp", myargv[p+1]); } if (D_AddFile (file)) { strncpy(demolumpname, lumpinfo[numlumps - 1].name, 8); demolumpname[8] = '\0'; printf("Playing demo %s.\n", file); } 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. strncpy(demolumpname, myargv[p + 1], 8); demolumpname[8] = '\0'; } } // Generate the WAD hash table. Speed things up a bit. W_GenerateHashTable(); D_IdentifyVersion(); InitGameVersion(); LoadChexDeh(); LoadHacxDeh(); D_SetGameDescription(); D_SetSaveGameDir(); // 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.")); } // 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; } //! // @category video // // Disable vertical mouse movement. // if (M_CheckParm("-novert")) novert = true; //! // @category video // // Enable vertical mouse movement. // if (M_CheckParm("-nonovert")) novert = false; if (W_CheckNumForName("SS_START") >= 0 || W_CheckNumForName("FF_END") >= 0) { printf ("===========================================================================\n"); 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"); } printf ("===========================================================================\n"); PrintBanner(gamedescription); printf ( "===========================================================================\n" " " PACKAGE_NAME " is free software, covered by the GNU General Public\n" " License. There is NO warranty; not even for MERCHANTABILITY or FITNESS\n" " FOR A PARTICULAR PURPOSE. You are welcome to change and distribute\n" " copies under certain conditions. See the source for more information.\n" "===========================================================================\n" ); PrintDehackedBanners(); 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("I_Init: Setting up machine state.\n"); I_Init (); #ifdef FEATURE_MULTIPLAYER printf ("NET_Init: Init network subsystem.\n"); NET_Init (); #endif 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; //! // @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) { strcpy(file, P_SaveGameFile(startloadgame)); 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 }
void D_StartNetGame(net_gamesettings_t *settings, netgame_startup_callback_t callback) { int i; offsetms = 0; recvtic = 0; settings->consoleplayer = 0; settings->num_players = 1; settings->player_classes[0] = player_class; //! // @category net // // Use new network client sync code rather than the classic // sync code. This is currently disabled by default because it // has some bugs. // if (M_CheckParm("-newsync") > 0) settings->new_sync = 1; else settings->new_sync = 0; // TODO: New sync code is not enabled by default because it's // currently broken. //if (M_CheckParm("-oldsync") > 0) // settings->new_sync = 0; //else // settings->new_sync = 1; //! // @category net // @arg <n> // // Send n extra tics in every packet as insurance against dropped // packets. // i = M_CheckParmWithArgs("-extratics", 1); if (i > 0) settings->extratics = atoi(myargv[i+1]); else settings->extratics = 1; //! // @category net // @arg <n> // // Reduce the resolution of the game by a factor of n, reducing // the amount of network bandwidth needed. // i = M_CheckParmWithArgs("-dup", 1); if (i > 0) settings->ticdup = atoi(myargv[i+1]); else settings->ticdup = 1; if (net_client_connected) { // Send our game settings and block until game start is received // from the server. NET_CL_StartGame(settings); BlockUntilStart(settings, callback); // Read the game settings that were received. NET_CL_GetSettings(settings); } if (drone) { settings->consoleplayer = 0; } // Set the local player and playeringame[] values. localplayer = settings->consoleplayer; for (i = 0; i < NET_MAXPLAYERS; ++i) { local_playeringame[i] = i < settings->num_players; } // Copy settings to global variables. ticdup = settings->ticdup; new_sync = settings->new_sync; // TODO: Message disabled until we fix new_sync. //if (!new_sync) //{ // printf("Syncing netgames like Vanilla Doom.\n"); //} }
void P_SetupLevel(int episode, int map, int playermask, skill_t skill) { int i; int parm; char lumpname[9]; int lumpnum; mobj_t *mobj; for (i = 0; i < MAXPLAYERS; i++) { players[i].killcount = players[i].secretcount = players[i].itemcount = 0; } players[consoleplayer].viewz = 1; // will be set by player think // Waiting-for-level-load song; not played if playing music from CD // (the seek time will be so long it will just make loading take // longer) if (!cdmusic) { S_StartSongName("chess", true); } Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); P_InitThinkers(); leveltime = 0; sprintf(lumpname, "MAP%02d", map); lumpnum = W_GetNumForName(lumpname); // // Begin processing map lumps // Note: most of this ordering is important // P_LoadBlockMap(lumpnum + ML_BLOCKMAP); P_LoadVertexes(lumpnum + ML_VERTEXES); P_LoadSectors(lumpnum + ML_SECTORS); P_LoadSideDefs(lumpnum + ML_SIDEDEFS); P_LoadLineDefs(lumpnum + ML_LINEDEFS); P_LoadSubsectors(lumpnum + ML_SSECTORS); P_LoadNodes(lumpnum + ML_NODES); P_LoadSegs(lumpnum + ML_SEGS); rejectmatrix = W_CacheLumpNum(lumpnum + ML_REJECT, PU_LEVEL); P_GroupLines(); bodyqueslot = 0; po_NumPolyobjs = 0; deathmatch_p = deathmatchstarts; P_LoadThings(lumpnum + ML_THINGS); PO_Init(lumpnum + ML_THINGS); // Initialize the polyobjs P_LoadACScripts(lumpnum + ML_BEHAVIOR); // ACS object code // // End of map lump processing // // If deathmatch, randomly spawn the active players TimerGame = 0; if (deathmatch) { for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { // must give a player spot before deathmatchspawn mobj = P_SpawnMobj(playerstarts[0][i].x << 16, playerstarts[0][i].y << 16, 0, MT_PLAYER_FIGHTER); players[i].mo = mobj; G_DeathMatchSpawnPlayer(i); P_RemoveMobj(mobj); } } //! // @arg <n> // @category net // @vanilla // // For multiplayer games: exit each level after n minutes. // parm = M_CheckParmWithArgs("-timer", 1); if (parm) { TimerGame = atoi(myargv[parm + 1]) * 35 * 60; } } // set up world state P_SpawnSpecials(); // build subsector connect matrix // P_ConnectSubsectors (); // Load colormap and set the fullbright flag i = P_GetMapFadeTable(gamemap); W_ReadLump(i, colormaps); if (i == W_GetNumForName("COLORMAP")) { LevelUseFullBright = true; } else { // Probably fog ... don't use fullbright sprites LevelUseFullBright = false; } // preload graphics if (precache) R_PrecacheLevel(); // Check if the level is a lightning level P_InitLightning(); S_StopAllSound(); SN_StopAllSequences(); S_StartSong(gamemap, true); //printf ("free memory: 0x%x\n", Z_FreeMemory()); }
// // M_SaveCVARs // void M_SaveCVARs(void) { int numaliases = 0; int p; FILE *file; if (!cvarsloaded || vanilla || togglingvanilla) return; p = M_CheckParmWithArgs("-config", 1, 1); if (!(file = fopen((p ? myargv[p + 1] : packageconfig), "w"))) return; // can't write the file, but don't complain if (returntowidescreen) vid_widescreen = true; for (int i = 0; i < arrlen(cvars); i++) { if (!*cvars[i].name) { fputs("\n", file); continue; } if (cvars[i].name[0] == ';') { fputs(cvars[i].name, file); continue; } // Print the name fprintf(file, "%s ", cvars[i].name); // Print the value switch (cvars[i].type) { case DEFAULT_INT: { dboolean flag = false; int v = *(int *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { char *v_str = commify(v); fputs(v_str, file); free(v_str); } break; } case DEFAULT_INT_UNSIGNED: { char *cvars_location_free = commify(*(unsigned int *)cvars[i].location); fputs(cvars_location_free, file); free(cvars_location_free); } break; case DEFAULT_INT_PERCENT: { dboolean flag = false; int v = *(int *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { char *v_str = commify(v); fprintf(file, "%s%%", v_str); free(v_str); } break; } case DEFAULT_FLOAT: { dboolean flag = false; float v = *(float *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { static char buf[128]; int len; M_snprintf(buf, sizeof(buf), "%.2f", v); len = (int)strlen(buf); if (len >= 2 && buf[len - 1] == '0' && buf[len - 2] == '0') buf[len - 1] = '\0'; fputs(buf, file); } break; } case DEFAULT_FLOAT_PERCENT: { dboolean flag = false; float v = *(float *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { char *v_str = striptrailingzero(v, 1); fprintf(file, "%s%%", v_str); free(v_str); } break; } case DEFAULT_STRING: if (M_StringCompare(*(char **)cvars[i].location, EMPTYVALUE)) fputs(*(char **)cvars[i].location, file); else fprintf(file, "%s%s%s", (M_StringCompare(cvars[i].name, "version") ? "" : "\""), *(char **)cvars[i].location, (M_StringCompare(cvars[i].name, "version") ? "" : "\"")); break; case DEFAULT_OTHER: fputs(*(char **)cvars[i].location, file); break; } fputs("\n", file); } fputs("\n; bound controls\n", file); for (int i = 0; *actions[i].action; i++) { if (actions[i].keyboard1) SaveBindByValue(file, actions[i].action, *(int *)actions[i].keyboard1, keyboardcontrol); if (actions[i].keyboard2) SaveBindByValue(file, actions[i].action, *(int *)actions[i].keyboard2, keyboardcontrol); if (actions[i].mouse1) SaveBindByValue(file, actions[i].action, *(int *)actions[i].mouse1, mousecontrol); if (actions[i].gamepad1) SaveBindByValue(file, actions[i].action, *(int *)actions[i].gamepad1, gamepadcontrol); if (actions[i].gamepad2) SaveBindByValue(file, actions[i].action, *(int *)actions[i].gamepad2, gamepadcontrol); } for (int i = 0; controls[i].type; i++) if (controls[i].type == keyboardcontrol && keyactionlist[controls[i].value][0]) SaveBind(file, controls[i].control, keyactionlist[controls[i].value]); else if (controls[i].type == mousecontrol && mouseactionlist[controls[i].value][0]) SaveBind(file, controls[i].control, mouseactionlist[controls[i].value]); for (int i = 0; i < MAXALIASES; i++) if (*aliases[i].name) numaliases++; if (numaliases) { fputs("\n; aliases\n", file); for (int i = 0; i < MAXALIASES; i++) if (*aliases[i].name) fprintf(file, "alias %s \"%s\"\n", aliases[i].name, aliases[i].string); } fclose(file); if (returntowidescreen) vid_widescreen = false; }