summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-29 16:09:25 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-29 19:02:18 +0200
commit2e136285e1dfb4435c11769bf7cabb1ec2057e08 (patch)
treebd6cd67422cc6649a2b75761b52ad220de71b24e /src/town_cmd.cpp
parent661728558e9ce2eb8cfdb6afd7182b85e1f19a67 (diff)
downloadopenttd-2e136285e1dfb4435c11769bf7cabb1ec2057e08.tar.xz
Codechange: move from C-string to std::string for DoCommand
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index f70776c57..ee1ac343e 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1928,7 +1928,7 @@ static bool IsUniqueTownName(const std::string &name)
* @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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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 tile)
* @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 *FindFirstCargoWithTownEffect(TownEffect effect)
* @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 tile, DoCommandFlag flags, uint32 p1, uin
* @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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
* @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 tile, DoCommandFlag flags, uint32 p1, ui
* @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, DoCommandFlag flags, uint32 p1, uint32
* @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, DoCommandFlag flags, uint32 p1, uint32
* @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, CompanyID cid, const Town *t)
* @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;