(svn r26820) [1.4] -Backport from trunk:

- Fix: Crashes on joining a server with pending order backups [FS#6112] (r26819)
- Fix: Crashes on start due to dereferencing the -1 index of the file names array of music files (r26809)
This commit is contained in:
frosch 2014-09-14 15:24:39 +00:00
parent 6043b839af
commit 57f6cb970b
3 changed files with 27 additions and 20 deletions

View File

@ -200,12 +200,17 @@ static void SelectSongToPlay()
memset(_cur_playlist, 0, sizeof(_cur_playlist));
do {
const char *filename = BaseMusic::GetUsedSet()->files[_playlists[_settings_client.music.playlist][i] - 1].filename;
/* We are now checking for the existence of that file prior
* to add it to the list of available songs */
if (!StrEmpty(filename) && FioCheckFileExists(filename, BASESET_DIR)) {
_cur_playlist[j] = _playlists[_settings_client.music.playlist][i];
j++;
/* File is the index into the file table of the music set. The play list uses 0 as 'no entry',
* so we need to subtract 1. In case of 'no entry' (file = -1), just skip adding it outright. */
int file = _playlists[_settings_client.music.playlist][i] - 1;
if (file >= 0) {
const char *filename = BaseMusic::GetUsedSet()->files[file].filename;
/* We are now checking for the existence of that file prior
* to add it to the list of available songs */
if (!StrEmpty(filename) && FioCheckFileExists(filename, BASESET_DIR)) {
_cur_playlist[j] = _playlists[_settings_client.music.playlist][i];
j++;
}
}
} while (_playlists[_settings_client.music.playlist][++i] != 0 && j < lengthof(_cur_playlist) - 1);

View File

@ -51,6 +51,7 @@
#include "../core/backup_type.hpp"
#include "../smallmap_gui.h"
#include "../news_func.h"
#include "../order_backup.h"
#include "../error.h"
@ -2914,6 +2915,21 @@ bool AfterLoadGame()
}
}
/*
* Only keep order-backups for network clients.
* If we are a network server or not networking, then we just loaded a previously
* saved-by-server savegame. There are no clients with a backup, so clear it.
* Furthermore before savegame version 192 the actual content was always corrupt.
*/
if (!_networking || _network_server || IsSavegameVersionBefore(192)) {
/* Note: We cannot use CleanPool since that skips part of the destructor
* and then leaks un-reachable Orders in the order pool. */
OrderBackup *ob;
FOR_ALL_ORDER_BACKUPS(ob) {
delete ob;
}
}
/* Station acceptance is some kind of cache */
if (IsSavegameVersionBefore(127)) {

View File

@ -288,20 +288,6 @@ void Load_BKOR()
OrderBackup *ob = new (index) OrderBackup();
SlObject(ob, GetOrderBackupDescription());
}
/* Only load order-backups for network clients.
* If we are a network server or not networking, then we just loaded a previously
* saved-by-server savegame. There are no clients with a backup, so clear it.
* Furthermore before savegame version 192 the actual content was always corrupt.
*/
if (!_networking || _network_server || IsSavegameVersionBefore(192)) {
/* Note: We cannot use CleanPool since that skips part of the destructor
* and then leaks un-reachable Orders in the order pool. */
OrderBackup *ob;
FOR_ALL_ORDER_BACKUPS(ob) {
delete ob;
}
}
}
static void Ptrs_BKOR()