From 5417153982f226247f3f3848bd70594897a834bc Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 11 Feb 2012 19:42:33 +0000 Subject: (svn r23924) -Fix [FS#5054]: [NoGo] "Some" news messages would cause an assertion to be triggered due to a missing proper location for the viewport of the news message, so only allow building when valid data for the viewport is provided or no viewport is used --- src/news_gui.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/news_gui.cpp') diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 2b4cc1616..47817d77e 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -761,6 +761,31 @@ CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, ui default: return CMD_ERROR; } + const WindowDesc *desc = _news_subtype_data[subtype].desc; + for (int i = 0; i < desc->nwid_length; i++) { + if (desc->nwid_parts[i].type == NWID_VIEWPORT && reftype1 != NR_VEHICLE && GetReferenceTile(reftype1, p2) == INVALID_TILE) { + return CMD_ERROR; + } + } + + switch (subtype) { + /* These sub types require more parameters that are never passed. */ + case NS_COMPANY_TROUBLE: + case NS_COMPANY_MERGER: + case NS_COMPANY_BANKRUPT: + case NS_COMPANY_NEW: + return CMD_ERROR; + + /* This one only accepts engines. */ + case NS_NEW_VEHICLES: + if (reftype1 != NR_ENGINE) return CMD_ERROR; + break; + + /* The rest, in theory, accepts everything. */ + default: + break; + } + if (company != INVALID_OWNER && company != _local_company) return CommandCost(); if (flags & DC_EXEC) { -- cgit v1.2.3-70-g09d2