changeset 11090:df23c4e04638 draft

(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
author rubidium <rubidium@openttd.org>
date Mon, 09 Feb 2009 21:20:05 +0000
parents c98af41d49f0
children c4c35a89bad7
files src/aircraft_cmd.cpp src/autoreplace.cpp src/autoreplace_cmd.cpp src/autoreplace_func.h src/bridge.h src/clear_cmd.cpp src/command.cpp src/command_func.h src/command_type.h src/company_cmd.cpp src/dummy_land.cpp src/economy.cpp src/engine.cpp src/group_cmd.cpp src/industry_cmd.cpp src/landscape.cpp src/misc_cmd.cpp src/misc_gui.cpp src/order_cmd.cpp src/rail_cmd.cpp src/road_cmd.cpp src/road_internal.h src/roadveh_cmd.cpp src/settings.cpp src/ship_cmd.cpp src/signs.cpp src/station_cmd.cpp src/terraform_cmd.cpp src/tile_cmd.h src/timetable_cmd.cpp src/town.h src/town_cmd.cpp src/train_cmd.cpp src/tree_cmd.cpp src/tunnelbridge_cmd.cpp src/unmovable_cmd.cpp src/vehicle.cpp src/vehicle_base.h src/vehicle_func.h src/water_cmd.cpp src/waypoint.cpp src/waypoint.h
diffstat 42 files changed, 197 insertions(+), 194 deletions(-) [+]
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -246,7 +246,7 @@
  * @param p2 unused
  * return result of operation.  Could be cost, error
  */
-CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_company)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
 
@@ -449,7 +449,7 @@
  * @param p2 unused
  * @return result of operation.  Error or sold value
  */
-CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
@@ -497,7 +497,7 @@
  * - p2 bit 8-10 - VLW flag (for mass goto depot)
  * @return o if everything went well
  */
-CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSendAircraftToHangar(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p2 & DEPOT_MASS_SEND) {
 		/* Mass goto depot requested */
@@ -525,7 +525,7 @@
  * - p2 = (bit 16) - refit only this vehicle (ignored)
  * @return cost of refit or error
  */
-CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	byte new_subtype = GB(p2, 8, 8);
 
--- a/src/autoreplace.cpp
+++ b/src/autoreplace.cpp
@@ -47,7 +47,7 @@
 	return er == NULL ? INVALID_ENGINE : er->to;
 }
 
-CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
+CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
 {
 	EngineRenew *er;
 
@@ -72,7 +72,7 @@
 	return CommandCost();
 }
 
-CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags)
+CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags)
 {
 	EngineRenew *er = (EngineRenew *)(*erl);
 	EngineRenew *prev = NULL;
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -292,7 +292,7 @@
  * @param whole_chain move all vehicles following 'v' (true), or only 'v' (false)
  * @return success or error
  */
-static inline CommandCost MoveVehicle(const Vehicle *v, const Vehicle *after, uint32 flags, bool whole_chain)
+static inline CommandCost MoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlag flags, bool whole_chain)
 {
 	return DoCommand(0, v->index | (after != NULL ? after->index : INVALID_VEHICLE) << 16, whole_chain ? 1 : 0, flags, CMD_MOVE_RAIL_VEHICLE);
 }
@@ -302,7 +302,7 @@
  * @param new_head The new head of the completely replaced vehicle chain
  * @param flags the command flags to use
  */
-static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, uint32 flags)
+static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoCommandFlag flags)
 {
 	CommandCost cost = CommandCost();
 
@@ -346,7 +346,7 @@
  * @param nothing_to_do is set to 'false' when something was done (only valid when not failed)
  * @return cost or error
  */
-static CommandCost ReplaceFreeUnit(Vehicle **single_unit, uint32 flags, bool *nothing_to_do)
+static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlag flags, bool *nothing_to_do)
 {
 	Vehicle *old_v = *single_unit;
 	assert(old_v->type == VEH_TRAIN && !IsArticulatedPart(old_v) && !IsRearDualheaded(old_v));
@@ -395,7 +395,7 @@
  * @param nothing_to_do is set to 'false' when something was done (only valid when not failed)
  * @return cost or error
  */
-static CommandCost ReplaceChain(Vehicle **chain, uint32 flags, bool wagon_removal, bool *nothing_to_do)
+static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon_removal, bool *nothing_to_do)
 {
 	Vehicle *old_head = *chain;
 	assert(old_head->IsPrimaryVehicle());
@@ -601,7 +601,7 @@
  * @param p1 Index of vehicle
  * @param p2 not used
  */
-CommandCost CmdAutoreplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, 0);
 	bool nothing_to_do = true;
--- a/src/autoreplace_func.h
+++ b/src/autoreplace_func.h
@@ -32,7 +32,7 @@
  * @param flags The calling command flags.
  * @return 0 on success, CMD_ERROR on failure.
  */
-CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
+CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags);
 
 /**
  * Remove an engine replacement from a given renewlist.
@@ -41,7 +41,7 @@
  * @param flags The calling command flags.
  * @return 0 on success, CMD_ERROR on failure.
  */
-CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
+CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
 
 /**
  * Remove all engine replacement settings for the given company.
@@ -83,7 +83,7 @@
  * @param flags The calling command flags.
  * @return 0 on success, CMD_ERROR on failure.
  */
-static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
+static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
 {
 	return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, flags);
 }
@@ -95,7 +95,7 @@
  * @param flags The calling command flags.
  * @return 0 on success, CMD_ERROR on failure.
  */
-static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, uint32 flags)
+static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
 {
 	return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
 }
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -61,7 +61,7 @@
 
 void DrawBridgeMiddle(const TileInfo *ti);
 
-bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags = 0);
+bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
 int CalcBridgeLenCostFactor(int x);
 
 void ResetBridges();
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -20,7 +20,7 @@
 #include "table/sprites.h"
 #include "table/clear_land.h"
 
