diff options
author | frosch <frosch@openttd.org> | 2009-06-07 13:25:21 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-06-07 13:25:21 +0000 |
commit | 8745a309718b5241893c02425e01172212482dc6 (patch) | |
tree | 8b81a66f8bfb250f7a9552b9447c057c2a829ce8 /src | |
parent | 0c10006907b7d149f91d277a0c28a79b40eaa4c0 (diff) | |
download | openttd-8745a309718b5241893c02425e01172212482dc6.tar.xz |
(svn r16528) -Fix [FS#2959]: Draw PBS reservation as groundsprite resp. childsprite of foundation/bridgehead.
Diffstat (limited to 'src')
-rw-r--r-- | src/rail_cmd.cpp | 15 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 5 | ||||
-rw-r--r-- | src/viewport.cpp | 32 | ||||
-rw-r--r-- | src/viewport_func.h | 4 |
4 files changed, 30 insertions, 26 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 64be2e900..2f280aac2 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1792,7 +1792,8 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track) /* PBS debugging, draw reserved tracks darker */ if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation) { - TrackBits pbs = GetTrackReservation(ti->tile); + /* Get reservation, but mask track on halftile slope */ + TrackBits pbs = GetTrackReservation(ti->tile) & track; if (pbs & TRACK_BIT_X) { if (ti->tileh == SLOPE_FLAT || ti->tileh == SLOPE_ELEVATED) { DrawGroundSprite(rti->base_sprites.single_y, PALETTE_CRASH); @@ -1807,10 +1808,10 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track) DrawGroundSprite(_track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.single_sloped - 20, PALETTE_CRASH); } } - if (pbs & TRACK_BIT_UPPER) AddSortableSpriteToDraw(rti->base_sprites.single_n, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_N ? 8 : 0)); - if (pbs & TRACK_BIT_LOWER) AddSortableSpriteToDraw(rti->base_sprites.single_s, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_S ? 8 : 0)); - if (pbs & TRACK_BIT_LEFT) AddSortableSpriteToDraw(rti->base_sprites.single_w, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_W ? 8 : 0)); - if (pbs & TRACK_BIT_RIGHT) AddSortableSpriteToDraw(rti->base_sprites.single_e, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_E ? 8 : 0)); + if (pbs & TRACK_BIT_UPPER) DrawGroundSprite(rti->base_sprites.single_n, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_N ? -TILE_HEIGHT : 0); + if (pbs & TRACK_BIT_LOWER) DrawGroundSprite(rti->base_sprites.single_s, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_S ? -TILE_HEIGHT : 0); + if (pbs & TRACK_BIT_LEFT) DrawGroundSprite(rti->base_sprites.single_w, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_W ? -TILE_HEIGHT : 0); + if (pbs & TRACK_BIT_RIGHT) DrawGroundSprite(rti->base_sprites.single_e, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_E ? -TILE_HEIGHT : 0); } if (IsValidCorner(halftile_corner)) { @@ -1828,9 +1829,9 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track) } DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner])); - if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && IsSteepSlope(ti->tileh) && HasReservedTracks(ti->tile, CornerToTrackBits(halftile_corner))) { + if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasReservedTracks(ti->tile, CornerToTrackBits(halftile_corner))) { static const byte _corner_to_track_sprite[] = {3, 1, 2, 0}; - AddSortableSpriteToDraw(_corner_to_track_sprite[halftile_corner] + rti->base_sprites.single_n, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 16); + DrawGroundSprite(_corner_to_track_sprite[halftile_corner] + rti->base_sprites.single_n, PALETTE_CRASH, NULL, 0, -TILE_HEIGHT); } } } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 5d769053f..1f4272c6c 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -995,8 +995,8 @@ static void DrawTile_TunnelBridge(TileInfo *ti) /* draw ramp */ - /* Draw Trambits as SpriteCombine */ - if (transport_type == TRANSPORT_ROAD) StartSpriteCombine(); + /* Draw Trambits and PBS Reservation as SpriteCombine */ + if (transport_type == TRANSPORT_ROAD || transport_type == TRANSPORT_RAIL) StartSpriteCombine(); /* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on * it doesn't disappear behind it @@ -1030,6 +1030,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti) } EndSpriteCombine(); } else if (transport_type == TRANSPORT_RAIL) { + EndSpriteCombine(); if (HasCatenaryDrawn(GetRailType(ti->tile))) { DrawCatenary(ti); } diff --git a/src/viewport.cpp b/src/viewport.cpp index 3fac8bda6..e9be650a2 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -60,9 +60,8 @@ struct TileSpriteToDraw { SpriteID image; SpriteID pal; const SubSprite *sub; ///< only draw a rectangular part of the sprite - int32 x; - int32 y; - byte z; + int32 x; ///< screen X coordinate of sprite + int32 y; ///< screen Y coordinate of sprite }; struct ChildScreenSpriteToDraw { @@ -456,13 +455,15 @@ void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte * * @param image the image to draw. * @param pal the provided palette. - * @param x position x of the sprite. - * @param y position y of the sprite. - * @param z position z of the sprite. + * @param x position x (world coordinates) of the sprite. + * @param y position y (world coordinates) of the sprite. + * @param z position z (world coordinates) of the sprite. * @param sub Only draw a part of the sprite. + * @param extra_offs_x Pixel X offset for the sprite position. + * @param extra_offs_y Pixel Y offset for the sprite position. * */ -void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub) +void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub, int extra_offs_x, int extra_offs_y) { assert((image & SPRITE_MASK) < MAX_SPRITES); @@ -470,9 +471,9 @@ void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, ts->image = image; ts->pal = pal; ts->sub = sub; - ts->x = x; - ts->y = y; - ts->z = z; + Point pt = RemapCoords(x, y, z); + ts->x = pt.x + extra_offs_x; + ts->y = pt.y + extra_offs_y; } /** @@ -510,16 +511,18 @@ static void AddChildSpriteToFoundation(SpriteID image, SpriteID pal, const SubSp * @param image the image to draw. * @param pal the provided palette. * @param sub Only draw a part of the sprite. + * @param extra_offs_x Pixel X offset for the sprite position. + * @param extra_offs_y Pixel Y offset for the sprite position. */ -void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub) +void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y) { /* Switch to first foundation part, if no foundation was drawn */ if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL; if (_vd.foundation[_vd.foundation_part] != -1) { - AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, 0, 0); + AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, extra_offs_x, extra_offs_y); } else { - DrawGroundSpriteAt(image, pal, _cur_ti->x, _cur_ti->y, _cur_ti->z, sub); + DrawGroundSpriteAt(image, pal, _cur_ti->x, _cur_ti->y, _cur_ti->z, sub, extra_offs_x, extra_offs_y); } } @@ -1300,8 +1303,7 @@ static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv) { const TileSpriteToDraw *tsend = tstdv->End(); for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) { - Point pt = RemapCoords(ts->x, ts->y, ts->z); - DrawSprite(ts->image, ts->pal, pt.x, pt.y, ts->sub); + DrawSprite(ts->image, ts->pal, ts->x, ts->y, ts->sub); } } diff --git a/src/viewport_func.h b/src/viewport_func.h index f5c9c9410..601c5a574 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -33,8 +33,8 @@ static inline void MaxZoomInOut(int how, Window *w) void OffsetGroundSprite(int x, int y); -void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL); -void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL); +void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0); +void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0); void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL); void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 colour = 0, uint16 width = 0); void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL); |