Changeset - r6547:ba62fb7ed51e
[Not reviewed]
master
0 1 0
maedhros - 17 years ago 2007-04-29 09:18:52
maedhros@openttd.org
(svn r9743) -Fix [FS#598]: Stop flooded towns from building roads on water.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/town_cmd.cpp
Show inline comments
 
@@ -930,49 +930,49 @@ static bool GrowTown(Town *t)
 
		{ 0,  0}
 
	};
 

	
 
	/* Current player is a town */
 
	old_player = _current_player;
 
	_current_player = OWNER_TOWN;
 

	
 
	/* Find a road that we can base the construction on. */
 
	tile = t->xy;
 
	for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
 
		if (GetAnyRoadTrackBits(tile) != 0) {
 
			int r = GrowTownAtRoad(t, tile);
 
			_current_player = old_player;
 
			return r != 0;
 
		}
 
		tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
 
	}
 

	
 
	/* No road available, try to build a random road block by
 
	 * clearing some land and then building a road there. */
 
	tile = t->xy;
 
	for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
 
		/* Only work with plain land that not already has a house */
 
		if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
 
			if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) {
 
			if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
 
				DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
 
				_current_player = old_player;
 
				return true;
 
			}
 
		}
 
		tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
 
	}
 

	
 
	_current_player = old_player;
 
	return false;
 
}
 

	
 
static void UpdateTownRadius(Town *t)
 
{
 
	static const uint16 _town_radius_data[23][5] = {
 
		{  4,  0,  0,  0,  0}, // 0
 
		{ 16,  0,  0,  0,  0},
 
		{ 25,  0,  0,  0,  0},
 
		{ 36,  0,  0,  0,  0},
 
		{ 49,  0,  4,  0,  0},
 
		{ 64,  0,  4,  0,  0}, // 20
 
		{ 64,  0,  9,  0,  1},
 
		{ 64,  0,  9,  0,  4},
 
		{ 64,  0, 16,  0,  4},
0 comments (0 inline, 0 general)