-static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
+static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
 {
 	static const Money *clear_price_table[] = {
 		&_price.clear_grass,
@@ -357,7 +357,7 @@
 	_settings_game.game_creation.snow_line = _settings_game.game_creation.snow_line_height * TILE_HEIGHT;
 }
 
-static CommandCost TerraformTile_Clear(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 }
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -34,7 +34,7 @@
  *
  * @param yyyy The desired function name of the new command handler function.
  */
-#define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+#define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
 DEF_COMMAND(CmdBuildRailroadTrack);
 DEF_COMMAND(CmdRemoveRailroadTrack);
@@ -376,7 +376,7 @@
  * @see CommandProc
  * @return the cost
  */
-CommandCost DoCommand(const CommandContainer *container, uint32 flags)
+CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
 {
 	return DoCommand(container->tile, container->p1, container->p2, flags, container->cmd & CMD_ID_MASK, container->text);
 }
@@ -393,7 +393,7 @@
  * @see CommandProc
  * @return the cost
  */
-CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 cmd, const char *text)
+CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text)
 {
 	CommandCost res;
 
@@ -520,7 +520,7 @@
 	/* Command flags are used internally */
 	uint cmd_flags = GetCommandFlags(cmd);
 	/* Flags get send to the DoCommand */
-	uint32 flags = CommandFlagsToDCFlags(cmd_flags);
+	DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
 
 	/* Do not even think about executing out-of-bounds tile-commands */
 	if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return false;
--- a/src/command_func.h
+++ b/src/command_func.h
@@ -53,8 +53,8 @@
 /**
  * Execute a command
  */
-CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 cmd, const char *text = NULL);
-CommandCost DoCommand(const CommandContainer *container, uint32 flags);
+CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL);
+CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
 
 /**
  * Execute a network safe DoCommand function
@@ -91,9 +91,9 @@
  * @param cmd_flags Flags from GetCommandFlags
  * @return flags for DoCommand
  */
-static inline uint32 CommandFlagsToDCFlags(uint cmd_flags)
+static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
 {
-	uint32 flags = 0;
+	DoCommandFlag flags = DC_NONE;
 	if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
 	if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
 	if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -293,7 +293,8 @@
  *
  * This enums defines some flags which can be used for the commands.
  */
-enum {
+enum DoCommandFlag {
+	DC_NONE            = 0x000, ///< no flag is set
 	DC_EXEC            = 0x001, ///< execute the given command
 	DC_AUTO            = 0x002, ///< don't allow building on structures
 	DC_QUERY_COST      = 0x004, ///< query cost only,  don't build.
@@ -304,6 +305,7 @@
 	DC_AUTOREPLACE     = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
 	DC_ALL_TILES       = 0x100, ///< allow this command also on MP_VOID tiles
 };
+DECLARE_ENUM_AS_BIT_SET(DoCommandFlag);
 
 /**
  * Used to combine a StringID with the command.
@@ -361,7 +363,7 @@
  * @param text Additional text
  * @return The CommandCost of the command, which can be succeeded or failed.
  */
-typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text);
+typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
 
 /**
  * Define a command with the flags which belongs to it.
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -568,7 +568,7 @@
  * if p1 = 5, then
  * - p2 = enable renew_keep_length
  */
-CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidCompanyID(_current_company)) return CMD_ERROR;
 
@@ -711,7 +711,7 @@
  * @arg - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)@n
  * @arg - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received
  */
-CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (flags & DC_EXEC) _current_company = OWNER_NONE;
 
--- a/src/dummy_land.cpp
+++ b/src/dummy_land.cpp
@@ -26,7 +26,7 @@
 	return FOUNDATION_NONE;
 }
 
-static CommandCost ClearTile_Dummy(TileIndex tile, byte flags)
+static CommandCost ClearTile_Dummy(TileIndex tile, DoCommandFlag flags)
 {
 	return_cmd_error(STR_0001_OFF_EDGE_OF_MAP);
 }
@@ -69,7 +69,7 @@
 	return 0;
 }
 
-static CommandCost TerraformTile_Dummy(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Dummy(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	return_cmd_error(STR_0001_OFF_EDGE_OF_MAP);
 }
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1856,7 +1856,7 @@
  * @param p1 company to buy the shares from
  * @param p2 unused
  */
-CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_OTHER);
 
@@ -1901,7 +1901,7 @@
  * @param p1 company to sell the shares from
  * @param p2 unused
  */
-CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Check if selling shares is allowed (protection against modified clients) */
 	/* Cannot sell own shares */
@@ -1934,7 +1934,7 @@
  * @param p1 company to buy up
  * @param p2 unused
  */
-CommandCost CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CompanyID cid = (CompanyID)p1;
 
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -467,7 +467,7 @@
  * @param p1 engine-prototype offered
  * @param p2 unused
  */
-CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Engine *e;
 
@@ -581,7 +581,7 @@
  * @param p1 engine ID to rename
  * @param p2 unused
  */
-CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsEngineIndex(p1)) return CMD_ERROR;
 
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -75,7 +75,7 @@
  * @param p1   vehicle type
  * @param p2   unused
  */
-CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleType vt = (VehicleType)p1;
 	if (!IsCompanyBuildableVehicleType(vt)) return CMD_ERROR;
@@ -103,7 +103,7 @@
  *      - p1 bit 0-15 : GroupID
  * @param p2   unused
  */
-CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidGroupID(p1)) return CMD_ERROR;
 
@@ -162,7 +162,7 @@
  *   - p1 bit 0-15 : GroupID
  * @param p2   unused
  */
-CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidGroupID(p1)) return CMD_ERROR;
 
@@ -197,7 +197,7 @@
  * @param p2   vehicle to add to a group
  *   - p2 bit 0-15 : VehicleID
  */
-CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	GroupID new_g = p1;
 
@@ -244,7 +244,7 @@
  *  - p1 bit 0-15 : GroupID
  * @param p2   type of vehicles
  */
-CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleType type = (VehicleType)p2;
 	if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
@@ -281,7 +281,7 @@
  * - p1 bit 0-15 : GroupID
  * @param p2   type of vehicles
  */
-CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleType type = (VehicleType)p2;
 	if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
@@ -318,7 +318,7 @@
  * @param p2
  * - p2 bit 0    : 1 to set or 0 to clear protection.
  */
-CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSetGroupReplaceProtection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidGroupID(p1)) return CMD_ERROR;
 
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -406,7 +406,7 @@
 	}
 }
 
-static CommandCost ClearTile_Industry(TileIndex tile, byte flags)
+static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags)
 {
 	Industry *i = GetIndustryByTile(tile);
 	const IndustrySpec *indspec = GetIndustrySpec(i->type);
@@ -1262,7 +1262,7 @@
 				/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
 				CompanyID old_company = _current_company;
 				_current_company = OWNER_TOWN;
-				bool not_clearable = CmdFailed(DoCommand(cur_tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR));
+				bool not_clearable = CmdFailed(DoCommand(cur_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR));
 				_current_company = old_company;
 
 				if (not_clearable) return false;
@@ -1338,7 +1338,7 @@
  * This function tries to flatten out the land below an industry, without
  *  damaging the surroundings too much.
  */
-static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const IndustryTileTable *it, int type)
+static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags, const IndustryTileTable *it, int type)
 {
 	const int MKEND = -0x80;   // used for last element in an IndustryTileTable (see build_industry.h)
 	int max_x = 0;
@@ -1597,7 +1597,7 @@
  * @param seed random seed (possibly) used by industries
  * @return the pointer of the newly created industry, or NULL if it failed
  */
-static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint32 flags, const IndustrySpec *indspec, uint itspec_index, uint32 seed)
+static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 seed)
 {
 	const IndustryTileTable *it = indspec->table[itspec_index];
 	bool custom_shape_check = false;
@@ -1610,7 +1610,7 @@
 		if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL;
 	}
 
-	if (!custom_shape_check && _settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
+	if (!custom_shape_check && _settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, DC_NONE, it, type)) return NULL;
 	if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL;
 
 	const Town *t = CheckMultipleIndustryInTown(tile, type);
@@ -1642,7 +1642,7 @@
  * @param p2 seed to use for variable 8F
  * @return index of the newly create industry, or CMD_ERROR if it failed
  */
-CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	const IndustrySpec *indspec = GetIndustrySpec(GB(p1, 0, 16));
 	const Industry *ind = NULL;
@@ -2349,7 +2349,7 @@
 	return (_price.remove_house * this->removal_cost_multiplier) >> 8;
 }
 
-static CommandCost TerraformTile_Industry(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	if (AutoslopeEnabled()) {
 		/* We imitate here TTDP's behaviour:
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -588,7 +588,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
 }
@@ -599,7 +599,7 @@
  * @param flags of operation to conduct
  * @param p2 unused
  */
-CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p1 >= MapSize()) return CMD_ERROR;
 
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -28,7 +28,7 @@
  * @param p1 unused
  * @param p2 face bitmasked
  */
-CommandCost CmdSetCompanyManagerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CompanyManagerFace cmf = (CompanyManagerFace)p2;
 
@@ -49,7 +49,7 @@
  * p1 bits 8-9 set in use state or first/second colour
  * @param p2 new colour for vehicles, property, etc.
  */
-CommandCost CmdSetCompanyColour(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p2 >= 16) return CMD_ERROR; // max 16 colours
 
@@ -130,7 +130,7 @@
  *           when 1: loans the maximum loan permitting money (press CTRL),
  *           when 2: loans the amount specified in p1
  */
-CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Company *c = GetCompany(_current_company);
 
@@ -174,7 +174,7 @@
  *           when 1: pays back the maximum loan permitting money (press CTRL),
  *           when 2: pays back the amount specified in p1
  */
-CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Company *c = GetCompany(_current_company);
 
@@ -226,7 +226,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdRenameCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	bool reset = StrEmpty(text);
 
@@ -262,7 +262,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdRenamePresident(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	bool reset = StrEmpty(text);
 
@@ -314,7 +314,7 @@
  * @param p1 0 = decrease pause counter; 1 = increase pause counter
  * @param p2 unused
  */
-CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (flags & DC_EXEC) {
 		_pause_game += (p1 == 0) ? -1 : 1;
@@ -350,7 +350,7 @@
  * @param p1 the amount of money to receive (if negative), or spend (if positive)
  * @param p2 unused
  */
-CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 #ifndef _DEBUG
 	if (_networking) return CMD_ERROR;
@@ -367,7 +367,7 @@
  * @param p1 the amount of money to transfer; max 20.000.000
  * @param p2 the company to transfer the money to
  */
-CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!_settings_game.economy.give_money) return CMD_ERROR;
 
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -94,7 +94,7 @@
 
 		Money old_money = c->money;
 		c->money = INT64_MAX;
-		CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
+		CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
 		c->money = old_money;
 
 		/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -411,7 +411,7 @@
  *                        the maximum vehicle order id is 254.
  * @param p2 packed order to insert
  */
-CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	VehicleID veh   = GB(p1,  0, 16);
@@ -629,7 +629,7 @@
  * @param *dst delete the orders of this vehicle
  * @param flags execution flags
  */
-static CommandCost DecloneOrder(Vehicle *dst, uint32 flags)
+static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
 {
 	if (flags & DC_EXEC) {
 		DeleteVehicleOrders(dst);
@@ -645,7 +645,7 @@
  * @param p1 the ID of the vehicle
  * @param p2 the order to delete (max 255)
  */
-CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	VehicleID veh_id = p1;
@@ -713,7 +713,7 @@
  * @param p1 The ID of the vehicle which order is skipped
  * @param p2 the selected order to which we want to skip
  */
-CommandCost CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	VehicleID veh_id = p1;
@@ -753,7 +753,7 @@
  * @note The target order will move one place down in the orderlist
  *  if you move the order upwards else it'll move it one place down
  */
-CommandCost CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleID veh = p1;
 	VehicleOrderID moving_order = GB(p2,  0, 16);
@@ -831,7 +831,7 @@
  *  - p2 = (bit 0 -  3) - what data to modify (@see ModifyOrderFlags)
  *  - p2 = (bit 4 - 15) - the data to modify
  */
-CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleOrderID sel_ord = GB(p1, 16, 16); // XXX - automatically truncated to 8 bits.
 	VehicleID veh          = GB(p1,  0, 16);
@@ -1048,7 +1048,7 @@
  * - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
  * @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE
  */
-CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *dst;
 	VehicleID veh_src = GB(p1, 16, 16);
@@ -1177,7 +1177,7 @@
  *   - bit 8-15 Cargo subtype
  *   - bit 16-23 number of order to modify
  */
-CommandCost CmdOrderRefit(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	const Vehicle *v;
 	Order *order;
@@ -1333,7 +1333,7 @@
  * If we do want to backup/restore it, just add UnitID uid to BackuppedOrders, and
  * restore it as parameter 'y' (ugly hack I know) for example. "v->unitnumber = y;"
  */
-CommandCost CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRestoreOrderIndex(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	VehicleOrderID cur_ord = GB(p2,  0, 16);
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -303,7 +303,7 @@
  * @param p1 railtype of being built piece (normal, mono, maglev)
  * @param p2 rail track to build
  */
-CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Slope tileh;
 	RailType railtype = (RailType)p1;
@@ -442,7 +442,7 @@
  * @param p1 unused
  * @param p2 rail orientation
  */
-CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Track track = (Track)p2;
 	TrackBits trackbit;
@@ -668,7 +668,7 @@
  * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
  * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
  */
-static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
 	Track track = (Track)GB(p2, 4, 3);
@@ -718,7 +718,7 @@
  * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
  * @see CmdRailTrackHelper
  */
-CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 7), text);
 }
@@ -734,7 +734,7 @@
  * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
  * @see CmdRailTrackHelper
  */
-CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 7), text);
 }
