diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -72,7 +72,7 @@ CommandCost CmdBuildRoadVehicle(TileInde CommandCost CmdBuildShip (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v); CommandCost CmdBuildAircraft (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v); -CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text); +CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text); /** * Build a vehicle. @@ -86,7 +86,7 @@ CommandCost CmdRefitVehicle(TileIndex ti * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { /* Elementary check for valid location. */ if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR; @@ -154,7 +154,7 @@ CommandCost CmdBuildVehicle(TileIndex ti if (refitting) { /* Refit only one vehicle. If we purchased an engine, it may have gained free wagons. */ - value.AddCost(CmdRefitVehicle(tile, flags, v->index, cargo | (1 << 16), nullptr)); + value.AddCost(CmdRefitVehicle(tile, flags, v->index, cargo | (1 << 16), {})); } else { /* Fill in non-refitted capacities */ _returned_refit_capacity = e->GetDisplayDefaultCapacity(&_returned_mail_refit_capacity); @@ -206,7 +206,7 @@ CommandCost CmdSellRailWagon(DoCommandFl * @param text unused. * @return the cost of this operation or an error. */ -CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20)); if (v == nullptr) return CMD_ERROR; @@ -468,7 +468,7 @@ static CommandCost RefitVehicle(Vehicle * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr) return CMD_ERROR; @@ -556,7 +556,7 @@ CommandCost CmdRefitVehicle(TileIndex ti * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { /* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */ if ((flags & DC_AUTOREPLACE) == 0) SetBit(p2, 0); @@ -640,7 +640,7 @@ CommandCost CmdStartStopVehicle(TileInde * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { VehicleList list; bool do_start = HasBit(p1, 0); @@ -680,7 +680,7 @@ CommandCost CmdMassStartStopVehicle(Tile * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { VehicleList list; @@ -718,7 +718,7 @@ CommandCost CmdDepotSellAllVehicles(Tile * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { VehicleList list; CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES); @@ -822,7 +822,7 @@ static void CloneVehicleName(const Vehic * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { CommandCost total_cost(EXPENSES_NEW_VEHICLES); @@ -1044,7 +1044,7 @@ static CommandCost SendAllVehiclesToDepo * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { if (p1 & DEPOT_MASS_SEND) { /* Mass goto depot requested */ @@ -1069,7 +1069,7 @@ CommandCost CmdSendVehicleToDepot(TileIn * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -1077,7 +1077,7 @@ CommandCost CmdRenameVehicle(TileIndex t CommandCost ret = CheckOwnership(v->owner); if (ret.Failed()) return ret; - bool reset = StrEmpty(text); + bool reset = text.empty(); if (!reset) { if (Utf8StringLength(text) >= MAX_LENGTH_VEHICLE_NAME_CHARS) return CMD_ERROR; @@ -1110,7 +1110,7 @@ CommandCost CmdRenameVehicle(TileIndex t * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;