summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-02-06 16:12:23 +0000
committerfrosch <frosch@openttd.org>2008-02-06 16:12:23 +0000
commit113525c40b60e8e9a9ac19af16b421af08e949a8 (patch)
tree424c0effec495435001f65997bc895e2bb70ed9c
parent9b2ca61044df8bf90db74f07ceaa9a7b71df2542 (diff)
downloadopenttd-113525c40b60e8e9a9ac19af16b421af08e949a8.tar.xz
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
-rw-r--r--src/station_cmd.cpp42
-rw-r--r--src/water.h3
-rw-r--r--src/water_cmd.cpp33
3 files changed, 43 insertions, 35 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 538c68b72..8a60d740c 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2140,18 +2140,31 @@ static void DrawTile_Station(TileInfo *ti)
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 @@ static void DrawTile_Station(TileInfo *ti)
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 {
diff --git a/src/water.h b/src/water.h
index 3eecc15f4..2ed54856b 100644
--- a/src/water.h
+++ b/src/water.h
@@ -11,8 +11,7 @@ bool FloodHalftile(TileIndex t);
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);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index f569412a1..de620a9e2 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -542,15 +542,15 @@ static void DrawWaterEdges(SpriteID base, TileIndex tile)
}
/** 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 @@ struct LocksDrawTileStruct {
#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 @@ static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
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 @@ static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
}
}
-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 @@ void DrawRiverWater(const TileInfo *ti, bool draw_base)
}
}
- 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 @@ void DrawShoreTile(Slope tileh)
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 @@ static void DrawTile_Water(TileInfo *ti)
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;
}
}