(svn r23626) -Add: ScriptTown::SetText, which adds custom text to the Town GUI

This commit is contained in:
truebrain
2011-12-19 21:00:55 +00:00
parent 894216083d
commit ad48ab9237
9 changed files with 61 additions and 3 deletions

View File

@@ -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.