diff -r d8811e327d12 -r cd9968b6f96b src/players.cpp --- a/src/players.cpp Tue Jun 17 10:32:49 2008 +0000 +++ b/src/players.cpp Tue Jun 17 13:22:13 2008 +0000 @@ -28,6 +28,7 @@ #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" @@ -818,6 +819,8 @@ { if (flags & DC_EXEC) _current_player = OWNER_NONE; + InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0); + switch (p1) { case 0: { /* Create a new player */ /* Joining Client: @@ -1019,12 +1022,9 @@ } /** 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 */ @@ -1038,7 +1038,8 @@ /* 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; @@ -1270,8 +1271,11 @@ _player_colors[index] = p->player_color; /* This is needed so an AI is attached to a loaded AI */ - if (p->is_ai && (!_networking || _network_server) && _ai.enabled) + if (p->is_ai && (!_networking || _network_server) && _ai.enabled) { + /* Clear the memory of the new AI, otherwise we might be doing wrong things. */ + memset(&_players_ainew[index], 0, sizeof(PlayerAiNew)); AI_StartNewAI(p->index); + } } }