Пример #1
0
boolean has_recording_file(
	void)
{
	FileDesc spec;

	return get_recording_filedesc(&spec);
}
Пример #2
0
/* Note that we _must_ set the header information before we start recording!! */
void start_recording(
	void)
{
	FileDesc recording_file;
	long count;
	FileError error;
	
	assert(!replay.valid);
	replay.valid= TRUE;
	
	if(get_recording_filedesc(&recording_file))
	{
		delete_file(&recording_file);
	}

	error= create_file(&recording_file, FILM_FILE_TYPE);	
	if(!error)
	{
		/* I debate the validity of fsCurPerm here, but Alain had it, and it has been working */
		replay.recording_file_refnum= open_file_for_writing(&recording_file);
		if(replay.recording_file_refnum != NONE)
		{
			replay.game_is_being_recorded= TRUE;
	
			// save a header containing information about the game.
			count= sizeof(struct recording_header); 
			write_file(replay.recording_file_refnum, count, &replay.header);
		}
	}
}
Пример #3
0
bool find_replay_to_use(bool ask_user, FileSpecifier &file)
{
	if (ask_user) {
		return file.ReadDialog(_typecode_film);
	} else
		return get_recording_filedesc(file);
}
Пример #4
0
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;
}
Пример #5
0
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();
		}
	}
}
Пример #6
0
void move_replay(void)
{
	// Get source file specification
	FileSpecifier src_file, dst_file;
	if (!get_recording_filedesc(src_file))
		return;

	// Ask user for destination file
	char prompt[256], default_name[256];
	if (!dst_file.WriteDialog(_typecode_film, getcstr(prompt, strPROMPTS, _save_replay_prompt), getcstr(default_name, strFILENAMES, filenameMARATHON_RECORDING)))
		return;

	// Copy file
	dst_file.CopyContents(src_file);
	int error = dst_file.GetError();
	if (error)
		alert_user(infoError, strERRORS, fileError, error);
}
Пример #7
0
/* Note that we _must_ set the header information before we start recording!! */
void start_recording(
	void)
{
	assert(!replay.valid);
	replay.valid= true;
	
	if(get_recording_filedesc(FilmFileSpec))
		FilmFileSpec.Delete();

	if (FilmFileSpec.Create(_typecode_film))
	{
		/* I debate the validity of fsCurPerm here, but Alain had it, and it has been working */
		if (FilmFileSpec.Open(FilmFile,true))
		{
			replay.game_is_being_recorded= true;
	
			// save a header containing information about the game.
			byte Header[SIZEOF_recording_header];
			pack_recording_header(Header,&replay.header,1);
			FilmFile.Write(SIZEOF_recording_header,Header);
		}
	}
}
Пример #8
0
bool has_recording_file(void)
{
	FileSpecifier File;
	return get_recording_filedesc(File);
}