Example #1
0
void Movie_Start_f (void)
{
    char	name[MAX_OSPATH], path[256]; //qb: jqavi was MAX_FILELENGTH
    int     i;

    if (Cmd_Argc() != 2) //qb: autogenerate file name if none is given.
    {
        Q_strcpy(name,"qbs8_000.avi"); //qb: screenshots dir

        for (i=0 ; i<=999 ; i++)
        {
            name[5] = i/100 + '0';
            name[6] = (i/10)%10 + '0';
            name[7] = i%10 + '0';
            sprintf (path, "%s/%s/%s", com_gamedir, "screenshots", name);
            if (Sys_FileTime(path) == -1)
                break;	// file doesn't exist
        }
        if (i==1000)
        {
            Con_Printf ("Movie_Start_f: Too many AVI files in directory.\n");
            return;
        }
    }
    else
    {
        Q_strncpyz (name, Cmd_Argv(1), sizeof(name));
        COM_ForceExtension (name, ".avi");
    }

    hack_ctr = capture_hack.value;
    Q_snprintfz (path, sizeof(path), "%s/%s/%s", com_gamedir, "screenshots", name);
    if (!(moviefile = fopen(path, "wb")))
    {
        COM_CreatePath (path);
        if (!(moviefile = fopen(path, "wb")))
        {
            Con_Printf ("ERROR: Couldn't open %s\n", name);
            return;
        }
    }
    movie_is_capturing = Capture_Open (path);
    if (movie_is_capturing)
        Con_DPrintf("Capturing video %s\n", path);  //qb: is printed on the vid, so only in debug mode.
    else
        Con_Printf("Movie_Start_f: Movie capture open failed.\n");
}
Example #2
0
/*
====================
CL_Record_f

record <demoname>
====================
*/
void CL_Record_f (void)
{
	int		c;
	char	name[MAX_OSPATH];

	c = Cmd_Argc();
	if (c != 2)
	{
		Com_Printf ("record <demoname>\n");
		return;
	}

	if (cls.state != ca_active && cls.state != ca_disconnected) {
		Com_Printf ("Cannot record while connecting.\n");
		return;
	}

	if (cls.demorecording)
		CL_Stop_f();
  
	Q_snprintfz (name, sizeof(name), "%s/%s", cls.gamedir, Cmd_Argv(1));

//
// open the demo file
//
	COM_ForceExtension (name, ".qwd");

	cls.demofile = fopen (name, "wb");
	if (!cls.demofile)
	{
		Com_Printf ("ERROR: couldn't open.\n");
		return;
	}

	Com_Printf ("recording to %s.\n", name);

	if (cls.state == ca_active)
		CL_Record ();
	else
		cls.demorecording = true;
}
Example #3
0
/*
====================
CL_EasyRecord_f

easyrecord [demoname]
====================
*/
void CL_EasyRecord_f (void)
{
	int		c;
	char	name[1024];
	char	name2[MAX_OSPATH*2];
	int		i;
	char	*p;
	FILE	*f;

	c = Cmd_Argc();
	if (c > 2)
	{
		Com_Printf ("easyrecord <demoname>\n");
		return;
	}

	if (cls.state != ca_active) {
		Com_Printf ("You must be connected to record.\n");
		return;
	}

	if (cls.demorecording)
		CL_Stop_f();

/// FIXME: check buffer sizes!!!

	if (c == 2)
		Q_snprintfz (name, sizeof(name), "%s", Cmd_Argv(1));
	else if (cl.spectator) {
		// FIXME: if tracking a player, use his name
		Q_snprintfz (name, sizeof(name), "spec_%s_%s",
			TP_PlayerName(),
			TP_MapName());
	} else {
		// guess game type and write demo name
		i = TP_CountPlayers();
		if (cl.teamplay && i >= 3)
		{
			// Teamplay
			Q_snprintfz (name, sizeof(name), "%s_%s_vs_%s_%s",
				TP_PlayerName(),
				TP_PlayerTeam(),
				TP_EnemyTeam(),
				TP_MapName());
		} else {
			if (i == 2) {
				// Duel
				Q_snprintfz (name, sizeof(name), "%s_vs_%s_%s",
					TP_PlayerName(),
					TP_EnemyName(),
					TP_MapName());
			}
			else if (i > 2) {
				// FFA
				Q_snprintfz (name, sizeof(name), "%s_ffa_%s",
					TP_PlayerName(), 
					TP_MapName());
			}
			else {
				// one player
				Q_snprintfz (name, sizeof(name), "%s_%s",
					TP_PlayerName(),
					TP_MapName());
			}
		}
	}

// Make sure the filename doesn't contain illegal characters
	for (p = name; *p; p++)	{
		char c;
		*p &= 0x7F;		// strip high bit
		c = *p;
		if (c <= ' ' || c == '?' || c == '*' || c == '\\' || c == '/' || c == ':'
			|| c == '<' || c == '>' || c == '"')
			*p = '_';
	}

	strlcpy (name, va("%s/%s", cls.gamedir, name), MAX_OSPATH);

// find a filename that doesn't exist yet
	strcpy (name2, name);
	COM_ForceExtension (name2, ".qwd");
	f = fopen (name2, "rb");
	if (f) {
		i = 0;
		do {
			fclose (f);
			strcpy (name2, va("%s_%02i", name, i));
			COM_ForceExtension (name2, ".qwd");
			f = fopen (name2, "rb");
			i++;
		} while (f);
	}

//
// open the demo file
//
	cls.demofile = fopen (name2, "wb");
	if (!cls.demofile)
	{
		Com_Printf ("ERROR: couldn't open.\n");
		return;
	}

	Com_Printf ("recording to %s.\n", name2);
	CL_Record ();
}