Changeset - r15518:e589c4f3f9c1
[Not reviewed]
master
0 8 0
rubidium - 14 years ago 2010-07-19 17:00:54
rubidium@openttd.org
(svn r20187) -Codechange: move _tileh_to_sprite into a function in a more logical place and with a more descriptive name
8 files changed with 25 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -50,13 +50,13 @@ static CommandCost ClearTile_Clear(TileI
 

	
 
void DrawClearLandTile(const TileInfo *ti, byte set)
 
{
 
	DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19, PAL_NONE);
 
	DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE);
 
}
 

	
 
void DrawHillyLandTile(const TileInfo *ti)
 
{
 
	if (ti->tileh != SLOPE_FLAT) {
 
		DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
		DrawGroundSprite(SPR_FLAT_ROUGH_LAND + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
 
	} else {
 
		DrawGroundSprite(_landscape_clear_sprites_rough[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
 
	}
 
@@ -92,16 +92,16 @@ static void DrawTile_Clear(TileInfo *ti)
 
			break;
 

	
 
		case CLEAR_ROCKS:
 
			DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
			DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
 
			break;
 

	
 
		case CLEAR_FIELDS:
 
			DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
			DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
 
			break;
 

	
 
		case CLEAR_SNOW:
 
		case CLEAR_DESERT:
 
			DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
			DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
 
			break;
 
	}
 

	
src/landscape.cpp
Show inline comments
 
@@ -63,8 +63,8 @@ const TileTypeProcs * const _tile_type_p
 
	&_tile_type_unmovable_procs,    ///< Callback functions for MP_UNMOVABLE tiles
 
};
 

	
 
/* landscape slope => sprite */
 
const byte _tileh_to_sprite[32] = {
 
/** landscape slope => sprite */
 
extern const byte _slope_to_sprite_offset[32] = {
 
	0, 1, 2, 3, 4, 5, 6,  7, 8, 9, 10, 11, 12, 13, 14, 0,
 
	0, 0, 0, 0, 0, 0, 0, 16, 0, 0,  0, 17,  0, 15, 18, 0,
 
};
src/rail_cmd.cpp
Show inline comments
 
@@ -1876,7 +1876,7 @@ static void DrawTrackBitsOverlay(TileInf
 
			default:                     image = SPR_FLAT_GRASS_TILE; break;
 
		}
 

	
 
		image += _tileh_to_sprite[ti->tileh];
 
		image += SlopeToSpriteOffset(ti->tileh);
 

	
 
		DrawGroundSprite(image, PAL_NONE);
 
	}
 
@@ -1966,7 +1966,7 @@ static void DrawTrackBitsOverlay(TileInf
 
			default:                     image = SPR_FLAT_GRASS_TILE; break;
 
		}
 

	
 
		image += _tileh_to_sprite[fake_slope];
 
		image += SlopeToSpriteOffset(fake_slope);
 

	
 
		DrawGroundSprite(image, PAL_NONE, &(_halftile_sub_sprite[halftile_corner]));
 

	
 
@@ -2038,7 +2038,7 @@ static void DrawTrackBits(TileInfo *ti, 
 
				case RAIL_GROUND_ICE_DESERT: image = SPR_FLAT_SNOW_DESERT_TILE; break;
 
				default:                     image = SPR_FLAT_GRASS_TILE; break;
 
			}
 
			image += _tileh_to_sprite[ti->tileh];
 
			image += SlopeToSpriteOffset(ti->tileh);
 
		}
 
	} else {
 
		if (ti->tileh != SLOPE_FLAT) {
src/slope_func.h
Show inline comments
 
@@ -397,4 +397,16 @@ static inline Foundation SpecialRailFoun
 
	return (Foundation)(FOUNDATION_RAIL_W + corner);
 
}
 

	
 
/**
 
 * Returns the #Sprite offset for a given #Slope.
 
 *
 
 * @param s The #Slope to get the offset for.
 
 * @return The sprite offset for this #Slope.
 
 */
 
static inline uint SlopeToSpriteOffset(Slope s)
 
{
 
	extern const byte _slope_to_sprite_offset[32];
 
	return _slope_to_sprite_offset[s];
 
}
 

	
 
#endif /* SLOPE_FUNC_H */
src/tree_cmd.cpp
Show inline comments
 
@@ -457,7 +457,7 @@ static void DrawTile_Trees(TileInfo *ti)
 
		case TREE_GROUND_SHORE: DrawShoreTile(ti->tileh); break;
 
		case TREE_GROUND_GRASS: DrawClearLandTile(ti, GetTreeDensity(ti->tile)); break;
 
		case TREE_GROUND_ROUGH: DrawHillyLandTile(ti); break;
 
		default: DrawGroundSprite(_clear_land_sprites_snow_desert[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break;
 
		default: DrawGroundSprite(_clear_land_sprites_snow_desert[GetTreeDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break;
 
	}
 

	
 
	DrawClearLandFence(ti);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1060,7 +1060,7 @@ static void DrawTile_TunnelBridge(TileIn
 
		if (!ice) {
 
			DrawClearLandTile(ti, 3);
 
		} else {
 
			DrawGroundSprite(SPR_FLAT_SNOW_DESERT_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
			DrawGroundSprite(SPR_FLAT_SNOW_DESERT_TILE + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
 
		}
 

	
 
		/* draw ramp */
src/variables.h
Show inline comments
 
@@ -28,7 +28,4 @@ VARDEF char *_config_file;
 
VARDEF char *_highscore_file;
 
VARDEF char *_log_file;
 

	
 
/* landscape.cpp */
 
extern const byte _tileh_to_sprite[32];
 

	
 
#endif /* VARIABLES_H */
src/viewport.cpp
Show inline comments
 
@@ -851,7 +851,7 @@ static void DrawTileSelectionRect(const 
 
		}
 
		sel += opposite_corner;
 
	} else {
 
		sel = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh];
 
		sel = SPR_SELECT_TILE + SlopeToSpriteOffset(ti->tileh);
 
	}
 
	DrawSelectionSprite(sel, pal, ti, 7, FOUNDATION_PART_NORMAL);
 
}
0 comments (0 inline, 0 general)