コード例 #1
0
int main (int argc, char **argv)
{
	int	ret;

	printf("Hexen II: Hammer of Thyrion Launcher, version %i.%i.%i\n",
		LAUNCHER_VERSION_MAJ, LAUNCHER_VERSION_MID, LAUNCHER_VERSION_MIN);

/* initialize the user interface */
	ret = ui_init(&argc, &argv);
	if (ret != 0)
	{
		fprintf (stderr, "Couldn't initialize user interface\n");
		exit (ret);
	}

	ValidateByteorder ();

	ret = Sys_GetUserdir(userdir, sizeof(userdir));
	if (ret != 0)
		Sys_Error (ret, "Couldn't determine userspace directory");

	memset(basedir, 0, sizeof(basedir));
	Sys_FindBinDir (argv[0], basedir);
	printf ("Basedir  : %s\n", basedir);
	printf ("Userdir  : %s\n", userdir);

/* go into the binary's directory */
	chdir (basedir);

	cfg_read_basedir();
	scan_game_installation();
	read_config_file();

/* run the graphical user interface */
	ret = ui_main ();
	if (ret == 0)
		ret = write_config_file ();

	return ret;
}
コード例 #2
0
ファイル: light.c プロジェクト: svn2github/uhexen2
/*
========
main

light modelfile
========
*/
int main (int argc, char **argv)
{
	int		i;
	int		wantthreads;
	double		start, end;
	char		source[1024];

	printf ("----- LightFaces ----\n");

	ValidateByteorder ();

	wantthreads = 1;	// default to single threaded

	for (i = 1 ; i < argc ; i++)
	{
		if (!strcmp(argv[i],"-threads"))
		{
			if (i >= argc - 1)
				COM_Error("Missing argument to \"%s\"", argv[i]);
			wantthreads = atoi (argv[++i]);
		}
		else if (!strcmp(argv[i],"-extra"))
		{
			extrasamples = true;
			printf ("extra sampling enabled\n");
		}
		else if (!strcmp(argv[i],"-dist"))
		{
			if (i >= argc - 1)
				COM_Error("Missing argument to \"%s\"", argv[i]);
			scaledist = (float)atof (argv[++i]);
		}
		else if (!strcmp(argv[i],"-range"))
		{
			if (i >= argc - 1)
				COM_Error("Missing argument to \"%s\"", argv[i]);
			rangescale = (float)atof (argv[++i]);
		}
		else if (argv[i][0] == '-')
			COM_Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i != argc - 1)
		COM_Error ("usage: light [-threads num] [-extra] [-dist ?] [-range ?] bspfile");

	InitThreads (wantthreads, 0);

	start = COM_GetTime ();

	strcpy (source, argv[i]);
	StripExtension (source);
	DefaultExtension (source, ".bsp", sizeof(source));

	LoadBSPFile (source);
	LoadEntities ();

	MakeTnodes (&dmodels[0]);

	LightWorld ();

	WriteEntitiesToString ();
	WriteBSPFile (source);

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

	return 0;
}
コード例 #3
0
ファイル: hcc.c プロジェクト: svn2github/uhexen2
/*
============
main
============
*/
int main (int argc, char **argv)
{
	const char	*psrc;
	void		*src, *src2;
	char	filename[1024];
	char	*nameptr; /* filename[] without the parent sourcedir */
	int		p, crc;
	double	start, stop;
	int		registerCount, registerSize;
	int		statementCount, statementSize;
	int		functionCount, functionSize;
	int		fileInfo;
	int		quiet;

	myargc = argc;
	myargv = argv;

	if (CheckParm("-?") || CheckParm("-h") || CheckParm("-help") || CheckParm("--help"))
	{
		printf(" -oi              : Optimize Immediates\n");
		printf(" -on              : Optimize Name Table\n");
		printf(" -os              : Optimize String Heap\n");
		printf(" -quiet           : Quiet mode\n");
		printf(" -fileinfo        : Show object sizes per file\n");
		printf(" -pf              : precache_file() calls go into progs (old HCC compat)\n");
		printf(" -sc              : STR_ constants can be saved globals (old HCC compat)\n");
		printf(" -old             : Combined -pf and -sc (as above) for old HCC behavior\n");
		printf(" -src <directory> : Specify source directory\n");
		printf(" -name <source>   : Specify the name of the .src file\n");
		printf(" -version <n>     : Output progs as version n (either 6 or 7)\n");
		printf(" -v6              : Output progs as version 6\n");
		printf(" -v7              : Output progs as version 7\n");
		exit(0);
	}

	ValidateByteorder ();

	start = COM_GetTime ();

	hcc_version_req = -1;	/* output as v6 if possible, otherwise as v7 */
	p = CheckParm("-version");
	if (p != 0)
	{
		if (p >= argc - 1)
			COM_Error ("No num specified for -version");
		p = atoi(argv[p+1]);
		switch (p)
		{
		case 6:
			hcc_version_req = PROG_VERSION_V6;
			break;
		case 7:
			hcc_version_req = PROG_VERSION_V7;
			break;
		default:
			COM_Error ("Version must be either 6 or 7");
			break;
		}
	}

	if (CheckParm("-v6"))	hcc_version_req = PROG_VERSION_V6;
	if (CheckParm("-v7"))	hcc_version_req = PROG_VERSION_V7;

	p = CheckParm("-src");
	if (p != 0)
	{
	/* everything will now be relative to sourcedir: */
		if (p >= argc - 1)
			COM_Error ("No source dirname specified with -src");
		strcpy(sourcedir, argv[p+1]);
		p = strlen (sourcedir);
		if (p && !IS_DIR_SEPARATOR(sourcedir[p - 1]))
		{
			sourcedir[p] = DIR_SEPARATOR_CHAR;
			sourcedir[p + 1] = '\0';
		}
		printf("Source directory: %s\n", sourcedir);
		strcpy(filename, sourcedir);
		nameptr = strchr(filename, '\0');
	}
	else
	{
		sourcedir[0] = '\0';
		nameptr = filename;
	}

	p = CheckParm("-name");
	if (p != 0)
	{
		if (p >= argc - 1)
			COM_Error ("No input filename specified with -name");
		strcpy(nameptr, argv[p+1]);
		printf("Input file: %s\n", nameptr);
	}
	else
	{
		strcpy(nameptr, "progs.src");
	}
	LoadFile(filename, &src);
	psrc = (char *) src;

	psrc = COM_Parse(psrc);
	if (!psrc)
		COM_Error("No destination filename. hcc -help for info.");
	q_snprintf(destfile, sizeof(destfile), "%s%s", sourcedir, com_token);

	hcc_Compat_precache_file = CheckParm("-pf");
	hcc_Compat_STR_SAVEGLOBL = CheckParm("-sc");
	if (CheckParm("-old"))
	{
		hcc_Compat_precache_file = 1;
		hcc_Compat_STR_SAVEGLOBL = 1;
	}
	hcc_OptimizeImmediates = CheckParm("-oi");
	hcc_OptimizeNameTable = CheckParm("-on");
	hcc_OptimizeStringHeap = CheckParm("-os");
	hcc_WarningsActive = CheckParm("-nowarnings") ? false : true;
	hcc_ShowUnrefFuncs = CheckParm("-urfunc") ? true : false;

	fileInfo = CheckParm("-fileinfo");
	quiet = CheckParm("-quiet");

	InitData ();
	LX_Init ();
	CO_Init ();
	EX_Init ();

	PR_BeginCompilation();

	// compile all the files
	do
	{
		psrc = COM_Parse(psrc);
		if (!psrc)
			break;

		registerCount = numpr_globals;
		statementCount = numstatements;
		functionCount = numfunctions;
		strcpy (nameptr, com_token);
		if (!quiet)
			printf("compiling %s\n", nameptr);
		LoadFile (filename, &src2);

		if (!CO_CompileFile((char *)src2, nameptr))
			exit (1);
		if (!quiet && fileInfo)
		{
			registerCount = numpr_globals-registerCount;
			registerSize = registerCount*sizeof(float);
			statementCount = numstatements-statementCount;
			statementSize = statementCount*sizeof(dstatement_t);
			functionCount = numfunctions-functionCount;
			functionSize = functionCount*sizeof(dfunction_t);
			printf("      registers: %10d (%10d bytes)\n", registerCount, registerSize);
			printf("     statements: %10d (%10d bytes)\n", statementCount, statementSize);
			printf("      functions: %10d (%10d bytes)\n", functionCount, functionSize);
			printf("     total size: %10d bytes\n", registerSize+statementSize+functionSize);
		}
	} while (1);

	if (!PR_FinishCompilation())
		COM_Error ("compilation errors");

	p = CheckParm("-asm");
	if (p != 0)
	{
		for (p++; p < argc; p++)
		{
			if (argv[p][0] == '-')
				break;
			PrintFunction(argv[p]);
		}
	}

	// write progdefs.h
	strcpy(nameptr, "progdefs.h");
	crc = PR_WriteProgdefs(filename);

	// write data file
	WriteData(crc);

	// write files.dat
	WriteFiles();
	printf(" precache_sound: %10d / %10d\n", numsounds, MAX_SOUNDS);
	printf(" precache_model: %10d / %10d\n", nummodels, MAX_MODELS);
	printf("  precache_file: %10d / %10d\n", numfiles, MAX_FILES);

	stop = COM_GetTime ();
	printf("\n%d seconds elapsed.\n", (int)(stop - start));

	return 0;
}
コード例 #4
0
ファイル: hcc.c プロジェクト: crutchwalkfactory/motocakerteam
/*
============
main
============
*/
int main (int argc, char **argv)
{
	const char	*psrc;
	void		*src, *src2;
	char	filename[1024];
	int		p, c;
	unsigned short		crc;
	double	start, stop;
	FILE	*f;

	myargc = argc;
	myargv = argv;

	if (CheckParm("-?") || CheckParm("-h") || CheckParm("-help") || CheckParm("--help"))
	{
		printf(" Compiles progs.dat using progs.src in the current directory\n");
		printf(" -src <directory> : Specify source directory\n");
		printf(" -dcc : decompile the progs.dat in the current directory\n");
		printf(" -dcc -fix : fixes mangled names during decompilation\n");
		printf(" -dcc -asm <functionname> : decompile filename to the console\n");
		printf(" -dcc -dump -asm <functionname> : same as above but will show\n\t\tinstructions (opcodes and parms) as well\n");
		exit(0);
	}

	ValidateByteorder ();

	start = GetTime ();

	p = CheckParm("-src");
	if (p && p < argc-1)
	{
		strcpy(sourcedir, argv[p+1]);
		strcat(sourcedir, "/");
		printf("Source directory: %s\n", sourcedir);
	}
	else
	{
		sourcedir[0] = '\0';
	}

	InitData ();

	PR_FILE = stdout;

	p = CheckParm("-dump");
	if (p)
		pr_dumpasm = true;

	// do a crc of the file
	p = CheckParm("-crc");
	if (p)
	{
		CRC_Init (&crc);
		f = fopen ("progdefs.h", "r");
		while ((c = fgetc(f)) != EOF)
			CRC_ProcessByte (&crc, (byte)c);

		printf ("#define PROGHEADER_CRC %i %d\n", crc, (int)crc);
		fclose (f);
		exit (0);
	}

	p = CheckParm("-dcc");
	if (p)
	{
		DEC_ReadData ("progs.dat");
		//fix mangled names if asked
		p = CheckParm ("-fix");
		if (p)
			FILE_NUM_FOR_NAME = 1;

		memset(func_headers, 0, MAX_FUNCTIONS * sizeof(char *));
		memset(temp_val, 0, MAX_REGS * sizeof(char *));

		p = CheckParm("-bbb");
		if (p)
		{
		/*	i= -999;
			for (p = 0; p < numstatements; p++)
				if ((statements+p)->op > i)
					i = (statements+p)->op;
			printf("largest op %d\n", i); */
			FindBuiltinParameters(1);

			exit (0);
		}

		p = CheckParm("-ddd");
		if (p)
		{
			for (p++ ; p < argc ; p++)
			{
				if (argv[p][0] == '-')
					break;
				DccFunctionOP (atoi(argv[p]));
			}
			exit (0);
		}

		p = CheckParm("-info2");
		if (p)
		{
			printf("\n=======================\n");
			printf("fields\n");
			printf("=======================\n");
			PrintFields ();
			printf("\n=======================\n");
			printf("globals\n");
			printf("=======================\n");
			PrintGlobals ();
			exit (0);
		}

		p = CheckParm("-info");
		if (p)
		{
			printf("\n=======================\n");
			printf("strings\n");
			printf("=======================\n");
			PrintStrings ();
			printf("\n=======================\n");
			printf("functions");
			printf("\n=======================\n");
			PrintFunctions ();
			printf("\n=======================\n");
			printf("fields\n");
			printf("=======================\n");
			PrintFields ();
			printf("\n=======================\n");
			printf("globals\n");
			printf("=======================\n");
			PrintGlobals ();
			printf("\n=======================\n");
			printf("pr_globals\n");
			printf("=======================\n");
			PrintPRGlobals ();
			printf("\n=======================\n");
			printf("statements\n");
			printf("=======================\n");
			Printstatements();
			exit (0);
		}

		p = CheckParm("-asm");
		if (p)
		{
			for (p++; p < argc; p++)
			{
				if (argv[p][0] == '-')
					break;
				PR_PrintFunction(argv[p]);
			}
		}
		else
		{
			Dcc_Functions ();
			stop = GetTime ();
			printf("\n%d seconds elapsed.\n", (int)(stop-start));
		}

		exit (0);
	}

	sprintf(filename, "%sprogs.src", sourcedir);
	LoadFile(filename, &src);
	psrc = (char *) src;

	psrc = COM_Parse(psrc);
	if (!psrc)
	{
		Error("No destination filename.  HCC -help for info.\n");
	}

	strcpy(destfile, com_token);
	printf("outputfile: %s\n", destfile);

	pr_dumpasm = false;

	PR_BeginCompilation();

	// compile all the files
	do
	{
		psrc = COM_Parse(psrc);
		if (!psrc)
			break;

		sprintf (filename, "%s%s", sourcedir, com_token);
		printf ("compiling %s\n", filename);
		LoadFile (filename, &src2);

		if (!PR_CompileFile((char *)src2, filename))
			exit (1);

	} while (1);

	if (!PR_FinishCompilation())
	{
		Error ("compilation errors");
	}

	p = CheckParm("-asm");
	if (p)
	{
		for (p++; p < argc; p++)
		{
			if (argv[p][0] == '-')
			{
				break;
			}
			PrintFunction(argv[p]);
		}
	}

	// write progdefs.h
	crc = PR_WriteProgdefs("progdefs.h");
//	crc = 14046;	// FIXME: cheap hack for now!!!!!!!!!!!!!

	// write data file
	WriteData(crc);

	// write files.dat
	WriteFiles();

	stop = GetTime ();
	printf("\n%d seconds elapsed.\n", (int)(stop-start));

	exit (0);
}
コード例 #5
0
/*
==================
main

==================
*/
int main (int argc, char **argv)
{
    int			i;
    double		start, end;
    char		sourcename[1024];
    char		destname[1024];

    printf ("---- qbsp ----\n");

    ValidateByteorder ();

#ifdef PLATFORM_WINDOWS
    gargs[0] = 0;
    for (i = 1 ; i < argc ; i++)
    {
        strcat(gargs,argv[i]);
        strcat(gargs," ");
    }
#endif

//	malloc_debug (15);

//
// let forked processes change name for ps status
//
    argv0 = argv[0];
//
// check command line flags
//
    for (i = 1 ; i < argc ; i++)
    {
        if (argv[i][0] != '-')
            break;
        else if (!strcmp (argv[i],"-draw"))
            drawflag = true;
        else if (!strcmp (argv[i],"-watervis"))
            watervis = true;
        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],"-usehulls"))
            usehulls = true;	// don't fork -- use the existing files
        else if (!strcmp (argv[i],"-hullnum"))
        {
            hullnum = atoi(argv[i+1]);
            sprintf (argv0, "HUL%i", hullnum);
            i++;
        }
        else if (!strcmp (argv[i],"-proj"))
        {
            strcpy (projectpath, argv[i+1]);
            i++;
        }
        else
            Error ("qbsp: Unknown option '%s'", argv[i]);
    }

    if (i != argc - 2 && i != argc - 1)
        Error ("usage: qbsp [options] sourcefile [destfile]\noptions: -notjunc -nofill -draw -onlyents -verbose -proj <projectpath>");

    MakeProjectPath (argv[i]);

