diff options
author | alberth <alberth@openttd.org> | 2014-12-18 18:22:23 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2014-12-18 18:22:23 +0000 |
commit | 107bf32953f3261a0d7c02fa9113afeb94b68219 (patch) | |
tree | 5369e1e38edbef69201aa91f20e0c20001bece23 | |
parent | 78896895cf23deead6ebffe6bcd615729a833d3a (diff) | |
download | openttd-107bf32953f3261a0d7c02fa9113afeb94b68219.tar.xz |
(svn r27086) -Codechange: Simplify opening of windows by always returning a valid window pointer.
-rw-r--r-- | src/newgrf_debug_gui.cpp | 4 | ||||
-rw-r--r-- | src/story_gui.cpp | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 4abfa4b1f..82c7a7d22 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -702,8 +702,8 @@ void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 gr if (!IsNewGRFInspectable(feature, index)) return; WindowNumber wno = GetInspectWindowNumber(feature, index); - NewGRFInspectWindow *w = AllocateWindowDescFront<NewGRFInspectWindow>(feature == GSF_TRAINS || feature == GSF_ROADVEHICLES ? &_newgrf_inspect_chain_desc : &_newgrf_inspect_desc, wno); - if (w == NULL) w = (NewGRFInspectWindow *)FindWindowById(WC_NEWGRF_INSPECT, wno); + WindowDesc *desc = (feature == GSF_TRAINS || feature == GSF_ROADVEHICLES) ? &_newgrf_inspect_chain_desc : &_newgrf_inspect_desc; + NewGRFInspectWindow *w = AllocateWindowDescFront<NewGRFInspectWindow>(desc, wno, true); w->SetCallerGRFID(grfid); } diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 1c0edd925..003843310 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -758,13 +758,15 @@ static WindowDesc _story_book_desc( _nested_story_book_widgets, lengthof(_nested_story_book_widgets) ); +/** + * Raise or create the story book window for \a company, at page \a page_id. + * @param company 'Owner' of the story book, may be #INVALID_COMPANY. + * @param page_id Page to open, may be #INVALID_STORY_PAGE. + */ void ShowStoryBook(CompanyID company, uint16 page_id) { if (!Company::IsValidID(company)) company = (CompanyID)INVALID_COMPANY; - StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(&_story_book_desc, company); - if (page_id != INVALID_STORY_PAGE) { - if (w == NULL) w = (StoryBookWindow *)FindWindowById(WC_STORY_BOOK, company); - w->SetSelectedPage(page_id); - } + StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(&_story_book_desc, company, true); + if (page_id != INVALID_STORY_PAGE) w->SetSelectedPage(page_id); } |