Changeset - r3183:d3ef2fb28a8a
[Not reviewed]
master
0 7 0
tron - 18 years ago 2006-03-12 12:19:25
tron@openttd.org
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
7 files changed with 82 insertions and 84 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -312,18 +312,13 @@ bool IsAircraftHangarTile(TileIndex tile
 
	return IsTileType(tile, MP_STATION) &&
 
				(_m[tile].m5 == 32 || _m[tile].m5 == 65 || _m[tile].m5 == 86);
 
}
 

	
 
bool CheckStoppedInHangar(const Vehicle* v)
 
{
 
	if (!(v->vehstatus & VS_STOPPED) || !IsAircraftHangarTile(v->tile)) {
 
		_error_message = STR_A01B_AIRCRAFT_MUST_BE_STOPPED;
 
		return false;
 
	}
 

	
 
	return true;
 
	return v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile);
 
}
 

	
 

	
 
static void DoDeleteAircraft(Vehicle *v)
 
{
 
	DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
@@ -343,14 +338,14 @@ int32 CmdSellAircraft(int x, int y, uint
 
	Vehicle *v;
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 

	
 
	if (v->type != VEH_Aircraft || !CheckOwnership(v->owner) || !CheckStoppedInHangar(v))
 
		return CMD_ERROR;
 
	if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!CheckStoppedInHangar(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 

	
 
	if (flags & DC_EXEC) {
 
		// Invalidate depot
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
station_cmd.c
Show inline comments
 
@@ -761,58 +761,53 @@ int32 CheckFlatLandBelow(TileIndex tile,
 
				a) the player building is an "old-school" AI
 
				-OR-
 
				b) the build_on_slopes switch is disabled
 
		*/
 
		if (IsSteepTileh(tileh) ||
 
				((_is_old_ai_player || !_patches.build_on_slopes) && tileh != 0)) {
 
			_error_message = STR_0007_FLAT_LAND_REQUIRED;
 
			return CMD_ERROR;
 
			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
		}
 

	
 
		flat_z = z;
 
		if (tileh) {
 
			// need to check so the entrance to the station is not pointing at a slope.
 
			if ((invalid_dirs&1 && !(tileh & 0xC) && (uint)w_cur == w) ||
 
					(invalid_dirs&2 && !(tileh & 6) &&	h_cur == 1) ||
 
					(invalid_dirs&4 && !(tileh & 3) && w_cur == 1) ||
 
					(invalid_dirs&8 && !(tileh & 9) && (uint)h_cur == h)) {
 
				_error_message = STR_0007_FLAT_LAND_REQUIRED;
 
				return CMD_ERROR;
 
				return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
			}
 
			cost += _price.terraform;
 
			flat_z += 8;
 
		}
 

	
 
		// get corresponding flat level and make sure that all parts of the station have the same level.
 
		if (allowed_z == -1) {
 
			// first tile
 
			allowed_z = flat_z;
 
		} else if (allowed_z != flat_z) {
 
			_error_message = STR_0007_FLAT_LAND_REQUIRED;
 
			return CMD_ERROR;
 
			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
		}
 

	
 
		// if station is set, then we have special handling to allow building on top of already existing stations.
 
		// so station points to INVALID_STATION if we can build on any station. or it points to a station if we're only allowed to build
 
		// on exactly that station.
 
		if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
 
			if (_m[tile_cur].m5 >= 8) {
 
				_error_message = ClearTile_Station(tile_cur, DC_AUTO); // get error message
 
				return CMD_ERROR;
 
				return ClearTile_Station(tile_cur, DC_AUTO); // get error message
 
			} else {
 
				StationID st = _m[tile_cur].m2;
 
				if (*station == INVALID_STATION) {
 
					*station = st;
 
				} else if (*station != st) {
 
					_error_message = STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING;
 
					return CMD_ERROR;
 
					return_cmd_error(STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING);
 
				}
 
			}
 
		} else {
 
			ret = DoCommandByTile(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
			if (CmdFailed(ret)) return CMD_ERROR;
 
			if (CmdFailed(ret)) return ret;
 
			cost += ret;
 
		}
 
	END_TILE_LOOP(tile_cur, w, h, tile)
 

	
 
	return cost;
 
}
 
@@ -966,13 +961,14 @@ int32 CmdBuildRailroadStation(int x, int
 
	finalvalues[2] = h_org;
 

	
 
	// Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station)
 
	est = INVALID_STATION;
 
	// If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
 
	//  for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
 
	if (CmdFailed(ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags&~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
 
	ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
 
	if (CmdFailed(ret)) return ret;
 
	cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len;
 

	
 
	// Make sure there are no similar stations around us.
 
	st = GetStationAround(tile_org, w_org, h_org, est);
 
	if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
 

	
 
@@ -1018,13 +1014,14 @@ int32 CmdBuildRailroadStation(int x, int
 
		const StationSpec *statspec;
 
		Track track;
 

	
 
		// Now really clear the land below the station
 
		// It should never return CMD_ERROR.. but you never know ;)
 
		//  (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags)
 
		if (CmdFailed(CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
 
		ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
 
		if (CmdFailed(ret)) return ret;
 

	
 
		st->train_tile = finalvalues[0];
 
		if (!st->facilities) st->xy = finalvalues[0];
 
		st->facilities |= FACIL_TRAIN;
 
		st->owner = _current_player;
 

	
 
@@ -1302,26 +1299,28 @@ int32 CmdBuildRoadStop(int x, int y, uin
 
	Station *st;
 
	RoadStop *road_stop;
 
	RoadStop **currstop;
 
	RoadStop *prev = NULL;
 
	TileIndex tile;
 
	int32 cost;
 
	int32 ret;
 
	bool type = !!p2;
 

	
 
	/* Saveguard the parameters */
 
	if (p1 > 3) return CMD_ERROR;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	tile = TileVirtXY(x, y);
 

	
 
	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
 
		return CMD_ERROR;
 

	
 
	cost = CheckFlatLandBelow(tile, 1, 1, flags, 1 << p1, NULL);
 
	if (CmdFailed(cost)) return CMD_ERROR;
 
	ret = CheckFlatLandBelow(tile, 1, 1, flags, 1 << p1, NULL);
 
	if (CmdFailed(ret)) return ret;
 
	cost = ret;
 

	
 
	st = GetStationAround(tile, 1, 1, -1);
 
	if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
 

	
 
	/* Find a station close to us */
 
	if (st == NULL) {
 
@@ -1519,12 +1518,13 @@ static const byte * const _airport_map5_
 
int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex tile;
 
	Town *t;
 
	Station *st;
 
	int32 cost;
 
	int32 ret;
 
	int w, h;
 
	bool airport_upgrade = true;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	/* Check if a valid, buildable airport was chosen for construction */
 
@@ -1550,14 +1550,15 @@ int32 CmdBuildAirport(int x, int y, uint
 
		}
 
	}
 

	
 
	w = _airport_size_x[p1];
 
	h = _airport_size_y[p1];
 

	
 
	cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
 
	if (CmdFailed(cost)) return CMD_ERROR;
 
	ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
 
	if (CmdFailed(ret)) return ret;
 
	cost = ret;
 

	
 
	st = GetStationAround(tile, w, h, -1);
 
	if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
 

	
 
	/* Find a station close to us */
 
	if (st == NULL) {
train_cmd.c
Show inline comments
 
@@ -773,34 +773,29 @@ int32 CmdBuildRailVehicle(int x, int y, 
 

	
 
	return value;
 
}
 

	
 

	
 
/* Check if all the wagons of the given train are in a depot, returns the
 
 * number of cars (including loco) then. If not, sets the error message to
 
 * STR_881A_TRAINS_CAN_ONLY_BE_ALTERED and returns -1 */
 
 * number of cars (including loco) then. If not it returns -1 */
 
int CheckTrainStoppedInDepot(const Vehicle *v)
 
{
 
	int count;
 
	TileIndex tile = v->tile;
 

	
 
	/* check if stopped in a depot */
 
	if (!IsTileDepotType(tile, TRANSPORT_RAIL) || v->cur_speed != 0) {
 
		_error_message = STR_881A_TRAINS_CAN_ONLY_BE_ALTERED;
 
		return -1;
 
	}
 
	if (!IsTileDepotType(tile, TRANSPORT_RAIL) || v->cur_speed != 0) return -1;
 

	
 
	count = 0;
 
	for (; v != NULL; v = v->next) {
 
		/* This count is used by the depot code to determine the number of engines
 
		 * in the consist. Exclude articulated parts so that autoreplacing to
 
		 * engines with more articulated parts that before works correctly. */
 
		if (!IsArticulatedPart(v)) count++;
 
		if (v->u.rail.track != 0x80 || v->tile != tile ||
 
				(IsFrontEngine(v) && !(v->vehstatus & VS_STOPPED))) {
 
			_error_message = STR_881A_TRAINS_CAN_ONLY_BE_ALTERED;
 
			return -1;
 
		}
 
	}
 

	
 
	return count;
 
}
 
@@ -980,22 +975,22 @@ int32 CmdMoveRailVehicle(int x, int y, u
 
	{
 
		int src_len = 0;
 
		int max_len = _patches.mammoth_trains ? 100 : 9;
 

	
 
		// check if all vehicles in the source train are stopped inside a depot.
 
		src_len = CheckTrainStoppedInDepot(src_head);
 
		if (src_len < 0) return CMD_ERROR;
 
		if (src_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
 

	
 
		// check the destination row if the source and destination aren't the same.
 
		if (src_head != dst_head) {
 
			int dst_len = 0;
 

	
 
			if (dst_head != NULL) {
 
				// check if all vehicles in the dest train are stopped.
 
				dst_len = CheckTrainStoppedInDepot(dst_head);
 
				if (dst_len < 0) return CMD_ERROR;
 
				if (dst_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
 

	
 
				assert(dst_head->tile == src_head->tile);
 
			}
 

	
 
			// We are moving between rows, so only count the wagons from the source
 
			// row that are being moved.
 
@@ -1214,13 +1209,15 @@ int32 CmdSellRailWagon(int x, int y, uin
 
	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 

	
 
	while (IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);
 
	first = GetFirstVehicleInChain(v);
 

	
 
	// make sure the vehicle is stopped in the depot
 
	if (CheckTrainStoppedInDepot(first) < 0) return CMD_ERROR;
 
	if (CheckTrainStoppedInDepot(first) < 0) {
 
		return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
 
	}
 

	
 
	if (IsMultiheaded(v) && !IsTrainEngine(v)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
 

	
 
	if (flags & DC_EXEC) {
 
		if (v == first && IsFrontEngine(first)) {
 
			DeleteWindowById(WC_VEHICLE_VIEW, first->index);
 
@@ -1590,14 +1587,12 @@ static void ReverseTrainDirection(Vehicl
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 

	
 
	if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	_error_message = STR_EMPTY;
 

	
 
//	if (v->u.rail.track & 0x80 || IsTileDepotType(v->tile, TRANSPORT_RAIL))
 
//		return CMD_ERROR;
 

	
 
	if (v->u.rail.crash_anim_pos != 0 || v->breakdown_ctr != 0) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
tree_cmd.c
Show inline comments
 
@@ -127,12 +127,13 @@ void GenerateTrees(void)
 
 * @param x,y start tile of area-drag of tree plantation
 
 * @param p1 tree type, -1 means random.
 
 * @param p2 end tile of area-drag
 
 */
 
int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID msg = INVALID_STRING_ID;
 
	int32 cost;
 
	int sx, sy, x, y;
 

	
 
	if (p2 >= MapSize()) return CMD_ERROR;
 
	/* Check the tree type. It can be random or some valid value within the current climate */
 
	if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR;
 
@@ -155,13 +156,13 @@ int32 CmdPlantTree(int ex, int ey, uint3
 
			if (!EnsureNoVehicle(tile)) continue;
 

	
 
			switch (GetTileType(tile)) {
 
				case MP_TREES:
 
					// no more space for trees?
 
					if (_game_mode != GM_EDITOR && GetTreeCount(tile) == 3) {
 
						_error_message = STR_2803_TREE_ALREADY_HERE;
 
						msg = STR_2803_TREE_ALREADY_HERE;
 
						continue;
 
					}
 

	
 
					if (flags & DC_EXEC) {
 
						AddTreeCount(tile, 1);
 
						MarkTileDirtyByTile(tile);
 
@@ -169,13 +170,13 @@ int32 CmdPlantTree(int ex, int ey, uint3
 
					// 2x as expensive to add more trees to an existing tile
 
					cost += _price.build_trees * 2;
 
					break;
 

	
 
				case MP_CLEAR:
 
					if (!IsTileOwner(tile, OWNER_NONE)) {
 
						_error_message = STR_2804_SITE_UNSUITABLE;
 
						msg = STR_2804_SITE_UNSUITABLE;
 
						continue;
 
					}
 

	
 
					switch (GetClearGround(tile)) {
 
						case CL_FIELDS: cost += _price.clear_3; break;
 
						case CL_ROCKS:  cost += _price.clear_2; break;
 
@@ -210,19 +211,23 @@ int32 CmdPlantTree(int ex, int ey, uint3
 
							SetMapExtraBits(tile, 2);
 
					}
 
					cost += _price.build_trees;
 
					break;
 

	
 
				default:
 
					_error_message = STR_2804_SITE_UNSUITABLE;
 
					msg = STR_2804_SITE_UNSUITABLE;
 
					break;
 
			}
 
		}
 
	}
 

	
 
	return (cost == 0) ? CMD_ERROR : cost;
 
	if (cost == 0) {
 
		return_cmd_error(msg);
 
	} else {
 
		return cost;
 
	}
 
}
 

	
 
typedef struct TreeListEnt {
 
	uint32 image;
 
	byte x,y;
 
} TreeListEnt;
tunnelbridge_cmd.c
Show inline comments
 
@@ -279,26 +279,26 @@ int32 CmdBuildBridge(int x, int y, uint3
 
	// Towns are not allowed to use bridges on slopes.
 
	allow_on_slopes = (!_is_old_ai_player
 
	                   && _current_player != OWNER_TOWN && _patches.build_on_slopes);
 

	
 
	/* Try and clear the start landscape */
 

	
 
	if (CmdFailed(ret = DoCommandByTile(ti_start.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)))
 
		return CMD_ERROR;
 
	ret = DoCommandByTile(ti_start.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(ret)) return ret;
 
	cost = ret;
 

	
 
	// true - bridge-start-tile, false - bridge-end-tile
 
	terraformcost = CheckBridgeSlope(direction, ti_start.tileh, true);
 
	if (CmdFailed(terraformcost) || (terraformcost && !allow_on_slopes))
 
		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 
	cost += terraformcost;
 

	
 
	/* Try and clear the end landscape */
 

	
 
	ret = DoCommandByTile(ti_end.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(ret)) return CMD_ERROR;
 
	if (CmdFailed(ret)) return ret;
 
	cost += ret;
 

	
 
	// false - end tile slope check
 
	terraformcost = CheckBridgeSlope(direction, ti_end.tileh, false);
 
	if (CmdFailed(terraformcost) || (terraformcost && !allow_on_slopes))
 
		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 
@@ -333,21 +333,19 @@ int32 CmdBuildBridge(int x, int y, uint3
 
	delta = (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
 
	for (i = 0; i != bridge_len; i++) {
 
		uint z;
 

	
 
		tile += delta;
 

	
 
		_error_message = STR_5009_LEVEL_LAND_OR_WATER_REQUIRED;
 
		if (GetTileSlope(tile, &z) != 0 && z >= ti_start.z) return CMD_ERROR;
 
		if (GetTileSlope(tile, &z) != 0 && z >= ti_start.z) {
 
			return_cmd_error(STR_5009_LEVEL_LAND_OR_WATER_REQUIRED);
 
		}
 

	
 
		switch (GetTileType(tile)) {
 
			case MP_WATER:
 
				if (!EnsureNoVehicle(tile)) {
 
					_error_message = STR_980E_SHIP_IN_THE_WAY;
 
					return CMD_ERROR;
 
				}
 
				if (!EnsureNoVehicle(tile)) return_cmd_error(STR_980E_SHIP_IN_THE_WAY);
 
				if (_m[tile].m5 > 1) goto not_valid_below;
 
				m5 = 0xC8;
 
				break;
 

	
 
			case MP_RAILWAY:
 
				if (_m[tile].m5 != (direction == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X)) {
 
@@ -365,13 +363,13 @@ int32 CmdBuildBridge(int x, int y, uint3
 
				break;
 

	
 
			default:
 
not_valid_below:;
 
				/* try and clear the middle landscape */
 
				ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
				if (CmdFailed(ret)) return CMD_ERROR;
 
				if (CmdFailed(ret)) return ret;
 
				cost += ret;
 
				m5 = 0xC0;
 
				break;
 
		}
 

	
 
		/* do middle part of bridge */
unmovable_cmd.c
Show inline comments
 
@@ -66,20 +66,22 @@ static int32 DestroyCompanyHQ(TileIndex 
 
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
 
int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex tile = TileVirtXY(x, y);
 
	Player *p = GetPlayer(_current_player);
 
	int cost;
 
	int32 ret;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
 

	
 
	cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
 
	if (CmdFailed(cost)) return CMD_ERROR;
 
	ret = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
 
	if (CmdFailed(ret)) return ret;
 
	cost = ret;
 

	
 
	if (p->location_of_house != 0) { /* Moving HQ */
 
		int32 ret = DestroyCompanyHQ(p->location_of_house, flags);
 
		ret = DestroyCompanyHQ(p->location_of_house, flags);
 
		if (CmdFailed(ret)) return CMD_ERROR;
 
		cost += ret;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		int score = UpdateCompanyRatingAndValue(p, false);
water_cmd.c
Show inline comments
 
@@ -233,49 +233,51 @@ int32 CmdBuildCanal(int x, int y, uint32
 
	if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR;
 

	
 
	cost = 0;
 
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
 
		if (GetTileSlope(tile, NULL) != 0) return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 

	
 
			// can't make water of water!
 
			if (IsTileType(tile, MP_WATER)) {
 
				_error_message = STR_1007_ALREADY_BUILT;
 
			} else {
 
				/* is middle piece of a bridge? */
 
				if (IsTileType(tile, MP_TUNNELBRIDGE) && _m[tile].m5 & 0x40) { /* build under bridge */
 
					if (_m[tile].m5 & 0x20) // transport route under bridge
 
						return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
 
		// can't make water of water!
 
		if (IsTileType(tile, MP_WATER)) continue;
 

	
 
					if (_m[tile].m5 & 0x18) { // already water under bridge
 
						return_cmd_error(STR_1007_ALREADY_BUILT);
 
					}
 
		/* is middle piece of a bridge? */
 
		if (IsTileType(tile, MP_TUNNELBRIDGE) && _m[tile].m5 & 0x40) { /* build under bridge */
 
			if (_m[tile].m5 & 0x20) // transport route under bridge
 
				return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
 

	
 
			if (_m[tile].m5 & 0x18) { // already water under bridge
 
				return_cmd_error(STR_1007_ALREADY_BUILT);
 
			}
 

	
 
					if (flags & DC_EXEC) {
 
						// change owner to OWNER_WATER and set land under bridge bit to water
 
						ModifyTile(tile, MP_MAP5 | MP_MAPOWNER, OWNER_WATER, _m[tile].m5 | 0x08);
 
					}
 
				} else {
 
					/* no bridge, try to clear it. */
 
					int32 ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 

	
 
					if (CmdFailed(ret)) return CMD_ERROR;
 
					cost += ret;
 
			if (flags & DC_EXEC) {
 
				// change owner to OWNER_WATER and set land under bridge bit to water
 
				ModifyTile(tile, MP_MAP5 | MP_MAPOWNER, OWNER_WATER, _m[tile].m5 | 0x08);
 
			}
 
		} else {
 
			/* no bridge, try to clear it. */
 
			int32 ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 

	
 
					if (flags & DC_EXEC) {
 
						MakeWater(tile);
 
						MarkTileDirtyByTile(tile);
 
					}
 
				}
 
			if (CmdFailed(ret)) return ret;
 
			cost += ret;
 

	
 
				if (flags & DC_EXEC) MarkTilesAroundDirty(tile);
 
			if (flags & DC_EXEC) {
 
				MakeWater(tile);
 
				MarkTileDirtyByTile(tile);
 
			}
 
		}
 

	
 
				cost += _price.clear_water;
 
			}
 
		if (flags & DC_EXEC) MarkTilesAroundDirty(tile);
 

	
 
		cost += _price.clear_water;
 
	} END_TILE_LOOP(tile, size_x, size_y, 0);
 

	
 
	return (cost == 0) ? CMD_ERROR : cost;
 
	if (cost == 0) {
 
		return_cmd_error(STR_1007_ALREADY_BUILT);
 
	} else {
 
		return cost;
 
	}
 
}
 

	
 
static int32 ClearTile_Water(TileIndex tile, byte flags)
 
{
 
	byte m5 = _m[tile].m5;
 

	
0 comments (0 inline, 0 general)