summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-09-14 15:11:33 +0000
committerrubidium <rubidium@openttd.org>2014-09-14 15:11:33 +0000
commit32c56b5f84887ca8214bd290344c40dbc481f42d (patch)
tree47b9f49bec3064e31280aa7ad9d943f5e4057fbe
parent5a2fd3630b4c942da25bbb0e5d5f4aee850fb2b3 (diff)
downloadopenttd-32c56b5f84887ca8214bd290344c40dbc481f42d.tar.xz
(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)
-rw-r--r--src/saveload/afterload.cpp16
-rw-r--r--src/saveload/order_sl.cpp14
2 files changed, 16 insertions, 14 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 8ecd27b49..ae6b6a774 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -51,6 +51,7 @@
#include "../core/backup_type.hpp"
#include "../smallmap_gui.h"
#include "../news_func.h"
+#include "../order_backup.h"
#include "../error.h"
@@ -2916,6 +2917,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)) {
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index ba1f79c38..d55d577cb 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -295,20 +295,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()