示例#1
0
int main(int argc, char **argv)
{
	int i;
	byte *mvd_data = NULL;
	long mvd_len = 0;

	Sys_InitDoubleTime();
	LogVarHashTable_Init();

	if (!Cmdline_Parse(argc, argv))
	{
		ShowHelp(argv[0]);
		return 1;
	}

	if (!Log_ParseOutputTemplates(&logger, cmdargs.template_file) && !Log_ParseOutputTemplates(&logger, "template.dat"))
	{
		Sys_PrintError("Failed to load template file.\n");
		return 1;
	}

	if (!LoadFragFile(cmdargs.frag_file, false) && !LoadFragFile("fragfile.dat", false))
	{
		Sys_PrintError("Failed to load fragfile.dat\n");
		return 1;
	}

	for (i = 0; i < cmdargs.mvd_files_count; i++)
	{
		// Read the mvd demo file.
		if (!COM_ReadFile(cmdargs.mvd_files[i], &mvd_data, &mvd_len))
		{
			Sys_PrintError("Failed to read %s.\n", cmdargs.mvd_files[i]);
		}
		else
		{
			char *demopath = cmdargs.mvd_files[i];

			// Parse the demo.
			Sys_Print("Starting to parse %s\n", cmdargs.mvd_files[i]);
			MVD_Parser_StartParse(demopath, mvd_data, mvd_len);
		}

		Q_free(mvd_data);
	}

	Log_ClearLogger(&logger);
	CmdArgs_Clear();

	return 0;
}
示例#2
0
void Info_RemoveKey(char *s, char *key)
{
    char *start, pkey[512], value[512], *o;

    if (strstr(key, "\\"))
    {
        Sys_PrintError("Info_RemoveKey: Can't use a key with a \\\n");
        return;
    }

    while (1)
    {
        start = s;

        if (*s == '\\')
            s++;
        o = pkey;

        while (*s != '\\')
        {
            if (!*s)
                return;
            *o++ = *s++;
        }

        *o = 0;
        s++;

        o = value;

        while (*s != '\\' && *s)
        {
            if (!*s)
                return;
            *o++ = *s++;
        }

        *o = 0;

        if (!strcmp(key, pkey))
        {
            strcpy(start, s);	// Remove this part.
            return;
        }

        if (!*s)
            return;
    }
}
示例#3
0
void Sys_LogError(const char* msg, int flags)
{
#ifdef _WIN32
    int lastError = WSAGetLastError();
#else
    int lastError = errno;
#endif

    FILE* fp = fopen(g_errlog_file.c_str(), "a+");
    if (fp)
    {
        fprintf(fp, Sys_GetDate());
        fprintf(fp, msg);

        fprintf(fp, "   Last socket error: %d\n", lastError);

        fclose(fp);
    }
    fp = NULL;

    // print it to stdout as well
    Sys_PrintError(msg, lastError);
}
示例#4
0
qbool Cmdline_Parse(int argc, char **argv)
{
	int i;
	char *files_temp[1024];
	int filecount = 0;
	char *arg;

	memset(&cmdargs, 0, sizeof(cmdargs));

	if (argc < 2)
	{
		return false;
	}

	for (i = 1; i < argc; i++)
	{
		arg = argv[i];

		if (((arg[0] == '-') || (arg[0] == '/')) && arg[1])
		{
			// Command line switch.
			switch(arg[1])
			{
				case 'v' :
				{
					// Verbosity based on how many v's where specified.
					int j = 1;
					
					while (arg[j] == 'v')
					{
						cmdargs.debug++;
						j++;						
					}	
					break;
				}
				case 'f' :
				{
					int next_arg = (i + 1);

					if (next_arg < argc)
					{
						cmdargs.frag_file = Q_strdup(argv[next_arg]);
					}

					break;
				}
				case 't' :
				{
					int next_arg = (i + 1);

					if (next_arg < argc)
					{
						cmdargs.template_file = Q_strdup(argv[next_arg]);
					}
					else
					{
						Sys_PrintError("-t: No template specified\n");
					}
					
					break;
				}
			}
		}
		else
		{
			// Regard as being a file.
			files_temp[filecount] = arg;
			filecount++;
		}
	}

	cmdargs.mvd_files_count = filecount;

	// Allocate memory for the filenames.
	if (filecount > 0)
	{
		cmdargs.mvd_files = (char **)Q_calloc(filecount, sizeof(char **));

		for (i = 0; i < filecount; i++)
		{
			cmdargs.mvd_files[i] = Q_strdup(files_temp[i]);
		}
	}

	return true;
}