void handle_scoreboard_save(scoreboard_local *local) { int slot = 0; for(int i = 0; i < 20; i++) { unsigned int ex_score = local->data.entries[local->page][i].score; unsigned int my_score = local->pending_data.score; if(ex_score < my_score) { slot = i; break; } } // Move next entries forward by one slot memmove( &local->data.entries[local->page][slot+1], &local->data.entries[local->page][slot], sizeof(score_entry) * (20 - slot - 1)); // Copy new entry to the right spot memcpy( &local->data.entries[local->page][slot], &local->pending_data, sizeof(score_entry)); // Write to file scores_write(&local->data); }
void scores_maybe_add_player(int abort_flag) { char text1[COOL_MESSAGE_LEN+10]; newmenu_item m[10]; int i,position; #ifdef APPLE_DEMO // no high scores in apple oem version return; #endif if ((gameData.app.nGameMode & GM_MULTI) && !(gameData.app.nGameMode & GM_MULTI_COOP)) return; scores_read(); position = MAX_HIGH_SCORES; for (i=0; i<MAX_HIGH_SCORES; i++ ) { if ( gameData.multi.players[gameData.multi.nLocalPlayer].score > Scores.stats[i].score ) { position = i; break; } } if ( position == MAX_HIGH_SCORES ) { if (abort_flag) return; scores_fill_struct( &Last_game ); } else { //-- if ( gameStates.app.nDifficultyLevel < 1 ) { //-- ExecMessageBox( "GRADUATION TIME!", 1, "Ok", "If you would had been\nplaying at a higher difficulty\nlevel, you would have placed\n#%d on the high score list.", position+1 ); //-- return; //-- } memset (m, 0, sizeof (m)); if ( position==0 ) { strcpy( text1, "" ); m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING; m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5; ExecMenu( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL, NULL ); strncpy( Scores.cool_saying, text1, COOL_MESSAGE_LEN ); if (strlen(Scores.cool_saying)<1) sprintf( Scores.cool_saying, TXT_NO_COMMENT ); } else { ExecMessageBox( TXT_HIGH_SCORE, NULL, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, GAMETEXT (57 + position)); } // move everyone down... for ( i=MAX_HIGH_SCORES-1; i>position; i-- ) { Scores.stats[i] = Scores.stats[i-1]; } scores_fill_struct( &Scores.stats[position] ); scores_write(); } scores_view(position); }
void scores_maybe_add_player(int abort_flag) { char text1[COOL_MESSAGE_LEN+10]; newmenu_item m[10]; int i,position; #ifdef APPLE_DEMO // no high scores in apple oem version return; #endif if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) return; scores_read(); position = MAX_HIGH_SCORES; for (i=0; i<MAX_HIGH_SCORES; i++ ) { if ( Players[Player_num].score > Scores.stats[i].score ) { position = i; break; } } if ( position == MAX_HIGH_SCORES ) { if (abort_flag) return; scores_fill_struct( &Last_game ); } else { //-- if ( Difficulty_level < 1 ) { //-- nm_messagebox( "GRADUATION TIME!", 1, "Ok", "If you would had been\nplaying at a higher difficulty\nlevel, you would have placed\n#%d on the high score list.", position+1 ); //-- return; //-- } if ( position==0 ) { strcpy( text1, "" ); m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING; m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5; newmenu_do( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL ); strncpy( Scores.cool_saying, text1, COOL_MESSAGE_LEN ); if (strlen(Scores.cool_saying)<1) sprintf( Scores.cool_saying, "No Comment" ); } else { nm_messagebox( TXT_HIGH_SCORE, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, *(&TXT_1ST + position) ); } // move everyone down... for ( i=MAX_HIGH_SCORES-1; i>position; i-- ) { Scores.stats[i] = Scores.stats[i-1]; } scores_fill_struct( &Scores.stats[position] ); scores_write(); } scores_view(position); }
void scores_maybe_add_player(int abort_flag) { char text1[COOL_MESSAGE_LEN+10]; newmenu_item m[10]; int i,position; all_scores scores; stats_info last_game; if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) return; scores_read(&scores); position = MAX_HIGH_SCORES; for (i=0; i<MAX_HIGH_SCORES; i++ ) { if ( Players[Player_num].score > scores.stats[i].score ) { position = i; break; } } if ( position == MAX_HIGH_SCORES ) { if (abort_flag) return; scores_fill_struct( &last_game ); } else { if ( position==0 ) { strcpy( text1, "" ); m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING; m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5; newmenu_do( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL, NULL ); strncpy( scores.cool_saying, text1, COOL_MESSAGE_LEN ); if (strlen(scores.cool_saying)<1) sprintf( scores.cool_saying, "No Comment" ); } else { nm_messagebox( TXT_HIGH_SCORE, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, *(&TXT_1ST + position) ); } // move everyone down... for ( i=MAX_HIGH_SCORES-1; i>position; i-- ) { scores.stats[i] = scores.stats[i-1]; } scores_fill_struct( &scores.stats[position] ); scores_write(&scores); } scores_view(&last_game, position); if (Game_wind) window_close(Game_wind); // prevent the next game from doing funny things }