Mercurial > hg > openttd
changeset 8496:1a19e49ad645 draft
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 06 Feb 2008 16:12:23 +0000 |
parents | 486b50380194 |
children | 722cc5446e37 |
files | src/station_cmd.cpp src/water.h src/water_cmd.cpp |
diffstat | 3 files changed, 43 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2140,18 +2140,31 @@ if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)]; - SpriteID image = t->ground_sprite; - if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { - image += GetCustomStationGroundRelocation(statspec, st, ti->tile); - image += custom_ground_offset; + + if (IsBuoy(ti->tile) || IsDock(ti->tile)) { + if (ti->tileh == SLOPE_FLAT) { + DrawWaterClassGround(ti); + } else { + assert(IsDock(ti->tile)); + TileIndex water_tile = ti->tile + TileOffsByDiagDir(GetDockDirection(ti->tile)); + WaterClass wc = GetWaterClass(water_tile); + if (wc == WATER_CLASS_SEA) { + DrawShoreTile(ti->tileh); + } else { + DrawClearLandTile(ti, 3); + } + } } else { - image += total_offset; + SpriteID image = t->ground_sprite; + if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { + image += GetCustomStationGroundRelocation(statspec, st, ti->tile); + image += custom_ground_offset; + } else { + image += total_offset; + } + DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE); } - /* station_land array has been increased from 82 elements to 114 - * but this is something else. If AI builds station with 114 it looks all weird */ - DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE); - if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti); if (HasBit(roadtypes, ROADTYPE_TRAM)) { @@ -2160,18 +2173,9 @@ DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y); } - if (IsBuoy(ti->tile)) { - /* Draw appropriate water edges */ - switch (GetWaterClass(ti->tile)) { - case WATER_CLASS_SEA: break; - case WATER_CLASS_CANAL: DrawCanalWater(ti->tile, false); break; - case WATER_CLASS_RIVER: DrawRiverWater(ti, false); break; - } - } - const DrawTileSeqStruct *dtss; foreach_draw_tile_seq(dtss, t->seq) { - image = dtss->image; + SpriteID image = dtss->image; if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { image += total_offset; } else {
--- a/src/water.h +++ b/src/water.h @@ -11,8 +11,7 @@ void ConvertGroundTilesIntoWaterTiles(); void DrawShipDepotSprite(int x, int y, int image); -void DrawCanalWater(TileIndex tile, bool draw_base); -void DrawRiverWater(const struct TileInfo *ti, bool draw_base); +void DrawWaterClassGround(const struct TileInfo *ti); void DrawShoreTile(Slope tileh); void MakeWaterKeepingClass(TileIndex tile, Owner o);
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -542,15 +542,15 @@ } /** Draw a plain sea water tile with no edges */ -void DrawSeaWater(TileIndex tile) +static void DrawSeaWater(TileIndex tile) { DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); } /** draw a canal styled water tile with dikes around */ -void DrawCanalWater(TileIndex tile, bool draw_base) +static void DrawCanalWater(TileIndex tile) { - if (draw_base) DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); + DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); /* Test for custom graphics, else use the default */ SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile); @@ -568,7 +568,7 @@ #include "table/water_land.h" static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts, - SpriteID palette, uint base + SpriteID palette, uint base, bool draw_ground ) { SpriteID image; @@ -586,7 +586,7 @@ image = wdts++->image; if (image < 4) image += water_base; - DrawGroundSprite(image, PAL_NONE); + if (draw_ground) DrawGroundSprite(image, PAL_NONE); for (; wdts->delta_x != 0x80; wdts++) { AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette, @@ -597,7 +597,7 @@ } } -void DrawRiverWater(const TileInfo *ti, bool draw_base) +static void DrawRiverWater(const TileInfo *ti) { SpriteID image = SPR_FLAT_WATER_TILE; SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->tile); @@ -623,7 +623,7 @@ } } - if (draw_base) DrawGroundSprite(image, PAL_NONE); + DrawGroundSprite(image, PAL_NONE); /* Draw river edges if available. */ if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile); @@ -646,15 +646,19 @@ DrawGroundSprite(SPR_SHORE_BASE + tileh_to_shoresprite[tileh], PAL_NONE); } +void DrawWaterClassGround(const TileInfo *ti) { + switch (GetWaterClass(ti->tile)) { + case WATER_CLASS_SEA: DrawSeaWater(ti->tile); break; + case WATER_CLASS_CANAL: DrawCanalWater(ti->tile); break; + case WATER_CLASS_RIVER: DrawRiverWater(ti); break; + } +} + static void DrawTile_Water(TileInfo *ti) { switch (GetWaterTileType(ti->tile)) { case WATER_TILE_CLEAR: - switch (GetWaterClass(ti->tile)) { - case WATER_CLASS_SEA: DrawSeaWater(ti->tile); break; - case WATER_CLASS_CANAL: DrawCanalWater(ti->tile, true); break; - case WATER_CLASS_RIVER: DrawRiverWater(ti, true); break; - } + DrawWaterClassGround(ti); DrawBridgeMiddle(ti); break; @@ -665,11 +669,12 @@ case WATER_TILE_LOCK: { const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)]; - DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0); + DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0, true); } break; case WATER_TILE_DEPOT: - DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0); + DrawWaterClassGround(ti); + DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false); break; } }