Changeset - r6842:b381328cc05c
[Not reviewed]
master
0 2 0
rubidium - 17 years ago 2007-06-10 10:52:19
rubidium@openttd.org
(svn r10081) -Fix [FS851]: towns/AIs didn't build bridges anymore (boekabart).
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -2879,25 +2879,25 @@ static inline void AiCheckBuildRoadBridg
 

	
 
			if (type == MP_CLEAR || type == MP_TREES || GetTileSlope(tile, NULL) != SLOPE_FLAT) {
 
				// Allow a bridge if either we have a tile that's water, rail or street,
 
				// or if we found an up tile.
 
				if (!flag) return;
 
				break;
 
			}
 
			if (type != MP_WATER && type != MP_RAILWAY && type != MP_STREET) return;
 
			flag = true;
 
		}
 

	
 
		// Is building a (rail)bridge possible at this place (type doesn't matter)?
 
		if (CmdFailed(DoCommand(tile_new, tile, 0x8000, DC_AUTO, CMD_BUILD_BRIDGE)))
 
		if (CmdFailed(DoCommand(tile_new, tile, ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE)))
 
			return;
 
		AiBuildRoadRecursive(arf, tile_new, dir2);
 

	
 
		// At the bottom depth, check if the new path is better than the old one.
 
		if (arf->depth == 1) {
 
			if (AiCheckRoadPathBetter(arf, p)) arf->bridge_end_tile = tile_new;
 
		}
 
	}
 
}
 

	
 
static inline void AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile, const byte *p)
 
{
 
@@ -3029,31 +3029,31 @@ do_some_terraform:
 
		int i;
 
		int32 bridge_len;
 
		p->ai.cur_tile_a = arf.bridge_end_tile;
 
		bridge_len = GetBridgeLength(tile, p->ai.cur_tile_a); // tile
 

	
 
		/* Figure out what (road)bridge type to build
 
		 * start with best bridge, then go down to worse and worse bridges
 
		 * unnecessary to check for worse bridge (i=0), since AI will always build that.
 
		 *AI is so fucked up that fixing this small thing will probably not solve a thing
 
		 */
 
		for (i = 10; i != 0; i--) {
 
			if (CheckBridge_Stuff(i, bridge_len)) {
 
				int32 cost = DoCommand(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO, CMD_BUILD_BRIDGE);
 
				int32 cost = DoCommand(tile, p->ai.cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE);
 
				if (!CmdFailed(cost) && cost < (p->player_money >> 5)) break;
 
			}
 
		}
 

	
 
		// Build it
 
		DoCommand(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
 
		DoCommand(tile, p->ai.cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
 

	
 
		p->ai.state_counter = 0;
 
	} else if (arf.best_ptr[0] & 0x40) {
 
		// tunnel
 
		DoCommand(tile, 0x200, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
 
		p->ai.cur_tile_a = _build_tunnel_endtile;
 
		p->ai.state_counter = 0;
 
	} else {
 
		// road
 
		if (!AiBuildRoadHelper(tile, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, arf.best_ptr[0]))
 
			goto do_some_terraform;
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -1087,25 +1087,25 @@ build_road_and_exit:
 

	
 
	/* no water tiles in between? */
 
	if (j == -10)
 
		goto build_road_and_exit;
 

	
 
	/* Quit if it selecting an appropiate bridge type fails a large number of times. */
 
	j = 22;
 
	{
 
		int32 bridge_len = GetBridgeLength(tile, tmptile);
 
		do {
 
			byte bridge_type = RandomRange(MAX_BRIDGES - 1);
 
			if (CheckBridge_Stuff(bridge_type, bridge_len)) {
 
				if (!CmdFailed(DoCommand(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
 
				if (!CmdFailed(DoCommand(tile, tmptile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
 
					_grow_town_result = -1;
 

	
 
				/* obviously, if building any bridge would fail, there is no need to try other bridge-types */
 
				return;
 
			}
 
		} while (--j != 0);
 
	}
 
}
 

	
 
/** Returns "growth" if a house was built, or no if the build failed.
 
 * @param t town to inquiry
 
 * @param tile to inquiry
0 comments (0 inline, 0 general)