void stop_recording( void) { if (replay.game_is_being_recorded) { short player_index; long count; long total_length; FileError error; assert(replay.valid); for (player_index= 0; player_index<dynamic_world->player_count; player_index++) { save_recording_queue_chunk(player_index); } replay.game_is_being_recorded = FALSE; /* Rewrite the header, since it has the new length */ set_fpos(replay.recording_file_refnum, 0l); count= sizeof(struct recording_header); error= write_file(replay.recording_file_refnum, count, &replay.header); assert(!error); total_length= get_file_length(replay.recording_file_refnum); assert(total_length==replay.header.length); close_file(replay.recording_file_refnum); } replay.valid= FALSE; return; }
void stop_recording( void) { if (replay.game_is_being_recorded) { replay.game_is_being_recorded = false; short player_index; int32 total_length; assert(replay.valid); for (player_index= 0; player_index<dynamic_world->player_count; player_index++) { save_recording_queue_chunk(player_index); } /* Rewrite the header, since it has the new length */ FilmFile.SetPosition(0); byte Header[SIZEOF_recording_header]; pack_recording_header(Header,&replay.header,1); // ZZZ: removing code that does stuff from assert() argument. BUT... // should we really be asserting on this anyway? I mean, the write could fail // in 'normal operation' too, not just when we screwed something up in writing the program? bool successfulWrite = FilmFile.Write(SIZEOF_recording_header,Header); assert(successfulWrite); FilmFile.GetLength(total_length); assert(total_length==replay.header.length); FilmFile.Close(); } replay.valid= false; }
void check_recording_replaying( void) { short player_index, queue_size; if (replay.game_is_being_recorded) { boolean enough_data_to_save= TRUE; // it's time to save the queues if all of them have >= RECORD_CHUNK_SIZE flags in them. for (player_index= 0; enough_data_to_save && player_index<dynamic_world->player_count; player_index++) { queue_size= get_recording_queue_size(player_index); if (queue_size < RECORD_CHUNK_SIZE) enough_data_to_save= FALSE; } if(enough_data_to_save) { boolean success; unsigned long freespace; FileDesc recording_file; get_recording_filedesc(&recording_file); success= get_freespace_on_disk(&recording_file, &freespace); if (success && freespace>(RECORD_CHUNK_SIZE*sizeof(short)*sizeof(long)*dynamic_world->player_count)) { for (player_index= 0; player_index<dynamic_world->player_count; player_index++) { save_recording_queue_chunk(player_index); } } } } else if (replay.game_is_being_replayed) { boolean load_new_data= TRUE; // it's time to refill the requeues if they all have < RECORD_CHUNK_SIZE flags in them. for (player_index= 0; load_new_data && player_index<dynamic_world->player_count; player_index++) { queue_size= get_recording_queue_size(player_index); if(queue_size>= RECORD_CHUNK_SIZE) load_new_data= FALSE; } if(load_new_data) { // at this point, weÕve determined that the queues are sufficently empty, so // weÕll fill Õem up. read_recording_queue_chunks(); } } return; }
void check_recording_replaying( void) { short player_index, queue_size; if (replay.game_is_being_recorded) { bool enough_data_to_save= true; // it's time to save the queues if all of them have >= RECORD_CHUNK_SIZE flags in them. for (player_index= 0; enough_data_to_save && player_index<dynamic_world->player_count; player_index++) { queue_size= get_recording_queue_size(player_index); if (queue_size < RECORD_CHUNK_SIZE) enough_data_to_save= false; } if(enough_data_to_save) { bool success; uint32 freespace = 0; FileSpecifier FilmFile_Check; get_recording_filedesc(FilmFile_Check); success= FilmFile_Check.GetFreeSpace(freespace); if (success && freespace>(RECORD_CHUNK_SIZE*sizeof(int16)*sizeof(uint32)*dynamic_world->player_count)) { for (player_index= 0; player_index<dynamic_world->player_count; player_index++) { save_recording_queue_chunk(player_index); } } } } else if (replay.game_is_being_replayed) { bool load_new_data= true; // it's time to refill the requeues if they all have < RECORD_CHUNK_SIZE flags in them. for (player_index= 0; load_new_data && player_index<dynamic_world->player_count; player_index++) { queue_size= get_recording_queue_size(player_index); if(queue_size>= RECORD_CHUNK_SIZE) load_new_data= false; } if(load_new_data) { // at this point, we've determined that the queues are sufficently empty, so // we'll fill 'em up. read_recording_queue_chunks(); } } }