@@ -748,7 +748,7 @@
  * @todo When checking for the tile slope,
  * distingush between "Flat land required" and "land sloped in wrong direction"
  */
-CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Slope tileh;
 
@@ -812,7 +812,7 @@
  * @param p2 used for CmdBuildManySignals() to copy direction of first signal
  * TODO: p2 should be replaced by two bits for "along" and "against" the track.
  */
-CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Track track = (Track)GB(p1, 0, 3);
 	bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
@@ -1024,7 +1024,7 @@
  * - p2 = (bit  7- 9) - default signal type
  * - p2 = (bit 24-31) - user defined signals_density
  */
-static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
 	int signal_ctr;
@@ -1150,7 +1150,7 @@
  * - p2 = (bit 24-31) - user defined signals_density
  * @see CmdSignalTrackHelper
  */
-CommandCost CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	return CmdSignalTrackHelper(tile, flags, p1, p2,text);
 }
@@ -1164,7 +1164,7 @@
  *           - (bit  4)    - 0 = signals, 1 = semaphores
  * @param p2 unused
  */
-CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Track track = (Track)GB(p1, 0, 3);
 
@@ -1219,7 +1219,7 @@
  * - p2 = (bit 24-31) - user defined signals_density
  * @see CmdSignalTrackHelper
  */
-CommandCost CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	return CmdSignalTrackHelper(tile, flags, p1, SetBit(p2, 5), text); // bit 5 is remove bit
 }
@@ -1244,7 +1244,7 @@
  * @param p1 start tile of drag
  * @param p2 new railtype to convert to
  */
-CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	RailType totype = (RailType)p2;
@@ -1417,7 +1417,7 @@
 	return (cost.GetCost() == 0) ? CMD_ERROR : cost;
 }
 
-static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags)
+static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
 {
 	if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER)
 		return CMD_ERROR;
@@ -1446,7 +1446,7 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot);
 }
 
-static CommandCost ClearTile_Track(TileIndex tile, byte flags)
+static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	CommandCost ret;
@@ -2547,7 +2547,7 @@
 	return  cost;
 }
 
