Changeset - r21681:544ac4e247ba
[Not reviewed]
master
0 2 0
rubidium - 10 years ago 2014-09-14 15:11:33
rubidium@openttd.org
(svn r26819) -Fix [FS#6112] (r26787): trying to delete just loaded objects that had not yet resolved their references caused a crash upon savegame load (only when loading a game from a server, e.g. joining MP)
2 files changed with 16 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/saveload/afterload.cpp
Show inline comments
 
@@ -48,12 +48,13 @@
 
#include "../newgrf.h"
 
#include "../engine_func.h"
 
#include "../rail_gui.h"
 
#include "../core/backup_type.hpp"
 
#include "../smallmap_gui.h"
 
#include "../news_func.h"
 
#include "../order_backup.h"
 
#include "../error.h"
 

	
 

	
 
#include "saveload_internal.h"
 

	
 
#include <signal.h>
 
@@ -2913,12 +2914,27 @@ bool AfterLoadGame()
 
				}
 
				cur_skip--;
 
			}
 
		}
 
	}
 

	
 
	/*
 
	 * 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)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
 
	}
src/saveload/order_sl.cpp
Show inline comments
 
@@ -292,26 +292,12 @@ void Load_BKOR()
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		/* set num_orders to 0 so it's a valid OrderList */
 
		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()
 
{
 
	OrderBackup *ob;
 
	FOR_ALL_ORDER_BACKUPS(ob) {
0 comments (0 inline, 0 general)