mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
This commit is contained in:
parent
e95e887772
commit
7860d8d18a
|
@ -2140,17 +2140,30 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
|
|
||||||
if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)];
|
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;
|
|
||||||
} else {
|
|
||||||
image += total_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* station_land array has been increased from 82 elements to 114
|
if (IsBuoy(ti->tile) || IsDock(ti->tile)) {
|
||||||
* but this is something else. If AI builds station with 114 it looks all weird */
|
if (ti->tileh == SLOPE_FLAT) {
|
||||||
DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
|
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 {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
|
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
|
||||||
|
|
||||||
|
@ -2160,18 +2173,9 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
|
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;
|
const DrawTileSeqStruct *dtss;
|
||||||
foreach_draw_tile_seq(dtss, t->seq) {
|
foreach_draw_tile_seq(dtss, t->seq) {
|
||||||
image = dtss->image;
|
SpriteID image = dtss->image;
|
||||||
if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
|
if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
|
||||||
image += total_offset;
|
image += total_offset;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,8 +11,7 @@ bool FloodHalftile(TileIndex t);
|
||||||
void ConvertGroundTilesIntoWaterTiles();
|
void ConvertGroundTilesIntoWaterTiles();
|
||||||
|
|
||||||
void DrawShipDepotSprite(int x, int y, int image);
|
void DrawShipDepotSprite(int x, int y, int image);
|
||||||
void DrawCanalWater(TileIndex tile, bool draw_base);
|
void DrawWaterClassGround(const struct TileInfo *ti);
|
||||||
void DrawRiverWater(const struct TileInfo *ti, bool draw_base);
|
|
||||||
void DrawShoreTile(Slope tileh);
|
void DrawShoreTile(Slope tileh);
|
||||||
|
|
||||||
void MakeWaterKeepingClass(TileIndex tile, Owner o);
|
void MakeWaterKeepingClass(TileIndex tile, Owner o);
|
||||||
|
|
|
@ -542,15 +542,15 @@ static void DrawWaterEdges(SpriteID base, TileIndex tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Draw a plain sea water tile with no edges */
|
/** 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);
|
DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** draw a canal styled water tile with dikes around */
|
/** 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 */
|
/* Test for custom graphics, else use the default */
|
||||||
SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile);
|
SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile);
|
||||||
|
@ -568,7 +568,7 @@ struct LocksDrawTileStruct {
|
||||||
#include "table/water_land.h"
|
#include "table/water_land.h"
|
||||||
|
|
||||||
static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
|
static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
|
||||||
SpriteID palette, uint base
|
SpriteID palette, uint base, bool draw_ground
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
SpriteID image;
|
SpriteID image;
|
||||||
|
@ -586,7 +586,7 @@ static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
|
||||||
|
|
||||||
image = wdts++->image;
|
image = wdts++->image;
|
||||||
if (image < 4) image += water_base;
|
if (image < 4) image += water_base;
|
||||||
DrawGroundSprite(image, PAL_NONE);
|
if (draw_ground) DrawGroundSprite(image, PAL_NONE);
|
||||||
|
|
||||||
for (; wdts->delta_x != 0x80; wdts++) {
|
for (; wdts->delta_x != 0x80; wdts++) {
|
||||||
AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette,
|
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 image = SPR_FLAT_WATER_TILE;
|
||||||
SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->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. */
|
/* Draw river edges if available. */
|
||||||
if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile);
|
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);
|
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)
|
static void DrawTile_Water(TileInfo *ti)
|
||||||
{
|
{
|
||||||
switch (GetWaterTileType(ti->tile)) {
|
switch (GetWaterTileType(ti->tile)) {
|
||||||
case WATER_TILE_CLEAR:
|
case WATER_TILE_CLEAR:
|
||||||
switch (GetWaterClass(ti->tile)) {
|
DrawWaterClassGround(ti);
|
||||||
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;
|
|
||||||
}
|
|
||||||
DrawBridgeMiddle(ti);
|
DrawBridgeMiddle(ti);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -665,11 +669,12 @@ static void DrawTile_Water(TileInfo *ti)
|
||||||
|
|
||||||
case WATER_TILE_LOCK: {
|
case WATER_TILE_LOCK: {
|
||||||
const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)];
|
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;
|
} break;
|
||||||
|
|
||||||
case WATER_TILE_DEPOT:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue