From c00571286ecc6c09be0acd2bbf3ca102137d3d32 Mon Sep 17 00:00:00 2001 From: sezero Date: Wed, 18 Jul 2012 20:51:35 +0000 Subject: [PATCH] * cl_demo.c: for a command like "record demoname map [track]", don't continue if the map cannot be started. do not continue if the demo file cannot be opened for the timedemo command. for playdemo, verify that the forcetrack '\n' byte appears among the very first 12 bytes of the file. * r_world.c (R_MarkSurfaces): reset vis_changed to false. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@696 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/cl_demo.c | 44 ++++++++++++++++++++++++++++++-------------- Quake/r_world.c | 1 + 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Quake/cl_demo.c b/Quake/cl_demo.c index cf28de20..93aee9fb 100644 --- a/Quake/cl_demo.c +++ b/Quake/cl_demo.c @@ -249,15 +249,15 @@ void CL_Record_f (void) q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1)); -// // start the map up -// if (c > 2) + { Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command); + if (cls.state != ca_connected) + return; + } -// // open the demo file -// COM_DefaultExtension (name, ".dem", sizeof(name)); Con_Printf ("recording to %s.\n", name); @@ -300,14 +300,10 @@ void CL_PlayDemo_f (void) // get rid of the menu and/or console key_dest = key_game; -// // disconnect from server -// CL_Disconnect (); -// // open the demo file -// q_strlcpy (name, Cmd_Argv(1), sizeof(name)); COM_DefaultExtension (name, ".dem", sizeof(name)); @@ -321,22 +317,40 @@ void CL_PlayDemo_f (void) return; } - cls.demoplayback = true; - cls.state = ca_connected; // ZOID, fscanf is evil +// O.S.: if a space character e.g. 0x20 (' ') follows '\n', +// fscanf skips that byte too and screws up further reads. // fscanf (cls.demofile, "%i\n", &cls.forcetrack); cls.forcetrack = 0; neg = false; - while ((c = getc(cls.demofile)) != '\n') + // read a decimal integer possibly with a leading '-', + // followed by a '\n': + for (i = 0; i < 13; i++) { - if (c == '-') + c = getc(cls.demofile); + if (c == '\n') + break; + if (c == '-') { neg = true; - else - cls.forcetrack = cls.forcetrack * 10 + (c - '0'); + continue; + } + // check for multiple '-' or legal digits? meh... + cls.forcetrack = cls.forcetrack * 10 + (c - '0'); + } + if (c != '\n') + { + fclose (cls.demofile); + cls.demofile = NULL; + cls.demonum = -1; // stop demo loop + Con_Printf ("ERROR: demo \"%s\" is invalid\n", name); + return; } if (neg) cls.forcetrack = -cls.forcetrack; + cls.demoplayback = true; + cls.state = ca_connected; + // Get a new message on playback start. // Moved from CL_TimeDemo_f to here, Pa3PyX. cls.td_lastframe = -1; @@ -382,6 +396,8 @@ void CL_TimeDemo_f (void) } CL_PlayDemo_f (); + if (!cls.demofile) + return; // cls.td_starttime will be grabbed at the second frame of the demo, so // all the loading time doesn't get counted diff --git a/Quake/r_world.c b/Quake/r_world.c index 31e4059a..9b880ba9 100644 --- a/Quake/r_world.c +++ b/Quake/r_world.c @@ -80,6 +80,7 @@ void R_MarkSurfaces (void) return; } + vis_changed = false; r_visframecount++; r_oldviewleaf = r_viewleaf;