comparison src/rail_cmd.cpp @ 8523:76d0527eea17 draft

(svn r12098) -Fix: make snow appear on rail tiles dependant on track height, not on height of the lowest part of the tile
author smatz <smatz@openttd.org>
date Sun, 10 Feb 2008 11:35:05 +0000
parents 0e4b2a37af1f
children 4f95a16c1080
comparison
equal deleted inserted replaced
8522:105d9dd7d05c 8523:76d0527eea17
1696 Slope fake_slope = SlopeWithThreeCornersRaised(OppositeCorner(halftile_corner)); 1696 Slope fake_slope = SlopeWithThreeCornersRaised(OppositeCorner(halftile_corner));
1697 image = _track_sloped_sprites[fake_slope - 1] + rti->base_sprites.track_y; 1697 image = _track_sloped_sprites[fake_slope - 1] + rti->base_sprites.track_y;
1698 pal = PAL_NONE; 1698 pal = PAL_NONE;
1699 switch (rgt) { 1699 switch (rgt) {
1700 case RAIL_GROUND_BARREN: pal = PALETTE_TO_BARE_LAND; break; 1700 case RAIL_GROUND_BARREN: pal = PALETTE_TO_BARE_LAND; break;
1701 case RAIL_GROUND_ICE_DESERT: image += rti->snow_offset; break; 1701 case RAIL_GROUND_ICE_DESERT:
1702 case RAIL_GROUND_HALF_SNOW: image += rti->snow_offset; break; // higher part has snow in this case too
1702 default: break; 1703 default: break;
1703 } 1704 }
1704 DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner])); 1705 DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner]));
1705 } 1706 }
1706 } 1707 }
1932 TileLoop_Water(tile); 1933 TileLoop_Water(tile);
1933 return; 1934 return;
1934 } 1935 }
1935 1936
1936 switch (_opt.landscape) { 1937 switch (_opt.landscape) {
1937 case LT_ARCTIC: 1938 case LT_ARCTIC: {
1938 if (GetTileZ(tile) > GetSnowLine()) { 1939 uint z;
1939 new_ground = RAIL_GROUND_ICE_DESERT; 1940 Slope slope = GetTileSlope(tile, &z);
1941 bool half = false;
1942
1943 /* for non-flat track, use lower part of track
1944 * in other cases, use the highest part with track */
1945 if (IsPlainRailTile(tile)) {
1946 TrackBits track = GetTrackBits(tile);
1947 Foundation f = GetRailFoundation(slope, track);
1948
1949 switch (f) {
1950 case FOUNDATION_NONE:
1951 /* no foundation - is the track on the upper side of three corners raised tile? */
1952 if (IsSlopeWithThreeCornersRaised(slope)) z += TILE_HEIGHT;
1953 break;
1954
1955 case FOUNDATION_INCLINED_X:
1956 case FOUNDATION_INCLINED_Y:
1957 /* sloped track - is it on a steep slope? */
1958 if (IsSteepSlope(slope)) z += TILE_HEIGHT;
1959 break;
1960
1961 case FOUNDATION_STEEP_LOWER:
1962 /* only lower part of steep slope */
1963 z += TILE_HEIGHT;
1964 break;
1965
1966 default:
1967 /* if it is a steep slope, then there is a track on higher part */
1968 if (IsSteepSlope(slope)) z += TILE_HEIGHT;
1969 z += TILE_HEIGHT;
1970 break;
1971 }
1972
1973 half = IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
1974 } else {
1975 /* is the depot on a non-flat tile? */
1976 if (slope != SLOPE_FLAT) z += TILE_HEIGHT;
1977 }
1978
1979 /* 'z' is now the lowest part of the highest track bit -
1980 * for sloped track, it is 'z' of lower part
1981 * for two track bits, it is 'z' of higher track bit
1982 * For non-continuous foundations (and STEEP_BOTH), 'half' is set */
1983 if (z > GetSnowLine()) {
1984 if (half && z - GetSnowLine() == TILE_HEIGHT) {
1985 /* track on non-continuous foundation, lower part is not under snow */
1986 new_ground = RAIL_GROUND_HALF_SNOW;
1987 } else {
1988 new_ground = RAIL_GROUND_ICE_DESERT;
1989 }
1940 goto set_ground; 1990 goto set_ground;
1941 } 1991 }
1942 break; 1992 break;
1993 }
1943 1994
1944 case LT_TROPIC: 1995 case LT_TROPIC:
1945 if (GetTropicZone(tile) == TROPICZONE_DESERT) { 1996 if (GetTropicZone(tile) == TROPICZONE_DESERT) {
1946 new_ground = RAIL_GROUND_ICE_DESERT; 1997 new_ground = RAIL_GROUND_ICE_DESERT;
1947 goto set_ground; 1998 goto set_ground;