//
// create destination name if not specified
//
    strcpy (sourcename, argv[i]);
    DefaultExtension (sourcename, ".map", sizeof(sourcename));

    if (i != argc - 2)
    {
        strcpy (destname, argv[i]);
        StripExtension (destname);
        strcat (destname, ".bsp");
        printf ("outputfile: %s\n", destname);
    }
    else
        strcpy (destname, argv[i+1]);

//
// do it!
//
    start = GetTime ();
    ProcessFile (sourcename, destname);
    end = GetTime ();
    printf ("%5.1f seconds elapsed\n", end-start);

    return 0;
}
コード例 #6
0
ファイル: hcc.c プロジェクト: svn2github/uhexen2
/*
============
main
============
*/
int main (int argc, char **argv)
{
	const char	*psrc;
	void		*src, *src2;
	char	filename[1024];
	char	*nameptr; /* filename[] without the parent sourcedir */
	int		p, crc;
	double	start, stop;

	myargc = argc;
	myargv = argv;

	if (CheckParm("-?") || CheckParm("-h") || CheckParm("-help") || CheckParm("--help"))
	{
		printf(" Compiles progs.dat using progs.src in the current directory\n");
		printf(" -src <directory> : Specify source directory\n");
		printf(" -name <source>   : Specify the name of the .src file\n");
		printf(" -version <n>     : Output progs as version n (either 6 or 7)\n");
		printf(" -v6              : Output progs as version 6\n");
		printf(" -v7              : Output progs as version 7\n");
		printf(" -dcc (or -dec)   : decompile progs.dat in current directory\n");
		printf(" -dcc -name <progsname> : specify name of progs to decompile\n");
		printf(" -dcc -info : only print brief info about the progs and exit\n");
		printf(" -dcc -fix : fixes mangled names during decompile\n");
		printf(" -dcc -fields     : dumps all fielddefs to stdout\n");
		printf(" -dcc -functions  : dumps all functions to stdout\n");
		printf(" -dcc -globaldefs : dumps all globaldefs to stdout\n");
		printf(" -dcc -prglobals  : dumps all pr_globals to stdout\n");
		printf(" -dcc -statements : dumps all statements to stdout\n");
		printf(" -dcc -strings    : dumps all pr_strings to stdout\n");
		printf(" -dcc -asm <functionname> : decompile filename to the console\n");
		printf(" -dcc -dump -asm <functionname> : same as above but will show\n\t\tinstructions (opcodes and parms) as well\n");
		exit(0);
	}

	ValidateByteorder ();

	if (CheckParm("-dcc") || CheckParm("-dec"))
	{
		Dcc_main (argc, argv);
		exit (0);
	}

	start = COM_GetTime ();

	hcc_version_req = -1;	/* output as v6 if possible, otherwise as v7 */
	p = CheckParm("-version");
	if (p != 0)
	{
		if (p >= argc - 1)
			COM_Error ("No num specified for -version");
		p = atoi(argv[p+1]);
		switch (p)
		{
		case 6:
			hcc_version_req = PROG_VERSION_V6;
			break;
		case 7:
			hcc_version_req = PROG_VERSION_V7;
			break;
		default:
			COM_Error ("Version must be either 6 or 7");
			break;
		}
	}

	if (CheckParm("-v6"))	hcc_version_req = PROG_VERSION_V6;
	if (CheckParm("-v7"))	hcc_version_req = PROG_VERSION_V7;

	p = CheckParm("-src");
	if (p != 0)
	{
	/* everything will now be relative to sourcedir: */
		if (p >= argc - 1)
			COM_Error ("No source dirname specified with -src");
		strcpy(sourcedir, argv[p+1]);
		p = strlen (sourcedir);
		if (p && !IS_DIR_SEPARATOR(sourcedir[p - 1]))
		{
			sourcedir[p] = DIR_SEPARATOR_CHAR;
			sourcedir[p + 1] = '\0';
		}
		printf("Source directory: %s\n", sourcedir);
		strcpy(filename, sourcedir);
		nameptr = strchr(filename, '\0');
	}
	else
	{
		sourcedir[0] = '\0';
		nameptr = filename;
	}

	p = CheckParm("-name");
	if (p != 0)
	{
		if (p >= argc - 1)
			COM_Error ("No input filename specified with -name");
		strcpy(nameptr, argv[p+1]);
		printf("Input file: %s\n", nameptr);
	}
	else
	{
		strcpy(nameptr, "progs.src");
	}
	LoadFile(filename, &src);
	psrc = (char *) src;

	psrc = COM_Parse(psrc);
	if (!psrc)
		COM_Error("No destination filename. dhcc -help for info.");
	q_snprintf(destfile, sizeof(destfile), "%s%s", sourcedir, com_token);
	printf("outputfile: %s\n", destfile);

	hcc_OptimizeStringHeap = 1;

	InitData ();

	PR_BeginCompilation();

	// compile all the files
	do
	{
		psrc = COM_Parse(psrc);
		if (!psrc)
			break;

		strcpy (nameptr, com_token);
		printf ("compiling %s\n", nameptr);
		LoadFile (filename, &src2);

		if (!PR_CompileFile((char *)src2, nameptr))
			exit (1);
	} while (1);

	if (!PR_FinishCompilation())
		COM_Error ("compilation errors");

	p = CheckParm("-asm");
	if (p != 0)
	{
		for (p++; p < argc; p++)
		{
			if (argv[p][0] == '-')
				break;
			PrintFunction(argv[p]);
		}
	}

	// write progdefs.h
	strcpy(nameptr, "progdefs.h");
	crc = PR_WriteProgdefs(filename);

	// write data file
	WriteData(crc);

	// write files.dat
	WriteFiles();
	printf(" precache_sound: %10d / %10d\n", numsounds, MAX_SOUNDS);
	printf(" precache_model: %10d / %10d\n", nummodels, MAX_MODELS);
	printf("  precache_file: %10d / %10d\n", numfiles, MAX_FILES);

	stop = COM_GetTime ();
	printf("\n%d seconds elapsed.\n", (int)(stop - start));

	return 0;
}