void InitStreams(void) { // obtain information about system // !!! FIXME: Move this into an abstraction of some sort... #ifdef PLATFORM_WIN32 SYSTEM_INFO siSystemInfo; GetSystemInfo( &siSystemInfo); // and remember page size _ulPageSize = siSystemInfo.dwPageSize*16; // cca. 64kB on WinNT/Win95 #else _ulPageSize = PAGESIZE; #endif // keep a copy of path for setting purposes _fnmApp = _fnmApplicationPath; // if no mod defined yet if (_fnmMod=="") { // check for 'default mod' file LoadStringVar(CTString("DefaultMod.txt"), _fnmMod); } CPrintF(TRANSV("Current mod: %s\n"), (_fnmMod=="") ? TRANS("<none>") : (const char *) (CTString&)_fnmMod); // if there is a mod active if (_fnmMod!="") { // load mod's include/exclude lists CPrintF(TRANSV("Loading mod include/exclude lists...\n")); BOOL bOK = FALSE; bOK |= LoadFileList(_afnmBaseWriteInc , CTString("BaseWriteInclude.lst")); bOK |= LoadFileList(_afnmBaseWriteExc , CTString("BaseWriteExclude.lst")); bOK |= LoadFileList(_afnmBaseBrowseInc, CTString("BaseBrowseInclude.lst")); bOK |= LoadFileList(_afnmBaseBrowseExc, CTString("BaseBrowseExclude.lst")); // if none found if (!bOK) { // the mod is not valid _fnmMod = CTString(""); CPrintF(TRANSV("Error: MOD not found!\n")); // if mod is ok } else { // remember mod name (the parameter that is passed on cmdline) _strModName = _fnmMod; _strModName.DeleteChar(_strModName.Length()-1); _strModName = CTFileName(_strModName).FileName(); } } // find eventual extension for the mod's dlls _strModExt = ""; LoadStringVar(CTString("ModExt.txt"), _strModExt); CPrintF(TRANSV("Loading group files...\n")); CDynamicArray<CTString> *files = NULL; // for each group file in base directory files = _pFileSystem->FindFiles(_fnmApplicationPath, "*.gro"); int max = files->Count(); int i; // for each .gro file in the directory for (i = 0; i < max; i++) { // add it to active set UNZIPAddArchive( _fnmApplicationPath+((*files)[i]) ); } delete files; // if there is a mod active if (_fnmMod!="") { // for each group file in mod directory files = _pFileSystem->FindFiles(_fnmApplicationPath+_fnmMod, "*.gro"); max = files->Count(); for (i = 0; i < max; i++) { UNZIPAddArchive( _fnmApplicationPath + _fnmMod + ((*files)[i]) ); } delete files; } // if there is a CD path if (_fnmCDPath!="") { // for each group file on the CD files = _pFileSystem->FindFiles(_fnmCDPath, "*.gro"); max = files->Count(); for (i = 0; i < max; i++) { UNZIPAddArchive( _fnmCDPath + ((*files)[i]) ); } delete files; // if there is a mod active if (_fnmMod!="") { // for each group file in mod directory files = _pFileSystem->FindFiles(_fnmCDPath+_fnmMod, "*.gro"); max = files->Count(); for (i = 0; i < max; i++) { UNZIPAddArchive( _fnmCDPath + _fnmMod + ((*files)[i]) ); } delete files; } } // try to try { // read the zip directories UNZIPReadDirectoriesReverse_t(); // if failed } catch( char *strError) { // report warning CPrintF( TRANS("There were group file errors:\n%s"), strError); } CPrintF("\n"); const char *dirsep = CFileSystem::GetDirSeparator(); LoadFileList(_afnmNoCRC, CTFILENAME("Data") + CTString(dirsep) + CTString("NoCRC.lst")); _pShell->SetINDEX(CTString("sys")+"_iCPU"+"Misc", 1); }
BOOL Init(int argc, char* argv[]) { _bDedicatedServer = TRUE; if (argc!=1+1 && argc!=2+1) { // NOTE: this cannot be translated - translations are not loaded yet printf("Usage: DedicatedServer <configname> [<modname>]\n" "This starts a server reading configs from directory 'Scripts\\Dedicated\\<configname>\\'\n"); getch(); exit(0); } SetConsoleTitleA(argv[1]); ded_strConfig = CTString("Scripts\\Dedicated\\")+argv[1]+"\\"; if (argc==2+1) { _fnmMod = CTString("Mods\\")+argv[2]+"\\"; } _strLogFile = CTString("Dedicated_")+argv[1]; // initialize engine SE_InitEngine(sam_strGameName); // ParseCommandLine(strCmdLine); // load all translation tables InitTranslation(); CTFileName fnmTransTable; try { fnmTransTable = CTFILENAME("Data\\Translations\\Engine.txt"); AddTranslationTable_t(fnmTransTable); fnmTransTable = CTFILENAME("Data\\Translations\\Game.txt"); AddTranslationTable_t(fnmTransTable); fnmTransTable = CTFILENAME("Data\\Translations\\Entities.txt"); AddTranslationTable_t(fnmTransTable); fnmTransTable = CTFILENAME("Data\\Translations\\SeriousSam.txt"); AddTranslationTable_t(fnmTransTable); fnmTransTable = CTFILENAME("Data\\Translations\\Levels.txt"); AddTranslationTable_t(fnmTransTable); FinishTranslationTable(); } catch (char *strError) { FatalError("%s %s", CTString(fnmTransTable), strError); } // always disable all warnings when in serious sam _pShell->Execute( "con_bNoWarnings=1;"); // declare shell symbols _pShell->DeclareSymbol("persistent user INDEX ded_iMaxFPS;", &ded_iMaxFPS); _pShell->DeclareSymbol("user void Quit(void);", &QuitGame); _pShell->DeclareSymbol("user CTString ded_strLevel;", &ded_strLevel); _pShell->DeclareSymbol("user FLOAT ded_tmTimeout;", &ded_tmTimeout); _pShell->DeclareSymbol("user INDEX ded_bRestartWhenEmpty;", &ded_bRestartWhenEmpty); _pShell->DeclareSymbol("user void Restart(void);", &RestartGame); _pShell->DeclareSymbol("user void NextMap(void);", &NextMap); _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;", &sam_strIntroLevel); _pShell->DeclareSymbol("persistent user CTString sam_strGameName;", &sam_strGameName); _pShell->DeclareSymbol("user CTString sam_strFirstLevel;", &sam_strFirstLevel); // init game - this will load persistent symbols InitializeGame(); _pNetwork->md_strGameID = sam_strGameName; LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), _strSamVersion); CPrintF(TRANS("Serious Sam version: %s\n"), _strSamVersion); SetConsoleCtrlHandler(HandlerRoutine, TRUE); // if there is a mod if (_fnmMod!="") { // execute the mod startup script _pShell->Execute(CTString("include \"Scripts\\Mod_startup.ini\";")); } return TRUE; }