diff options
author | zuu <zuu@openttd.org> | 2013-07-21 13:18:45 +0000 |
---|---|---|
committer | zuu <zuu@openttd.org> | 2013-07-21 13:18:45 +0000 |
commit | 09897c5fd68668c148859314f5e6a1f64dd4634b (patch) | |
tree | e9f32e20509dcef2ee790c00b5189f978b5bff4c /src/saveload | |
parent | 5eb8f0a0bb8fcebeb5605346508d76f1a9cd1044 (diff) | |
download | openttd-09897c5fd68668c148859314f5e6a1f64dd4634b.tar.xz |
(svn r25620) -Fix (r25342): Save/load of story books were broken
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 1 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 3 | ||||
-rw-r--r-- | src/saveload/saveload_internal.h | 1 | ||||
-rw-r--r-- | src/saveload/story_sl.cpp | 24 |
4 files changed, 24 insertions, 5 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index d969a40fc..a715c9162 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2818,6 +2818,7 @@ bool AfterLoadGame() AfterLoadRoadStops(); AfterLoadLabelMaps(); AfterLoadCompanyStats(); + AfterLoadStoryBook(); GamelogPrintDebug(1); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 4f59486a9..8f58ea381 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -250,8 +250,9 @@ * 182 25296 * 183 25363 * 184 25508 + * 185 25620 */ -extern const uint16 SAVEGAME_VERSION = 184; ///< Current savegame version of OpenTTD. +extern const uint16 SAVEGAME_VERSION = 185; ///< Current savegame version of OpenTTD. SavegameType _savegame_type; ///< type of savegame we are loading diff --git a/src/saveload/saveload_internal.h b/src/saveload/saveload_internal.h index 476a324f8..74e5b9936 100644 --- a/src/saveload/saveload_internal.h +++ b/src/saveload/saveload_internal.h @@ -31,6 +31,7 @@ void FixupTrainLengths(); void AfterLoadStations(); void AfterLoadRoadStops(); void AfterLoadLabelMaps(); +void AfterLoadStoryBook(); void AfterLoadLinkGraphs(); void AfterLoadCompanyStats(); void UpdateHousesAndTowns(); diff --git a/src/saveload/story_sl.cpp b/src/saveload/story_sl.cpp index 0ee5fe947..310f96fcb 100644 --- a/src/saveload/story_sl.cpp +++ b/src/saveload/story_sl.cpp @@ -14,10 +14,24 @@ #include "saveload.h" +/** Called after load to trash broken pages. */ +void AfterLoadStoryBook() +{ + if (IsSavegameVersionBefore(185)) { + /* Trash all story pages and page elements because + * they were saved with wrong data types. + */ + _story_page_element_pool.CleanPool(); + _story_page_pool.CleanPool(); + } +} + static const SaveLoad _story_page_elements_desc[] = { - SLE_VAR(StoryPageElement, sort_value, SLE_UINT16), + SLE_CONDVAR(StoryPageElement, sort_value, SLE_FILE_U16 | SLE_VAR_U32, 0, 184), + SLE_CONDVAR(StoryPageElement, sort_value, SLE_UINT32, 185, SL_MAX_VERSION), SLE_VAR(StoryPageElement, page, SLE_UINT16), - SLE_VAR(StoryPageElement, type, SLE_UINT16), + SLE_CONDVAR(StoryPageElement, type, SLE_FILE_U16 | SLE_VAR_U8, 0, 184), + SLE_CONDVAR(StoryPageElement, type, SLE_UINT8, 185, SL_MAX_VERSION), SLE_VAR(StoryPageElement, referenced_id, SLE_UINT32), SLE_STR(StoryPageElement, text, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_END() @@ -50,9 +64,11 @@ static void Load_STORY_PAGE_ELEMENT() } static const SaveLoad _story_pages_desc[] = { - SLE_VAR(StoryPage, sort_value, SLE_UINT16), + SLE_CONDVAR(StoryPage, sort_value, SLE_FILE_U16 | SLE_VAR_U32, 0, 184), + SLE_CONDVAR(StoryPage, sort_value, SLE_UINT32, 185, SL_MAX_VERSION), SLE_VAR(StoryPage, date, SLE_UINT32), - SLE_VAR(StoryPage, company, SLE_UINT16), + SLE_CONDVAR(StoryPage, company, SLE_FILE_U16 | SLE_VAR_U8, 0, 184), + SLE_CONDVAR(StoryPage, company, SLE_UINT8, 185, SL_MAX_VERSION), SLE_STR(StoryPage, title, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_END() }; |