|
@@ -1928,7 +1928,7 @@ static bool IsUniqueTownName(const std::
|
|
|
* @param text Custom name for the town. If empty, the town name parts will be used.
|
|
|
* @return the cost of this operation or an error
|
|
|
*/
|
|
|
CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
TownSize size = Extract<TownSize, 0, 2>(p1);
|
|
|
bool city = HasBit(p1, 2);
|
|
@@ -1953,7 +1953,7 @@ CommandCost CmdFoundTown(TileIndex tile,
|
|
|
return CMD_ERROR;
|
|
|
}
|
|
|
|
|
|
if (StrEmpty(text)) {
|
|
|
if (text.empty()) {
|
|
|
/* If supplied name is empty, townnameparts has to generate unique automatic name */
|
|
|
if (!VerifyTownName(townnameparts, &par)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
|
|
} else {
|
|
@@ -2003,7 +2003,7 @@ CommandCost CmdFoundTown(TileIndex tile,
|
|
|
UpdateNearestTownForRoadTiles(false);
|
|
|
old_generating_world.Restore();
|
|
|
|
|
|
if (t != nullptr && !StrEmpty(text)) {
|
|
|
if (t != nullptr && !text.empty()) {
|
|
|
t->name = text;
|
|
|
t->UpdateVirtCoord();
|
|
|
}
|
|
@@ -2743,12 +2743,12 @@ void ClearTownHouse(Town *t, TileIndex t
|
|
|
* @param text the new name or an empty string when resetting to the default
|
|
|
* @return the cost of this operation or an error
|
|
|
*/
|
|
|
CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
Town *t = Town::GetIfValid(p1);
|
|
|
if (t == nullptr) return CMD_ERROR;
|
|
|
|
|
|
bool reset = StrEmpty(text);
|
|
|
bool reset = text.empty();
|
|
|
|
|
|
if (!reset) {
|
|
|
if (Utf8StringLength(text) >= MAX_LENGTH_TOWN_NAME_CHARS) return CMD_ERROR;
|
|
@@ -2796,7 +2796,7 @@ const CargoSpec *FindFirstCargoWithTownE
|
|
|
* @param text Unused.
|
|
|
* @return Empty cost or an error.
|
|
|
*/
|
|
|
CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
|
|
|
|
@@ -2829,7 +2829,7 @@ CommandCost CmdTownCargoGoal(TileIndex t
|
|
|
* @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)
|
|
|
CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
|
|
Town *t = Town::GetIfValid(p1);
|
|
@@ -2837,7 +2837,7 @@ CommandCost CmdTownSetText(TileIndex til
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
t->text.clear();
|
|
|
if (!StrEmpty(text)) t->text = text;
|
|
|
if (!text.empty()) t->text = text;
|
|
|
InvalidateWindowData(WC_TOWN_VIEW, p1);
|
|
|
}
|
|
|
|
|
@@ -2853,7 +2853,7 @@ CommandCost CmdTownSetText(TileIndex til
|
|
|
* @param text Unused.
|
|
|
* @return Empty cost or an error.
|
|
|
*/
|
|
|
CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
|
|
if (GB(p2, 16, 16) != 0) return CMD_ERROR;
|
|
@@ -2893,7 +2893,7 @@ CommandCost CmdTownGrowthRate(TileIndex
|
|
|
* @param text Unused.
|
|
|
* @return Empty cost or an error.
|
|
|
*/
|
|
|
CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
|
|
|
|
@@ -2922,7 +2922,7 @@ CommandCost CmdTownRating(TileIndex tile
|
|
|
* @param text Unused.
|
|
|
* @return Empty cost or an error.
|
|
|
*/
|
|
|
CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) return CMD_ERROR;
|
|
|
Town *t = Town::GetIfValid(p1);
|
|
@@ -2962,7 +2962,7 @@ CommandCost CmdExpandTown(TileIndex tile
|
|
|
* @param text Unused.
|
|
|
* @return Empty cost or an error.
|
|
|
*/
|
|
|
CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
if (_game_mode != GM_EDITOR && !_generating_world) return CMD_ERROR;
|
|
|
Town *t = Town::GetIfValid(p1);
|
|
@@ -3351,7 +3351,7 @@ uint GetMaskOfTownActions(int *nump, Com
|
|
|
* @param text unused
|
|
|
* @return the cost of this operation or an error
|
|
|
*/
|
|
|
CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
|
|
{
|
|
|
Town *t = Town::GetIfValid(p1);
|
|
|
if (t == nullptr || p2 >= lengthof(_town_action_proc)) return CMD_ERROR;
|