-static CommandCost TerraformTile_Track(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	uint z_old;
 	Slope tileh_old = GetTileSlope(tile, &z_old);
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -112,7 +112,7 @@
  * @param town_check Shall the town rating checked/affected
  * @return true when it is allowed to remove the road bits
  */
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, uint32 flags, bool town_check)
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, DoCommandFlag flags, bool town_check)
 {
 	if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return true;
 
@@ -170,7 +170,7 @@
  * @param rt roadtype to remove
  * @param crossing_check should we check if there is a tram track when we are removing road from crossing?
  */
-static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, RoadType rt, bool crossing_check, bool town_check = true)
+static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadType rt, bool crossing_check, bool town_check = true)
 {
 	RoadTypes rts = GetRoadTypes(tile);
 	/* The tile doesn't have the given road type */
@@ -346,7 +346,7 @@
  *           bit 4..5 road type
  * @param p2 unused
  */
-CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	RoadType rt = (RoadType)GB(p1, 4, 2);
 	if (!IsValidRoadType(rt)) return CMD_ERROR;
@@ -440,7 +440,7 @@
  *           bit 6..7 disallowed directions to toggle
  * @param p2 the town that is building the road (0 if not applicable)
  */
-CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 
@@ -683,7 +683,7 @@
  * - p2 = (bit 3 + 4) - road type
  * - p2 = (bit 5) - set road direction
  */
-CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildLongRoad(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	bool had_bridge = false;
@@ -769,7 +769,7 @@
  * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
  * - p2 = (bit 3 + 4) - road type
  */
-CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveLongRoad(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 
@@ -834,7 +834,7 @@
  * @todo When checking for the tile slope,
  * distingush between "Flat land required" and "land sloped in wrong direction"
  */
-CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	DiagDirection dir = Extract<DiagDirection, 0>(p1);
 	RoadType rt = (RoadType)GB(p1, 2, 2);
@@ -867,7 +867,7 @@
 	return cost.AddCost(_price.build_road_depot);
 }
 
-static CommandCost RemoveRoadDepot(TileIndex tile, uint32 flags)
+static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
 {
 	if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;
 
@@ -881,7 +881,7 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot);
 }
 
-static CommandCost ClearTile_Road(TileIndex tile, byte flags)
+static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
 {
 	switch (GetRoadTileType(tile)) {
 		case ROAD_TILE_NORMAL: {
@@ -1588,7 +1588,7 @@
 	}
 }
 
-static CommandCost TerraformTile_Road(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
 		switch (GetRoadTileType(tile)) {
--- a/src/road_internal.h
+++ b/src/road_internal.h
@@ -25,7 +25,7 @@
  * @param town_check Shall the town rating checked/affected
  * @return true when it is allowed to remove the road bits
  */
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, uint32 flags, bool town_check = true);
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, DoCommandFlag flags, bool town_check = true);
 
 /**
  * Draw the catenary for tram road bits
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -158,7 +158,7 @@
  * @param p1 bus/truck type being built (engine)
  * @param p2 unused
  */
-CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	UnitID unit_num;
@@ -313,7 +313,7 @@
  * @param p1 vehicle ID to be sold
  * @param p2 unused
  */
-CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSellRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 
@@ -418,7 +418,7 @@
  * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  * - p2 bit 8-10 - VLW flag (for mass goto depot)
  */
-CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSendRoadVehToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p2 & DEPOT_MASS_SEND) {
 		/* Mass goto depot requested */
@@ -441,7 +441,7 @@
  * @param p1 vehicle ID to turn
  * @param p2 unused
  */
-CommandCost CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 
@@ -1336,7 +1336,7 @@
 	CompanyID original_company = _current_company;
 	_current_company = c;
 
-	CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, 0, CMD_BUILD_ROAD);
+	CommandCost ret = DoCommand(t, ROADTYPE_TRAM << 4 | r, 0, DC_NONE, CMD_BUILD_ROAD);
 
 	_current_company = original_company;
 	return CmdSucceeded(ret);
@@ -1984,7 +1984,7 @@
  * - p2 = (bit 16) - refit only this vehicle
  * @return cost of refit or error
  */
-CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	CommandCost cost(EXPENSES_ROADVEH_RUN);
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1973,7 +1973,7 @@
  * The new value is properly clamped to its minimum/maximum when setting
  * @see _settings
  */
-CommandCost CmdChangeSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	const SettingDesc *sd = GetSettingDescription(p1);
 
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -728,7 +728,7 @@
  * @param p1 ship type being built (engine)
  * @param p2 unused
  */
-CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	UnitID unit_num;
 
@@ -820,7 +820,7 @@
  * @param p1 vehicle ID to be sold
  * @param p2 unused
  */
-CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSellShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 
@@ -865,7 +865,7 @@
  * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  * - p2 bit 8-10 - VLW flag (for mass goto depot)
  */
-CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSendShipToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p2 & DEPOT_MASS_SEND) {
 		/* Mass goto depot requested */
@@ -893,7 +893,7 @@
  * - p2 = (bit 16) - refit only this vehicle (ignored)
  * @return cost of refit or error
  */
-CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Vehicle *v;
 	CommandCost cost(EXPENSES_SHIP_RUN);
--- a/src/signs.cpp
+++ b/src/signs.cpp
@@ -90,7 +90,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Try to locate a new sign */
 	if (!Sign::CanAllocateItem()) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
@@ -128,7 +128,7 @@
  * @param p2 unused
  * @return 0 if succesfull, otherwise CMD_ERROR
  */
-CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidSignID(p1)) return CMD_ERROR;
 
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -696,7 +696,7 @@
 	UpdateStationSignCoord(st);
 }
 
-static CommandCost ClearTile_Station(TileIndex tile, byte flags);
+static CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags);
 
 /** Tries to clear the given area.
  * @param tile TileIndex to start check
@@ -708,7 +708,7 @@
  * @param check_clear if clearing tile should be performed (in wich case, cost will be added)
  * @return the cost in case of success, or an error code if it failed.
  */
-CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true)
+CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	int allowed_z = -1;
@@ -900,7 +900,7 @@
  * - p2 = (bit  8-15) - custom station id
  * - p2 = (bit 16-31) - station ID to join (INVALID_STATION if build new one)
  */
-CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Does the authority allow this? */
 	if (!CheckIfAuthorityAllowsNewStation(tile_org, flags)) return CMD_ERROR;
@@ -1192,7 +1192,7 @@
  * @param p1 start_tile
  * @param p2 unused
  */
-CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	TileIndex start = p1 == 0 ? tile : p1;
 
@@ -1297,7 +1297,7 @@
 }
 
 
-static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
+static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, DoCommandFlag flags)
 {
 	/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
 	if (_current_company == OWNER_WATER && _settings_game.station.nonuniform_stations) {
@@ -1395,7 +1395,7 @@
  *           bit 5: allow stations directly adjacent to other stations.
  *           bit 16..31: station ID to join (INVALID_STATION if build new one)
  */
-CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	bool type = HasBit(p2, 0);
 	bool is_drive_through = HasBit(p2, 1);
@@ -1544,7 +1544,7 @@
  * @param tile TileIndex been queried
  * @return cost or failure of operation
  */
-static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
+static CommandCost RemoveRoadStop(Station *st, DoCommandFlag flags, TileIndex tile)
 {
 	if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
 		return CMD_ERROR;
@@ -1617,7 +1617,7 @@
  * @param p1 not used
  * @param p2 bit 0: 0 for Bus stops, 1 for truck stops
  */
-CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Make sure the specified tile is a road stop of the correct type */
 	if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != GB(p2, 0, 1)) return CMD_ERROR;
@@ -1847,7 +1847,7 @@
  * - p2 = (bit     0) - allow airports directly adjacent to other airports.
  * - p2 = (bit 16-31) - station ID to join (INVALID_STATION if build new one)
  */
-CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	bool airport_upgrade = true;
 	StationID station_to_join = GB(p2, 16, 16);
@@ -1991,7 +1991,7 @@
 	return cost;
 }
 
-static CommandCost RemoveAirport(Station *st, uint32 flags)
+static CommandCost RemoveAirport(Station *st, DoCommandFlag flags)
 {
 	if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
 		return CMD_ERROR;
@@ -2058,7 +2058,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE);
 	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
@@ -2120,7 +2120,7 @@
 	return false;
 }
 
