@@ -979,34 +979,31 @@ int8 SaveHighScoreValue(const Player *p)
{
HighScore *hs = _highscore_table[_opt.diff_level];
uint i;
uint16 score = p->old_economy[0].performance_history;
/* Exclude cheaters from the honour of being in the highscore table */
if (CheatHasBeenUsed())
return -1;
for (i = 0; i < lengthof(_highscore_table[0]); i++) {
/* You are in the TOP5. Move all values one down and save us there */
if (hs[i].score <= score) {
char buf[sizeof(hs[i].company)];
// move all elements one down starting from the replaced one
memmove(&hs[i + 1], &hs[i], sizeof(HighScore) * (lengthof(_highscore_table[0]) - i - 1));
SetDParam(0, p->president_name_1);
SetDParam(1, p->president_name_2);
SetDParam(2, p->name_1);
SetDParam(3, p->name_2);
GetString(buf, STR_HIGHSCORE_NAME); // get manager/company name string
ttd_strlcpy(hs[i].company, buf, sizeof(buf));
GetString(hs[i].company, STR_HIGHSCORE_NAME); // get manager/company name string
hs[i].score = score;
hs[i].title = EndGameGetPerformanceTitleFromValue(score);
return i;
}
return -1; // too bad; we did not make it into the top5
/* Sort all players given their performance */
static int CDECL HighScoreSorter(const void *a, const void *b)
@@ -1031,34 +1028,30 @@ int8 SaveHighScoreValueNetwork(void)
qsort(player_sort, count, sizeof(player_sort[0]), HighScoreSorter);
HighScore *hs;
Player* const *p_cur = &player_sort[0];
uint8 i;
memset(_highscore_table[LAST_HS_ITEM], 0, sizeof(_highscore_table[0]));
/* Copy over Top5 companies */
for (i = 0; i < lengthof(_highscore_table[LAST_HS_ITEM]) && i < count; i++) {
char buf[sizeof(_highscore_table[0]->company)];
hs = &_highscore_table[LAST_HS_ITEM][i];
SetDParam(0, (*p_cur)->president_name_1);
SetDParam(1, (*p_cur)->president_name_2);
SetDParam(2, (*p_cur)->name_1);
SetDParam(3, (*p_cur)->name_2);
ttd_strlcpy(hs->company, buf, sizeof(buf));
GetString(hs->company, STR_HIGHSCORE_NAME); // get manager/company name string
hs->score = (*p_cur)->old_economy[0].performance_history;
hs->title = EndGameGetPerformanceTitleFromValue(hs->score);
// get the ranking of the local player
if ((*p_cur)->index == _local_player)
player = i;
p_cur++;
/* Add top5 players to highscore table */
Status change: