From ad48ab923764087bf66153d1c26ed0eb05a19989 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 21:00:55 +0000 Subject: (svn r23626) -Add: ScriptTown::SetText, which adds custom text to the Town GUI --- src/town_cmd.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/town_cmd.cpp') diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 096468599..fac15efe5 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -62,6 +62,7 @@ INSTANTIATE_POOL_METHODS(Town) Town::~Town() { free(this->name); + free(this->text); if (CleaningPool()) return; @@ -2473,6 +2474,30 @@ CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uin return CommandCost(); } +/** + * Set a custom text in the Town window. + * @param tile Unused. + * @param flags Type of operation. + * @param p1 Town ID to change the text of. + * @param p2 Unused. + * @param text The new text (empty to remove the text). + * @return Empty cost or an error. + */ +CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +{ + if (_current_company != OWNER_DEITY) return CMD_ERROR; + Town *t = Town::GetIfValid(p1); + if (t == NULL) return CMD_ERROR; + + if (flags & DC_EXEC) { + free(t->text); + t->text = StrEmpty(text) ? NULL : strdup(text); + InvalidateWindowData(WC_TOWN_VIEW, p1); + } + + return CommandCost(); +} + /** * Change the growth rate of the town. * @param tile Unused. -- cgit v1.2.3-54-g00ecf