-static CommandCost RemoveBuoy(Station *st, uint32 flags)
+static CommandCost RemoveBuoy(Station *st, DoCommandFlag flags)
 {
 	/* XXX: strange stuff */
 	if (!IsValidCompanyID(_current_company)) return_cmd_error(INVALID_STRING_ID);
@@ -2168,7 +2168,7 @@
  * @param p1 (bit 0) - allow docks directly adjacent to other docks.
  * @param p2 bit 16-31: station ID to join (INVALID_STATION if build new one)
  */
-CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	StationID station_to_join = GB(p2, 16, 16);
 	bool distant_join = (station_to_join != INVALID_STATION);
@@ -2269,7 +2269,7 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
 }
 
-static CommandCost RemoveDock(Station *st, uint32 flags)
+static CommandCost RemoveDock(Station *st, DoCommandFlag flags)
 {
 	if (!CheckOwnership(st->owner)) return CMD_ERROR;
 
@@ -2917,7 +2917,7 @@
  * @param p1 station ID that is to be renamed
  * @param p2 unused
  */
-CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidStationID(p1)) return CMD_ERROR;
 
@@ -3174,7 +3174,7 @@
  * @param flags command flags
  * @return true if the road can be cleared
  */
-static bool CanRemoveRoadWithStop(TileIndex tile, uint32 flags)
+static bool CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
 {
 	/* The road can always be cleared if it was not a town-owned road */
 	if (!GetStopBuiltOnTownRoad(tile)) return true;
@@ -3182,7 +3182,7 @@
 	return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, ROADTYPE_ROAD, flags);
 }
 
-static CommandCost ClearTile_Station(TileIndex tile, byte flags)
+static CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
 {
 	if (flags & DC_AUTO) {
 		switch (GetStationType(tile)) {
@@ -3232,7 +3232,7 @@
 	_station_tick_ctr = 0;
 }
 
-static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
 		/* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here.
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -228,7 +228,7 @@
  * @param p2 direction; eg up (non-zero) or down (zero)
  * @return error or cost of terraforming
  */
-CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	_terraform_err_tile = INVALID_TILE;
 
@@ -354,7 +354,7 @@
  * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
  * @return  error or cost of terraforming
  */
-CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p1 >= MapSize()) return CMD_ERROR;
 
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -66,7 +66,7 @@
  */
 typedef void DrawTileProc(TileInfo *ti);
 typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
-typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
+typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags);
 
 /**
  * Tile callback function signature for obtaining accepted carog of a tile
@@ -127,7 +127,7 @@
  * @param tileh_new Slope after terraforming.
  * @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
  */
-typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new);
+typedef CommandCost TerraformTileProc(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new);
 
 /**
  * Set of callback functions for performing tile operations of a given tile type.
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -52,7 +52,7 @@
  *                      Travelling time if p1 bit 25 is set.
  * - p2 = (bit 16-31) - Waiting time if p1 bit 25 is set
  */
-CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!_settings_game.order.timetabling) return CMD_ERROR;
 
@@ -110,7 +110,7 @@
  * @param p1 Various bitstuffed elements
  * - p1 = (bit  0-15) - Vehicle with the orders to change.
  */
-CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!_settings_game.order.timetabling) return CMD_ERROR;
 
@@ -138,7 +138,7 @@
  * - p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill.
  * - p2 = (bit 1) - Set to 1 to preserve waiting times in non-destructive mode
  */
-CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!_settings_game.order.timetabling) return CMD_ERROR;
 
--- a/src/town.h
+++ b/src/town.h
@@ -18,6 +18,7 @@
 #include "viewport_type.h"
 #include "economy_type.h"
 #include "map_type.h"
+#include "command_type.h"
 
 enum {
 	HOUSE_NO_CLASS   = 0,
@@ -280,7 +281,7 @@
 	TOWN_HAS_STADIUM    = 2    ///< There can be only one stadium by town.
 };
 
-bool CheckforTownRating(uint32 flags, Town *t, byte type);
+bool CheckforTownRating(DoCommandFlag flags, Town *t, byte type);
 
 static inline HouseSpec *GetHouseSpecs(HouseID house_id)
 {
@@ -352,7 +353,7 @@
 void ClearTownHouse(Town *t, TileIndex tile);
 void UpdateTownMaxPass(Town *t);
 void UpdateTownRadius(Town *t);
-bool CheckIfAuthorityAllowsNewStation(TileIndex tile, uint32 flags);
+bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags);
 Town *ClosestTownFromTile(TileIndex tile, uint threshold);
 void ChangeTownRating(Town *t, int add, int max);
 HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile);
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -516,7 +516,7 @@
 	return false;
 }
 
-static CommandCost ClearTile_Town(TileIndex tile, byte flags)
+static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
 {
 	if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
 	if (!CanDeleteHouse(tile)) return CMD_ERROR;
@@ -1510,7 +1510,7 @@
  *            3..5 town road layout (@see TownLayout)
  * @param p2 unused
  */
-CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Only in the scenario editor */
 	if (_game_mode != GM_EDITOR) return CMD_ERROR;
@@ -2098,7 +2098,7 @@
  * @param p1 town ID to rename
  * @param p2 unused
  */
-CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidTownID(p1)) return CMD_ERROR;
 
@@ -2368,7 +2368,7 @@
  * @param p1 town to do the action at
  * @param p2 action to perform, @see _town_action_proc for the list of available actions
  */
-CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;
 
@@ -2497,7 +2497,7 @@
  * @param tile The tile where the station shall be constructed.
  * @param flags Command flags. DC_NO_TOWN_RATING is tested.
  */
