summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-08-11 09:42:12 +0000
committerrubidium <rubidium@openttd.org>2006-08-11 09:42:12 +0000
commitbdb64325fd3eff1fdb61e189fcf3d901007a28fd (patch)
treed5638a072e8af1145cf6b5ae147e4bfb4ab94e86
parent811e79ba4c8f53f6db73eaabecbd221488762cb8 (diff)
downloadopenttd-bdb64325fd3eff1fdb61e189fcf3d901007a28fd.tar.xz
(svn r5841) -Fix r5794: use the height of the edge of the map for shadows of disasters that are outside the map
-rw-r--r--disaster_cmd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/disaster_cmd.c b/disaster_cmd.c
index 27ca9e29d..f34b1446f 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -116,7 +116,6 @@ static void DeleteDisasterVeh(Vehicle *v)
static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z)
{
Vehicle *u;
- int yt;
BeginVehicleMove(v);
v->x_pos = x;
@@ -129,11 +128,14 @@ static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z)
EndVehicleMove(v);
if ( (u=v->next) != NULL) {
+ int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
+ int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
BeginVehicleMove(u);
u->x_pos = x;
- u->y_pos = yt = y - 1 - (max(z - GetSlopeZ(x, y-1), 0) >> 3);
- u->z_pos = GetSlopeZ(x,yt);
+ u->y_pos = y - 1 - (max(z - GetSlopeZ(safe_x, safe_y), 0) >> 3);
+ safe_y = clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
+ u->z_pos = GetSlopeZ(safe_x, safe_y);
u->direction = v->direction;
DisasterVehicleUpdateImage(u);