mirror of https://github.com/OpenTTD/OpenTTD
(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)release/1.4
parent
6043b839af
commit
57f6cb970b
|
@ -200,12 +200,17 @@ static void SelectSongToPlay()
|
||||||
|
|
||||||
memset(_cur_playlist, 0, sizeof(_cur_playlist));
|
memset(_cur_playlist, 0, sizeof(_cur_playlist));
|
||||||
do {
|
do {
|
||||||
const char *filename = BaseMusic::GetUsedSet()->files[_playlists[_settings_client.music.playlist][i] - 1].filename;
|
/* File is the index into the file table of the music set. The play list uses 0 as 'no entry',
|
||||||
/* We are now checking for the existence of that file prior
|
* so we need to subtract 1. In case of 'no entry' (file = -1), just skip adding it outright. */
|
||||||
* to add it to the list of available songs */
|
int file = _playlists[_settings_client.music.playlist][i] - 1;
|
||||||
if (!StrEmpty(filename) && FioCheckFileExists(filename, BASESET_DIR)) {
|
if (file >= 0) {
|
||||||
_cur_playlist[j] = _playlists[_settings_client.music.playlist][i];
|
const char *filename = BaseMusic::GetUsedSet()->files[file].filename;
|
||||||
j++;
|
/* 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);
|
} while (_playlists[_settings_client.music.playlist][++i] != 0 && j < lengthof(_cur_playlist) - 1);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include "../core/backup_type.hpp"
|
#include "../core/backup_type.hpp"
|
||||||
#include "../smallmap_gui.h"
|
#include "../smallmap_gui.h"
|
||||||
#include "../news_func.h"
|
#include "../news_func.h"
|
||||||
|
#include "../order_backup.h"
|
||||||
#include "../error.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 */
|
/* Station acceptance is some kind of cache */
|
||||||
if (IsSavegameVersionBefore(127)) {
|
if (IsSavegameVersionBefore(127)) {
|
||||||
|
|
|
@ -288,20 +288,6 @@ void Load_BKOR()
|
||||||
OrderBackup *ob = new (index) OrderBackup();
|
OrderBackup *ob = new (index) OrderBackup();
|
||||||
SlObject(ob, GetOrderBackupDescription());
|
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()
|
static void Ptrs_BKOR()
|
||||||
|
|
Loading…
Reference in New Issue