-bool CheckIfAuthorityAllowsNewStation(TileIndex tile, uint32 flags)
+bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
 {
 	if (!IsValidCompanyID(_current_company) || (flags & DC_NO_TOWN_RATING)) return true;
 
@@ -2630,7 +2630,7 @@
 	{ 96, 384, 768}, // Hostile
 };
 
-bool CheckforTownRating(uint32 flags, Town *t, byte type)
+bool CheckforTownRating(DoCommandFlag flags, Town *t, byte type)
 {
 	/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
 	if (t == NULL || !IsValidCompanyID(_current_company) || _cheats.magic_bulldozer.value)
@@ -2692,7 +2692,7 @@
 	_total_towns = 0;
 }
 
-static CommandCost TerraformTile_Town(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	if (AutoslopeEnabled()) {
 		HouseID house = GetHouseType(tile);
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -579,7 +579,7 @@
 	}
 }
 
-static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
+static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandFlag flags)
 {
 	const RailVehicleInfo *rvi = RailVehInfo(engine);
 	CommandCost value(EXPENSES_NEW_VEHICLES, GetEngine(engine)->GetCost());
@@ -725,7 +725,7 @@
  * @param p1 engine type id
  * @param p2 bit 1 prevents any free cars from being added to the train
  */
-CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Check if the engine-type is valid (for the company) */
 	if (!IsEngineBuildable(p1, VEH_TRAIN, _current_company)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
@@ -988,7 +988,7 @@
  * - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
  * @param p2 (bit 0) move all vehicles following the source vehicle
  */
-CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleID s = GB(p1, 0, 16);
 	VehicleID d = GB(p1, 16, 16);
@@ -1343,7 +1343,7 @@
  * - p2 = 1: sell the vehicle and all vehicles following it in the chain
  *           if the wagon is dragged, don't delete the possibly belonging rear-engine to some front
  */
-CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSellRailWagon(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Check if we deleted a vehicle window */
 	Window *w = NULL;
@@ -1905,7 +1905,7 @@
  * @param p1 train to reverse
  * @param p2 if true, reverse a unit in a train (needs to be in a depot)
  */
-CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
@@ -1955,7 +1955,7 @@
  * @param p1 train to ignore the red signal
  * @param p2 unused
  */
-CommandCost CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
@@ -1978,7 +1978,7 @@
  * - p2 = (bit 16) - refit only this vehicle
  * @return cost of refit or error
  */
-CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRefitRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CargoID new_cid = GB(p2, 0, 8);
 	byte new_subtype = GB(p2, 8, 8);
@@ -2182,7 +2182,7 @@
  * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
  * - p2 bit 8-10 - VLW flag (for mass goto depot)
  */
-CommandCost CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSendTrainToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (p2 & DEPOT_MASS_SEND) {
 		/* Mass goto depot requested */
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -320,7 +320,7 @@
  * @param p1 tree type, -1 means random.
  * @param p2 end tile of area-drag
  */
-CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	StringID msg = INVALID_STRING_ID;
 	CommandCost cost(EXPENSES_OTHER);
@@ -526,7 +526,7 @@
 	return FOUNDATION_NONE;
 }
 
-static CommandCost ClearTile_Trees(TileIndex tile, byte flags)
+static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags)
 {
 	uint num;
 
@@ -762,7 +762,7 @@
 	_trees_tick_ctr = 0;
 }
 
-static CommandCost TerraformTile_Trees(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Trees(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 }
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -150,7 +150,7 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 }
 
-bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags)
+bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
 {
 	if (flags & DC_QUERY_COST) {
 		return bridge_len <= (_settings_game.construction.longbridges ? 100U : 16U);
@@ -176,7 +176,7 @@
  * - p2 = (bit  8-14) - rail type or road types.
  * - p2 = (bit 15-16) - transport type.
  */
-CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	BridgeType bridge_type;
 	RailType railtype = INVALID_RAILTYPE;
@@ -463,7 +463,7 @@
  * @param p1 railtype or roadtypes. bit 9 set means road tunnel
  * @param p2 unused
  */
-CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	TileIndexDiff delta;
 	TileIndex end_tile;
@@ -590,7 +590,7 @@
 	return false;
 }
 
-static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
+static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
 {
 	Town *t = NULL;
 	TileIndex endtile;
@@ -653,7 +653,7 @@
 }
 
 
-static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
+static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
 {
 	DiagDirection direction;
 	TileIndexDiff delta;
@@ -726,7 +726,7 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, (GetTunnelBridgeLength(tile, endtile) + 2) * _price.clear_bridge);
 }
 
-static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
+static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags)
 {
 	if (IsTunnel(tile)) {
 		if (flags & DC_AUTO) return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST);
@@ -1462,7 +1462,7 @@
 	return VETSB_CONTINUE;
 }
 
-static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	if (_settings_game.construction.build_on_slopes && AutoslopeEnabled() && IsBridge(tile) && GetTunnelBridgeTransportType(tile) != TRANSPORT_WATER) {
 		DiagDirection direction = GetTunnelBridgeDirection(tile);
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -49,7 +49,7 @@
  * @param flags docommand flags of calling function
  * @return cost of the operation
  */
-static CommandCost DestroyCompanyHQ(CompanyID cid, uint32 flags)
+static CommandCost DestroyCompanyHQ(CompanyID cid, DoCommandFlag flags)
 {
 	Company *c = GetCompany(cid);
 
@@ -89,7 +89,7 @@
 	MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
 }
 
-extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true);
+extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true);
 
 /** Build or relocate the HQ. This depends if the HQ is already built or not
  * @param tile tile where the HQ will be built or relocated to
@@ -97,7 +97,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildCompanyHQ(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Company *c = GetCompany(_current_company);
 	CommandCost cost(EXPENSES_PROPERTY);
@@ -131,7 +131,7 @@
  * @param p2 unused
  * @return error of cost of operation
  */
-CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 
@@ -158,7 +158,7 @@
  * @param p2 unused
  * @return error or cost of operation
  */
-CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
 	if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;
