Announcement

Collapse
No announcement yet.

Features for Demos menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I'd thought about length and end stats, but I'd have to parse the entire demo file to get them, which is not impossible but would involve writing a version of the full server update parser in the menus, checking for all server messages, and advancing the message pointer appropriately for the data type(s) and size(s).

    Player names are not really practical, as a demo could potentially have any number of players entering and leaving at any point in it.

    There's also space considerations, with a limited amount of space to display the info.

    One thing I did add though was a filter (also works on Maps and Load/Save) - type the first few letters of the demo name and the selection will be restricted to demos that match. Very handy if you've got a really really long list to select from.
    IT LIVES! http://directq.blogspot.com/

    Comment


    • #17
      first of all: mhquake looks great and i cant wait to see it in action!

      on topic: how about zipping demo's (dzip) right after recording them.. i have used qracks autodemo feature a lot in the past and my demos folder got into the GB's really fast! (a 30 minute game will typically result in a 20-30 MB .dem)
      Maybe you could write demostats to a separate file right after recording and include it in the dzip for easy parsing and displaying them later in the menu..

      Comment


      • #18
        That's a neat enough idea.

        Hmmmm - demos only compress to about one-third the size using ZIP compression; 7z gets them to about one-fifth. That would be because they're using a binary format, which won't compress well. I wonder if I switched them over to plain text, what would happen?

        Autodemo sounds like a nice feature, but I've just realised that I've already got it in my "Record new demo" option, which just toggles a "I'm going to record a demo on the next map load" internal switch, then lets you set up a game whatever way you want.
        IT LIVES! http://directq.blogspot.com/

        Comment


        • #19
          Originally posted by mhquake View Post
          That's a neat enough idea.

          Hmmmm - demos only compress to about one-third the size using ZIP compression; 7z gets them to about one-fifth. That would be because they're using a binary format, which won't compress well. I wonder if I switched them over to plain text, what would happen?
          .dz is a pretty well established emerging standard.

          All the demos recorded by the speedrunners are in .dz format too like at http://speeddemosarchive.com/ .

          The .dz format has been supported by JoeQuake for aeons and through inheritance is supported by Qrack (and some other JoeQuake spin-offs like Tremor). I also made the ProQuake Launcher tool thingy support them way back when.

          The mechanics of how the dzip support in JoeQuake works (for playing) can be seen in cl_demo.c in the JoeQuake source. It's pretty easy really. It creates a new process executing the dzip.exe in the JoeQuake folder and if I recall correctly, periodically checks for the successful completion of the process handle.

          Partial cl_demo.c excerpt:

          // .dz playback
          #ifdef _WIN32
          static HANDLE hDZipProcess = NULL;
          #else
          //#include <sys/types.h>
          #include <sys/wait.h>
          #include <unistd.h>
          static qboolean hDZipProcess = false;
          #endif
          The tougher thing would be adding automatic conversion to .dz format upon demo completion as a demo can end recording in several ways (disconnect from server, the stop command, a client quitting).

          The dzip page: http://speeddemosarchive.com/dzip/

          The dzip process code from cl_demo.c in JoeQuake 0.15

          Code:
          static void PlayDZDemo (void)
          {
          	char	*name, *p, dz_name[256];
          #ifdef _WIN32
          	char	cmdline[512];
          	STARTUPINFO si;
          	PROCESS_INFORMATION pi;
          
          	if (hDZipProcess)
          	{
          		Con_Printf ("Cannot unpack -- DZip is still running!\n");
          		return;
          	}
          #else
          	char	dzipRealPath[256], tmppath[256];
          	pid_t	pid;
          #endif
          
          	name = Cmd_Argv (1);
          
          	if (strstr(name, "..") == name)
          	{
          		Q_snprintfz (dem_basedir, sizeof(dem_basedir), "%s%s", com_basedir, name + 2);
          		p = strrchr (dem_basedir, '/');
          		*p = 0;
          		name = strrchr (name, '/') + 1;	// we have to cut off the path for the name
          	}
          	else
          	{
          		Q_strncpyz (dem_basedir, com_gamedir, sizeof(dem_basedir));
          	}
          
          #ifndef _WIN32
          	if (!realpath(dem_basedir, tmppath))
          	{
          		Con_Printf ("Couldn't realpath '%s'\n", dem_basedir);
          		return;
          	}
          	Q_strncpyz (dem_basedir, tmppath, sizeof(dem_basedir));
          #endif
          
          	Q_snprintfz (dz_name, sizeof(dz_name), "%s/%s", dem_basedir, name);
          
          	// check if the file exists
          	if (Sys_FileTime(dz_name) == -1)
          	{
          		Con_Printf ("ERROR: couldn't open %s\n", name);
          		return;
          	}
          
          	COM_StripExtension (dz_name, tempdem_name);
          	strcat (tempdem_name, ".dem");
          
          	if ((cls.demofile = fopen(tempdem_name, "rb")))
          	{
          		// .dem already exists, so just play it
          		Con_Printf ("Playing demo from %s\n", tempdem_name);
          		StartPlayingOpenedDemo ();
          		return;
          	}
          
          	Con_Printf ("\x02" "\nunpacking demo. please wait...\n\n");
          	key_dest = key_game;
          
          	// start DZip to unpack the demo
          #ifdef _WIN32
          	memset (&si, 0, sizeof(si));
          	si.cb = sizeof(si);
          	si.wShowWindow = SW_HIDE;
          	si.dwFlags = STARTF_USESHOWWINDOW;
          
          	Q_snprintfz (cmdline, sizeof(cmdline), "%s/dzip.exe -x -f \"%s\"", com_basedir, name);
          	if (!CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, dem_basedir, &si, &pi))
          	{
          		Con_Printf ("Couldn't execute %s/dzip.exe\n", com_basedir);
          		return;
          	}
          
          	hDZipProcess = pi.hProcess;
          #else
          	if (!realpath(com_basedir, dzipRealPath))
          	{
          		Con_Printf ("Couldn't realpath '%s'\n", com_basedir);
          		return;
          	}
          
          	if (chdir(dem_basedir) == -1)
          	{
          		Con_Printf ("Couldn't chdir to '%s'\n", dem_basedir);
          		return;
          	}
          
          	switch (pid = fork())
          	{
          	case -1:
          		Con_Printf ("Couldn't create subprocess\n");
          		return;
          
          	case 0:
          		if (execlp(va("%s/dzip-linux", dzipRealPath), "dzip-linux", "-x", "-f", dz_name, NULL) == -1)
          		{
          			Con_Printf ("Couldn't execute %s/dzip-linux\n", com_basedir);
          			exit (-1);
          		}
          
          	default:
          		if (waitpid(pid, NULL, 0) == -1)
          		{
          			Con_Printf ("waitpid failed\n");
          			return;
          		}
          		break;
          	}
          
          	if (chdir(dzipRealPath) == -1)
          	{
          		Con_Printf ("Couldn't chdir to '%s'\n", dzipRealPath);
          		return;
          	}
          
          	hDZipProcess = true;
          #endif
          
          	dz_unpacking = dz_playback = true;
          
          	// demo playback doesn't actually start yet, we just set cls.demoplayback
          	// so that CL_StopPlayback() will be called if CL_Disconnect() is issued
          	cls.demoplayback = true;
          	cls.demofile = NULL;
          	cls.state = ca_connected;
          }
          Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

          So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

          Comment


          • #20
            I see that dzip source code is available - sounds like a possible additional feature then, as I rather hate external dependencies.
            IT LIVES! http://directq.blogspot.com/

            Comment

            Working...
            X