Exemplo n.º 1
0
Arquivo: qbsp.c Projeto: dommul/super8
/*
==================
main

==================
*/
int main (int argc, char **argv)
{
	int		i;
	double	start, end;

	myargc = argc;
	myargv = argv;

	//	malloc_debug (15);
	printf( "hmap2 by LordHavoc and Vic\n");
	printf( "based on id Software's quake qbsp, light and vis utilities source code\n" );
	printf( "\n" );

	//
	// check command line flags
	//

	if (argc == 1)
		goto error;

	// create all the filenames pertaining to this map
	strcpy(filename_map, argv[argc-1]);ReplaceExtension(filename_map, ".bsp", ".map", ".map");
	strcpy(filename_bsp, filename_map);ReplaceExtension(filename_bsp, ".map", ".bsp", ".bsp");
	strcpy(filename_prt, filename_bsp);ReplaceExtension(filename_prt, ".bsp", ".prt", ".prt");
	strcpy(filename_pts, filename_bsp);ReplaceExtension(filename_pts, ".bsp", ".pts", ".pts");
	strcpy(filename_lin, filename_bsp);ReplaceExtension(filename_lin, ".bsp", ".lin", ".lin");
	strcpy(filename_lit, filename_bsp);ReplaceExtension(filename_lit, ".bsp", ".lit", ".lit");
	strcpy(filename_dlit, filename_bsp);ReplaceExtension(filename_dlit, ".bsp", ".dlit", ".dlit");
	strcpy(filename_lights, filename_bsp);ReplaceExtension(filename_lights, ".bsp", ".lights", ".lights");

	if (!strcmp(filename_map, filename_bsp))
		Error("filename_map \"%s\" == filename_bsp \"%s\"\n", filename_map, filename_bsp);

	for (i = 0; i < argc; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			i++;
			if( i >= argc )
				Error( "no value was given to -numthreads\n" );
			numthreads = atoi (argv[i]);
		}
	}

	ThreadSetDefault ();

	i = 1;
	ismcbsp = false;
	if (!strcmp (argv[i], "-mc"))
	{
		printf ("Using Martial Concert bsp format\n");
		ismcbsp = true;
		i++;
	}

	if (argc == i)
		goto error;

	if (!strcmp (argv[i], "-bsp2prt"))
		return Bsp2Prt_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-bspinfo"))
		return BspInfo_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-vis"))
		return Vis_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-light"))
		return Light_Main (argc-i, argv+i);

	nofill = false;
	notjunc = false;
	noclip = false;
	onlyents = false;
	verbose = true;
	allverbose = false;
	transwater = true;
	forcevis = true;
	waterlightmap = true;
	subdivide_size = 240;
	option_solidbmodels = false;

	for (; i < argc; i++)
	{
		if (argv[i][0] != '-')
			break;
		else if (!strcmp (argv[i],"-nowater"))
			transwater = false;
		else if (!strcmp (argv[i],"-notjunc"))
			notjunc = true;
		else if (!strcmp (argv[i],"-nofill"))
			nofill = true;
		else if (!strcmp (argv[i],"-noclip"))
			noclip = true;
		else if (!strcmp (argv[i],"-onlyents"))
			onlyents = true;
		else if (!strcmp (argv[i],"-verbose"))
			allverbose = true;
		else if (!strcmp (argv[i],"-nowaterlightmap"))
			waterlightmap = false;
		else if (!strcmp (argv[i],"-subdivide"))
		{
			subdivide_size = atoi(argv[i+1]);
			i++;
		}
		else if (!strcmp (argv[i],"-darkplaces"))
		{
			// produce 256x256 texel lightmaps
			subdivide_size = 4080;
		}
		else if (!strcmp (argv[i],"-noforcevis"))
			forcevis = false;
		else if (!strcmp (argv[i],"-solidbmodels"))
			option_solidbmodels = true;
		else if (!strcmp (argv[i],"-wadpath"))
			i++; // handled later in wad lookups
		else
			Error ("Unknown option '%s'", argv[i]);
	}

	if (i != argc - 1)
error:
		Error ("%s",
"usage: hmap2 [options] sourcefile\n"
"Compiles .map to .bsp, does not compile vis or lighting data\n"
"\n"
"other utilities available:\n"
"-bsp2prt    bsp2prt utility, run -bsp2prt as the first parameter for more\n"
"-bspinfo    bspinfo utility, run -bspinfo as the first parameter for more\n"
"-light      lighting utility, run -light as the first parameter for more\n"
"-vis        vis utility, run -vis as the first parameter for more\n"
"\n"
"What the options do:\n"
"-nowater    disable watervis; r_wateralpha in glquake will not work right\n"
"-notjunc    disable tjunction fixing; glquake will have holes between polygons\n"
"-nofill     disable sealing of map and vis, used for ammoboxes\n"
"-onlyents   patchs entities in existing .bsp, for relighting\n"
"-verbose    show more messages\n"
"-darkplaces allow really big polygons\n"
"-noforcevis don't make a .prt if the map leaks\n"
"-nowaterlightmap disable darkplaces lightmapped water feature\n"
"-notex      store blank textures instead of real ones, smaller bsp if zipped\n"
"-solidbmodels use qbsp behavior of making water/sky submodels solid\n"
		);

	printf("inputfile: %s\n", filename_map);
	printf("outputfile: %s\n", filename_bsp);

	// init memory
	Q_InitMem ();

	//
	// do it!
	//
	start = I_DoubleTime ();
	ProcessFile (filename_map, filename_bsp);
	end = I_DoubleTime ();
	printf ("%5.1f seconds elapsed\n\n", end-start);

	// print memory stats
	Q_PrintMem ();

	// free allocated memory
	Q_ShutdownMem ();

	return 0;
}
Exemplo n.º 2
0
int main(int argc,char **argv)
{
	int		i;
	double	start, end;

	printf("Katana Level (based on hmap2 by LordHavoc and Vic)\n");
	printf("Compiled: "__DATE__" "__TIME__"\n");
	printf("\n" );

	// Check command line flags
	if(argc == 1)
		goto STARTERROR;

	// create all the filenames pertaining to this map
	strcpy(filename_map, argv[argc - 1]);
	ReplaceExtension(filename_map,BSP_EXTENSION, ".map", ".map");
	strcpy(filename_bsp, filename_map);
	ReplaceExtension(filename_bsp, ".map",BSP_EXTENSION,BSP_EXTENSION);
	strcpy(filename_prt, filename_bsp);
	ReplaceExtension(filename_prt,BSP_EXTENSION, ".prt", ".prt");
	strcpy(filename_pts, filename_bsp);
	ReplaceExtension(filename_pts,BSP_EXTENSION, ".pts", ".pts");
	strcpy(cFilenameEntity, filename_pts);
	ReplaceExtension(cFilenameEntity, ".pts", ".entity", ".entity");

	if(!strcmp(filename_map, filename_bsp))
		Error("filename_map \"%s\" == filename_bsp \"%s\"\n", filename_map, filename_bsp);

/*	for (i = 0; i < argc; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			i++;
			if( i >= argc )
				Error( "no value was given to -numthreads\n" );
			numthreads = atoi (argv[i]);
		}
	}*/

	i = 1;
	if(argc == i)
		goto STARTERROR;

	if(!strcmp(argv[i],"-threads"))
	{
		if(i >= argc)
			Error("No value was given to -threads!\n");
		numthreads = atoi(argv[i+1]);
	}

	ThreadSetDefault();

	if (!strcmp (argv[i], "-bsp2prt"))
		return Bsp2Prt_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-bspinfo"))
		return BspInfo_Main();
	else if (!strcmp (argv[i], "-vis"))
		return Vis_Main (argc-i, argv+i);
	else if (!strcmp (argv[i], "-light"))
		return Light_Main (argc-i, argv+i);

	nofill			= false;
	notjunc			= false;
	noclip			= false;
	onlyents		= false;
	verbose			= true;
	allverbose		= false;
	transwater		= true;
	forcevis		= true;
	waterlightmap	= true;
	subdivide_size	= 1024;

	for (; i < argc; i++)
	{
		if (argv[i][0] != '-')
			break;
		else if (!strcmp (argv[i],"-nowater"))
			transwater = false;
		else if (!strcmp (argv[i],"-notjunc"))
			notjunc = true;
		else if (!strcmp (argv[i],"-nofill"))
			nofill = true;
		else if (!strcmp (argv[i],"-noclip"))
			noclip = true;
		else if (!strcmp (argv[i],"-onlyents"))
			onlyents = true;
		else if (!strcmp (argv[i],"-verbose"))
			allverbose = true;
		else if (!strcmp (argv[i],"-nowaterlightmap"))
			waterlightmap = false;
		else if (!strcmp (argv[i],"-subdivide"))
		{
			subdivide_size = atoi(argv[i+1]);
			i++;
		}
		else if (!strcmp (argv[i],"-noforcevis"))
			forcevis = false;
		else if (!strcmp(argv[i], "-wadpath"))
		{ 
			sprintf(wadPath, "%s", argv[i + 1]);
			i++;
		}
		else
			Error("Unknown option '%s'",argv[i]);
	}

	if(i != argc-1)
STARTERROR:
		Error(	"%s",
				"usage: hmap2 [options] sourcefile\n"
				"Compiles .map to "BSP_EXTENSION", does not compile vis or lighting data\n"
				"\n"
				"other utilities available:\n"
				"-bsp2prt    bsp2prt utility, run -bsp2prt as the first parameter for more\n"
				"-bspinfo    bspinfo utility, run -bspinfo as the first parameter for more\n"
				"-light      lighting utility, run -light as the first parameter for more\n"
				"-vis        vis utility, run -vis as the first parameter for more\n"
				"\n"
				"What the options do:\n"
				"-wadpath (Sets the path to load WADs from.)\n"
				"-nowater			disable watervis; r_wateralpha in glquake will not work right\n"
				"-notjunc			disable tjunction fixing; glquake will have holes between polygons\n"
				"-nofill			disable sealing of map and vis, used for ammoboxes\n"
				"-onlyents			patchs entities in existing "BSP_EXTENSION", for relighting\n"
				"-verbose			show more messages\n"
				"-subdivide			allow really big polygons (e.g. -subdivide 1024)\n"
				"-noforcevis		don't make a .prt if the map leaks\n"
				"-nowaterlightmap	disable darkplaces lightmapped water feature\n"
				"-notex				store blank textures instead of real ones, smaller bsp if zipped\n");

	printf("Input:	%s\n", filename_map);
	printf("Output: %s\n", filename_bsp);

	// Init memory
	Q_InitMem ();

	// Do it!
	start = I_DoubleTime ();

	ProcessFile(filename_map);

	end = I_DoubleTime ();
	printf("%5.1f seconds elapsed\n\n",end-start);

	// Print memory stats
	Q_PrintMem();

	// Free allocated memory
	Q_ShutdownMem();

	return 0;
}