コード例 #1
0
ファイル: main.c プロジェクト: ChunHungLiu/GtkRadiant
int main( int argc, char **argv )
{
	int		i, r;
	double	start, end;
	
	
	/* we want consistent 'randomness' */
	srand( 0 );
	
	/* start timer */
	start = I_FloatTime();

	/* this was changed to emit version number over the network */
	printf( Q3MAP_VERSION "\n" );
	
	/* set exit call */
	atexit( ExitQ3Map );
	
	/* read general options first */
	for( i = 1; i < argc; i++ )
	{
		/* -connect */
		if( !strcmp( argv[ i ], "-connect" ) )
		{
			argv[ i ] = NULL;
			i++;
			Broadcast_Setup( argv[ i ] );
			argv[ i ] = NULL;
		}
		
		/* verbose */
		else if( !strcmp( argv[ i ], "-v" ) )
		{
			verbose = qtrue;
			argv[ i ] = NULL;
		}
		
		/* force */
		else if( !strcmp( argv[ i ], "-force" ) )
		{
			force = qtrue;
			argv[ i ] = NULL;
		}
		
		/* patch subdivisions */
		else if( !strcmp( argv[ i ], "-subdivisions" ) )
		{
			argv[ i ] = NULL;
			i++;
			patchSubdivisions = atoi( argv[ i ] );
			argv[ i ] = NULL;
			if( patchSubdivisions <= 0 )
				patchSubdivisions = 1;
		}
		
		/* threads */
		else if( !strcmp( argv[ i ], "-threads" ) )
		{
			argv[ i ] = NULL;
			i++;
			numthreads = atoi( argv[ i ] );
			argv[ i ] = NULL;
		}
	}
	
	/* init model library */
	PicoInit();
	PicoSetMallocFunc( safe_malloc );
	PicoSetFreeFunc( free );
	PicoSetPrintFunc( PicoPrintFunc );
	PicoSetLoadFileFunc( PicoLoadFileFunc );
	PicoSetFreeFileFunc( free );
	
	/* set number of threads */
	ThreadSetDefault();
	
	/* generate sinusoid jitter table */
	for( i = 0; i < MAX_JITTERS; i++ )
	{
		jitters[ i ] = sin( i * 139.54152147 );
		//%	Sys_Printf( "Jitter %4d: %f\n", i, jitters[ i ] );
	}
	
	/* we print out two versions, q3map's main version (since it evolves a bit out of GtkRadiant)
	   and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
	
	Sys_Printf( "Q3Map         - v1.0r (c) 1999 Id Software Inc.\n" );
	Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
	Sys_Printf( "GtkRadiant    - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
	Sys_Printf( "%s\n", Q3MAP_MOTD );
	
	/* ydnar: new path initialization */
	InitPaths( &argc, argv );
	
	/* check if we have enough options left to attempt something */
	if( argc < 2 )
		Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] );
	
	/* fixaas */
	if( !strcmp( argv[ 1 ], "-fixaas" ) )
		r = FixAAS( argc - 1, argv + 1 );
	
	/* analyze */
	else if( !strcmp( argv[ 1 ], "-analyze" ) )
		r = AnalyzeBSP( argc - 1, argv + 1 );
	
	/* info */
	else if( !strcmp( argv[ 1 ], "-info" ) )
		r = BSPInfo( argc - 2, argv + 2 );
	
	/* vis */
	else if( !strcmp( argv[ 1 ], "-vis" ) )
		r = VisMain( argc - 1, argv + 1 );
	
	/* light */
	else if( !strcmp( argv[ 1 ], "-light" ) )
		r = LightMain( argc - 1, argv + 1 );
	
	/* vlight */
	else if( !strcmp( argv[ 1 ], "-vlight" ) )
	{
		Sys_Printf( "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
		argv[ 1 ] = "-fast";	/* eek a hack */
		r = LightMain( argc, argv );
	}
	
	/* ydnar: lightmap export */
	else if( !strcmp( argv[ 1 ], "-export" ) )
		r = ExportLightmapsMain( argc - 1, argv + 1 );
	
	/* ydnar: lightmap import */
	else if( !strcmp( argv[ 1 ], "-import" ) )
		r = ImportLightmapsMain( argc - 1, argv + 1 );
	
	/* ydnar: bsp scaling */
	else if( !strcmp( argv[ 1 ], "-scale" ) )
		r = ScaleBSPMain( argc - 1, argv + 1 );
	
	/* ydnar: bsp conversion */
	else if( !strcmp( argv[ 1 ], "-convert" ) )
		r = ConvertBSPMain( argc - 1, argv + 1 );
	
	/* ydnar: otherwise create a bsp */
	else
		r = BSPMain( argc, argv );
	
	/* emit time */
	end = I_FloatTime();
	Sys_Printf( "%9.0f seconds elapsed\n", end - start );
	
	/* shut down connection */
	Broadcast_Shutdown();
	
	/* return any error code */
	return r;
}
コード例 #2
0
ファイル: bsp.c プロジェクト: kingtiger01/OpenMOHAA
int main (int argc, char **argv) {
	int		i;
	double		start, end;
	char		path[1024];

	_printf ("Q3Map v1.0s (c) 1999 Id Software Inc.\n");
  	_printf ("OMmap (su44) - v0.1\n");

	if ( argc < 2 ) {
		Error ("usage: q3map [options] mapfile");
	}

	// check for general program options
	if (!strcmp(argv[1], "-info")) {
		Bspinfo( argc - 2, argv + 2 );
		return 0;
	}
	if (!strcmp(argv[1], "-light")) {
		LightMain( argc - 1, argv + 1 );
		return 0;
	}
	if (!strcmp(argv[1], "-vlight")) {
		VLightMain( argc - 1, argv + 1 );
		return 0;
	}
	if (!strcmp(argv[1], "-vsound")) {
		VSoundMain( argc - 1, argv + 1 );
		return 0;
	}
	if (!strcmp(argv[1], "-vis")) {
		VisMain( argc - 1, argv + 1 );
		return 0;
	}

	// do a bsp if nothing else was specified

	_printf ("---- q3map ----\n");

  tempsource[0] = '\0';

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i],"-tempname"))
    {
      strcpy(tempsource, argv[++i]);
    }
		else if (!strcmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i],"-glview"))
		{
			glview = qtrue;
		}
		else if (!strcmp(argv[i], "-v"))
		{
			_printf ("verbose = true\n");
			verbose = qtrue;
		}
		else if (!strcmp(argv[i], "-draw"))
		{
			_printf ("drawflag = true\n");
			drawflag = qtrue;
		}
		else if (!strcmp(argv[i], "-nowater"))
		{
			_printf ("nowater = true\n");
			nowater = qtrue;
		}
		else if (!strcmp(argv[i], "-noopt"))
		{
			_printf ("noopt = true\n");
			noopt = qtrue;
		}
		else if (!strcmp(argv[i], "-nofill"))
		{
			_printf ("nofill = true\n");
			nofill = qtrue;
		}
		else if (!strcmp(argv[i], "-nodetail"))
		{
			_printf ("nodetail = true\n");
			nodetail = qtrue;
		}
		else if (!strcmp(argv[i], "-fulldetail"))
		{
			_printf ("fulldetail = true\n");
			fulldetail = qtrue;
		}
		else if (!strcmp(argv[i], "-onlyents"))
		{
			_printf ("onlyents = true\n");
			onlyents = qtrue;
		}
		else if (!strcmp(argv[i], "-onlytextures"))
		{
			_printf ("onlytextures = true\n");	// FIXME: make work again!
			onlytextures = qtrue;
		}
		else if (!strcmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i+1]);
			_printf ("microvolume = %f\n", microvolume);
			i++;
		}
		else if (!strcmp(argv[i], "-nofog"))
		{
			_printf ("nofog = true\n");
			nofog = qtrue;
		}
		else if (!strcmp(argv[i], "-nosubdivide"))
		{
			_printf ("nosubdivide = true\n");
			nosubdivide = qtrue;
		}
		else if (!strcmp(argv[i], "-leaktest"))
		{
			_printf ("leaktest = true\n");
			leaktest = qtrue;
		}
		else if (!strcmp(argv[i], "-verboseentities"))
		{
			_printf ("verboseentities = true\n");
			verboseentities = qtrue;
		}
		else if (!strcmp(argv[i], "-nocurves"))
		{
			noCurveBrushes = qtrue;
			_printf ("no curve brushes\n");
		}
		else if (!strcmp(argv[i], "-notjunc"))
		{
			notjunc = qtrue;
			_printf ("no tjunction fixing\n");
		}
		else if (!strcmp(argv[i], "-expand"))
		{
			testExpand = qtrue;
			_printf ("Writing expanded.map.\n");
		}
		else if (!strcmp(argv[i], "-showseams"))
		{
			showseams = qtrue;
			_printf ("Showing seams on terrain.\n");
		}
		else if (!strcmp (argv[i],"-tmpout"))
		{
			strcpy (outbase, "/tmp");
		}
		else if (!strcmp (argv[i],"-fakemap"))
		{
			fakemap = qtrue;
			_printf( "will generate fakemap.map\n");
		}
		else if (!strcmp(argv[i], "-samplesize"))
		{
			samplesize = atoi(argv[i+1]);
			if (samplesize < 1) samplesize = 1;
			i++;
			_printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		Error ("usage: q3map [options] mapfile");

	start = I_FloatTime ();

	ThreadSetDefault ();
	//numthreads = 1;		// multiple threads aren't helping because of heavy malloc use
	SetQdirFromPath (argv[i]);

#ifdef _WIN32
  InitPakFile(gamedir, NULL);
#endif

	strcpy (source, ExpandArg (argv[i]));
	StripExtension (source);

	// delete portal and line files
	sprintf (path, "%s.prt", source);
	remove (path);
	sprintf (path, "%s.lin", source);
	remove (path);

	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;
	}

	//
	// if onlytextures, just grab the textures and resave
	//
	if ( onlytextures ) {
		OnlyTextures();
		return 0;
	}

	//
	// start from scratch
	//
	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);
  } else {
	  LoadMapFile (name);
  }

	SetModelNumbers ();
	SetLightStyles ();

	ProcessModels ();

	EndBSPFile();

	end = I_FloatTime ();
	_printf ("%5.0f seconds elapsed\n", end-start);

  // remove temp name if appropriate
  if (strlen(tempsource) > 0) {
    remove(tempsource);
  }

	return 0;
}