|
@@ -25,12 +25,13 @@
|
|
|
#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"
|
|
@@ -1018,18 +1019,15 @@ int8 SaveHighScoreValue(const Player *p)
|
|
|
}
|
|
|
|
|
|
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()
|
|
|
{
|
|
@@ -1037,13 +1035,14 @@ int8 SaveHighScoreValueNetwork()
|
|
|
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]));
|
|
|
|