Changeset - r7684:f5f93b1de29d
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2007-10-05 22:39:15
rubidium@openttd.org
(svn r11215) -Codechange: replace magic constants with less magic symbols. Patch by skidd13.
1 file changed with 15 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/town_cmd.cpp
Show inline comments
 
@@ -98,6 +98,13 @@ Town::~Town()
 
// Local
 
static int _grow_town_result;
 

	
 
/* Describe the possible states */
 
enum TownGrowthResult {
 
	GROWTH_SUCCEED         = -1,
 
	GROWTH_SEARCH_STOPPED  =  0
 
//	GROWTH_SEARCH_RUNNING >=  1
 
};
 

	
 
static bool BuildTownHouse(Town *t, TileIndex tile);
 
static void DoBuildTownHouse(Town *t, TileIndex tile);
 

	
 
@@ -861,7 +868,7 @@ static bool GrowTownWithExtraHouse(Town 
 
		/* If there are enough neighbors stop here */
 
		if (counter >= 3) {
 
			if (BuildTownHouse(t, tile)) {
 
				_grow_town_result = -1;
 
				_grow_town_result = GROWTH_SUCCEED;
 
				return true;
 
			}
 
			return false;
 
@@ -881,7 +888,7 @@ static bool GrowTownWithExtraHouse(Town 
 
static bool GrowTownWithRoad(const Town *t, TileIndex tile, RoadBits rcmd)
 
{
 
	if (CmdSucceeded(DoCommand(tile, rcmd, t->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
 
		_grow_town_result = -1;
 
		_grow_town_result = GROWTH_SUCCEED;
 
		return true;
 
	}
 
	return false;
 
@@ -936,7 +943,7 @@ static bool GrowTownWithBridge(const Tow
 
		/* Can we actually build the bridge? */
 
		if (CmdSucceeded(DoCommand(tile, bridge_tile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE))) {
 
			DoCommand(tile, bridge_tile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE);
 
			_grow_town_result--;
 
			_grow_town_result = GROWTH_SUCCEED;
 
			return true;
 
		}
 
	}
 
@@ -972,7 +979,7 @@ static void GrowTownInTile(TileIndex *ti
 
	if (cur_rb == ROAD_NONE) {
 
		/* Tile has no road. First reset the status counter
 
		 * to say that this is the last iteration. */
 
		_grow_town_result = 0;
 
		_grow_town_result = GROWTH_SEARCH_STOPPED;
 

	
 
		/* Remove hills etc */
 
		LevelTownLand(tile);
 
@@ -1024,7 +1031,7 @@ static void GrowTownInTile(TileIndex *ti
 
		/* Continue building on a partial road.
 
		 * Should be allways OK, so we only generate
 
		 * the fitting RoadBits */
 
		_grow_town_result = 0;
 
		_grow_town_result = GROWTH_SEARCH_STOPPED;
 

	
 
		switch (_patches.town_layout) {
 
			default: NOT_REACHED();
 
@@ -1103,13 +1110,13 @@ static void GrowTownInTile(TileIndex *ti
 
				/* And build a house.
 
				 * Set result to -1 if we managed to build it. */
 
				if (BuildTownHouse(t1, house_tile)) {
 
					_grow_town_result = -1;
 
					_grow_town_result = GROWTH_SUCCEED;
 
				}
 
			}
 
			return;
 
		}
 

	
 
		_grow_town_result = 0;
 
		_grow_town_result = GROWTH_SEARCH_STOPPED;
 
	}
 

	
 
	/* Return if a water tile */
 
@@ -1176,7 +1183,7 @@ static int GrowTownAtRoad(Town *t, TileI
 
		if (IsTileType(tile, MP_ROAD)) {
 
			/* Don't allow building over roads of other cities */
 
			if (IsTileOwner(tile, OWNER_TOWN) && GetTownByTile(tile) != t) {
 
				_grow_town_result = -1;
 
				_grow_town_result = GROWTH_SUCCEED;
 
			} else if (_game_mode == GM_EDITOR) {
 
				/* If we are in the SE, and this road-piece has no town owner yet, it just found an
 
				 * owner :) (happy happy happy road now) */
0 comments (0 inline, 0 general)