(svn r1801) -Fix [Multistop] Fixed a crash that occured when copying orders due to not checking a pointer to be non-NULL
authorcelestar
Sat, 05 Feb 2005 15:05:52 +0000
changeset 1297 c828ac28760b
parent 1296 28cbaedf9f93
child 1298 d4aee03d99ae
(svn r1801) -Fix [Multistop] Fixed a crash that occured when copying orders due to not checking a pointer to be non-NULL
order_cmd.c
--- a/order_cmd.c	Sat Feb 05 14:18:25 2005 +0000
+++ b/order_cmd.c	Sat Feb 05 15:05:52 2005 +0000
@@ -485,14 +485,18 @@
 			/* Trucks can't copy all the orders from busses (and visa versa) */
 			if (src->type == VEH_Road) {
 				const Order *order;
-				TileIndex required_dst;
+				TileIndex required_dst = INVALID_TILE;
 
 				FOR_VEHICLE_ORDERS(src, order) {
 					if (order->type == OT_GOTO_STATION) {
 						const Station *st = GetStation(order->station);
-						required_dst = (dst->cargo_type == CT_PASSENGERS) ? st->bus_stops->xy : st->truck_stops->xy;
+						if (dst->cargo_type == CT_PASSENGERS) {
+							if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
+						} else {
+							if (st->truck_stops != NULL) required_dst = st->truck_stops->xy;
+						}
 						/* This station has not the correct road-bay, so we can't copy! */
-						if (!required_dst)
+						if (required_dst == INVALID_TILE)
 							return CMD_ERROR;
 					}
 				}