@@ -258,7 +258,7 @@
 	return IsOwnedLand(tile) ? FOUNDATION_NONE : FlatteningFoundation(tileh);
 }
 
-static CommandCost ClearTile_Unmovable(TileIndex tile, byte flags)
+static CommandCost ClearTile_Unmovable(TileIndex tile, DoCommandFlag flags)
 {
 	if (IsCompanyHQ(tile)) {
 		if (_current_company == OWNER_WATER) {
@@ -486,7 +486,7 @@
 	}
 }
 
-static CommandCost TerraformTile_Unmovable(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	/* Owned land remains unsold */
 	if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -966,7 +966,7 @@
  * @param p2 bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety)
  * @return result of operation.  Nothing if everything went well
  */
-CommandCost CmdStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	/* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */
 	if ((flags & DC_AUTOREPLACE) == 0) SetBit(p2, 0);
@@ -1039,7 +1039,7 @@
  *   - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
  *   - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)
  */
-CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleList list;
 	CommandCost return_value = CMD_ERROR;
@@ -1089,7 +1089,7 @@
  * @param p1 Vehicle type
  * @param p2 unused
  */
-CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleList list;
 
@@ -1126,7 +1126,7 @@
  * @param p1 Type of vehicle
  * @param p2 If bit 0 is set, then either replace all or nothing (instead of replacing until money runs out)
  */
-CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	VehicleList list;
 	CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES);
@@ -1178,7 +1178,7 @@
  * @param p1 the original vehicle's index
  * @param p2 1 = shared orders, else copied orders
  */
-CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost total_cost(EXPENSES_NEW_VEHICLES);
 	uint32 build_argument = 2;
@@ -1346,7 +1346,7 @@
  * @param vlw_flag tells what kind of list requested the goto depot
  * @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
  */
-CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, Owner owner, uint16 vlw_flag, uint32 id)
+CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id)
 {
 	VehicleList list;
 
@@ -1528,7 +1528,7 @@
  * @param p1 vehicle ID to name
  * @param p2 unused
  */
-CommandCost CmdRenameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
@@ -1559,7 +1559,7 @@
  * @param p1 vehicle ID that is being service-interval-changed
  * @param p2 new service interval
  */
-CommandCost CmdChangeServiceInt(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */
 
@@ -2051,7 +2051,7 @@
 	InvalidateVehicleOrder(this, 0);
 }
 
-CommandCost Vehicle::SendToDepot(uint32 flags, DepotCommand command)
+CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
 {
 	if (!CheckOwnership(this->owner)) return CMD_ERROR;
 	if (this->vehstatus & VS_CRASHED) return CMD_ERROR;
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -594,7 +594,7 @@
 	 * @param command the command to execute.
 	 * @return the cost of the depot action.
 	 */
-	CommandCost SendToDepot(uint32 flags, DepotCommand command);
+	CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command);
 };
 
 /**
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -65,7 +65,7 @@
 void TrainPowerChanged(Vehicle *v);
 Money GetTrainRunningCost(const Vehicle *v);
 
-CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, Owner owner, uint16 vlw_flag, uint32 id);
+CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id);
 void VehicleEnterDepot(Vehicle *v);
 
 bool CanBuildVehicleInfrastructure(VehicleType type);
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -99,7 +99,7 @@
  * @param p1 bit 0 depot orientation (Axis)
  * @param p2 unused
  */
-CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	TileIndex tile2;
 
@@ -162,7 +162,7 @@
 	}
 }
 
-static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
+static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
 {
 	if (!IsShipDepot(tile)) return CMD_ERROR;
 	if (!CheckTileOwnership(tile)) return CMD_ERROR;
@@ -188,7 +188,7 @@
 }
 
 /** build a shiplift */
-static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
+static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, DoCommandFlag flags)
 {
 	CommandCost ret;
 	int delta;
@@ -234,7 +234,7 @@
 	return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 22 >> 3);
 }
 
-static CommandCost RemoveShiplift(TileIndex tile, uint32 flags)
+static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
 {
 	TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile));
 
@@ -263,7 +263,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
 	if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
@@ -280,7 +280,7 @@
  * @param p1 start tile of stretch-dragging
  * @param p2 specifies canal (0), water (1) or river (2); last two can only be built in scenario editor
  */
-CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	CommandCost cost(EXPENSES_CONSTRUCTION);
 	int size_x, size_y;
@@ -343,7 +343,7 @@
 	}
 }
 
-static CommandCost ClearTile_Water(TileIndex tile, byte flags)
+static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
 {
 	switch (GetWaterTileType(tile)) {
 		case WATER_TILE_CLEAR:
@@ -1147,7 +1147,7 @@
 	return VETSB_CONTINUE;
 }
 
-static CommandCost TerraformTile_Water(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
+static CommandCost TerraformTile_Water(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 {
 	/* Canals can't be terraformed */
 	if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_MUST_DEMOLISH_CANAL_FIRST);
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -156,7 +156,7 @@
  * @todo When checking for the tile slope,
  * distingush between "Flat land required" and "land sloped in wrong direction"
  */
-CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	Waypoint *wp;
 	Slope tileh;
@@ -270,7 +270,7 @@
  * @param justremove will indicate if it is removed from rail or if rails are removed too
  * @return cost of operation or error
  */
-CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
+CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove)
 {
 	Waypoint *wp;
 
@@ -318,7 +318,7 @@
  * @param p2 unused
  * @return cost of operation or error
  */
-CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	return RemoveTrainWaypoint(tile, flags, true);
 }
@@ -342,7 +342,7 @@
  * @param p2 unused
  * @return cost of operation or error
  */
-CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
+CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
 	if (!IsValidWaypointID(p1)) return CMD_ERROR;
 
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -60,7 +60,7 @@
 	return GetWaypoint(GetWaypointIndex(tile));
 }
 
-CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
+CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove);
 Station *ComposeWaypointStation(TileIndex tile);
 void ShowWaypointWindow(const Waypoint *wp);
 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);