Changeset - r22029:7153f47dd2f2
[Not reviewed]
master
0 1 0
michi_cc - 9 years ago 2015-03-14 14:27:07
michi_cc@openttd.org
(svn r27186) -Codechange: Rename AlwaysDrawUnpavedRoads() to better reflect what it does.
1 file changed with 8 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/road_cmd.cpp
Show inline comments
 
@@ -1147,34 +1147,33 @@ static Foundation GetRoadFoundation(Slop
 
	/* Roads on steep Slopes or on Slopes with one corner raised */
 
	return (bits == ROAD_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
 
}
 

	
 
const byte _road_sloped_sprites[14] = {
 
	0,  0,  2,  0,
 
	0,  1,  0,  0,
 
	3,  0,  0,  0,
 
	0,  0
 
};
 

	
 
/**
 
 * Whether to draw unpaved roads regardless of the town zone.
 
 * By default, OpenTTD always draws roads as unpaved if they are on a desert
 
 * tile or above the snowline. Newgrf files, however, can set a bit that allows
 
 * paved roads to be built on desert tiles as they would be on grassy tiles.
 
 * Should the road be drawn as a unpaved snow/desert road?
 
 * By default, roads are always drawn as unpaved if they are on desert or
 
 * above the snow line, but NewGRFs can override this for desert.
 
 *
 
 * @param tile The tile the road is on
 
 * @param roadside What sort of road this is
 
 * @return True if the road should be drawn unpaved regardless of the roadside.
 
 * @return True if snow/desert road sprites should be used.
 
 */
 
static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
 
static bool DrawRoadAsSnowDesert(TileIndex tile, Roadside roadside)
 
{
 
	return (IsOnSnow(tile) &&
 
			!(_settings_game.game_creation.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
 
				roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS));
 
}
 

	
 
/**
 
 * Draws the catenary for the given tile
 
 * @param ti   information about the tile (slopes, height etc)
 
 * @param tram the roadbits for the tram
 
 */
 
void DrawTramCatenary(const TileInfo *ti, RoadBits tram)
 
@@ -1236,25 +1235,25 @@ static void DrawRoadBits(TileInfo *ti)
 
	if (ti->tileh != SLOPE_FLAT) {
 
		DrawFoundation(ti, GetRoadFoundation(ti->tileh, road | tram));
 

	
 
		/* DrawFoundation() modifies ti.
 
		 * Default sloped sprites.. */
 
		if (ti->tileh != SLOPE_FLAT) image = _road_sloped_sprites[ti->tileh - 1] + SPR_ROAD_SLOPE_START;
 
	}
 

	
 
	if (image == 0) image = _road_tile_sprites_1[road != ROAD_NONE ? road : tram];
 

	
 
	Roadside roadside = GetRoadside(ti->tile);
 

	
 
	if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
 
	if (DrawRoadAsSnowDesert(ti->tile, roadside)) {
 
		image += 19;
 
	} else {
 
		switch (roadside) {
 
			case ROADSIDE_BARREN:           pal = PALETTE_TO_BARE_LAND; break;
 
			case ROADSIDE_GRASS:            break;
 
			case ROADSIDE_GRASS_ROAD_WORKS: break;
 
			default:                        image -= 19; break; // Paved
 
		}
 
	}
 

	
 
	DrawGroundSprite(image, pal);
 

	
 
@@ -1319,25 +1318,25 @@ static void DrawTile_Road(TileInfo *ti)
 
		case ROAD_TILE_CROSSING: {
 
			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
 

	
 
			PaletteID pal = PAL_NONE;
 
			const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
 

	
 
			if (rti->UsesOverlay()) {
 
				Axis axis = GetCrossingRailAxis(ti->tile);
 
				SpriteID road = SPR_ROAD_Y + axis;
 

	
 
				Roadside roadside = GetRoadside(ti->tile);
 

	
 
				if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
 
				if (DrawRoadAsSnowDesert(ti->tile, roadside)) {
 
					road += 19;
 
				} else {
 
					switch (roadside) {
 
						case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
 
						case ROADSIDE_GRASS:  break;
 
						default:              road -= 19; break; // Paved
 
					}
 
				}
 

	
 
				DrawGroundSprite(road, pal);
 

	
 
				SpriteID rail = GetCustomRailSprite(rti, ti->tile, RTSG_CROSSING) + axis;
 
@@ -1345,25 +1344,25 @@ static void DrawTile_Road(TileInfo *ti)
 
				pal = (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) ? PALETTE_CRASH : PAL_NONE;
 
				DrawGroundSprite(rail, pal);
 

	
 
				DrawRailTileSeq(ti, &_crossing_layout, TO_CATENARY, rail, 0, PAL_NONE);
 
			} else {
 
				SpriteID image = rti->base_sprites.crossing;
 

	
 
				if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
 
				if (IsCrossingBarred(ti->tile)) image += 2;
 

	
 
				Roadside roadside = GetRoadside(ti->tile);
 

	
 
				if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
 
				if (DrawRoadAsSnowDesert(ti->tile, roadside)) {
 
					image += 8;
 
				} else {
 
					switch (roadside) {
 
						case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
 
						case ROADSIDE_GRASS:  break;
 
						default:              image += 4; break; // Paved
 
					}
 
				}
 

	
 
				DrawGroundSprite(image, pal);
 

	
 
				/* PBS debugging, draw reserved tracks darker */
0 comments (0 inline, 0 general)