@@ -55,15 +55,17 @@
}
/* static */ bool ScriptTown::SetText(TownID town_id, Text *text)
{
CCountedPtr<Text> counter(text);
EnforcePrecondition(false, text != nullptr);
const char *encoded_text = text->GetEncodedText();
EnforcePreconditionEncodedText(false, encoded_text);
const char *encoded_text = nullptr;
if (text != nullptr) {
encoded_text = text->GetEncodedText();
EnforcePrecondition(false, IsValidTown(town_id));
return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);
/* static */ int32 ScriptTown::GetPopulation(TownID town_id)
@@ -143,23 +143,23 @@ public:
*/
static char *GetName(TownID town_id);
/**
* Rename a town.
* @param town_id The town to rename
* @param name The new name of the town. If nullptr or an empty string is passed, the town name will be reset to the default name.
* @param name The new name of the town. If null is passed, the town name will be reset to the default name.
* @pre IsValidTown(town_id).
* @return True if the action succeeded.
* @api -ai
static bool SetName(TownID town_id, Text *name);
* Set the custom text of a town, shown in the GUI.
* @param town_id The town to set the custom text of.
* @param text The text to set it to (can be either a raw string, or a ScriptText object).
* @param text The text to set it to (can be either a raw string, or a ScriptText object). If null is passed, the text will be removed.
static bool SetText(TownID town_id, Text *text);
Status change: