Changeset - r12952:f1e4fe94bb97
[Not reviewed]
master
0 7 0
yexo - 15 years ago 2009-09-07 13:38:57
yexo@openttd.org
(svn r17455) -Codechange: use sprite names instead of magic numbers in table/clear_land.h and change some names
7 files changed with 59 insertions and 75 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -58,7 +58,7 @@ void DrawHillyLandTile(const TileInfo *t
 
	if (ti->tileh != SLOPE_FLAT) {
 
		DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
	} else {
 
		DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
 
		DrawGroundSprite(_landscape_clear_sprites_rough[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
 
	}
 
}
 

	
 
@@ -72,11 +72,11 @@ void DrawClearLandFence(const TileInfo *
 
	}
 

	
 
	if (GetFenceSW(ti->tile) != 0) {
 
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh[ti->tileh], PAL_NONE, ti->x, ti->y, z);
 
		DrawGroundSpriteAt(_clear_land_fence_sprites[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh_sw[ti->tileh], PAL_NONE, ti->x, ti->y, z);
 
	}
 

	
 
	if (GetFenceSE(ti->tile) != 0) {
 
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_2[ti->tileh], PAL_NONE, ti->x, ti->y, z);
 
		DrawGroundSpriteAt(_clear_land_fence_sprites[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_se[ti->tileh], PAL_NONE, ti->x, ti->y, z);
 
	}
 
}
 

	
 
@@ -96,15 +96,12 @@ static void DrawTile_Clear(TileInfo *ti)
 
			break;
 

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

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

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

	
src/rail_cmd.cpp
Show inline comments
 
@@ -1733,7 +1733,7 @@ static void DrawTrackBits(TileInfo *ti, 
 
		} else {
 
			switch (rgt) {
 
				case RAIL_GROUND_BARREN:     image = SPR_FLAT_BARE_LAND;  break;
 
				case RAIL_GROUND_ICE_DESERT: image = SPR_FLAT_SNOWY_TILE; break;
 
				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];
 
@@ -1927,7 +1927,7 @@ static void DrawTile_Track(TileInfo *ti)
 
			if (image != SPR_FLAT_GRASS_TILE) {
 
				image += rti->snow_offset; // tile with tracks
 
			} else {
 
				image = SPR_FLAT_SNOWY_TILE; // flat ground
 
				image = SPR_FLAT_SNOW_DESERT_TILE; // flat ground
 
			}
 
		}
 

	
src/table/clear_land.h
Show inline comments
 
@@ -9,25 +9,25 @@
 

	
 
/** @file clear_land.h Tables with sprites for clear land and fences. */
 

	
 
static const SpriteID _landscape_clear_sprites[8] = {
 
	0xFA0,
 
	0xFB3,
 
	0xFB4,
 
	0xFB5,
 
	0xFB6,
 
	0xFA0,
 
	0xFB3,
 
	0xFB4,
 
static const SpriteID _landscape_clear_sprites_rough[8] = {
 
	SPR_FLAT_ROUGH_LAND,
 
	SPR_FLAT_ROUGH_LAND_1,
 
	SPR_FLAT_ROUGH_LAND_2,
 
	SPR_FLAT_ROUGH_LAND_3,
 
	SPR_FLAT_ROUGH_LAND_4,
 
	SPR_FLAT_ROUGH_LAND,
 
	SPR_FLAT_ROUGH_LAND_1,
 
	SPR_FLAT_ROUGH_LAND_2,
 
};
 

	
 
static const byte _fence_mod_by_tileh[32] = {
 
static const byte _fence_mod_by_tileh_sw[32] = {
 
	0, 2, 4, 0, 0, 2, 4, 0,
 
	0, 2, 4, 0, 0, 2, 4, 0,
 
	0, 2, 4, 0, 0, 2, 4, 4,
 
	0, 2, 4, 2, 0, 2, 4, 0,
 
};
 

	
 
static const byte _fence_mod_by_tileh_2[32] = {
 
static const byte _fence_mod_by_tileh_se[32] = {
 
	1, 1, 5, 5, 3, 3, 1, 1,
 
	1, 1, 5, 5, 3, 3, 1, 1,
 
	1, 1, 5, 5, 3, 3, 1, 5,
 
@@ -35,37 +35,30 @@ static const byte _fence_mod_by_tileh_2[
 
};
 

	
 

	
 
static const SpriteID _clear_land_fence_sprites_1[7] = {
 
	0xFFA,
 
	0x1000,
 
	0x1006,
 
	0x100C,
 
	0x1012,
 
	0x1018,
 
static const SpriteID _clear_land_fence_sprites[7] = {
 
	SPR_HEDGE_BUSHES,
 
	SPR_HEDGE_BUSHES_WITH_GATE,
 
	SPR_HEDGE_FENCE,
 
	SPR_HEDGE_BLOOMBUSH_YELLOW,
 
	SPR_HEDGE_BLOOMBUSH_RED,
 
	SPR_HEDGE_STONE,
 
};
 

	
 
static const SpriteID _clear_land_sprites_1[16] = {
 
	0x101E,
 
	0x1031,
 
	0x1044,
 
	0x1057,
 
	0x106A,
 
	0x107D,
 
	0x1090,
 
	0x10A3,
 
	0x10B6,
 
static const SpriteID _clear_land_sprites_farmland[16] = {
 
	SPR_FARMLAND_BARE,
 
	SPR_FARMLAND_STATE_1,
 
	SPR_FARMLAND_STATE_2,
 
	SPR_FARMLAND_STATE_3,
 
	SPR_FARMLAND_STATE_4,
 
	SPR_FARMLAND_STATE_5,
 
	SPR_FARMLAND_STATE_6,
 
	SPR_FARMLAND_STATE_7,
 
	SPR_FARMLAND_HAYPACKS,
 
};
 

	
 
static const SpriteID _clear_land_sprites_2[8] = {
 
	0x118D,
 
	0x11A0,
 
	0x11B3,
 
	0x11C6,
 
static const SpriteID _clear_land_sprites_snow_desert[8] = {
 
	SPR_FLAT_1_QUART_SNOW_DESERT_TILE,
 
	SPR_FLAT_2_QUART_SNOW_DESERT_TILE,
 
	SPR_FLAT_3_QUART_SNOW_DESERT_TILE,
 
	SPR_FLAT_SNOW_DESERT_TILE,
 
};
 

	
 
static const SpriteID _clear_land_sprites_3[8] = {
 
	0x118D,
 
	0x11A0,
 
	0x11B3,
 
	0x11C6,
 
};
src/table/sprites.h
Show inline comments
 
@@ -518,22 +518,22 @@ enum Sprites {
 
	SPR_EXCAVATION_Y = 1415,
 

	
 
	/* Landscape sprites */
 
	SPR_FLAT_BARE_LAND          = 3924,
 
	SPR_FLAT_1_THIRD_GRASS_TILE = 3943,
 
	SPR_FLAT_2_THIRD_GRASS_TILE = 3962,
 
	SPR_FLAT_GRASS_TILE         = 3981,
 
	SPR_FLAT_ROUGH_LAND         = 4000,
 
	SPR_FLAT_ROUGH_LAND_1       = 4019,
 
	SPR_FLAT_ROUGH_LAND_2       = 4020,
 
	SPR_FLAT_ROUGH_LAND_3       = 4021,
 
	SPR_FLAT_ROUGH_LAND_4       = 4022,
 
	SPR_FLAT_ROCKY_LAND_1       = 4023,
 
	SPR_FLAT_ROCKY_LAND_2       = 4042,
 
	SPR_FLAT_WATER_TILE         = 4061,
 
	SPR_FLAT_1_QUART_SNOWY_TILE = 4493,
 
	SPR_FLAT_2_QUART_SNOWY_TILE = 4512,
 
	SPR_FLAT_3_QUART_SNOWY_TILE = 4531,
 
	SPR_FLAT_SNOWY_TILE         = 4550,
 
	SPR_FLAT_BARE_LAND                = 3924,
 
	SPR_FLAT_1_THIRD_GRASS_TILE       = 3943,
 
	SPR_FLAT_2_THIRD_GRASS_TILE       = 3962,
 
	SPR_FLAT_GRASS_TILE               = 3981,
 
	SPR_FLAT_ROUGH_LAND               = 4000,
 
	SPR_FLAT_ROUGH_LAND_1             = 4019,
 
	SPR_FLAT_ROUGH_LAND_2             = 4020,
 
	SPR_FLAT_ROUGH_LAND_3             = 4021,
 
	SPR_FLAT_ROUGH_LAND_4             = 4022,
 
	SPR_FLAT_ROCKY_LAND_1             = 4023,
 
	SPR_FLAT_ROCKY_LAND_2             = 4042,
 
	SPR_FLAT_WATER_TILE               = 4061,
 
	SPR_FLAT_1_QUART_SNOW_DESERT_TILE = 4493,
 
	SPR_FLAT_2_QUART_SNOW_DESERT_TILE = 4512,
 
	SPR_FLAT_3_QUART_SNOW_DESERT_TILE = 4531,
 
	SPR_FLAT_SNOW_DESERT_TILE         = 4550,
 

	
 
	/* Hedge, Farmland-fence sprites */
 
	SPR_HEDGE_BUSHES            = 4090,
src/table/tree_land.h
Show inline comments
 
@@ -12,13 +12,6 @@
 
#ifndef TREE_LAND_H
 
#define TREE_LAND_H
 

	
 
static const SpriteID _tree_sprites_1[] = {
 
	SPR_FLAT_1_QUART_SNOWY_TILE,
 
	SPR_FLAT_2_QUART_SNOWY_TILE,
 
	SPR_FLAT_3_QUART_SNOWY_TILE,
 
	SPR_FLAT_SNOWY_TILE
 
};
 

	
 
static const byte _tree_base_by_landscape[4] = {0, 12, 20, 32};
 
static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9};
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -32,6 +32,7 @@
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
#include "table/tree_land.h"
 
#include "table/clear_land.h"
 

	
 
/**
 
 * List of tree placer algorithm.
 
@@ -446,7 +447,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(_tree_sprites_1[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break;
 
		default: DrawGroundSprite(_clear_land_sprites_snow_desert[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break;
 
	}
 

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

	
 
		/* draw ramp */
0 comments (0 inline, 0 general)