summaryrefslogtreecommitdiff
path: root/src/saveload/story_sl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/saveload/story_sl.cpp')
-rw-r--r--src/saveload/story_sl.cpp24
1 files changed, 20 insertions, 4 deletions
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()
};