// // D_CleanseFileName // // Strips a file name of path information and transforms it into uppercase // std::string D_CleanseFileName(const std::string &filename, const std::string &ext) { std::string newname(filename); FixPathSeparator(newname); if (ext.length()) M_AppendExtension(newname, "." + ext); size_t slash = newname.find_last_of(PATHSEPCHAR); if (slash != std::string::npos) newname = newname.substr(slash + 1, newname.length() - slash); std::transform(newname.begin(), newname.end(), newname.begin(), toupper); return newname; }
void SV_InitMultipleFiles (std::vector<std::string> filenames) { wadnames.clear(); for(size_t i = 0; i < filenames.size(); i++) { FixPathSeparator (filenames[i]); std::string name = filenames[i]; M_AppendExtension (filenames[i], ".wad"); size_t slash = name.find_last_of(PATHSEPCHAR); if(slash != std::string::npos) name = name.substr(slash + 1, name.length() - slash); std::transform(name.begin(), name.end(), name.begin(), toupper); wadnames.push_back(name); } }
std::string W_AddFile (std::string filename) { wadinfo_t header; lumpinfo_t* lump_p; size_t i; FILE *handle; size_t length; size_t startlump; size_t res; filelump_t* fileinfo; filelump_t singleinfo; FixPathSeparator (filename); std::string name = filename; M_AppendExtension (name, ".wad"); // open the file if ( (handle = fopen (filename.c_str(), "rb")) == NULL) { Printf (PRINT_HIGH, " couldn't open %s\n", filename.c_str()); return ""; } Printf (PRINT_HIGH, "adding %s\n", filename.c_str()); startlump = numlumps; res = fread (&header, sizeof(header), 1, handle); header.identification = LELONG(header.identification); if (header.identification != IWAD_ID && header.identification != PWAD_ID) { // raw lump file fileinfo = &singleinfo; singleinfo.filepos = 0; singleinfo.size = M_FileLength(handle); M_ExtractFileBase (filename, name); numlumps++; Printf (PRINT_HIGH, " (single lump)\n", header.numlumps); } else { // WAD file header.numlumps = LELONG(header.numlumps); header.infotableofs = LELONG(header.infotableofs); length = header.numlumps*sizeof(filelump_t); if(length > (unsigned)M_FileLength(handle)) { Printf (PRINT_HIGH, " bad number of lumps for %s\n", filename.c_str()); fclose(handle); return ""; } fileinfo = (filelump_t *)Z_Malloc (length, PU_STATIC, 0); fseek (handle, header.infotableofs, SEEK_SET); res = fread (fileinfo, length, 1, handle); numlumps += header.numlumps; Printf (PRINT_HIGH, " (%d lumps)\n", header.numlumps); } // Fill in lumpinfo lumpinfo = (lumpinfo_t *)Realloc (lumpinfo, numlumps*sizeof(lumpinfo_t)); if (!lumpinfo) I_Error ("Couldn't realloc lumpinfo"); lump_p = &lumpinfo[startlump]; for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++) { lump_p->handle = handle; lump_p->position = LELONG(fileinfo->filepos); lump_p->size = LELONG(fileinfo->size); strncpy (lump_p->name, fileinfo->name, 8); // W_CheckNumForName needs all lump names in upper case std::transform(lump_p->name, lump_p->name+8, lump_p->name, toupper); } return W_MD5(filename); }
// // D_DoomMain // // [NightFang] - Cause I cant call ArgsSet from g_level.cpp // [ML] 23/1/07 - Add Response file support back in // void D_DoomMain() { unsigned int p; gamestate = GS_STARTUP; // init console so it can capture all of the startup messages C_InitConsole(); atterm(C_ShutdownConsole); W_SetupFileIdentifiers(); // [RH] Initialize items. Still only used for the give command. :-( InitItems(); M_FindResponseFile(); // [ML] 23/1/07 - Add Response file support back in if (lzo_init () != LZO_E_OK) // [RH] Initialize the minilzo package. I_FatalError("Could not initialize LZO routines"); C_ExecCmdLineParams(false, true); // [Nes] test for +logfile command // Always log by default if (!LOG.is_open()) C_DoCommand("logfile"); M_LoadDefaults(); // load before initing other systems C_ExecCmdLineParams(true, false); // [RH] do all +set commands on the command line std::vector<std::string> newwadfiles, newpatchfiles; const char* iwad_filename_cstr = Args.CheckValue("-iwad"); if (iwad_filename_cstr) { std::string iwad_filename(iwad_filename_cstr); M_AppendExtension(iwad_filename, ".WAD"); newwadfiles.push_back(iwad_filename); } D_AddWadCommandLineFiles(newwadfiles); D_AddDehCommandLineFiles(newpatchfiles); D_LoadResourceFiles(newwadfiles, newpatchfiles); Printf(PRINT_HIGH, "I_Init: Init hardware.\n"); I_Init(); // [SL] Call init routines that need to be reinitialized every time WAD changes D_Init(); atterm(D_Shutdown); Printf(PRINT_HIGH, "SV_InitNetwork: Checking network game status.\n"); SV_InitNetwork(); // Base systems have been inited; enable cvar callbacks cvar_t::EnableCallbacks(); // [RH] User-configurable startup strings. Because BOOM does. if (GStrings(STARTUP1)[0]) Printf(PRINT_HIGH, "%s\n", GStrings(STARTUP1)); if (GStrings(STARTUP2)[0]) Printf(PRINT_HIGH, "%s\n", GStrings(STARTUP2)); if (GStrings(STARTUP3)[0]) Printf(PRINT_HIGH, "%s\n", GStrings(STARTUP3)); if (GStrings(STARTUP4)[0]) Printf(PRINT_HIGH, "%s\n", GStrings(STARTUP4)); if (GStrings(STARTUP5)[0]) Printf(PRINT_HIGH, "%s\n", GStrings(STARTUP5)); // developer mode devparm = Args.CheckParm("-devparm"); if (devparm) Printf (PRINT_HIGH, "%s", GStrings(D_DEVSTR)); // D_DEVSTR // Nomonsters if (Args.CheckParm("-nomonsters")) sv_nomonsters = 1; // Respawn if (Args.CheckParm("-respawn")) sv_monstersrespawn = 1; // Fast if (Args.CheckParm("-fast")) sv_fastmonsters = 1; // get skill / episode / map from parms strcpy(startmap, (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1"); const char* val = Args.CheckValue("-skill"); if (val) sv_skill.Set(val[0] - '0'); p = Args.CheckParm("-timer"); if (p && p < Args.NumArgs() - 1) { float time = atof(Args.GetArg(p + 1)); Printf(PRINT_HIGH, "Levels will end after %g minute%s.\n", time, time > 1 ? "s" : ""); sv_timelimit.Set(time); } if (Args.CheckValue("-avg")) { Printf(PRINT_HIGH, "Austin Virtual Gaming: Levels will end after 20 minutes\n"); sv_timelimit.Set(20); } // [RH] Lock any cvars that should be locked now that we're // about to begin the game. cvar_t::EnableNoSet(); // [RH] Now that all game subsystems have been initialized, // do all commands on the command line other than +set C_ExecCmdLineParams(false, false); // [AM] Initialize banlist SV_InitBanlist(); Printf(PRINT_HIGH, "========== Odamex Server Initialized ==========\n"); #ifdef UNIX if (Args.CheckParm("-fork")) daemon_init(); #endif p = Args.CheckParm("-warp"); if (p && p < Args.NumArgs() - (1+(gameinfo.flags & GI_MAPxx ? 0 : 1))) { int ep, map; if (gameinfo.flags & GI_MAPxx) { ep = 1; map = atoi(Args.GetArg(p+1)); } else { ep = Args.GetArg(p+1)[0]-'0'; map = Args.GetArg(p+2)[0]-'0'; } strncpy(startmap, CalcMapName(ep, map), 8); autostart = true; } // [RH] Hack to handle +map p = Args.CheckParm("+map"); if (p && p < Args.NumArgs() - 1) { strncpy(startmap, Args.GetArg(p + 1), 8); ((char*)Args.GetArg(p))[0] = '-'; autostart = true; } strncpy(level.mapname, startmap, sizeof(level.mapname)); G_ChangeMap(); D_DoomLoop(); // never returns }