mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
(svn r25621) -Fix (r25342): Also delete page elments when their page is removed (so that they don't reappear on a new page later on)
This commit is contained in:
parent
4b036690e2
commit
267431346b
@ -63,6 +63,9 @@ struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_po
|
|||||||
inline ~StoryPageElement() { free(this->text); }
|
inline ~StoryPageElement() { free(this->text); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FOR_ALL_STORY_PAGE_ELEMENTS_FROM(var, start) FOR_ALL_ITEMS_FROM(StoryPageElement, story_page_element_index, var, start)
|
||||||
|
#define FOR_ALL_STORY_PAGE_ELEMENTS(var) FOR_ALL_STORY_PAGE_ELEMENTS_FROM(var, 0)
|
||||||
|
|
||||||
/** Struct about stories, current and completed */
|
/** Struct about stories, current and completed */
|
||||||
struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
|
struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
|
||||||
uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index.
|
uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index.
|
||||||
@ -79,11 +82,18 @@ struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> {
|
|||||||
/**
|
/**
|
||||||
* (Empty) destructor has to be defined else operator delete might be called with NULL parameter
|
* (Empty) destructor has to be defined else operator delete might be called with NULL parameter
|
||||||
*/
|
*/
|
||||||
inline ~StoryPage() { free(this->title); }
|
inline ~StoryPage()
|
||||||
|
{
|
||||||
|
if (!this->CleaningPool()) {
|
||||||
|
StoryPageElement *spe;
|
||||||
|
FOR_ALL_STORY_PAGE_ELEMENTS(spe) {
|
||||||
|
if (spe->page == this->index) delete spe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(this->title);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_STORY_PAGE_ELEMENTS_FROM(var, start) FOR_ALL_ITEMS_FROM(StoryPageElement, story_page_element_index, var, start)
|
|
||||||
#define FOR_ALL_STORY_PAGE_ELEMENTS(var) FOR_ALL_STORY_PAGE_ELEMENTS_FROM(var, 0)
|
|
||||||
#define FOR_ALL_STORY_PAGES_FROM(var, start) FOR_ALL_ITEMS_FROM(StoryPage, story_page_index, var, start)
|
#define FOR_ALL_STORY_PAGES_FROM(var, start) FOR_ALL_ITEMS_FROM(StoryPage, story_page_index, var, start)
|
||||||
#define FOR_ALL_STORY_PAGES(var) FOR_ALL_STORY_PAGES_FROM(var, 0)
|
#define FOR_ALL_STORY_PAGES(var) FOR_ALL_STORY_PAGES_FROM(var, 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user