void main (int argc, char **argv) { int i; char source[1024]; int size; FILE *f; printf( "bspinfo.exe v2.1 (%s)\n", __DATE__ ); printf ("---- bspinfo ----\n" ); if (argc == 1) Error ("usage: bspinfo bspfile [bspfiles]"); for (i=1 ; i<argc ; i++) { printf ("---------------------\n"); strcpy (source, argv[i]); DefaultExtension (source, ".bsp"); f = fopen (source, "rb"); if (f) { size = filelength (f); fclose (f); } else size = 0; printf ("%s: %i\n", source, size); LoadBSPFile (source); PrintBSPFileSizes (); printf ("---------------------\n"); } }
static void AddModules( void ) { lib_cmd *cmd; char buff[ MAX_IMPORT_STRING ]; for( cmd = CmdList; cmd != NULL; cmd = cmd->next ) { if( !( cmd->ops & OP_ADD ) ) continue; strcpy( buff, cmd->name ); if( cmd->ops & OP_IMPORT ) { ProcessImport( buff ); } else { DefaultExtension( buff, EXT_OBJ ); ProcessLibOrObj( buff, OBJ_PROCESS, AddOneObject ); } Options.modified = TRUE; if( Options.ar && Options.verbose ) { if( cmd->ops & OP_DELETED ) { Message( "r - %s", cmd->name ); } else { Message( "a - %s", cmd->name ); } } } }
void SaveSkinDialog (void) { // strcpy (szDirName, ValueForKey (project_entity, "basepath") ); // strcat (szDirName, "\\maps"); /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = mainwindow; ofn.lpstrFilter = szSkinFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; /* Display the Open dialog box. */ if (!GetSaveFileName(&ofn)) return; // canceled DefaultExtension (ofn.lpstrFile, ".lbm"); Skin_SaveFile (ofn.lpstrFile); strcpy (skin_filename, ofn.lpstrFile); }
void MakeLITFile (const char *filename) { char litname[1024]; FILE *litfile; litheader_t litheader; strcpy (litname, filename); StripExtension (litname); DefaultExtension (litname, ".lit", sizeof(litname)); litfile = fopen (litname, "wb"); if (!litfile) { printf ("Unable to create %s\n", litname); return; } litheader.ident[0] = 'Q'; litheader.ident[1] = 'L'; litheader.ident[2] = 'I'; litheader.ident[3] = 'T'; litheader.version = LittleLong(LIT_VERSION); fwrite (&litheader, sizeof(litheader), 1, litfile); fwrite (&newdlightdata, newlightdatasize, 1, litfile); fclose (litfile); printf ("Wrote litfile: %s\n", litname); }
C4SoundEffect* C4SoundSystem::GetEffect(const char *szSndName) { // Remember wildcards before adding .* extension - if there are 2 versions with different file extensions, play the last added bool bRandomSound = SCharCount('?',szSndName) || SCharCount('*',szSndName); // Evaluate sound name char szName[C4MaxSoundName+2+1]; SCopy(szSndName,szName,C4MaxSoundName); // Any extension accepted DefaultExtension(szName,"*"); // Play nth Sound. Standard: 1 int32_t iNumber = 1; // Sound with a wildcard: determine number of available matches if (bRandomSound) { iNumber = 0; // Count matching sounds for (C4SoundEffect *pSfx=FirstSound; pSfx; pSfx=pSfx->Next) if (WildcardMatch(szName,pSfx->Name)) ++iNumber; // Nothing found? Abort if(iNumber == 0) return NULL; iNumber=UnsyncedRandom(iNumber)+1; } // Find requested sound effect in bank C4SoundEffect *pSfx; for (pSfx=FirstSound; pSfx; pSfx=pSfx->Next) if (WildcardMatch(szName,pSfx->Name)) if(!--iNumber) break; return pSfx; // Is still NULL if nothing is found }
/* ============ Bspinfo ============ */ void Bspinfo( int count, char **fileNames ) { int i; char source[1024]; int size; FILE *f; if ( count < 1 ) { _printf( "No files to dump info for.\n"); return; } for ( i = 0 ; i < count ; i++ ) { _printf ("---------------------\n"); strcpy (source, fileNames[ i ] ); DefaultExtension (source, ".bsp"); f = fopen (source, "rb"); if (f) { size = Q_filelength (f); fclose (f); } else size = 0; _printf ("%s: %i\n", source, size); LoadBSPFile (source); PrintBSPFileSizes (); _printf ("---------------------\n"); } }
C4SoundEffect *C4SoundSystem::GetEffect(const char *szSndName) { C4SoundEffect *pSfx; char szName[C4MaxSoundName + 4 + 1]; int32_t iNumber; // Evaluate sound name SCopy(szSndName, szName, C4MaxSoundName); // Default extension DefaultExtension(szName, "wav"); // Convert old style '*' wildcard to correct '?' wildcard // For sound effects, '*' is supposed to match single digits only SReplaceChar(szName, '*', '?'); // Sound with a wildcard: determine number of available matches if (SCharCount('?', szName)) { // Search global sound file if (!(iNumber = SoundFile.EntryCount(szName))) // Search scenario local files if (!(iNumber = Game.ScenarioFile.EntryCount(szName))) // Search bank loaded sounds if (!(iNumber = EffectInBank(szName))) // None found: failure return NULL; // Insert index to name iNumber = BoundBy(1 + SafeRandom(iNumber), 1, 9); SReplaceChar(szName, '?', '0' + iNumber); } // Find requested sound effect in bank for (pSfx = FirstSound; pSfx; pSfx = pSfx->Next) if (SEqualNoCase(szName, pSfx->Name)) break; // Sound not in bank, try add if (!pSfx) if (!(pSfx = AddEffect(szName))) return NULL; return pSfx; }
void MakeAllScales (void) { strcpy(transferfile, source); StripExtension( transferfile ); DefaultExtension( transferfile, ".r2" ); if ( !incremental || !IsIncremental(incrementfile) || (unsigned)readtransfers(transferfile, num_patches) != num_patches ) { // determine visibility between patches BuildVisMatrix (); RunThreadsOn (num_patches, true, MakeScales); if ( incremental ) writetransfers(transferfile, num_patches); else unlink(transferfile); // release visibility matrix FreeVisMatrix (); } qprintf ("transfer lists: %5.1f megs\n" , (float)total_transfer * sizeof(transfer_t) / (1024*1024)); }
/* ======================================================================================================================= ======================================================================================================================= */ void SaveAsDialog(bool bRegion) { strcpy(szDirName, ValueForKey(g_qeglobals.d_project_entity, "basepath")); CString strPath = szDirName; AddSlash(strPath); strPath += "maps"; if (g_PrefsDlg.m_strMaps.GetLength() > 0) { strPath += va("\\%s", g_PrefsDlg.m_strMaps); } /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_pParentWnd->GetSafeHwnd(); ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = strPath; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; /* Display the Open dialog box. */ if (!GetSaveFileName(&ofn)) { return; // canceled } if (bRegion) { DefaultExtension(ofn.lpstrFile, ".reg"); } else { DefaultExtension(ofn.lpstrFile, ".map"); } if (!bRegion) { strcpy(currentmap, ofn.lpstrFile); AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile); PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu, GetSubMenu(GetMenu(g_pParentWnd->GetSafeHwnd()), 0), ID_FILE_EXIT); } Map_SaveFile(ofn.lpstrFile, bRegion); // ignore region }
/* =========== main =========== */ int VIS_Main(){ char portalfile[1024]; char source[1024]; char name[1024]; double start, end; int total_vis_time; Sys_Printf( "\n----- VIS ----\n\n" ); //if (i != argc - 1) // Error ("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile"); start = I_FloatTime(); ThreadSetDefault(); SetQdirFromPath( mapname ); strcpy( source, ExpandArg( mapname ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); sprintf( name, "%s%s", inbase, source ); Sys_Printf( "reading %s\n", name ); LoadBSPFile( name ); if ( numnodes == 0 || numfaces == 0 ) { Error( "Empty map" ); } sprintf( portalfile, "%s%s", inbase, ExpandArg( mapname ) ); StripExtension( portalfile ); strcat( portalfile, ".prt" ); Sys_Printf( "reading %s\n", portalfile ); LoadPortals( portalfile ); CalcVis(); CalcPHS(); visdatasize = vismap_p - dvisdata; Sys_Printf( "visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize * 2 ); sprintf( name, "%s%s", outbase, source ); Sys_Printf( "writing %s\n", name ); WriteBSPFile( name ); end = I_FloatTime(); total_vis_time = (int) ( end - start ); Sys_Printf( "\nVIS Time: " ); if ( total_vis_time > 59 ) { Sys_Printf( "%d Minutes ", total_vis_time / 60 ); } Sys_Printf( "%d Seconds\n", total_vis_time % 60 ); return 0; }
int BSPInfo( int count, char **fileNames ) { int i; char source[ 1024 ], ext[ 64 ]; int size; FILE *f; /* dummy check */ if( count < 1 ) { Sys_Printf( "No files to dump info for.\n"); return -1; } /* enable info mode */ infoMode = qtrue; /* walk file list */ for( i = 0; i < count; i++ ) { Sys_Printf( "---------------------------------\n" ); /* mangle filename and get size */ strcpy( source, fileNames[ i ] ); ExtractFileExtension( source, ext ); if( !Q_stricmp( ext, "map" ) ) StripExtension( source ); DefaultExtension( source, ".bsp" ); f = fopen( source, "rb" ); if( f ) { size = Q_filelength (f); fclose( f ); } else size = 0; /* load the bsp file and print lump sizes */ Sys_Printf( "%s\n", source ); LoadBSPFile( source ); PrintBSPFileSizes(); /* print sizes */ Sys_Printf( "\n" ); Sys_Printf( " total %9d\n", size ); Sys_Printf( " %9d KB\n", size / 1024 ); Sys_Printf( " %9d MB\n", size / (1024 * 1024) ); Sys_Printf( "---------------------------------\n" ); } /* return count */ return i; }
int32_t C4SoundSystem::EffectInBank(const char *szSound) { int32_t iResult = 0; C4SoundEffect *pSfx; char szName[C4MaxSoundName + 4 + 1]; // Compose name (with extension) SCopy(szSound, szName, C4MaxSoundName); DefaultExtension(szName, "wav"); // Count all matching sounds in bank for (pSfx = FirstSound; pSfx; pSfx = pSfx->Next) if (WildcardMatch(szName, pSfx->Name)) iResult++; return iResult; }
C4SoundInstance *C4SoundSystem::FindInstance(const char *szSndName, C4Object *pObj) { char szName[C4MaxSoundName + 4 + 1]; // Evaluate sound name (see GetEffect) SCopy(szSndName, szName, C4MaxSoundName); DefaultExtension(szName, "wav"); SReplaceChar(szName, '*', '?'); // Find an effect with a matching instance for (C4SoundEffect *csfx = FirstSound; csfx; csfx = csfx->Next) if (WildcardMatch(szName, csfx->Name)) { C4SoundInstance *pInst = csfx->GetInstance(pObj); if (pInst) return pInst; } return NULL; }
/* ============ WriteBSP ============ */ void WriteBSP (char *name) { char path[1024]; strcpy (path, name); DefaultExtension (path, ".bsp"); SetModelNumbers (); SetLightStyles (); UnparseEntities (); if ( !onlyents ) WriteMiptex (); WriteBSPFile (path); }
static void DelModules( void ) { lib_cmd *cmd; char buff[ MAX_IMPORT_STRING ]; for( cmd = CmdList; cmd != NULL; cmd = cmd->next ) { if( !( cmd->ops & OP_DELETE ) ) continue; strcpy( buff, cmd->name ); DefaultExtension( buff, EXT_OBJ ); if( IsExt( buff, EXT_LIB ) ) { ProcessLibOrObj( buff, OBJ_SKIP, DelOneObject ); cmd->ops |= OP_DELETED; } if( !( cmd->ops & OP_DELETED ) && !( cmd->ops & OP_ADD ) ) { Warning( ERR_CANT_DELETE, cmd->name ); } else if( ( cmd->ops & OP_DELETED ) && !( cmd->ops & OP_ADD ) && Options.ar && Options.verbose ) { Message( "-d %s", cmd->name ); } } }
int main (int argc, char **argv) { int i; char source[1024]; if (argc == 1) Error ("usage: bspinfo bspfile [bspfiles]"); for (i=1 ; i<argc ; i++) { printf ("---------------------\n"); strcpy (source, argv[i]); DefaultExtension (source, ".bsp"); printf ("%s\n", source); LoadBSPFile (source); PrintBSPFileSizes (); printf ("---------------------\n"); } return 0; }
/* ================= ProcessLumpyScript Loads a script file, then grabs everything from it ================= */ void ProcessLumpyScript (char *basename) { char script[256]; printf ("qlumpy script: %s\n",basename); // // create default destination directory // strcpy (destfile, ExpandPath(basename)); StripExtension (destfile); strcat (destfile,".wad"); // unless the script overrides, save in cwd // // save in a wadfile by default // savesingle = false; grabbed = 0; outputcreated = false; // // read in the script file // strcpy (script, basename); DefaultExtension (script, ".ls"); LoadScriptFile (script); strcpy (basepath, basename); ParseScript (); // execute load / grab commands if (!savesingle) { WriteWad (do16bit); // write out the wad directory printf ("%i lumps grabbed in a wad file\n",grabbed); } else printf ("%i lumps written seperately\n",grabbed); }
void SaveAsDialog (void) { strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") ); strcat (szDirName, "\\maps"); /* Place the terminating null character in the szFile. */ szFile[0] = '\0'; /* Set the members of the OPENFILENAME structure. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_qeglobals.d_hwndCamera; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; /* Display the Open dialog box. */ if (!GetSaveFileName(&ofn)) return; // canceled DefaultExtension (ofn.lpstrFile, ".map"); strcpy (currentmap, ofn.lpstrFile); // Add the file in MRU. AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile); // Refresh the File menu. PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0), ID_FILE_EXIT); Map_SaveFile (ofn.lpstrFile, false); // ignore region }
int ExportEntitiesMain( int argc, char **argv ){ /* arg checking */ if ( argc < 1 ) { Sys_Printf( "Usage: q3map -exportents [-v] <mapname>\n" ); return 0; } /* do some path mangling */ strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); /* load the bsp */ Sys_Printf( "Loading %s\n", source ); LoadBSPFile( source ); /* export the lightmaps */ ExportEntities(); /* return to sender */ return 0; }
void WriteLitFile(const char *filename, int version) { FILE *l; char f[1024]; litheader_t h; strncpy(f, filename, 1019); /* 1024 - space for extension - '\0' */ f[1023] = '\0'; StripExtension(f); DefaultExtension(f, ".lit"); h.ident[0] = 'Q'; h.ident[1] = 'L'; h.ident[2] = 'I'; h.ident[3] = 'T'; h.version = LittleLong(version); l = SafeOpenWrite(f); SafeWrite(l, &h, sizeof(litheader_t)); SafeWrite(l, lit_filebase, lightdatasize * 3); fclose(l); }
/* =========== main =========== */ int main (int argc, char **argv) { char portalfile[1024]; char source[1024]; int i; double start, end; printf ("vis.exe v1.3 (%s)\n", __DATE__); printf ("---- vis ----\n"); verbose = false; for (i=1 ; i<argc ; i++) { if (!strcmp(argv[i],"-threads")) { numthreads = atoi (argv[i+1]); i++; } else if (!strcmp(argv[i], "-fast")) { printf ("fastvis = true\n"); fastvis = true; } else if (!strcmp(argv[i], "-v")) { printf ("verbose = true\n"); verbose = true; } else if (argv[i][0] == '-') Error ("Unknown option \"%s\"", argv[i]); else break; } if (i != argc - 1) Error ("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile"); start = I_FloatTime (); ThreadSetDefault (); printf ("%i thread(s)\n", numthreads); strcpy (source, argv[i]); StripExtension (source); DefaultExtension (source, ".bsp"); LoadBSPFile (source); strcpy (portalfile, argv[i]); StripExtension (portalfile); strcat (portalfile, ".prt"); LoadPortals (portalfile); uncompressed = malloc(bitbytes*portalleafs); memset (uncompressed, 0, bitbytes*portalleafs); CalcVis (); qprintf ("c_chains: %i\n",c_chains); visdatasize = vismap_p - dvisdata; printf ("visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize); CalcAmbientSounds (); WriteBSPFile (source); // unlink (portalfile); end = I_FloatTime (); printf ("%5.1f seconds elapsed\n", end-start); free(uncompressed); return 0; }
/* ============== main ============== */ int main (int argc, char **argv) { static int i; // VC4.2 compiler bug if auto... char path[1024]; // using GtkRadiant's versioning next to Id's versioning printf ("Q3Data - (c) 1999 Id Software Inc.\n"); printf ("GtkRadiant - v" RADIANT_VERSION " " __DATE__ "\n"); ExpandWildcards (&argc, &argv); for (i=1 ; i<argc ; i++) { if (!strcmp(argv[i], "-archive")) { archive = qtrue; strcpy (archivedir, argv[i+1]); printf ("Archiving source to: %s\n", archivedir); i++; } else if (!strcmp(argv[i], "-release")) { g_release = qtrue; strcpy (g_releasedir, argv[i+1]); printf ("Copy output to: %s\n", g_releasedir); i++; } else if ( !strcmp( argv[i], "-nostrips" ) ) { g_stripify = qfalse; printf( "Not optimizing for strips\n" ); } else if ( !strcmp( argv[i], "-writedir" ) ) { strcpy( writedir, argv[i+1] ); printf( "Write output to: %s\n", writedir ); i++; } else if ( !strcmp( argv[i], "-verbose" ) ) { g_verbose = qtrue; } else if ( !strcmp( argv[i], "-dump" ) ) { printf( "Dumping contents of: '%s'\n", argv[i+1] ); if ( strstr( argv[i+1], ".md3" ) ) { MD3_Dump( argv[i+1] ); } else { Error( "Do not know how to dump the contents of '%s'\n", argv[i+1] ); } i++; } else if ( !strcmp( argv[i], "-3dsconvert" ) ) { // NOTE TTimo this is broken, tried on a sample .3ds // what happens .. it calls the Convert3DStoMD3, // which calls the scriptlib function in non initialized state .. and crashes printf( "Converting %s.3DS to %s.MD3\n", argv[i+1], argv[i+1] ); SetQdirFromPath( argv[i+1] ); vfsInitDirectory( gamedir ); Convert3DStoMD3( argv[i+1] ); i++; } else if (!strcmp(argv[i], "-only")) { strcpy (g_only, argv[i+1]); printf ("Only grabbing %s\n", g_only); i++; } else if (!strcmp(argv[i], "-gamedir")) { strcpy(gamedir, argv[i+1]); i++; } else if (argv[i][0] == '-') Error ("Unknown option \"%s\"", argv[i]); else break; } if (i == argc) Error ("usage: q3data [-archive <directory>] [-dump <file.md3>] [-release <directory>] [-only <model>] [-3dsconvert <file.3ds>] [-verbose] [file.qdt]"); for ( ; i<argc ; i++) { printf ("--------------- %s ---------------\n", argv[i]); // load the script strcpy (path, argv[i]); DefaultExtension (path, ".qdt"); if(!gamedir[0]) SetQdirFromPath (path); // NOTE TTimo // q3data went through a partial conversion to use the vfs // it was never actually tested before 1.1.1 // the code is still mostly using direct file access calls vfsInitDirectory( gamedir ); LoadScriptFile (ExpandArg(path), -1); // // parse it // ParseScript (); // write out the last model FinishModel ( TYPE_UNKNOWN ); } return 0; }
/* ============== main ============== */ int main (int argc, char **argv) { static int i; // VC4.2 compiler bug if auto... char path[1024]; ExpandWildcards (&argc, &argv); for (i=1 ; i<argc ; i++) { if (!strcmp(argv[i], "-archive")) { // -archive f:/quake2/release/dump_11_30 archive = true; strcpy (archivedir, argv[i+1]); printf ("Archiving source to: %s\n", archivedir); i++; } else if (!strcmp(argv[i], "-release")) { g_release = true; strcpy (g_releasedir, argv[i+1]); printf ("Copy output to: %s\n", g_releasedir); i++; } else if (!strcmp(argv[i], "-compress")) { g_compress_pak = true; printf ("Compressing pakfile\n"); } else if (!strcmp(argv[i], "-pak")) { g_release = true; g_pak = true; printf ("Building pakfile: %s\n", argv[i+1]); BeginPak (argv[i+1]); i++; } else if (!strcmp(argv[i], "-only")) { strcpy (g_only, argv[i+1]); printf ("Only grabbing %s\n", g_only); i++; } else if (!strcmp(argv[i], "-3ds")) { do3ds = true; printf ("loading .3ds files\n"); } else if (argv[i][0] == '-') Error ("Unknown option \"%s\"", argv[i]); else break; } if (i >= argc) Error ("usage: qgrab [-archive <directory>] [-release <directory>] [-only <model>] [-3ds] file.qgr"); if (do3ds) trifileext = ext_3ds; else trifileext = ext_tri; for ( ; i<argc ; i++) { printf ("--------------- %s ---------------\n", argv[i]); // load the script strcpy (path, argv[i]); DefaultExtension (path, ".qdt"); SetQdirFromPath (path); LoadScriptFile (ExpandArg(path)); // // parse it // ParseScript (); // write out the last model FinishModel (); FinishSprite (); } if (g_pak) FinishPak (); return 0; }
/* ConvertBspToASE() exports an 3d studio ase file from the bsp */ int ConvertBspToASE(int argc, char **argv) { int i; double start, end; char source[1024]; char dest[1024]; Sys_Printf("---- convert map to ase ----\n"); for(i = 1; i < argc; i++) { if(!strcmp(argv[i], "-threads")) { numthreads = atoi(argv[i + 1]); i++; } else if(!strcmp(argv[i], "-v")) { Sys_Printf("verbose = true\n"); verbose = qtrue; } else if(!strcmp(argv[i], "-connect")) { Broadcast_Setup(argv[++i]); } else if(argv[i][0] == '-') Error("Unknown option \"%s\"", argv[i]); else break; } if(i != argc - 1) { Error("usage: xmap -bsp2ase [-<switch> [-<switch> ...]] <mapname.bsp>\n" "\n" "Switches:\n" " v = verbose output\n"); //" quake1 = convert from QuakeWorld to XreaL\n" //" quake2 = convert from Quake2 to XreaL\n" //" quake3 = convert from Quake3 to XreaL\n" //" quake4 = convert from Quake4 to XreaL\n"); } start = I_FloatTime(); ThreadSetDefault(); SetQdirFromPath(argv[i]); strcpy(source, ExpandArg(argv[i])); StripExtension(source); DefaultExtension(source, ".bsp"); // start from scratch LoadShaderInfo(); Sys_Printf("reading %s\n", source); LoadBSPFile(source); ParseEntities(); // strcpy(dest, ExpandArg(argv[i])); StripExtension(dest); strcat(dest, "_converted"); DefaultExtension(dest, ".ase"); WriteASEFile(dest); end = I_FloatTime(); Sys_Printf("%5.0f seconds elapsed\n", end - start); // shut down connection Broadcast_Shutdown(); return 0; }
/* * ================== * main * light modelfile * ================== */ int main(int argc, const char **argv) { int i, bsp_version; double start; double end; char source[1024]; init_log("light.log"); logprint("----- TyrLight v0.99e -----\n" #if 0 "** Beta version " __DATE__ " " __TIME__ "\n" #endif ); numthreads = GetDefaultThreads(); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-threads")) { numthreads = atoi(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-extra")) { extrasamples = true; logprint("extra sampling enabled\n"); } else if (!strcmp(argv[i], "-dist")) { scaledist = atof(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-range")) { rangescale = atof(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-light")) { worldminlight = atof(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-compress")) { compress_ents = true; logprint("light entity compression enabled\n"); } else if (!strcmp(argv[i], "-colored") || !strcmp(argv[i], "-coloured")) { colored = true; } else if (!strcmp(argv[i], "-bsp30")) { bsp30 = true; } else if (!strcmp(argv[i], "-lit")) { litfile = true; } else if (!strcmp(argv[i], "-nominlimit")) { nominlimit = true; } else if (argv[i][0] == '-') Error("Unknown option \"%s\"", argv[i]); else break; } if (numthreads > 1) logprint("running with %d threads\n", numthreads); // Switch on colored flag if specifying -lit or -bsp30 if (bsp30 || litfile) colored = true; // Check the colored options if (colored) { if (!bsp30 && !litfile) { logprint("colored output format not specified -> using bsp 30\n"); bsp30 = true; } else if (bsp30 && litfile) { Error("Two colored output formats specified"); } else if (litfile) { logprint("colored output format: lit\n"); } else if (bsp30) { logprint("colored output format: bsp30\n"); } } if (i != argc - 1) Error("usage: light [-threads num] [-light num] [-extra]\n" " [-colored] [-bsp30] [-lit]\n" " [-nocount] [-compress] [-nominlimit] bspfile\n"); start = I_FloatTime(); strcpy(source, argv[i]); StripExtension(source); DefaultExtension(source, ".bsp"); bsp_version = LoadBSPFile(source); LoadEntities(); MakeTnodes(); FindFaceOffsets(); LightWorld(); WriteEntitiesToString(); if (colored && bsp30) WriteBSPFile(source, 30); else WriteBSPFile(source, bsp_version); if (colored && litfile) WriteLitFile(source, LIT_VERSION); end = I_FloatTime(); logprint("%5.1f seconds elapsed\n", end - start); close_log(); return 0; }
int BSPMain( int argc, char **argv ) { int i; char path[ 1024 ], tempSource[ 1024 ]; qboolean onlyents = qfalse; /* note it */ Sys_Printf( "--- BSP ---\n" ); SetDrawSurfacesBuffer(); mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS ); memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS ); numMapDrawSurfs = 0; tempSource[ 0 ] = '\0'; /* set standard game flags */ maxSurfaceVerts = game->maxSurfaceVerts; maxSurfaceIndexes = game->maxSurfaceIndexes; emitFlares = game->emitFlares; /* process arguments */ for( i = 1; i < (argc - 1); i++ ) { if( !strcmp( argv[ i ], "-onlyents" ) ) { Sys_Printf( "Running entity-only compile\n" ); onlyents = qtrue; } else if( !strcmp( argv[ i ], "-tempname" ) ) strcpy( tempSource, argv[ ++i ] ); else if( !strcmp( argv[ i ], "-tmpout" ) ) strcpy( outbase, "/tmp" ); else if( !strcmp( argv[ i ], "-nowater" ) ) { Sys_Printf( "Disabling water\n" ); nowater = qtrue; } else if( !strcmp( argv[ i ], "-nodetail" ) ) { Sys_Printf( "Ignoring detail brushes\n") ; nodetail = qtrue; } else if( !strcmp( argv[ i ], "-fulldetail" ) ) { Sys_Printf( "Turning detail brushes into structural brushes\n" ); fulldetail = qtrue; } else if( !strcmp( argv[ i ], "-nofog" ) ) { Sys_Printf( "Fog volumes disabled\n" ); nofog = qtrue; } else if( !strcmp( argv[ i ], "-nosubdivide" ) ) { Sys_Printf( "Disabling brush face subdivision\n" ); nosubdivide = qtrue; } else if( !strcmp( argv[ i ], "-leaktest" ) ) { Sys_Printf( "Leaktest enabled\n" ); leaktest = qtrue; } else if( !strcmp( argv[ i ], "-verboseentities" ) ) { Sys_Printf( "Verbose entities enabled\n" ); verboseEntities = qtrue; } else if( !strcmp( argv[ i ], "-nocurves" ) ) { Sys_Printf( "Ignoring curved surfaces (patches)\n" ); noCurveBrushes = qtrue; } else if( !strcmp( argv[ i ], "-notjunc" ) ) { Sys_Printf( "T-junction fixing disabled\n" ); notjunc = qtrue; } else if( !strcmp( argv[ i ], "-fakemap" ) ) { Sys_Printf( "Generating fakemap.map\n" ); fakemap = qtrue; } else if( !strcmp( argv[ i ], "-samplesize" ) ) { sampleSize = atoi( argv[ i + 1 ] ); if( sampleSize < 1 ) sampleSize = 1; i++; Sys_Printf( "Lightmap sample size set to %dx%d units\n", sampleSize, sampleSize ); } else if( !strcmp( argv[ i ], "-custinfoparms") ) { Sys_Printf( "Custom info parms enabled\n" ); useCustomInfoParms = qtrue; } /* sof2 args */ else if( !strcmp( argv[ i ], "-rename" ) ) { Sys_Printf( "Appending _bsp suffix to misc_model shaders (SOF2)\n" ); renameModelShaders = qtrue; } /* ydnar args */ else if( !strcmp( argv[ i ], "-ne" ) ) { normalEpsilon = atof( argv[ i + 1 ] ); i++; Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon ); } else if( !strcmp( argv[ i ], "-de" ) ) { distanceEpsilon = atof( argv[ i + 1 ] ); i++; Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon ); } else if( !strcmp( argv[ i ], "-mv" ) ) { maxLMSurfaceVerts = atoi( argv[ i + 1 ] ); if( maxLMSurfaceVerts < 3 ) maxLMSurfaceVerts = 3; if( maxLMSurfaceVerts > maxSurfaceVerts ) maxSurfaceVerts = maxLMSurfaceVerts; i++; Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts ); } else if( !strcmp( argv[ i ], "-mi" ) ) { maxSurfaceIndexes = atoi( argv[ i + 1 ] ); if( maxSurfaceIndexes < 3 ) maxSurfaceIndexes = 3; i++; Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes ); } else if( !strcmp( argv[ i ], "-np" ) ) { npDegrees = atof( argv[ i + 1 ] ); if( npDegrees < 0.0f ) shadeAngleDegrees = 0.0f; else if( npDegrees > 0.0f ) Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees ); i++; } else if( !strcmp( argv[ i ], "-snap" ) ) { bevelSnap = atoi( argv[ i + 1 ]); if( bevelSnap < 0 ) bevelSnap = 0; i++; if( bevelSnap > 0 ) Sys_Printf( "Snapping brush bevel planes to %d units\n", bevelSnap ); } else if( !strcmp( argv[ i ], "-texrange" ) ) { texRange = atoi( argv[ i + 1 ]); if( texRange < 0 ) texRange = 0; i++; Sys_Printf( "Limiting per-surface texture range to %d texels\n", texRange ); } else if( !strcmp( argv[ i ], "-nohint" ) ) { Sys_Printf( "Hint brushes disabled\n" ); noHint = qtrue; } else if( !strcmp( argv[ i ], "-flat" ) ) { Sys_Printf( "Flatshading enabled\n" ); flat = qtrue; } else if( !strcmp( argv[ i ], "-meta" ) ) { Sys_Printf( "Creating meta surfaces from brush faces\n" ); meta = qtrue; } else if( !strcmp( argv[ i ], "-patchmeta" ) ) { Sys_Printf( "Creating meta surfaces from patches\n" ); patchMeta = qtrue; } else if( !strcmp( argv[ i ], "-flares" ) ) { Sys_Printf( "Flare surfaces enabled\n" ); emitFlares = qtrue; } else if( !strcmp( argv[ i ], "-noflares" ) ) { Sys_Printf( "Flare surfaces disabled\n" ); emitFlares = qfalse; } else if( !strcmp( argv[ i ], "-skyfix" ) ) { Sys_Printf( "GL_CLAMP sky fix/hack/workaround enabled\n" ); skyFixHack = qtrue; } else if( !strcmp( argv[ i ], "-debugsurfaces" ) ) { Sys_Printf( "emitting debug surfaces\n" ); debugSurfaces = qtrue; } else if( !strcmp( argv[ i ], "-debuginset" ) ) { Sys_Printf( "Debug surface triangle insetting enabled\n" ); debugInset = qtrue; } else if( !strcmp( argv[ i ], "-debugportals" ) ) { Sys_Printf( "Debug portal surfaces enabled\n" ); debugPortals = qtrue; } else if( !strcmp( argv[ i ], "-bsp" ) ) Sys_Printf( "-bsp argument unnecessary\n" ); else Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] ); } /* fixme: print more useful usage here */ if( i != (argc - 1) ) Error( "usage: q3map [options] mapfile" ); /* copy source name */ strcpy( source, ExpandArg( argv[ i ] ) ); StripExtension( source ); /* ydnar: set default sample size */ SetDefaultSampleSize( sampleSize ); /* delete portal, line and surface files */ sprintf( path, "%s.prt", source ); remove( path ); sprintf( path, "%s.lin", source ); remove( path ); //% sprintf( path, "%s.srf", source ); /* ydnar */ //% remove( path ); /* expand mapname */ strcpy( name, ExpandArg( argv[ i ] ) ); if( strcmp( name + strlen( name ) - 4, ".reg" ) ) { /* if we are doing a full map, delete the last saved region map */ sprintf( path, "%s.reg", source ); remove( path ); DefaultExtension( name, ".map" ); /* might be .reg */ } /* if onlyents, just grab the entites and resave */ if( onlyents ) { OnlyEnts(); return 0; } /* load shaders */ LoadShaderInfo(); /* load original file from temp spot in case it was renamed by the editor on the way in */ if( strlen( tempSource ) > 0 ) LoadMapFile( tempSource, qfalse ); else LoadMapFile( name, qfalse ); /* ydnar: decal setup */ ProcessDecals(); /* ydnar: cloned brush model entities */ SetCloneModelNumbers(); /* process world and submodels */ ProcessModels(); /* set light styles from targetted light entities */ SetLightStyles(); /* finish and write bsp */ EndBSPFile(); /* remove temp map source file if appropriate */ if( strlen( tempSource ) > 0) remove( tempSource ); /* return to sender */ return 0; }
static EIWADType IdentifyVersion (TArray<FString> &wadfiles, const char *iwad, const char *zdoom_wad) { WadStuff wads[countof(IWADNames)]; size_t foundwads[NUM_IWAD_TYPES] = { 0 }; const char *iwadparm = Args->CheckValue ("-iwad"); size_t numwads; int pickwad; size_t i; bool iwadparmfound = false; FString custwad; if (iwadparm == NULL && iwad != NULL && *iwad != 0) { iwadparm = iwad; } if (iwadparm) { custwad = iwadparm; FixPathSeperator (custwad); if (CheckIWAD (custwad, wads)) { // -iwad parameter was a directory iwadparm = NULL; } else { DefaultExtension (custwad, ".wad"); iwadparm = custwad; IWADNames[0] = iwadparm; CheckIWAD ("", wads); } } if (iwadparm == NULL || wads[0].Path.IsEmpty()) { if (GameConfig->SetSection ("IWADSearch.Directories")) { const char *key; const char *value; while (GameConfig->NextInSection (key, value)) { if (stricmp (key, "Path") == 0) { FString nice = NicePath(value); FixPathSeperator(nice); CheckIWAD(nice, wads); } } } #ifdef _WIN32 FString steam_path = I_GetSteamPath(); if (steam_path.IsNotEmpty()) { static const char *const steam_dirs[] = { "doom 2/base", "final doom/base", "heretic shadow of the serpent riders/base", "hexen/base", "hexen deathkings of the dark citadel/base", "ultimate doom/base" }; steam_path += "/SteamApps/common/"; for (i = 0; i < countof(steam_dirs); ++i) { CheckIWAD (steam_path + steam_dirs[i], wads); } } #endif } if (iwadparm != NULL && !wads[0].Path.IsEmpty()) { iwadparmfound = true; } for (i = numwads = 0; i < countof(IWADNames); i++) { if (!wads[i].Path.IsEmpty()) { if (i != numwads) { wads[numwads] = wads[i]; } foundwads[wads[numwads].Type] = numwads + 1; numwads++; } } if (foundwads[IWAD_HexenDK] && !foundwads[IWAD_Hexen]) { // Cannot play Hexen DK without Hexen size_t kill = foundwads[IWAD_HexenDK]; for (i = kill; i < numwads; ++i) { wads[i - 1] = wads[i]; } numwads--; foundwads[IWAD_HexenDK] = 0; for (i = 0; i < NUM_IWAD_TYPES; ++i) { if (foundwads[i] > kill) { foundwads[i]--; } } } if (numwads == 0) // [BB] Skulltag uses Rivecoder's IWAD setup screen now (only available under Windows). #ifdef _WIN32 throw CNoIWADError(); // [RC] #else { I_FatalError ("Cannot find a game IWAD (doom.wad, doom2.wad, heretic.wad, etc.).\n" "Did you install "GAMENAME" properly? You can do either of the following:\n" "\n" "1. Place one or more of these wads in the same directory as "GAMENAME".\n" "2. Edit your "GAMENAMELOWERCASE"-username.ini and add the directories of your iwads\n" "to the list beneath [IWADSearch.Directories]"); } #endif pickwad = 0; if (!iwadparmfound && numwads > 1) { int defiwad = 0; // Locate the user's prefered IWAD, if it was found. if (defaultiwad[0] != '\0') { for (i = 0; i < numwads; ++i) { FString basename = ExtractFileBase (wads[i].Path); if (stricmp (basename, defaultiwad) == 0) { defiwad = (int)i; break; } } } pickwad = I_PickIWad (wads, (int)numwads, queryiwad, defiwad); if (pickwad >= 0) { // The newly selected IWAD becomes the new default FString basename = ExtractFileBase (wads[pickwad].Path); defaultiwad = basename; } } if (pickwad < 0) exit (0); // zdoom.pk3 must always be the first file loaded and the IWAD second. D_AddFile (wadfiles, zdoom_wad); if (wads[pickwad].Type == IWAD_HexenDK) { // load hexen.wad before loading hexdd.wad D_AddFile (wadfiles, wads[foundwads[IWAD_Hexen]-1].Path); } D_AddFile (wadfiles, wads[pickwad].Path); if (wads[pickwad].Type == IWAD_Strife) { // Try to load voices.wad along with strife1.wad long lastslash = wads[pickwad].Path.LastIndexOf ('/'); FString path; if (lastslash == -1) { path = "";// wads[pickwad].Path; } else { path = FString (wads[pickwad].Path.GetChars(), lastslash + 1); } path += "voices.wad"; D_AddFile (wadfiles, path); } return wads[pickwad].Type; }
int FixAAS( int argc, char **argv ) { int length, checksum; void *buffer; FILE *file; char aas[ 1024 ], **ext; char *exts[] = { ".aas", "_b0.aas", "_b1.aas", NULL }; /* arg checking */ if( argc < 2 ) { Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" ); return 0; } /* do some path mangling */ strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); /* note it */ Sys_Printf( "--- FixAAS ---\n" ); /* load the bsp */ Sys_Printf( "Loading %s\n", source ); length = LoadFile( source, &buffer ); /* create bsp checksum */ Sys_Printf( "Creating checksum...\n" ); checksum = LittleLong( MD4BlockChecksum( buffer, length ) ); /* write checksum to aas */ ext = exts; while( *ext ) { /* mangle name */ strcpy( aas, source ); StripExtension( aas ); strcat( aas, *ext ); Sys_Printf( "Trying %s\n", aas ); ext++; /* fix it */ file = fopen( aas, "r+b" ); if( !file ) continue; if( fwrite( &checksum, 4, 1, file ) != 1 ) Error( "Error writing checksum to %s", aas ); fclose( file ); } /* return to sender */ return 0; }
int ConvertBSPMain( int argc, char **argv ) { int i; int (*convertFunc)( char * ); game_t *convertGame; /* set default */ convertFunc = ConvertBSPToASE; convertGame = NULL; /* arg checking */ if( argc < 1 ) { Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" ); return 0; } /* process arguments */ for( i = 1; i < (argc - 1); i++ ) { /* -format map|ase|... */ if( !strcmp( argv[ i ], "-format" ) ) { i++; if( !Q_stricmp( argv[ i ], "ase" ) ) convertFunc = ConvertBSPToASE; else if( !Q_stricmp( argv[ i ], "map" ) ) convertFunc = ConvertBSPToMap; else { convertGame = GetGame( argv[ i ] ); if( convertGame == NULL ) Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] ); } } } /* clean up map name */ strcpy( source, ExpandArg( argv[ i ] ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); LoadShaderInfo(); Sys_Printf( "Loading %s\n", source ); /* ydnar: load surface file */ //% LoadSurfaceExtraFile( source ); LoadBSPFile( source ); /* parse bsp entities */ ParseEntities(); /* bsp format convert? */ if( convertGame != NULL ) { /* set global game */ game = convertGame; /* write bsp */ StripExtension( source ); DefaultExtension( source, "_c.bsp" ); Sys_Printf( "Writing %s\n", source ); WriteBSPFile( source ); /* return to sender */ return 0; } /* normal convert */ return convertFunc( source ); }
int ScaleBSPMain( int argc, char **argv ) { int i; float f, scale; vec3_t vec; char str[ 1024 ]; /* arg checking */ if( argc < 2 ) { Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" ); return 0; } /* get scale */ scale = atof( argv[ argc - 2 ] ); if( scale == 0.0f ) { Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" ); Sys_Printf( "Non-zero scale value required.\n" ); return 0; } /* do some path mangling */ strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); StripExtension( source ); DefaultExtension( source, ".bsp" ); /* load the bsp */ Sys_Printf( "Loading %s\n", source ); LoadBSPFile( source ); ParseEntities(); /* note it */ Sys_Printf( "--- ScaleBSP ---\n" ); Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities ); /* scale entity keys */ for( i = 0; i < numBSPEntities && i < numEntities; i++ ) { /* scale origin */ GetVectorForKey( &entities[ i ], "origin", vec ); if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) ) { VectorScale( vec, scale, vec ); sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] ); SetKeyValue( &entities[ i ], "origin", str ); } /* scale door lip */ f = FloatForKey( &entities[ i ], "lip" ); if( f ) { f *= scale; sprintf( str, "%f", f ); SetKeyValue( &entities[ i ], "lip", str ); } } /* scale models */ for( i = 0; i < numBSPModels; i++ ) { VectorScale( bspModels[ i ].mins, scale, bspModels[ i ].mins ); VectorScale( bspModels[ i ].maxs, scale, bspModels[ i ].maxs ); } /* scale nodes */ for( i = 0; i < numBSPNodes; i++ ) { VectorScale( bspNodes[ i ].mins, scale, bspNodes[ i ].mins ); VectorScale( bspNodes[ i ].maxs, scale, bspNodes[ i ].maxs ); } /* scale leafs */ for( i = 0; i < numBSPLeafs; i++ ) { VectorScale( bspLeafs[ i ].mins, scale, bspLeafs[ i ].mins ); VectorScale( bspLeafs[ i ].maxs, scale, bspLeafs[ i ].maxs ); } /* scale drawverts */ for( i = 0; i < numBSPDrawVerts; i++ ) VectorScale( bspDrawVerts[ i ].xyz, scale, bspDrawVerts[ i ].xyz ); /* scale planes */ for( i = 0; i < numBSPPlanes; i++ ) bspPlanes[ i ].dist *= scale; /* scale gridsize */ GetVectorForKey( &entities[ 0 ], "gridsize", vec ); if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) == 0.0f ) VectorCopy( gridSize, vec ); VectorScale( vec, scale, vec ); sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] ); SetKeyValue( &entities[ 0 ], "gridsize", str ); /* write the bsp */ UnparseEntities(); StripExtension( source ); DefaultExtension( source, "_s.bsp" ); Sys_Printf( "Writing %s\n", source ); WriteBSPFile( source ); /* return to sender */ return 0; }