* 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: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@696 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2012-07-18 20:51:35 +00:00
parent 3c08cf2e3c
commit cc935a6d72
2 changed files with 31 additions and 14 deletions

View File

@ -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
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

View File

@ -80,6 +80,7 @@ void R_MarkSurfaces (void)
return;
}
vis_changed = false;
r_visframecount++;
r_oldviewleaf = r_viewleaf;