summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-12-09 18:18:21 +0000
committertron <tron@openttd.org>2004-12-09 18:18:21 +0000
commit93a4dbda4b10d8b26c575e4b16d4505ea881dae5 (patch)
tree61737620ce9f1ffcb58760a5a831d53da23627b6 /vehicle.c
parent4a818ecbb6288870fda43144fe33717dc29ca089 (diff)
downloadopenttd-93a4dbda4b10d8b26c575e4b16d4505ea881dae5.tar.xz
(svn r990) Fix a display bug in the order list:
TTD stores invalid orders different than OTTD, this resulted in empty lines in the order list. With the overhaul of the order system this got worse: no line was shown at all. Fix this by sanity checking while loading and convert the orders accordingly.
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/vehicle.c b/vehicle.c
index 003eca6c4..ceb164407 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -16,6 +16,24 @@
#define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
+Order UnpackOldOrder(uint16 packed)
+{
+ Order order;
+ order.type = (packed & 0x000f);
+ order.flags = (packed & 0x00f0) >> 4,
+ order.station = (packed & 0xff00) >> 8;
+
+ // Sanity check
+ // TTD stores invalid orders as OT_NOTHING with non-zero flags/station
+ if (order.type == OT_NOTHING && (order.flags != 0 || order.station != 0)) {
+ order.type = OT_DUMMY;
+ order.flags = 0;
+ }
+
+ return order;
+}
+
+
void VehicleInTheWayErrMsg(Vehicle *v)
{
StringID id;
@@ -1896,7 +1914,7 @@ static void Load_ORDR()
SlArray(orders, len, SLE_UINT16);
for (i = 0; i < len; ++i)
- _order_array[i] = UnpackOrder(orders[i]);
+ _order_array[i] = UnpackOldOrder(orders[i]);
}
const ChunkHandler _veh_chunk_handlers[] = {