summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-02-11 19:42:33 +0000
committerrubidium <rubidium@openttd.org>2012-02-11 19:42:33 +0000
commit5417153982f226247f3f3848bd70594897a834bc (patch)
treee1ce153a9588d122a0aa26d031c81bfc2cbdc824
parent445d12b6e543fe119d863735e3ba75a1c74602db (diff)
downloadopenttd-5417153982f226247f3f3848bd70594897a834bc.tar.xz
(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
-rw-r--r--src/news_gui.cpp25
-rw-r--r--src/script/api/script_news.hpp17
2 files changed, 26 insertions, 16 deletions
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) {
diff --git a/src/script/api/script_news.hpp b/src/script/api/script_news.hpp
index 49e72f912..3c40e6f33 100644
--- a/src/script/api/script_news.hpp
+++ b/src/script/api/script_news.hpp
@@ -22,26 +22,11 @@
class ScriptNews : public ScriptObject {
public:
/**
- * Enumeration for corners of tiles.
+ * Enumeration for the news types that a script can create news for.
*/
enum NewsType {
/* Note: these values represent part of the in-game NewsSubtype enum */
- NT_ARRIVAL_COMPANY = ::NS_ARRIVAL_COMPANY, ///< Category arrival for own company.
- NT_ARRIVAL_OTHER = ::NS_ARRIVAL_OTHER, ///< Category arrival for other companies.
- NT_ACCIDENT = ::NS_ACCIDENT, ///< Category accident.
- NT_COMPANY_TROUBLE = ::NS_COMPANY_TROUBLE, ///< Category company in trouble.
- NT_COMPANY_MERGER = ::NS_COMPANY_MERGER, ///< Category company merger.
- NT_COMPANY_BANKRUPT = ::NS_COMPANY_BANKRUPT, ///< Category company bankrupt.
- NT_COMPANY_NEW = ::NS_COMPANY_NEW, ///< Category company new.
- NT_INDUSTRY_OPEN = ::NS_INDUSTRY_OPEN, ///< Category industry open.
- NT_INDUSTRY_CLOSE = ::NS_INDUSTRY_CLOSE, ///< Category industry close.
NT_ECONOMY = ::NS_ECONOMY, ///< Category economy.
- NT_INDUSTRY_COMPANY = ::NS_INDUSTRY_COMPANY, ///< Category industry changes for own company.
- NT_INDUSTRY_OTHER = ::NS_INDUSTRY_OTHER, ///< Category industry changes for other companies.
- NT_INDUSTRY_NOBODY = ::NS_INDUSTRY_NOBODY, ///< Category industry changes for nobody.
- NT_ADVICE = ::NS_ADVICE, ///< Category advice.
- NT_NEW_VEHICLES = ::NS_NEW_VEHICLES, ///< Category new vehicle.
- NT_ACCEPTANCE = ::NS_ACCEPTANCE, ///< Category acceptance changes.
NT_SUBSIDIES = ::NS_SUBSIDIES, ///< Category subsidies.
NT_GENERAL = ::NS_GENERAL, ///< Category general.
};