summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp5
-rw-r--r--src/roadveh_cmd.cpp6
-rw-r--r--src/ship_cmd.cpp5
-rw-r--r--src/train_cmd.cpp8
4 files changed, 21 insertions, 3 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 767b8531d..22a3872a5 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -200,7 +200,10 @@ static SpriteID GetAircraftIcon(EngineID engine)
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, SpriteID pal)
{
- DrawSprite(GetAircraftIcon(engine), pal, preferred_x, y);
+ SpriteID sprite = GetAircraftIcon(engine);
+ const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+ preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
+ DrawSprite(sprite, pal, preferred_x, y);
if (!(AircraftVehInfo(engine)->subtype & AIR_CTOL)) {
SpriteID rotor_sprite = GetCustomRotorIcon(engine);
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index b0a535d04..bbe258e84 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -36,6 +36,7 @@
#include "effectvehicle_func.h"
#include "roadstop_base.h"
#include "cargotype.h"
+#include "spritecache.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -140,7 +141,10 @@ SpriteID RoadVehicle::GetImage(Direction direction) const
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, SpriteID pal)
{
- DrawSprite(GetRoadVehIcon(engine), pal, preferred_x, y);
+ SpriteID sprite = GetRoadVehIcon(engine);
+ const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+ preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
+ DrawSprite(sprite, pal, preferred_x, y);
}
static uint GetRoadVehLength(const RoadVehicle *v)
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index d2bf6a7fb..c482539ab 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -70,7 +70,10 @@ static SpriteID GetShipIcon(EngineID engine)
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, SpriteID pal)
{
- DrawSprite(GetShipIcon(engine), pal, preferred_x, y);
+ SpriteID sprite = GetShipIcon(engine);
+ const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+ preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
+ DrawSprite(sprite, pal, preferred_x, y);
}
/** Get the size of the sprite of a ship sprite heading west (used for lists)
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index aa6c53fce..bd5205b6c 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -35,6 +35,7 @@
#include "effectvehicle_func.h"
#include "gamelog.h"
#include "network/network.h"
+#include "spritecache.h"
#include "table/strings.h"
#include "table/train_cmd.h"
@@ -665,10 +666,17 @@ void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engin
SpriteID spritef = GetRailIcon(engine, false, yf);
SpriteID spriter = GetRailIcon(engine, true, yr);
+ const Sprite *real_spritef = GetSprite(spritef, ST_NORMAL);
+ const Sprite *real_spriter = GetSprite(spriter, ST_NORMAL);
+
+ preferred_x = Clamp(preferred_x, left - real_spritef->x_offs + 14, right - real_spriter->width - real_spriter->x_offs - 15);
+
DrawSprite(spritef, pal, preferred_x - 14, yf);
DrawSprite(spriter, pal, preferred_x + 15, yr);
} else {
SpriteID sprite = GetRailIcon(engine, false, y);
+ const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+ preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
DrawSprite(sprite, pal, preferred_x, y);
}
}