Mercurial > hg > openttd
changeset 12115:6318d41ef9ef draft
(svn r16528) -Fix [FS#2959]: Draw PBS reservation as groundsprite resp. childsprite of foundation/bridgehead.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 07 Jun 2009 13:25:21 +0000 |
parents | f020ec6be498 |
children | 84e88a206e66 |
files | src/rail_cmd.cpp src/tunnelbridge_cmd.cpp src/viewport.cpp src/viewport_func.h |
diffstat | 4 files changed, 30 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1792,7 +1792,8 @@ /* 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 @@ 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 @@ } 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); } } }
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -995,8 +995,8 @@ /* 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 @@ } EndSpriteCombine(); } else if (transport_type == TRANSPORT_RAIL) { + EndSpriteCombine(); if (HasCatenaryDrawn(GetRailType(ti->tile))) { DrawCatenary(ti); }
--- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -60,9 +60,8 @@ 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 @@ * * @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 @@ 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 @@ * @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 @@ { 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); } }
--- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -33,8 +33,8 @@ 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);