(svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
This commit is contained in:
		| @@ -1677,7 +1677,7 @@ static int AiBuildDefaultRailTrack(TileIndex tile, byte p0, byte p1, byte p2, by | |||||||
| 		if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 && | 		if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 && | ||||||
| 				(p->dir == 0xFF || p->dir == dir || ((p->dir - 1) & 3) == dir)) { | 				(p->dir == 0xFF || p->dir == dir || ((p->dir - 1) & 3) == dir)) { | ||||||
| 			*cost = AiDoBuildDefaultRailTrack(tile, p->data, DC_NO_TOWN_RATING); | 			*cost = AiDoBuildDefaultRailTrack(tile, p->data, DC_NO_TOWN_RATING); | ||||||
| 			if (*cost != CMD_ERROR && AiCheckTrackResources(tile, p->data, cargo)) | 			if (!CmdFailed(*cost) && AiCheckTrackResources(tile, p->data, cargo)) | ||||||
| 				return i; | 				return i; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -1804,7 +1804,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p) | |||||||
| 					_default_rail_track_data[rule]->data, | 					_default_rail_track_data[rule]->data, | ||||||
| 					DC_EXEC | DC_NO_TOWN_RATING | 					DC_EXEC | DC_NO_TOWN_RATING | ||||||
| 				); | 				); | ||||||
| 				assert(r != CMD_ERROR); | 				assert(!CmdFailed(r)); | ||||||
| 			} | 			} | ||||||
| 		} while (++aib,--j); | 		} while (++aib,--j); | ||||||
| 	} | 	} | ||||||
| @@ -2529,7 +2529,7 @@ static int AiFindBestDefaultRoadBlock(TileIndex tile, byte direction, byte cargo | |||||||
| 	for(i=0; (p = _road_default_block_data[i]) != NULL; i++) { | 	for(i=0; (p = _road_default_block_data[i]) != NULL; i++) { | ||||||
| 		if (p->dir == direction) { | 		if (p->dir == direction) { | ||||||
| 			*cost = AiDoBuildDefaultRoadBlock(tile, p->data, 0); | 			*cost = AiDoBuildDefaultRoadBlock(tile, p->data, 0); | ||||||
| 			if (*cost != CMD_ERROR && AiCheckRoadResources(tile, p->data, cargo)) | 			if (!CmdFailed(*cost) && AiCheckRoadResources(tile, p->data, cargo)) | ||||||
| 				return i; | 				return i; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -2690,7 +2690,7 @@ static void AiStateBuildDefaultRoadBlocks(Player *p) | |||||||
| 					_road_default_block_data[rule]->data, | 					_road_default_block_data[rule]->data, | ||||||
| 					DC_EXEC | DC_NO_TOWN_RATING | 					DC_EXEC | DC_NO_TOWN_RATING | ||||||
| 				); | 				); | ||||||
| 				assert(r != CMD_ERROR); | 				assert(!CmdFailed(r)); | ||||||
| 			} | 			} | ||||||
| 		} while (++aib,--j); | 		} while (++aib,--j); | ||||||
| 	} while (--i); | 	} while (--i); | ||||||
| @@ -3392,7 +3392,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli, | |||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		*cost = AiDoBuildDefaultAirportBlock(tile, p, 0); | 		*cost = AiDoBuildDefaultAirportBlock(tile, p, 0); | ||||||
| 		if (*cost != CMD_ERROR && AiCheckAirportResources(tile, p, cargo)) | 		if (!CmdFailed(*cost) && AiCheckAirportResources(tile, p, cargo)) | ||||||
| 			return i; | 			return i; | ||||||
| 	} | 	} | ||||||
| 	return -1; | 	return -1; | ||||||
| @@ -3463,7 +3463,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p) | |||||||
| 					_airport_default_block_data[rule], | 					_airport_default_block_data[rule], | ||||||
| 					DC_EXEC | DC_NO_TOWN_RATING | 					DC_EXEC | DC_NO_TOWN_RATING | ||||||
| 				); | 				); | ||||||
| 				assert(r != CMD_ERROR); | 				assert(!CmdFailed(r)); | ||||||
| 			} | 			} | ||||||
| 		} while (++aib,--j); | 		} while (++aib,--j); | ||||||
| 	} while (--i); | 	} while (--i); | ||||||
|   | |||||||
| @@ -659,7 +659,7 @@ static void AiNew_State_FindStation(Player *p) | |||||||
| 					if (accepts[p->ainew.cargo] >> 3 == 0) continue; | 					if (accepts[p->ainew.cargo] >> 3 == 0) continue; | ||||||
| 					// See if we can build the station | 					// See if we can build the station | ||||||
| 					r = AiNew_Build_Station(p, p->ainew.tbt, new_tile, 0, 0, 0, DC_QUERY_COST); | 					r = AiNew_Build_Station(p, p->ainew.tbt, new_tile, 0, 0, 0, DC_QUERY_COST); | ||||||
| 					if (r == CMD_ERROR) continue; | 					if (CmdFailed(r)) continue; | ||||||
| 					// We can build it, so add it to found_spot | 					// We can build it, so add it to found_spot | ||||||
| 					found_spot[i] = new_tile; | 					found_spot[i] = new_tile; | ||||||
| 					found_best[i++] = accepts[p->ainew.cargo]; | 					found_best[i++] = accepts[p->ainew.cargo]; | ||||||
| @@ -846,7 +846,7 @@ static void AiNew_State_FindDepot(Player *p) | |||||||
| 				if (ti.tileh != 0) continue; | 				if (ti.tileh != 0) continue; | ||||||
| 				// Check if everything went okay.. | 				// Check if everything went okay.. | ||||||
| 				r = AiNew_Build_Depot(p, tile + TileOffsByDir(j), j ^ 2, 0); | 				r = AiNew_Build_Depot(p, tile + TileOffsByDir(j), j ^ 2, 0); | ||||||
| 				if (r == CMD_ERROR) continue; | 				if (CmdFailed(r)) continue; | ||||||
| 				// Found a spot! | 				// Found a spot! | ||||||
| 				p->ainew.new_cost += r; | 				p->ainew.new_cost += r; | ||||||
| 				p->ainew.depot_tile = tile + TileOffsByDir(j); | 				p->ainew.depot_tile = tile + TileOffsByDir(j); | ||||||
| @@ -989,7 +989,7 @@ static void AiNew_State_BuildStation(Player *p) | |||||||
| 			res = AiNew_Build_Station(p, p->ainew.tbt, p->ainew.to_tile, 0, 0, p->ainew.to_direction, DC_EXEC); | 			res = AiNew_Build_Station(p, p->ainew.tbt, p->ainew.to_tile, 0, 0, p->ainew.to_direction, DC_EXEC); | ||||||
| 		p->ainew.state = AI_STATE_BUILD_PATH; | 		p->ainew.state = AI_STATE_BUILD_PATH; | ||||||
| 	} | 	} | ||||||
| 	if (res == CMD_ERROR) { | 	if (CmdFailed(res)) { | ||||||
| 		DEBUG(ai,0)("[AiNew - BuildStation] Strange but true... station can not be build!"); | 		DEBUG(ai,0)("[AiNew - BuildStation] Strange but true... station can not be build!"); | ||||||
| 		p->ainew.state = AI_STATE_NOTHING; | 		p->ainew.state = AI_STATE_NOTHING; | ||||||
| 		// If the first station _was_ build, destroy it | 		// If the first station _was_ build, destroy it | ||||||
| @@ -1119,7 +1119,7 @@ static void AiNew_State_BuildDepot(Player *p) | |||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	res = AiNew_Build_Depot(p, p->ainew.depot_tile, p->ainew.depot_direction, DC_EXEC); | 	res = AiNew_Build_Depot(p, p->ainew.depot_tile, p->ainew.depot_direction, DC_EXEC); | ||||||
| 	if (res == CMD_ERROR) { | 	if (CmdFailed(res)) { | ||||||
| 		DEBUG(ai,0)("[AiNew - BuildDepot] Strange but true... depot can not be build!"); | 		DEBUG(ai,0)("[AiNew - BuildDepot] Strange but true... depot can not be build!"); | ||||||
| 		p->ainew.state = AI_STATE_NOTHING; | 		p->ainew.state = AI_STATE_NOTHING; | ||||||
| 		return; | 		return; | ||||||
| @@ -1152,7 +1152,7 @@ static void AiNew_State_BuildVehicle(Player *p) | |||||||
|  |  | ||||||
| 	// Build the vehicle | 	// Build the vehicle | ||||||
| 	res = AiNew_Build_Vehicle(p, p->ainew.depot_tile, DC_EXEC); | 	res = AiNew_Build_Vehicle(p, p->ainew.depot_tile, DC_EXEC); | ||||||
| 	if (res == CMD_ERROR) { | 	if (CmdFailed(res)) { | ||||||
| 		// This happens when the AI can't build any more vehicles! | 		// This happens when the AI can't build any more vehicles! | ||||||
| 		p->ainew.state = AI_STATE_NOTHING; | 		p->ainew.state = AI_STATE_NOTHING; | ||||||
| 		return; | 		return; | ||||||
|   | |||||||
| @@ -130,7 +130,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type) | |||||||
| 	// returns CMD_ERROR on failure, and price on success | 	// returns CMD_ERROR on failure, and price on success | ||||||
| 	ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE); | 	ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE); | ||||||
|  |  | ||||||
| 	if (ret == CMD_ERROR) { | 	if (CmdFailed(ret)) { | ||||||
| 		errmsg = _error_message; | 		errmsg = _error_message; | ||||||
| 	} else { | 	} else { | ||||||
| 		// check which bridges can be built | 		// check which bridges can be built | ||||||
|   | |||||||
| @@ -1354,7 +1354,7 @@ static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable* | |||||||
| 					} | 					} | ||||||
| 				} else { | 				} else { | ||||||
| do_clear: | do_clear: | ||||||
| 					if (DoCommandByTile(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR) == CMD_ERROR) | 					if (CmdFailed(DoCommandByTile(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) | ||||||
| 						return false; | 						return false; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -59,7 +59,7 @@ static void LandInfoWndProc(Window *w, WindowEvent *e) | |||||||
| 		DrawStringCentered(140, 27, STR_01A7_OWNER, 0); | 		DrawStringCentered(140, 27, STR_01A7_OWNER, 0); | ||||||
|  |  | ||||||
| 		str = STR_01A4_COST_TO_CLEAR_N_A; | 		str = STR_01A4_COST_TO_CLEAR_N_A; | ||||||
| 		if (lid->costclear != CMD_ERROR) { | 		if (!CmdFailed(lid->costclear)) { | ||||||
| 			SetDParam(0, lid->costclear); | 			SetDParam(0, lid->costclear); | ||||||
| 			str = STR_01A5_COST_TO_CLEAR; | 			str = STR_01A5_COST_TO_CLEAR; | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -1099,12 +1099,12 @@ static int32 ClearTile_Track(TileIndex tile, byte flags) | |||||||
| 		case RAIL_TYPE_SIGNALS: | 		case RAIL_TYPE_SIGNALS: | ||||||
| 			if (_m[tile].m3 & _signals_table_both[0]) { | 			if (_m[tile].m3 & _signals_table_both[0]) { | ||||||
| 				ret = DoCommandByTile(tile, 0, 0, flags, CMD_REMOVE_SIGNALS); | 				ret = DoCommandByTile(tile, 0, 0, flags, CMD_REMOVE_SIGNALS); | ||||||
| 				if (ret == CMD_ERROR) return CMD_ERROR; | 				if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 				cost += ret; | 				cost += ret; | ||||||
| 			} | 			} | ||||||
| 			if (_m[tile].m3 & _signals_table_both[3]) { | 			if (_m[tile].m3 & _signals_table_both[3]) { | ||||||
| 				ret = DoCommandByTile(tile, 3, 0, flags, CMD_REMOVE_SIGNALS); | 				ret = DoCommandByTile(tile, 3, 0, flags, CMD_REMOVE_SIGNALS); | ||||||
| 				if (ret == CMD_ERROR) return CMD_ERROR; | 				if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 				cost += ret; | 				cost += ret; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @@ -1121,7 +1121,7 @@ static int32 ClearTile_Track(TileIndex tile, byte flags) | |||||||
| 			for (i = 0; m5 != 0; i++, m5 >>= 1) { | 			for (i = 0; m5 != 0; i++, m5 >>= 1) { | ||||||
| 				if (m5 & 1) { | 				if (m5 & 1) { | ||||||
| 					ret = DoCommandByTile(tile, 0, i, flags, CMD_REMOVE_SINGLE_RAIL); | 					ret = DoCommandByTile(tile, 0, i, flags, CMD_REMOVE_SINGLE_RAIL); | ||||||
| 					if (ret == CMD_ERROR) return CMD_ERROR; | 					if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 					cost += ret; | 					cost += ret; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -712,8 +712,7 @@ static int32 ClearTile_Road(TileIndex tile, byte flags) | |||||||
| 			return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); | 			return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); | ||||||
|  |  | ||||||
| 		ret = DoCommandByTile(tile, (m5&8)?5:10, 0, flags, CMD_REMOVE_ROAD); | 		ret = DoCommandByTile(tile, (m5&8)?5:10, 0, flags, CMD_REMOVE_ROAD); | ||||||
| 		if (ret == CMD_ERROR) | 		if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 			return CMD_ERROR; |  | ||||||
|  |  | ||||||
| 		if (flags & DC_EXEC) { | 		if (flags & DC_EXEC) { | ||||||
| 			DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 			DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | ||||||
|   | |||||||
| @@ -810,7 +810,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali | |||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			ret = DoCommandByTile(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 			ret = DoCommandByTile(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | ||||||
| 			if (ret == CMD_ERROR) return CMD_ERROR; | 			if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 			cost += ret; | 			cost += ret; | ||||||
| 		} | 		} | ||||||
| 	END_TILE_LOOP(tile_cur, w, h, tile) | 	END_TILE_LOOP(tile_cur, w, h, tile) | ||||||
| @@ -1390,7 +1390,7 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2) | |||||||
| 		return CMD_ERROR; | 		return CMD_ERROR; | ||||||
|  |  | ||||||
| 	cost = CheckFlatLandBelow(tile, 1, 1, flags, 1 << p1, NULL); | 	cost = CheckFlatLandBelow(tile, 1, 1, flags, 1 << p1, NULL); | ||||||
| 	if (cost == CMD_ERROR) return CMD_ERROR; | 	if (CmdFailed(cost)) return CMD_ERROR; | ||||||
|  |  | ||||||
| 	st = GetStationAround(tile, 1, 1, -1); | 	st = GetStationAround(tile, 1, 1, -1); | ||||||
| 	if (st == CHECK_STATIONS_ERR) return CMD_ERROR; | 	if (st == CHECK_STATIONS_ERR) return CMD_ERROR; | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								town_cmd.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								town_cmd.c
									
									
									
									
									
								
							| @@ -483,8 +483,8 @@ static bool IsRoadAllowedHere(TileIndex tile, int dir) | |||||||
| 			// No, try to build one in the direction. | 			// No, try to build one in the direction. | ||||||
| 			// if that fails clear the land, and if that fails exit. | 			// if that fails clear the land, and if that fails exit. | ||||||
| 			// This is to make sure that we can build a road here later. | 			// This is to make sure that we can build a road here later. | ||||||
| 			if (DoCommandByTile(tile, (dir&1)?0xA:0x5, 0, DC_AUTO, CMD_BUILD_ROAD) == CMD_ERROR && | 			if (CmdFailed(DoCommandByTile(tile, (dir&1)?0xA:0x5, 0, DC_AUTO, CMD_BUILD_ROAD)) && | ||||||
| 					DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR) == CMD_ERROR) | 					CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) | ||||||
| 				return false; | 				return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -664,7 +664,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, uint mask, int block, Town *t1) | |||||||
| 			(i++,ti.tileh != 12) && | 			(i++,ti.tileh != 12) && | ||||||
| 			(i++,ti.tileh != 6)) { | 			(i++,ti.tileh != 6)) { | ||||||
| build_road_and_exit: | build_road_and_exit: | ||||||
| 		if (DoCommandByTile(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD) != CMD_ERROR) | 		if (!CmdFailed(DoCommandByTile(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) | ||||||
| 			_grow_town_result = -1; | 			_grow_town_result = -1; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -690,7 +690,7 @@ build_road_and_exit: | |||||||
| 		do { | 		do { | ||||||
| 			byte bridge_type = RandomRange(MAX_BRIDGES - 1); | 			byte bridge_type = RandomRange(MAX_BRIDGES - 1); | ||||||
| 			if (CheckBridge_Stuff(bridge_type, bridge_len)) { | 			if (CheckBridge_Stuff(bridge_type, bridge_len)) { | ||||||
| 				if (DoCommandByTile(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE) != CMD_ERROR) | 				if (!CmdFailed(DoCommandByTile(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE))) | ||||||
| 					_grow_town_result = -1; | 					_grow_town_result = -1; | ||||||
|  |  | ||||||
| 				// obviously, if building any bridge would fail, there is no need to try other bridge-types | 				// obviously, if building any bridge would fail, there is no need to try other bridge-types | ||||||
| @@ -809,7 +809,7 @@ bool GrowTown(Town *t) | |||||||
|  |  | ||||||
| 		// Only work with plain land that not already has a house with map5=0 | 		// Only work with plain land that not already has a house with map5=0 | ||||||
| 		if (ti.tileh == 0 && (ti.type != MP_HOUSE || ti.map5 != 0)) { | 		if (ti.tileh == 0 && (ti.type != MP_HOUSE || ti.map5 != 0)) { | ||||||
| 			if (DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) { | 			if (!CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) { | ||||||
| 				DoCommandByTile(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD); | 				DoCommandByTile(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD); | ||||||
| 				_current_player = old_player; | 				_current_player = old_player; | ||||||
| 				return true; | 				return true; | ||||||
| @@ -1136,7 +1136,7 @@ static bool CheckBuildHouseMode(Town *t1, TileIndex tile, uint tileh, int mode) | |||||||
| 	if (b) | 	if (b) | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	return DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR) != CMD_ERROR; | 	return !CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR)); | ||||||
| } | } | ||||||
|  |  | ||||||
| int GetTownRadiusGroup(const Town *t, TileIndex tile) | int GetTownRadiusGroup(const Town *t, TileIndex tile) | ||||||
| @@ -1174,7 +1174,7 @@ static bool CheckFree2x2Area(Town *t1, TileIndex tile) | |||||||
| 		if (GetTileSlope(tile, NULL)) | 		if (GetTileSlope(tile, NULL)) | ||||||
| 			return false; | 			return false; | ||||||
|  |  | ||||||
| 		if (DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR) == CMD_ERROR) | 		if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR))) | ||||||
| 			return false; | 			return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -1361,7 +1361,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) | |||||||
| 	if (GetTileSlope(tile, NULL) & 0x10) return false; | 	if (GetTileSlope(tile, NULL) & 0x10) return false; | ||||||
|  |  | ||||||
| 	r = DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR); | 	r = DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR); | ||||||
| 	if (r == CMD_ERROR) return false; | 	if (CmdFailed(r)) return false; | ||||||
|  |  | ||||||
| 	DoBuildTownHouse(t, tile); | 	DoBuildTownHouse(t, tile); | ||||||
| 	return true; | 	return true; | ||||||
|   | |||||||
| @@ -279,7 +279,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2) | |||||||
|  |  | ||||||
| 	// true - bridge-start-tile, false - bridge-end-tile | 	// true - bridge-start-tile, false - bridge-end-tile | ||||||
| 	terraformcost = CheckBridgeSlope(direction, ti_start.tileh, true); | 	terraformcost = CheckBridgeSlope(direction, ti_start.tileh, true); | ||||||
| 	if (terraformcost == CMD_ERROR || (terraformcost && !allow_on_slopes)) | 	if (CmdFailed(terraformcost) || (terraformcost && !allow_on_slopes)) | ||||||
| 		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | 		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | ||||||
| 	cost += terraformcost; | 	cost += terraformcost; | ||||||
|  |  | ||||||
| @@ -291,7 +291,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2) | |||||||
|  |  | ||||||
| 	// false - end tile slope check | 	// false - end tile slope check | ||||||
| 	terraformcost = CheckBridgeSlope(direction, ti_end.tileh, false); | 	terraformcost = CheckBridgeSlope(direction, ti_end.tileh, false); | ||||||
| 	if (terraformcost == CMD_ERROR || (terraformcost && !allow_on_slopes)) | 	if (CmdFailed(terraformcost) || (terraformcost && !allow_on_slopes)) | ||||||
| 		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | 		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | ||||||
| 	cost += terraformcost; | 	cost += terraformcost; | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								water_cmd.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								water_cmd.c
									
									
									
									
									
								
							| @@ -136,17 +136,17 @@ static int32 DoBuildShiplift(TileIndex tile, int dir, uint32 flags) | |||||||
|  |  | ||||||
| 	// middle tile | 	// middle tile | ||||||
| 	ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 	ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | ||||||
| 	if (ret == CMD_ERROR) return CMD_ERROR; | 	if (CmdFailed(ret)) return CMD_ERROR; | ||||||
|  |  | ||||||
| 	delta = TileOffsByDir(dir); | 	delta = TileOffsByDir(dir); | ||||||
| 	// lower tile | 	// lower tile | ||||||
| 	ret = DoCommandByTile(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 	ret = DoCommandByTile(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | ||||||
| 	if (ret == CMD_ERROR) return CMD_ERROR; | 	if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 	if (GetTileSlope(tile - delta, NULL)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | 	if (GetTileSlope(tile - delta, NULL)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | ||||||
|  |  | ||||||
| 	// upper tile | 	// upper tile | ||||||
| 	ret = DoCommandByTile(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 	ret = DoCommandByTile(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | ||||||
| 	if (ret == CMD_ERROR) return CMD_ERROR; | 	if (CmdFailed(ret)) return CMD_ERROR; | ||||||
| 	if (GetTileSlope(tile + delta, NULL)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | 	if (GetTileSlope(tile + delta, NULL)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); | ||||||
|  |  | ||||||
| 	if (flags & DC_EXEC) { | 	if (flags & DC_EXEC) { | ||||||
| @@ -530,7 +530,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) | |||||||
| 			case MP_CLEAR: | 			case MP_CLEAR: | ||||||
| 			case MP_TREES: | 			case MP_TREES: | ||||||
| 				_current_player = OWNER_WATER; | 				_current_player = OWNER_WATER; | ||||||
| 				if (DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) { | 				if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { | ||||||
| 					ModifyTile( | 					ModifyTile( | ||||||
| 						target, | 						target, | ||||||
| 						MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | | 						MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | | ||||||
| @@ -569,7 +569,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) | |||||||
| 			if (v != NULL) FloodVehicle(v); | 			if (v != NULL) FloodVehicle(v); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) { | 		if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { | ||||||
| 			ModifyTile( | 			ModifyTile( | ||||||
| 				target, | 				target, | ||||||
| 				MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | | 				MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 peter1138
					peter1138