diff options
author | truebrain <truebrain@openttd.org> | 2011-12-19 21:00:55 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-12-19 21:00:55 +0000 |
commit | ad48ab923764087bf66153d1c26ed0eb05a19989 (patch) | |
tree | 7851cc098dee7c0e5c5ea0ffe183711342b2a283 /src/town_cmd.cpp | |
parent | 894216083d3f0b7c01ad705c253723e948297138 (diff) | |
download | openttd-ad48ab923764087bf66153d1c26ed0eb05a19989.tar.xz |
(svn r23626) -Add: ScriptTown::SetText, which adds custom text to the Town GUI
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r-- | src/town_cmd.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
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; @@ -2474,6 +2475,30 @@ CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uin } /** + * 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. * @param flags Type of operation. |