|
@@ -19,24 +19,25 @@
|
|
|
#include "ai/ai.h"
|
|
|
#include "player_face.h"
|
|
|
#include "group.h"
|
|
|
#include "window_func.h"
|
|
|
#include "tile_map.h"
|
|
|
#include "strings_func.h"
|
|
|
#include "gfx_func.h"
|
|
|
#include "functions.h"
|
|
|
#include "date_func.h"
|
|
|
#include "vehicle_func.h"
|
|
|
#include "sound_func.h"
|
|
|
#include "core/alloc_func.hpp"
|
|
|
#include "core/sort_func.hpp"
|
|
|
#include "autoreplace_func.h"
|
|
|
#include "autoreplace_gui.h"
|
|
|
#include "string_func.h"
|
|
|
#include "ai/default/default.h"
|
|
|
#include "ai/trolly/trolly.h"
|
|
|
#include "road_func.h"
|
|
|
#include "rail.h"
|
|
|
#include "sprite.h"
|
|
|
#include "debug.h"
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
#include "table/sprites.h"
|
|
@@ -1012,44 +1013,42 @@ int8 SaveHighScoreValue(const Player *p)
|
|
|
SetDParam(1, p->index);
|
|
|
GetString(hs[i].company, STR_HIGHSCORE_NAME, lastof(hs[i].company)); // 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)
|
|
|
static int CDECL HighScoreSorter(const Player* const *a, const Player* const *b)
|
|
|
{
|
|
|
const Player *pa = *(const Player* const*)a;
|
|
|
const Player *pb = *(const Player* const*)b;
|
|
|
|
|
|
return pb->old_economy[0].performance_history - pa->old_economy[0].performance_history;
|
|
|
return (*b)->old_economy[0].performance_history - (*a)->old_economy[0].performance_history;
|
|
|
}
|
|
|
|
|
|
/* Save the highscores in a network game when it has ended */
|
|
|
#define LAST_HS_ITEM lengthof(_highscore_table) - 1
|
|
|
int8 SaveHighScoreValueNetwork()
|
|
|
{
|
|
|
const Player* p;
|
|
|
const Player* pl[MAX_PLAYERS];
|
|
|
size_t count = 0;
|
|
|
int8 player = -1;
|
|
|
|
|
|
/* Sort all active players with the highest score first */
|
|
|
FOR_ALL_PLAYERS(p) if (p->is_active) pl[count++] = p;
|
|
|
qsort((Player*)pl, count, sizeof(pl[0]), HighScoreSorter);
|
|
|
|
|
|
GSortT(pl, count, &HighScoreSorter);
|
|
|
|
|
|
{
|
|
|
uint 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++) {
|
|
|
HighScore* hs = &_highscore_table[LAST_HS_ITEM][i];
|
|
|
|
|
|
SetDParam(0, pl[i]->index);
|
|
|
SetDParam(1, pl[i]->index);
|