fixed server side demo recording and some possible crashes with incorrect demos

This commit is contained in:
Magnus Auvinen 2008-11-16 13:58:27 +00:00
parent 8769ee1b04
commit e27e2d8b2a
4 changed files with 10 additions and 7 deletions

View file

@ -1296,7 +1296,7 @@ const DEMOPLAYBACK_INFO *client_demoplayer_getinfo()
void client_demoplayer_setpos(float percent)
{
const DEMOREC_PLAYBACKINFO *info = demorec_playback_info();
int point = (int)((info->seekable_points-1)*percent);
int point = (int)(info->seekable_points*percent);
demorec_playback_set(point);
}

View file

@ -301,7 +301,7 @@ static void scan_file()
if(read_chunk_header(&chunk_type, &chunk_size, &chunk_tick))
break;
/* read the chunk */
if(chunk_type&CHUNKTYPEFLAG_TICKMARKER)
{
@ -512,9 +512,9 @@ int demorec_playback_nextframe()
int demorec_playback_play()
{
/* fill in previous and next tick */
while(playbackinfo.previous_tick == -1)
while(playbackinfo.previous_tick == -1 && demorec_isplaying())
do_tick();
/* set start info */
/*playbackinfo.start_tick = playbackinfo.previous_tick;
playbackinfo.start_time = time_get();*/
@ -553,6 +553,9 @@ int demorec_playback_update()
int64 deltatime = now-playbackinfo.last_update;
playbackinfo.last_update = now;
if(!demorec_isplaying())
return 0;
if(playbackinfo.paused)
{

View file

@ -39,8 +39,6 @@ static int browseinfo_progression = -1;
static int64 lastheartbeat;
/*static NETADDR4 master_server;*/
static IOHANDLE demorec_file = 0;
static char current_map[64];
static int current_map_crc;
static unsigned char *current_map_data = 0;
@ -375,7 +373,7 @@ static void server_do_snap()
}
/* create snapshot for demo recording */
if(demorec_file)
if(demorec_isrecording())
{
char data[MAX_SNAPSHOT_SIZE];
int snapshot_size;

View file

@ -620,6 +620,8 @@ void GAMECLIENT::on_snapshot()
local_character_pos = vec2(snap.local_character->x, snap.local_character->y);
}
}
else
snap.spectate = true;
// update render info
for(int i = 0; i < MAX_CLIENTS; i++)