/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { Con_Print("recursive shutdown\n"); return; } if (setjmp(host_abortframe)) { Con_Print("aborted the quitting frame?!?\n"); return; } isdown = true; // be quiet while shutting down S_StopAllSounds(); // disconnect client from server if active CL_Disconnect(); // shut down local server if active Host_ShutdownServer (); // Shutdown menu if(MR_Shutdown) MR_Shutdown(); // AK shutdown PRVM // AK hmm, no PRVM_Shutdown(); yet CL_Gecko_Shutdown(); CL_Video_Shutdown(); Host_SaveConfig(); CDAudio_Shutdown (); S_Terminate (); Curl_Shutdown (); NetConn_Shutdown (); //PR_Shutdown (); if (cls.state != ca_dedicated) { R_Modules_Shutdown(); VID_Shutdown(); Thread_Shutdown(); } Cmd_Shutdown(); Key_Shutdown(); CL_Shutdown(); Sys_Shutdown(); Log_Close(); Crypto_Shutdown(); FS_Shutdown(); Con_Shutdown(); Memory_Shutdown(); }
/* <9a3f1> ../engine/sv_log.c:543 */ void SV_ServerLog_f(void) { if (Cmd_Argc() != 2) { Con_Printf("usage: log < on | off >\n"); if (g_psvs.log.active) Con_Printf("currently logging\n"); else Con_Printf("not currently logging\n"); return; } const char *s = Cmd_Argv(1); if (Q_stricmp(s,"off")) { if (Q_stricmp(s, "on")) Con_Printf("log: unknown parameter %s, 'on' and 'off' are valid\n", s); else { g_psvs.log.active = TRUE; Log_Open(); } } else if (g_psvs.log.active) { Log_Close(); Con_Printf("Server logging disabled.\n"); g_psvs.log.active = FALSE; } }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Log_Shutdown(void) { if (logfile.fp) { Log_Close(); } } //end of the function Log_Shutdown
int pascal WinMain ( HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line, int cmd_show ) { LogType *log; #if 0 log = Log_Open(LOG_TO_FILE,"test.log",LOG_RESET); Log_Timestamp(log); Log_Output(log,"test %d",1); Log_Close(&log); #endif #if 0 log = Log_Open(LOG_TO_FILE,"test.log",LOG_APPEND); Log_Timestamp(log); Log_Output(log,"test %d",3); Log_Close(&log); #endif log = Log_Open(LOG_TO_OPEN_NOTEPAD,"testn.log",LOG_APPEND); Log_Timestamp(log); Log_Output(log,"test %d",5); Log_Close(&log); #if 0 log = Log_Open(LOG_TO_NOTEPAD,"testn.log",LOG_RESET); Log_Timestamp(log); Log_Output(log,"test %d",2); Log_Close(&log); #endif #if 0 log = Log_Open(LOG_TO_NOTEPAD,"testn.log",LOG_APPEND); Log_Timestamp(log); Log_Output(log,"test %d",4); Log_Close(&log); #endif MessageBeep(-1); return 0; }
void Host_ShutdownServer( void ) { if( !SV_Active()) return; Q_strncpy( host.finalmsg, "Server was killed", MAX_STRING ); Log_Printf( "Server shutdown\n" ); Log_Close(); SV_Shutdown( false ); }
/* <9a1a9> ../engine/sv_log.c:162 */ void Log_Open(void) { time_t ltime; struct tm *today; char szFileBase[MAX_PATH]; char szTestFile[MAX_PATH]; int i; FileHandle_t fp; char *temp; if (!g_psvs.log.active || (sv_log_onefile.value != 0.0f && g_psvs.log.file)) return; if (mp_logfile.value == 0.0f) Con_Printf("Server logging data to console.\n"); else { Log_Close(); time(<ime); today = localtime(<ime); temp = Cvar_VariableString("logsdir"); if (!temp || Q_strlen(temp) <= 0 || Q_strstr(temp, ":") || Q_strstr(temp, "..")) Q_snprintf(szFileBase, sizeof(szFileBase), "logs/L%02i%02i", today->tm_mon + 1, today->tm_mday); else Q_snprintf(szFileBase, sizeof(szFileBase), "%s/L%02i%02i", temp, today->tm_mon + 1, today->tm_mday); for (i = 0; i < 1000; i++) { Q_snprintf(szTestFile, sizeof(szTestFile), "%s%03i.log", szFileBase, i); COM_FixSlashes(szTestFile); COM_CreatePath(szTestFile); fp = FS_OpenPathID(szTestFile, "r", "GAMECONFIG"); if (!fp) { COM_CreatePath(szTestFile); fp = FS_OpenPathID(szTestFile, "wt", "GAMECONFIG"); if (fp) { g_psvs.log.file = (void *)fp; Con_Printf("Server logging data to file %s\n", szTestFile); Log_Printf("Log file started (file \"%s\") (game \"%s\") (version \"%i/%s/%d\")\n", szTestFile, Info_ValueForKey(Info_Serverinfo(), "*gamedir"), PROTOCOL_VERSION, gpszVersionString, build_number()); } return; } FS_Close(fp); } Con_Printf("Unable to open logfiles under %s\nLogging disabled\n", szFileBase); g_psvs.log.active = FALSE; } }
int main(int argc, char *argv[]) { int n = 8; Log_Init("/tmp/httpserver.log", LOGFLAG_FILE); LOG_ERRORS("error !\n"); LOG_WARNS("warn !\n"); LOG_INFOS("info !\n"); LOG_DEBUGS("debug !\n"); LOG_TRACES("trace !\n"); Log_Close(); return 0; }
/* ================= Host_Shutdown ================= */ void EXPORT Host_Shutdown( void ) { if( host.shutdown_issued ) return; host.shutdown_issued = true; switch( host.state ) { case HOST_INIT: case HOST_CRASHED: case HOST_ERR_FATAL: if( host.type == HOST_NORMAL ) MsgDev( D_WARN, "Not shutting down normally (%d), skipping config save!\n", host.state ); if( host.state != HOST_ERR_FATAL) host.state = HOST_SHUTDOWN; break; default: if( host.type == HOST_NORMAL ) { Host_WriteConfig(); IN_TouchWriteConfig(); } host.state = HOST_SHUTDOWN; // prepare host to normal shutdown } if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg )); Log_Printf( "Server shutdown\n" ); Log_Close(); SV_Shutdown( false ); CL_Shutdown(); Mod_Shutdown(); NET_Shutdown(); HTTP_Shutdown(); Cmd_Shutdown(); Host_FreeCommon(); Con_DestroyConsole(); Sys_RestoreCrashHandler(); }
int main( int argc, char **argv ) { int i, comp = 0; char outputpath[MAX_PATH] = ""; char filename[MAX_PATH] = "unknown"; quakefile_t *qfiles, *qf; // Ridah, allow to specify an extension for multiple AAS files per map int has_ext = 0; // done. // Ridah, set the world pointer up for reachabilities aasworld = aasworlds; AAS_SetWorldPointer( &( *aasworld ) ); // done. myargc = argc; myargv = argv; Log_Open( "bspc.log" ); //open a log file Log_Print( "BSPC version " BSPC_VERSION ", %s %s by Mr Elusive\n", __DATE__, __TIME__ ); DefaultCfg(); for ( i = 1; i < argc; i++ ) { if ( !stricmp( argv[i],"-threads" ) ) { if ( i + 1 >= argc ) { i = 0; break; } numthreads = atoi( argv[++i] ); Log_Print( "threads = %d\n", numthreads ); } //end if else if ( !stricmp( argv[i], "-noverbose" ) ) { Log_Print( "verbose = false\n" ); verbose = false; } //end else if else if ( !stricmp( argv[i], "-nocsg" ) ) { Log_Print( "nocsg = true\n" ); nocsg = true; } //end else if else if ( !stricmp( argv[i], "-optimize" ) ) { Log_Print( "optimize = true\n" ); optimize = true; } //end else if /* else if (!stricmp(argv[i],"-glview")) { glview = true; } //end else if else if (!stricmp(argv[i], "-draw")) { Log_Print("drawflag = true\n"); drawflag = true; } //end else if else if (!stricmp(argv[i], "-noweld")) { Log_Print("noweld = true\n"); noweld = true; } //end else if else if (!stricmp(argv[i], "-noshare")) { Log_Print("noshare = true\n"); noshare = true; } //end else if else if (!stricmp(argv[i], "-notjunc")) { Log_Print("notjunc = true\n"); notjunc = true; } //end else if else if (!stricmp(argv[i], "-nowater")) { Log_Print("nowater = true\n"); nowater = true; } //end else if else if (!stricmp(argv[i], "-noprune")) { Log_Print("noprune = true\n"); noprune = true; } //end else if else if (!stricmp(argv[i], "-nomerge")) { Log_Print("nomerge = true\n"); nomerge = true; } //end else if else if (!stricmp(argv[i], "-nosubdiv")) { Log_Print("nosubdiv = true\n"); nosubdiv = true; } //end else if else if (!stricmp(argv[i], "-nodetail")) { Log_Print("nodetail = true\n"); nodetail = true; } //end else if else if (!stricmp(argv[i], "-fulldetail")) { Log_Print("fulldetail = true\n"); fulldetail = true; } //end else if else if (!stricmp(argv[i], "-onlyents")) { Log_Print("onlyents = true\n"); onlyents = true; } //end else if else if (!stricmp(argv[i], "-micro")) { if (i + 1 >= argc) {i = 0; break;} microvolume = atof(argv[++i]); Log_Print("microvolume = %f\n", microvolume); } //end else if else if (!stricmp(argv[i], "-leaktest")) { Log_Print("leaktest = true\n"); leaktest = true; } //end else if else if (!stricmp(argv[i], "-verboseentities")) { Log_Print("verboseentities = true\n"); verboseentities = true; } //end else if else if (!stricmp(argv[i], "-chop")) { if (i + 1 >= argc) {i = 0; break;} subdivide_size = atof(argv[++i]); Log_Print("subdivide_size = %f\n", subdivide_size); } //end else if else if (!stricmp (argv[i], "-tmpout")) { strcpy (outbase, "/tmp"); Log_Print("temp output\n"); } //end else if */ #ifdef ME else if ( !stricmp( argv[i], "-freetree" ) ) { freetree = true; Log_Print( "freetree = true\n" ); } //end else if else if ( !stricmp( argv[i], "-grapplereach" ) ) { calcgrapplereach = true; Log_Print( "grapplereach = true\n" ); } //end else if else if ( !stricmp( argv[i], "-nobrushmerge" ) ) { nobrushmerge = true; Log_Print( "nobrushmerge = true\n" ); } //end else if else if ( !stricmp( argv[i], "-noliquids" ) ) { noliquids = true; Log_Print( "noliquids = true\n" ); } //end else if else if ( !stricmp( argv[i], "-forcesidesvisible" ) ) { forcesidesvisible = true; Log_Print( "forcesidesvisible = true\n" ); } //end else if else if ( !stricmp( argv[i], "-output" ) ) { if ( i + 1 >= argc ) { i = 0; break; } if ( access( argv[i + 1], 0x04 ) ) { Warning( "the folder %s does not exist", argv[i + 1] ); } strcpy( outputpath, argv[++i] ); } //end else if else if ( !stricmp( argv[i], "-breadthfirst" ) ) { use_nodequeue = true; Log_Print( "breadthfirst = true\n" ); } //end else if else if ( !stricmp( argv[i], "-cfg" ) ) { if ( i + 1 >= argc ) { i = 0; break; } if ( !LoadCfgFile( argv[++i] ) ) { exit( 0 ); } } //end else if else if ( !stricmp( argv[i], "-bsp2map" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_BSP2MAP; qfiles = GetArgumentFiles( argc, argv, &i, "bsp" ); } //end else if else if ( !stricmp( argv[i], "-bsp2aas" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_BSP2AAS; qfiles = GetArgumentFiles( argc, argv, &i, "bsp" ); } //end else if else if ( !stricmp( argv[i], "-aasall" ) ) { if ( i + 1 >= argc ) { i = 0; break; } CreateAASFilesForAllBSPFiles( argv[++i] ); } //end else if else if ( !stricmp( argv[i], "-reach" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_REACH; qfiles = GetArgumentFiles( argc, argv, &i, "bsp" ); } //end else if else if ( !stricmp( argv[i], "-cluster" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_CLUSTER; qfiles = GetArgumentFiles( argc, argv, &i, "bsp" ); } //end else if else if ( !stricmp( argv[i], "-aasinfo" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_AASINFO; qfiles = GetArgumentFiles( argc, argv, &i, "aas" ); } //end else if else if ( !stricmp( argv[i], "-aasopt" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_AASOPTIMIZE; qfiles = GetArgumentFiles( argc, argv, &i, "aas" ); } //end else if else if ( !stricmp( argv[i], "-tetra" ) ) { if ( i + 1 >= argc ) { i = 0; break; } comp = COMP_TETRA; qfiles = GetArgumentFiles( argc, argv, &i, "aas" ); } //end else if // Ridah, allow to specify an extension for multiple AAS files per map else if ( !stricmp( argv[i], "-ext" ) ) { if ( i + 1 >= argc ) { i = 0; break; } strcpy( aas_extension, argv[++i] ); has_ext = 1; } //end else if // done. #endif //ME else { Log_Print( "unknown parameter %s\n", argv[i] ); break; } //end else } //end for //if there are parameters and there's no mismatch in one of the parameters if ( argc > 1 && i == argc ) { switch ( comp ) { case COMP_BSP2MAP: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { //copy the output path strcpy( filename, outputpath ); //append the bsp file base AppendPathSeperator( filename, MAX_PATH ); ExtractFileBase( qf->origname, &filename[strlen( filename )] ); //append .map strcat( filename, ".map" ); // Log_Print( "bsp2map: %s to %s\n", qf->origname, filename ); if ( qf->type != QFILETYPE_BSP ) { Warning( "%s is probably not a BSP file\n", qf->origname ); } // LoadMapFromBSP( qf ); //write the map file WriteMapFile( filename ); } //end for break; } //end case case COMP_BSP2AAS: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { AASOuputFile( qf, outputpath, filename ); // Log_Print( "bsp2aas: %s to %s\n", qf->origname, filename ); if ( qf->type != QFILETYPE_BSP ) { Warning( "%s is probably not a BSP file\n", qf->origname ); } //set before map loading create_aas = 1; LoadMapFromBSP( qf ); //create the AAS file AAS_Create( filename ); //if it's a Quake3 map calculate the reachabilities and clusters if ( loadedmaptype == MAPTYPE_QUAKE3 ) { AAS_CalcReachAndClusters( qf ); } // if ( optimize ) { AAS_Optimize(); } // //write out the stored AAS file if ( !AAS_WriteAASFile( filename ) ) { Error( "error writing %s\n", filename ); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_REACH: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { AASOuputFile( qf, outputpath, filename ); // Log_Print( "reach: %s to %s\n", qf->origname, filename ); if ( qf->type != QFILETYPE_BSP ) { Warning( "%s is probably not a BSP file\n", qf->origname ); } //if the AAS file exists in the output directory if ( !access( filename, 0x04 ) ) { if ( !AAS_LoadAASFile( filename, 0, 0 ) ) { Error( "error loading aas file %s\n", filename ); } //end if //assume it's a Quake3 BSP file loadedmaptype = MAPTYPE_QUAKE3; } //end if else { Warning( "AAS file %s not found in output folder\n", filename ); Log_Print( "creating %s...\n", filename ); //set before map loading create_aas = 1; LoadMapFromBSP( qf ); //create the AAS file AAS_Create( filename ); } //end else //if it's a Quake3 map calculate the reachabilities and clusters if ( loadedmaptype == MAPTYPE_QUAKE3 ) { AAS_CalcReachAndClusters( qf ); } //end if // if ( optimize ) { AAS_Optimize(); } //write out the stored AAS file if ( !AAS_WriteAASFile( filename ) ) { Error( "error writing %s\n", filename ); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_CLUSTER: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { AASOuputFile( qf, outputpath, filename ); // Log_Print( "cluster: %s to %s\n", qf->origname, filename ); if ( qf->type != QFILETYPE_BSP ) { Warning( "%s is probably not a BSP file\n", qf->origname ); } //if the AAS file exists in the output directory if ( !access( filename, 0x04 ) ) { if ( !AAS_LoadAASFile( filename, 0, 0 ) ) { Error( "error loading aas file %s\n", filename ); } //end if //assume it's a Quake3 BSP file loadedmaptype = MAPTYPE_QUAKE3; //if it's a Quake3 map calculate the clusters if ( loadedmaptype == MAPTYPE_QUAKE3 ) { ( *aasworld ).numclusters = 0; AAS_InitBotImport(); AAS_InitClustering(); } //end if } //end if else { Warning( "AAS file %s not found in output folder\n", filename ); Log_Print( "creating %s...\n", filename ); //set before map loading create_aas = 1; LoadMapFromBSP( qf ); //create the AAS file AAS_Create( filename ); //if it's a Quake3 map calculate the reachabilities and clusters if ( loadedmaptype == MAPTYPE_QUAKE3 ) { AAS_CalcReachAndClusters( qf ); } } //end else // if ( optimize ) { AAS_Optimize(); } //write out the stored AAS file if ( !AAS_WriteAASFile( filename ) ) { Error( "error writing %s\n", filename ); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_AASOPTIMIZE: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { AASOuputFile( qf, outputpath, filename ); // Log_Print( "optimizing: %s to %s\n", qf->origname, filename ); if ( qf->type != QFILETYPE_AAS ) { Warning( "%s is probably not a AAS file\n", qf->origname ); } // AAS_InitBotImport(); // if ( !AAS_LoadAASFile( qf->filename, qf->offset, qf->length ) ) { Error( "error loading aas file %s\n", qf->filename ); } //end if AAS_Optimize(); //write out the stored AAS file if ( !AAS_WriteAASFile( filename ) ) { Error( "error writing %s\n", filename ); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_AASINFO: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { AASOuputFile( qf, outputpath, filename ); // Log_Print( "aas info for: %s\n", filename ); if ( qf->type != QFILETYPE_AAS ) { Warning( "%s is probably not a AAS file\n", qf->origname ); } // AAS_InitBotImport(); // if ( !AAS_LoadAASFile( qf->filename, qf->offset, qf->length ) ) { Error( "error loading aas file %s\n", qf->filename ); } //end if AAS_ShowTotals(); } //end for } //end case case COMP_TETRA: { if ( !qfiles ) { Log_Print( "no files found\n" ); } for ( qf = qfiles; qf; qf = qf->next ) { //TH_AASToTetrahedrons(qf->filename); } //end for break; } //end case default: { Log_Print( "don't know what to do\n" ); break; } //end default } //end switch } //end if else { Log_Print( "Usage: bspc [-<switch> [-<switch> ...]]\n" #if defined( WIN32 ) || defined( _WIN32 ) "Example 1: bspc -bsp2aas d:\\quake3\\baseq3\\maps\\mymap?.bsp\n" "Example 2: bspc -bsp2aas d:\\quake3\\baseq3\\pak0.pk3\\maps/q3dm*.bsp\n" #else "Example 1: bspc -bsp2aas /quake3/baseq3/maps/mymap?.bsp\n" "Example 2: bspc -bsp2aas /quake3/baseq3/pak0.pk3/maps/q3dm*.bsp\n" #endif "\n" "Switches:\n" //" bsp2map <[pakfilter/]filter.bsp> = convert BSP to MAP\n" " bsp2aas <[pakfilter/]filter.bsp> = convert BSP to AAS\n" //" aasall <quake3folder> = create AAS files for all BSPs\n" " reach <filter.bsp> = compute reachability & clusters\n" " cluster <filter.aas> = compute clusters\n" " aasopt <filter.aas> = optimize aas file\n" //" tetra <filter.aas> = tetrahedral decomposition\n" " output <output path> = set output path\n" " threads <X> = set number of threads to X\n" " cfg <filename> = use this cfg file\n" " optimize = enable optimization\n" " noverbose = disable verbose output\n" " breadthfirst = breadth first bsp building\n" " nobrushmerge = don't merge brushes\n" " noliquids = don't write liquids to map\n" " freetree = free the bsp tree\n" " nocsg = disables brush chopping\n" " forcesidesvisible = force all sides to be visible\n" " grapplereach = calculate grapple reachabilities\n" /* " glview = output a GL view\n" " draw = enables drawing\n" " noweld = disables weld\n" " noshare = disables sharing\n" " notjunc = disables juncs\n" " nowater = disables water brushes\n" " noprune = disables node prunes\n" " nomerge = disables face merging\n" " nosubdiv = disables subdeviding\n" " nodetail = disables detail brushes\n" " fulldetail = enables full detail\n" " onlyents = only compile entities with bsp\n" " micro <volume>\n" " = sets the micro volume to the given float\n" " leaktest = perform a leak test\n" " verboseentities\n" " = enable entity verbose mode\n" " chop <subdivide_size>\n" " = sets the subdivide size to the given float\n"*/ "\n" ); } //end else Log_Close(); //close the log file return 0; } //end of the function main
int main (int argc, char **argv) { int i, comp = 0; char outputpath[MAX_PATH] = ""; char filename[MAX_PATH] = "unknown"; quakefile_t *qfiles = NULL, *qf; double start_time; myargc = argc; myargv = argv; start_time = I_FloatTime(); Log_Open("bspc.log"); //open a log file Log_Print(BSPC_NAME" version "BSPC_VERSION", %s %s\n", __DATE__, __TIME__); #ifdef ZTMAUTOARGS calcgrapplereach = true; forcesidesvisible = true; // Currently always required or BSPC fails? #endif DefaultCfg(); for (i = 1; i < argc; i++) { if (!stricmp(argv[i],"-threads")) { if (i + 1 >= argc) {i = 0; break;} numthreads = atoi(argv[++i]); Log_Print("threads = %d\n", numthreads); } //end if else if (!stricmp(argv[i], "-noverbose")) { Log_Print("verbose = false\n"); verbose = false; } //end else if else if (!stricmp(argv[i], "-nocsg")) { Log_Print("nocsg = true\n"); nocsg = true; } //end else if else if (!stricmp(argv[i], "-optimize")) { Log_Print("optimize = true\n"); optimize = true; } //end else if /* else if (!stricmp(argv[i], "-noweld")) { Log_Print("noweld = true\n"); noweld = true; } //end else if else if (!stricmp(argv[i], "-noshare")) { Log_Print("noshare = true\n"); noshare = true; } //end else if else if (!stricmp(argv[i], "-notjunc")) { Log_Print("notjunc = true\n"); notjunc = true; } //end else if else if (!stricmp(argv[i], "-nowater")) { Log_Print("nowater = true\n"); nowater = true; } //end else if else if (!stricmp(argv[i], "-noprune")) { Log_Print("noprune = true\n"); noprune = true; } //end else if else if (!stricmp(argv[i], "-nomerge")) { Log_Print("nomerge = true\n"); nomerge = true; } //end else if else if (!stricmp(argv[i], "-nosubdiv")) { Log_Print("nosubdiv = true\n"); nosubdiv = true; } //end else if else if (!stricmp(argv[i], "-nodetail")) { Log_Print("nodetail = true\n"); nodetail = true; } //end else if else if (!stricmp(argv[i], "-fulldetail")) { Log_Print("fulldetail = true\n"); fulldetail = true; } //end else if else if (!stricmp(argv[i], "-onlyents")) { Log_Print("onlyents = true\n"); onlyents = true; } //end else if else if (!stricmp(argv[i], "-micro")) { if (i + 1 >= argc) {i = 0; break;} microvolume = atof(argv[++i]); Log_Print("microvolume = %f\n", microvolume); } //end else if else if (!stricmp(argv[i], "-leaktest")) { Log_Print("leaktest = true\n"); leaktest = true; } //end else if else if (!stricmp(argv[i], "-verboseentities")) { Log_Print("verboseentities = true\n"); verboseentities = true; } //end else if else if (!stricmp(argv[i], "-chop")) { if (i + 1 >= argc) {i = 0; break;} subdivide_size = atof(argv[++i]); Log_Print("subdivide_size = %f\n", subdivide_size); } //end else if else if (!stricmp (argv[i], "-tmpout")) { strcpy (outbase, "/tmp"); Log_Print("temp output\n"); } //end else if */ else if (!stricmp(argv[i], "-freetree")) { freetree = true; Log_Print("freetree = true\n"); } //end else if else if (!stricmp(argv[i], "-grapplereach")) { calcgrapplereach = true; Log_Print("grapplereach = true\n"); } //end else if #ifdef ZTMAUTOARGS else if (!stricmp(argv[i], "-nograpplereach")) { calcgrapplereach = false; Log_Print("grapplereach = false\n"); } //end else if #endif else if (!stricmp(argv[i], "-nobrushmerge")) { nobrushmerge = true; Log_Print("nobrushmerge = true\n"); } //end else if else if (!stricmp(argv[i], "-noliquids")) { noliquids = true; Log_Print("noliquids = true\n"); } //end else if else if (!stricmp(argv[i], "-forcesidesvisible")) { forcesidesvisible = true; Log_Print("forcesidesvisible = true\n"); } //end else if #ifdef ZTMAUTOARGS else if (!stricmp(argv[i], "-noforcesidesvisible")) { forcesidesvisible = false; Log_Print("forcesidesvisible = false\n"); } //end else if #endif else if (!stricmp(argv[i], "-output")) { if (i + 1 >= argc) {i = 0; break;} if (access(argv[i+1], 0x04)) Warning("the folder %s does not exist", argv[i+1]); strcpy(outputpath, argv[++i]); } //end else if else if (!stricmp(argv[i], "-breadthfirst")) { use_nodequeue = true; Log_Print("breadthfirst = true\n"); } //end else if else if (!stricmp(argv[i], "-capsule")) { capsule_collision = true; Log_Print("capsule_collision = true\n"); } //end else if else if (!stricmp(argv[i], "-cfg")) { if (i + 1 >= argc) {i = 0; break;} if (!LoadCfgFile(argv[++i])) exit(0); } //end else if else if (!stricmp(argv[i], "-bsp2map")) { if (i + 1 >= argc) {i = 0; break;} comp = COMP_BSP2MAP; qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); } //end else if else if (!stricmp(argv[i], "-bsp2aas")) { if (i + 1 >= argc) {i = 0; break;} comp = COMP_BSP2AAS; qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); } //end else if else if (!stricmp(argv[i], "-aasall")) { if (i + 1 >= argc) {i = 0; break;} CreateAASFilesForAllBSPFiles(argv[++i]); } //end else if else if (!stricmp(argv[i], "-reach")) { if (i + 1 >= argc) {i = 0; break;} comp = COMP_REACH; qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); } //end else if else if (!stricmp(argv[i], "-cluster")) { if (i + 1 >= argc) {i = 0; break;} comp = COMP_CLUSTER; qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); } //end else if else if (!stricmp(argv[i], "-aasinfo")) { if (i + 1 >= argc) {i = 0; break;} comp = COMP_AASINFO; qfiles = GetArgumentFiles(argc, argv, &i, "aas"); } //end else if else if (!stricmp(argv[i], "-aasopt")) { if (i + 1 >= argc) {i = 0; break;} comp = COMP_AASOPTIMIZE; qfiles = GetArgumentFiles(argc, argv, &i, "aas"); } //end else if else { Log_Print("unknown parameter %s\n", argv[i]); break; } //end else } //end for //if there are parameters and there's no mismatch in one of the parameters if (argc > 1 && i == argc) { switch(comp) { case COMP_BSP2MAP: { if (!qfiles) Log_Print("no files found\n"); for (qf = qfiles; qf; qf = qf->next) { //copy the output path strcpy(filename, outputpath); //append the bsp file base AppendPathSeperator(filename, MAX_PATH); ExtractFileBase(qf->origname, &filename[strlen(filename)]); //append .map strcat(filename, ".map"); // Log_Print("bsp2map: %s to %s\n", qf->origname, filename); if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); // LoadMapFromBSP(qf); //write the map file WriteMapFile(filename); } //end for break; } //end case case COMP_BSP2AAS: { if (!qfiles) Log_Print("no files found\n"); for (qf = qfiles; qf; qf = qf->next) { AASOuputFile(qf, outputpath, filename); // Log_Print("bsp2aas: %s to %s\n", qf->origname, filename); if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); //set before map loading create_aas = 1; LoadMapFromBSP(qf); //create the AAS file AAS_Create(filename); //calculate the reachabilities and clusters AAS_CalcReachAndClusters(qf); // if (optimize) AAS_Optimize(); // //write out the stored AAS file if (!AAS_WriteAASFile(filename)) { Error("error writing %s\n", filename); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_REACH: { if (!qfiles) Log_Print("no files found\n"); for (qf = qfiles; qf; qf = qf->next) { AASOuputFile(qf, outputpath, filename); // Log_Print("reach: %s to %s\n", qf->origname, filename); if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); //if the AAS file exists in the output directory if (!access(filename, 0x04)) { if (!AAS_LoadAASFile(filename)) { Error("error loading aas file %s\n", filename); } //end if } //end if else { Warning("AAS file %s not found in output folder\n", filename); Log_Print("creating %s...\n", filename); //set before map loading create_aas = 1; LoadMapFromBSP(qf); //create the AAS file AAS_Create(filename); } //end else //calculate the reachabilities and clusters AAS_CalcReachAndClusters(qf); // if (optimize) AAS_Optimize(); //write out the stored AAS file if (!AAS_WriteAASFile(filename)) { Error("error writing %s\n", filename); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_CLUSTER: { if (!qfiles) Log_Print("no files found\n"); for (qf = qfiles; qf; qf = qf->next) { AASOuputFile(qf, outputpath, filename); // Log_Print("cluster: %s to %s\n", qf->origname, filename); if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); //if the AAS file exists in the output directory if (!access(filename, 0x04)) { if (!AAS_LoadAASFile(filename)) { Error("error loading aas file %s\n", filename); } //end if //calculate the clusters AAS_RecalcClusters(); } //end if else { Warning("AAS file %s not found in output folder\n", filename); Log_Print("creating %s...\n", filename); //set before map loading create_aas = 1; LoadMapFromBSP(qf); //create the AAS file AAS_Create(filename); //calculate the reachabilities and clusters AAS_CalcReachAndClusters(qf); } //end else // if (optimize) AAS_Optimize(); //write out the stored AAS file if (!AAS_WriteAASFile(filename)) { Error("error writing %s\n", filename); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_AASOPTIMIZE: { if (!qfiles) Log_Print("no files found\n"); for (qf = qfiles; qf; qf = qf->next) { AASOuputFile(qf, outputpath, filename); // Log_Print("optimizing: %s to %s\n", qf->origname, filename); if (qf->type != QFILETYPE_AAS) Warning("%s is probably not a AAS file\n", qf->origname); // AAS_InitBotImport(); // if (!AAS_LoadAASFile(qf->filename)) { Error("error loading aas file %s\n", qf->filename); } //end if AAS_Optimize(); //write out the stored AAS file if (!AAS_WriteAASFile(filename)) { Error("error writing %s\n", filename); } //end if //deallocate memory AAS_FreeMaxAAS(); } //end for break; } //end case case COMP_AASINFO: { if (!qfiles) Log_Print("no files found\n"); for (qf = qfiles; qf; qf = qf->next) { AASOuputFile(qf, outputpath, filename); // Log_Print("aas info for: %s\n", filename); if (qf->type != QFILETYPE_AAS) Warning("%s is probably not a AAS file\n", qf->origname); // AAS_InitBotImport(); // if (!AAS_LoadAASFile(qf->filename)) { Error("error loading aas file %s\n", qf->filename); } //end if AAS_ShowTotals(); } //end for break; } //end case default: { Log_Print("don't know what to do\n"); break; } //end default } //end switch } //end if else { Log_Print("Usage: bspc [-<switch> [-<switch> ...]]\n" #ifdef _WIN32 "Example 1: bspc -bsp2aas d:\\quake3\\baseq3\\maps\\mymap?.bsp\n" "Example 2: bspc -bsp2aas d:\\quake3\\baseq3\\pak0.pk3\\maps/q3dm*.bsp\n" #else "Example 1: bspc -bsp2aas /quake3/baseq3/maps/mymap?.bsp\n" "Example 2: bspc -bsp2aas /quake3/baseq3/pak0.pk3/maps/q3dm*.bsp\n" #endif "\n" "Switches:\n" //" bsp2map <[pakfilter/]filter.bsp> = convert BSP to MAP\n" //" aasall <quake3folder> = create AAS files for all BSPs\n" " bsp2aas <[pakfilter/]filter.bsp> = convert BSP to AAS\n" " reach <filter.bsp> = compute reachability & clusters\n" " cluster <filter.bsp> = compute clusters\n" " aasopt <filter.aas> = optimize aas file\n" " aasinfo <filter.aas> = show AAS file info\n" " output <output path> = set output path\n" " threads <X> = set number of threads to X\n" " cfg <filename> = use this cfg file\n" " optimize = enable optimization\n" " noverbose = disable verbose output\n" " breadthfirst = breadth first bsp building\n" " nobrushmerge = don't merge brushes\n" " noliquids = don't write liquids to map\n" " freetree = free the bsp tree\n" " nocsg = disables brush chopping\n" #ifdef ZTMAUTOARGS " noforcesidesvisible = don't force all sides to be visible\n" " nograpplereach = don't calculate grapple reachabilities\n" #else " forcesidesvisible = force all sides to be visible\n" " grapplereach = calculate grapple reachabilities\n" #endif /* " noweld = disables weld\n" " noshare = disables sharing\n" " notjunc = disables juncs\n" " nowater = disables water brushes\n" " noprune = disables node prunes\n" " nomerge = disables face merging\n" " nosubdiv = disables subdeviding\n" " nodetail = disables detail brushes\n" " fulldetail = enables full detail\n" " onlyents = only compile entities with bsp\n" " micro <volume>\n" " = sets the micro volume to the given float\n" " leaktest = perform a leak test\n" " verboseentities\n" " = enable entity verbose mode\n" " chop <subdivide_size>\n" " = sets the subdivide size to the given float\n"*/ "\n"); } //end else Log_Print("BSPC run time is %5.0f seconds\n", I_FloatTime() - start_time); Log_Close(); //close the log file return 0; } //end of the function main
/* ================= DumpReplaceFunctions ================= */ void DumpReplaceFunctions (char *typeName) { replacefunc_t *rf; char path[_MAX_PATH]; FILE *f; int len, newlen; unsigned char *buf, *newbuf = NULL; int updated; updated = 0; // dump the function header strcpy( path, "." ); strcat( path, PATHSEPERATOR_STR ); strcat( path, TEMP_LIST_NAME ); Log_Open( path ); for ( rf = replacefuncs; rf; rf = rf->next ) { if (typeName) Log_Print( "{\"%s\", &%s},\n", rf->name, rf->name ); else Log_Print( "{\"%s\", (byte *)%s},\n", rf->name, rf->name ); } //end for Log_Print( "{0, 0}\n" ); Log_Close(); // if it's different, rename the file over the real header strcpy( path, TEMP_LIST_NAME ); f = fopen( path, "rb" ); fseek( f, 0, SEEK_END ); len = ftell( f ); buf = (unsigned char *) malloc( len + 1 ); fseek( f, 0, SEEK_SET ); fread( buf, len, 1, f ); buf[len] = 0; fclose( f ); strcpy( path, func_listfile ); if ((f = fopen( path, "rb" )) != NULL) { fseek( f, 0, SEEK_END ); newlen = ftell( f ); newbuf = (unsigned char *) malloc( newlen + 1 ); fseek( f, 0, SEEK_SET ); fread( newbuf, newlen, 1, f ); newbuf[newlen] = 0; fclose( f ); if ( len != newlen || Q_stricmp( buf, newbuf ) ) { char newpath[_MAX_PATH]; // delete the old file, rename the new one strcpy( path, func_listfile ); remove( path ); strcpy( newpath, TEMP_LIST_NAME ); rename( newpath, path ); #ifdef _WIN32 // make g_save recompile itself remove( "debug\\g_save.obj" ); remove( "debug\\g_save.sbr" ); remove( "release\\g_save.obj" ); remove( "release\\g_save.sbr" ); #endif updated = 1; } else { // delete the old file strcpy( path, TEMP_LIST_NAME ); remove( path ); } } else { rename( TEMP_LIST_NAME, func_listfile ); } free( buf ); free( newbuf ); // dump the function declarations strcpy( path, TEMP_DECS_NAME ); Log_Open( path ); for ( rf = replacefuncs; rf; rf = rf->next ) { if (typeName) Log_Print( "extern %s %s;\n", typeName, rf->dec ); else Log_Print( "extern %s;\n", rf->dec ); } //end for Log_Close(); // if it's different, rename the file over the real header strcpy( path, TEMP_DECS_NAME ); f = fopen( path, "rb" ); fseek( f, 0, SEEK_END ); len = ftell( f ); buf = (unsigned char *) malloc( len + 1 ); fseek( f, 0, SEEK_SET ); fread( buf, len, 1, f ); buf[len] = 0; fclose( f ); strcpy( path, func_decsfile ); if ((f = fopen( path, "rb" )) != NULL) { fseek( f, 0, SEEK_END ); newlen = ftell( f ); newbuf = (unsigned char *) malloc( newlen + 1 ); fseek( f, 0, SEEK_SET ); fread( newbuf, newlen, 1, f ); newbuf[newlen] = 0; fclose( f ); if ( len != newlen || Q_stricmp( buf, newbuf ) ) { char newpath[_MAX_PATH]; // delete the old file, rename the new one strcpy( path, func_decsfile ); remove( path ); strcpy( newpath, TEMP_DECS_NAME ); rename( newpath, path ); #ifdef _WIN32 // make g_save recompile itself // NOTE TTimo win32 only? (harmless on *nix anyway) remove( "debug\\g_save.obj" ); remove( "debug\\g_save.sbr" ); remove( "release\\g_save.obj" ); remove( "release\\g_save.sbr" ); #endif updated = 1; } else { // delete the old file strcpy( path, TEMP_DECS_NAME ); remove( path ); } } else { rename( TEMP_DECS_NAME, func_decsfile ); } free( buf ); if (newbuf) free( newbuf ); #ifdef _WIN32 if ( updated ) { printf( "Updated the function table, recompile required.\n" ); } #endif } // end of the function DumpReplaceFunctions
/* =============== Host_Shutdown FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better to run quit through here before the final handoff to the sys code. =============== */ void Host_Shutdown(void) { static qboolean isdown = false; if (isdown) { Con_Print("recursive shutdown\n"); return; } if (setjmp(host_abortframe)) { Con_Print("aborted the quitting frame?!?\n"); return; } isdown = true; // be quiet while shutting down S_StopAllSounds(); // end the server thread if (svs.threaded) SV_StopThread(); // disconnect client from server if active CL_Disconnect(); // shut down local server if active SV_LockThreadMutex(); Host_ShutdownServer (); SV_UnlockThreadMutex(); #ifdef CONFIG_MENU // Shutdown menu if(MR_Shutdown) MR_Shutdown(); #endif // AK shutdown PRVM // AK hmm, no PRVM_Shutdown(); yet CL_Video_Shutdown(); IRC_Shutdown(); Host_SaveConfig(); #ifdef CONFIG_CD CDAudio_Shutdown (); #endif S_Terminate (); Curl_Shutdown (); NetConn_Shutdown (); //PR_Shutdown (); if (cls.state != ca_dedicated) { R_Modules_Shutdown(); VID_Shutdown(); } SV_StopThread(); Thread_Shutdown(); Cmd_Shutdown(); Key_Shutdown(); CL_Shutdown(); Sys_Shutdown(); Log_Close(); Crypto_Shutdown(); Host_UnlockSession(); S_Shutdown(); Con_Shutdown(); Memory_Shutdown(); }