summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-06-07 13:25:21 +0000
committerfrosch <frosch@openttd.org>2009-06-07 13:25:21 +0000
commit8745a309718b5241893c02425e01172212482dc6 (patch)
tree8b81a66f8bfb250f7a9552b9447c057c2a829ce8 /src/viewport.cpp
parent0c10006907b7d149f91d277a0c28a79b40eaa4c0 (diff)
downloadopenttd-8745a309718b5241893c02425e01172212482dc6.tar.xz
(svn r16528) -Fix [FS#2959]: Draw PBS reservation as groundsprite resp. childsprite of foundation/bridgehead.
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r--src/viewport.cpp32
1 files changed, 17 insertions, 15 deletions
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);
}
}