Ejemplo n.º 1
0
bool_t set_saved_race_results( char *player,
			       char *event,
			       char *cup,
			       char *race,
			       difficulty_level_t d,
			       scalar_t time,
			       int herring,
			       int score )
{
    hash_table_t player_table;
    hash_table_t event_table;
    hash_table_t cup_table;
    hash_table_t race_table;
    save_info_t *this_save;

    player_table = results_save_table[d];

    if ( !get_hash_entry( player_table, player, (hash_entry_t*)&event_table ) )
    {
	event_table = create_hash_table();
	add_hash_entry( player_table, player, (hash_entry_t)event_table );
    }

    if ( !get_hash_entry( event_table, event, (hash_entry_t*)&cup_table ) ) {
	cup_table = create_hash_table();
	add_hash_entry( event_table, event, (hash_entry_t)cup_table );
    }

    if ( !get_hash_entry( cup_table, cup, (hash_entry_t*)&race_table ) ) {
	race_table = create_hash_table();
	add_hash_entry( cup_table, cup, (hash_entry_t)race_table );
    }

    if ( !get_hash_entry( race_table, race, (hash_entry_t*)&this_save ) ) {
	this_save = (save_info_t*)malloc(sizeof(save_info_t));
	memset( this_save, 0, sizeof(save_info_t) );
	add_hash_entry( race_table, race, (hash_entry_t)this_save );
	this_save->data_type = RACE_RESULTS; 
    }

    check_assertion( this_save->data_type == RACE_RESULTS,
		     "Invalid data type" );

    strcpy( this_save->data.results.event, event );
    strcpy( this_save->data.results.cup, cup );
    strcpy( this_save->data.results.race, race );
    this_save->data.results.difficulty = d;
    this_save->data.results.time = time;
    this_save->data.results.herring = herring;
    this_save->data.results.score = score;

#ifdef __APPLE__
    // Write as soon as possible
    write_saved_games();
#endif

    return True;
}
Ejemplo n.º 2
0
/* This function is called on exit */
void cleanup(void)
{
    write_config_file();
    write_saved_games();

    shutdown_audio();

    winsys_shutdown();
}