summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Maton <max@maton.info>2018-09-16 05:17:10 +0200
committerNiels Martin Hansen <nielsm@indvikleren.dk>2018-09-18 18:35:26 +0200
commiteed0da60a2442a5b8a243b97fbbf64f639680ce7 (patch)
treefcbdef107b581e22889b9e5e48cd7c75e2386935
parent1a73c3983863304bde1810913525ad0c4d07883c (diff)
downloadopenttd-eed0da60a2442a5b8a243b97fbbf64f639680ce7.tar.xz
Fix #6622: Fixes empty company name in news when gamescript constructs a town
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/town_cmd.cpp20
2 files changed, 14 insertions, 7 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 0589ec4f1..6f3e5778a 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -815,6 +815,7 @@ STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLAC
STR_PRESIDENT_NAME_MANAGER :{BLACK}{PRESIDENT_NAME}{}(Manager)
STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}{RAW_STRING} sponsored construction of new town {TOWN}!
+STR_NEWS_NEW_TOWN_UNSPONSORED :{BLACK}{BIG_FONT}A new town called {TOWN} has been constructed!
STR_NEWS_INDUSTRY_CONSTRUCTION :{BIG_FONT}{BLACK}New {STRING} under construction near {TOWN}!
STR_NEWS_INDUSTRY_PLANTED :{BIG_FONT}{BLACK}New {STRING} being planted near {TOWN}!
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 92a3991ba..6ebf4e298 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1798,15 +1798,21 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (_game_mode != GM_EDITOR) {
/* 't' can't be NULL since 'random' is false outside scenedit */
assert(!random);
- char company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
- SetDParam(0, _current_company);
- GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
- char *cn = stredup(company_name);
- SetDParamStr(0, cn);
- SetDParam(1, t->index);
+ if (_current_company == OWNER_DEITY) {
+ SetDParam(0, t->index);
+ AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NT_INDUSTRY_OPEN, tile);
+ } else {
+ char company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
+ SetDParam(0, _current_company);
+ GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
+
+ char *cn = stredup(company_name);
+ SetDParamStr(0, cn);
+ SetDParam(1, t->index);
- AddTileNewsItem(STR_NEWS_NEW_TOWN, NT_INDUSTRY_OPEN, tile, cn);
+ AddTileNewsItem(STR_NEWS_NEW_TOWN, NT_INDUSTRY_OPEN, tile, cn);
+ }
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
Game::NewEvent(new ScriptEventTownFounded(t->index));
}