summaryrefslogtreecommitdiff
path: root/src/newgrf_station.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-04-01 19:55:56 +0000
committeryexo <yexo@openttd.org>2011-04-01 19:55:56 +0000
commita980319801448c9c8df2c4e819f5a9ba307f1ca2 (patch)
tree43fce9840da597840ca608b084229758106d81f1 /src/newgrf_station.cpp
parentd16ca328157fbd036e68244ac873e2d29d0be6d4 (diff)
downloadopenttd-a980319801448c9c8df2c4e819f5a9ba307f1ca2.tar.xz
(svn r22286) -Fix: [NewGRF] the c and p parts of station vars 40, 41 and 49 were incorrect for large stations
Diffstat (limited to 'src/newgrf_station.cpp')
-rw-r--r--src/newgrf_station.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 768e0085c..06216df69 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -110,24 +110,21 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i
Swap(x, y);
}
- /* Limit our sizes to 4 bits */
- platforms = min(15, platforms);
- length = min(15, length);
- x = min(15, x);
- y = min(15, y);
if (centred) {
x -= platforms / 2;
y -= length / 2;
+ x = Clamp(x, -8, 7);
+ y = Clamp(x, -8, 7);
SB(retval, 0, 4, y & 0xF);
SB(retval, 4, 4, x & 0xF);
} else {
- SB(retval, 0, 4, y);
- SB(retval, 4, 4, length - y - 1);
- SB(retval, 8, 4, x);
- SB(retval, 12, 4, platforms - x - 1);
+ SB(retval, 0, 4, min(15, y));
+ SB(retval, 4, 4, min(15, length - y - 1));
+ SB(retval, 8, 4, min(15, x));
+ SB(retval, 12, 4, min(15, platforms - x - 1));
}
- SB(retval, 16, 4, length);
- SB(retval, 20, 4, platforms);
+ SB(retval, 16, 4, min(15, length));
+ SB(retval, 20, 4, min(15, platforms));
SB(retval, 24, 4, tile);
return retval;