mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
* 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:
parent
3c08cf2e3c
commit
cc935a6d72
2 changed files with 31 additions and 14 deletions
|
@ -249,15 +249,15 @@ void CL_Record_f (void)
|
||||||
|
|
||||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||||
|
|
||||||
//
|
|
||||||
// start the map up
|
// start the map up
|
||||||
//
|
|
||||||
if (c > 2)
|
if (c > 2)
|
||||||
|
{
|
||||||
Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command);
|
Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command);
|
||||||
|
if (cls.state != ca_connected)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// open the demo file
|
// open the demo file
|
||||||
//
|
|
||||||
COM_DefaultExtension (name, ".dem", sizeof(name));
|
COM_DefaultExtension (name, ".dem", sizeof(name));
|
||||||
|
|
||||||
Con_Printf ("recording to %s.\n", 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
|
// get rid of the menu and/or console
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
|
|
||||||
//
|
|
||||||
// disconnect from server
|
// disconnect from server
|
||||||
//
|
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
|
|
||||||
//
|
|
||||||
// open the demo file
|
// open the demo file
|
||||||
//
|
|
||||||
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
||||||
COM_DefaultExtension (name, ".dem", sizeof(name));
|
COM_DefaultExtension (name, ".dem", sizeof(name));
|
||||||
|
|
||||||
|
@ -321,22 +317,40 @@ void CL_PlayDemo_f (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.demoplayback = true;
|
|
||||||
cls.state = ca_connected;
|
|
||||||
// ZOID, fscanf is evil
|
// 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);
|
// fscanf (cls.demofile, "%i\n", &cls.forcetrack);
|
||||||
cls.forcetrack = 0;
|
cls.forcetrack = 0;
|
||||||
neg = false;
|
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;
|
neg = true;
|
||||||
else
|
continue;
|
||||||
cls.forcetrack = cls.forcetrack * 10 + (c - '0');
|
}
|
||||||
|
// 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)
|
if (neg)
|
||||||
cls.forcetrack = -cls.forcetrack;
|
cls.forcetrack = -cls.forcetrack;
|
||||||
|
|
||||||
|
cls.demoplayback = true;
|
||||||
|
cls.state = ca_connected;
|
||||||
|
|
||||||
// Get a new message on playback start.
|
// Get a new message on playback start.
|
||||||
// Moved from CL_TimeDemo_f to here, Pa3PyX.
|
// Moved from CL_TimeDemo_f to here, Pa3PyX.
|
||||||
cls.td_lastframe = -1;
|
cls.td_lastframe = -1;
|
||||||
|
@ -382,6 +396,8 @@ void CL_TimeDemo_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
CL_PlayDemo_f ();
|
CL_PlayDemo_f ();
|
||||||
|
if (!cls.demofile)
|
||||||
|
return;
|
||||||
|
|
||||||
// cls.td_starttime will be grabbed at the second frame of the demo, so
|
// cls.td_starttime will be grabbed at the second frame of the demo, so
|
||||||
// all the loading time doesn't get counted
|
// all the loading time doesn't get counted
|
||||||
|
|
|
@ -80,6 +80,7 @@ void R_MarkSurfaces (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vis_changed = false;
|
||||||
r_visframecount++;
|
r_visframecount++;
|
||||||
r_oldviewleaf = r_viewleaf;
|
r_oldviewleaf = r_viewleaf;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue