//------ Begin of function GameFileArray::add_hall_of_fame -----// // // Add current game into the hall of hame // // <int> totalScore of the player. // // <int> type = 0 when human // = 1 when frythan // // return : <int> 1-hall of fame updated // 0-not updated // int GameFileArray::add_hall_of_fame(int totalScore, int type) { //-------- insert the record -----------// int i; for( i=0 ; i<HALL_FAME_NUM ; i++ ) { if( totalScore > hall_fame_array[type][i].score ) { //---------- move and insert the data --------// if( i < HALL_FAME_NUM-1 ) // it is not the last record { // ###### begin Gilbert 13/4 ########// memmove( &hall_fame_array[type][i+1], &hall_fame_array[type][i], sizeof(HallFame) * (HALL_FAME_NUM-i-1) ); // ###### end Gilbert 13/4 ########// } //-------- record the hall of fame rcord ------// hall_fame_array[type][i].record_data(totalScore); //--------- display the hall of fame ----------// write_hall_of_fame(); // must write hall of fame, because it also write the last saved game slot no. disp_hall_of_fame(type); return 1; } } return 0; }
void GameFileArray::deinit() { //-- Need to save hall of fame, because it contains last loaded/saved game --// write_hall_of_fame(); }