Mercurial > hg > openttd
comparison src/town_cmd.cpp @ 18778:153e9c1e0d36 draft
(svn r23626) -Add: ScriptTown::SetText, which adds custom text to the Town GUI
author | truebrain <truebrain@openttd.org> |
---|---|
date | Mon, 19 Dec 2011 21:00:55 +0000 |
parents | 1fa19d70aea9 |
children | 88567087417f |
comparison
equal
deleted
inserted
replaced
18777:693e2f94cbd1 | 18778:153e9c1e0d36 |
---|---|
60 INSTANTIATE_POOL_METHODS(Town) | 60 INSTANTIATE_POOL_METHODS(Town) |
61 | 61 |
62 Town::~Town() | 62 Town::~Town() |
63 { | 63 { |
64 free(this->name); | 64 free(this->name); |
65 free(this->text); | |
65 | 66 |
66 if (CleaningPool()) return; | 67 if (CleaningPool()) return; |
67 | 68 |
68 /* Delete town authority window | 69 /* Delete town authority window |
69 * and remove from list of sorted towns */ | 70 * and remove from list of sorted towns */ |
2472 | 2473 |
2473 return CommandCost(); | 2474 return CommandCost(); |
2474 } | 2475 } |
2475 | 2476 |
2476 /** | 2477 /** |
2478 * Set a custom text in the Town window. | |
2479 * @param tile Unused. | |
2480 * @param flags Type of operation. | |
2481 * @param p1 Town ID to change the text of. | |
2482 * @param p2 Unused. | |
2483 * @param text The new text (empty to remove the text). | |
2484 * @return Empty cost or an error. | |
2485 */ | |
2486 CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) | |
2487 { | |
2488 if (_current_company != OWNER_DEITY) return CMD_ERROR; | |
2489 Town *t = Town::GetIfValid(p1); | |
2490 if (t == NULL) return CMD_ERROR; | |
2491 | |
2492 if (flags & DC_EXEC) { | |
2493 free(t->text); | |
2494 t->text = StrEmpty(text) ? NULL : strdup(text); | |
2495 InvalidateWindowData(WC_TOWN_VIEW, p1); | |
2496 } | |
2497 | |
2498 return CommandCost(); | |
2499 } | |
2500 | |
2501 /** | |
2477 * Change the growth rate of the town. | 2502 * Change the growth rate of the town. |
2478 * @param tile Unused. | 2503 * @param tile Unused. |
2479 * @param flags Type of operation. | 2504 * @param flags Type of operation. |
2480 * @param p1 Town ID to cargo game of. | 2505 * @param p1 Town ID to cargo game of. |
2481 * @param p2 Amount of days between growth. | 2506 * @param p2 Amount of days between growth. |