comparison src/order_cmd.cpp @ 6329:34db8eef99ef draft

(svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
author peter1138 <peter1138@openttd.org>
date Sun, 18 Mar 2007 22:07:44 +0000
parents 715aa17970ab
children aacb290b6c73
comparison
equal deleted inserted replaced
6328:41239cc1907e 6329:34db8eef99ef
13 #include "station.h" 13 #include "station.h"
14 #include "player.h" 14 #include "player.h"
15 #include "news.h" 15 #include "news.h"
16 #include "saveload.h" 16 #include "saveload.h"
17 #include "vehicle_gui.h" 17 #include "vehicle_gui.h"
18 #include "cargotype.h"
18 19
19 /** 20 /**
20 * Called if a new block is added to the order-pool 21 * Called if a new block is added to the order-pool
21 */ 22 */
22 static void OrderPoolNewBlock(uint start_item) 23 static void OrderPoolNewBlock(uint start_item)
216 case VEH_TRAIN: 217 case VEH_TRAIN:
217 if (!(st->facilities & FACIL_TRAIN)) return CMD_ERROR; 218 if (!(st->facilities & FACIL_TRAIN)) return CMD_ERROR;
218 break; 219 break;
219 220
220 case VEH_ROAD: 221 case VEH_ROAD:
221 if (v->cargo_type == CT_PASSENGERS) { 222 if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
222 if (!(st->facilities & FACIL_BUS_STOP)) return CMD_ERROR; 223 if (!(st->facilities & FACIL_BUS_STOP)) return CMD_ERROR;
223 } else { 224 } else {
224 if (!(st->facilities & FACIL_TRUCK_STOP)) return CMD_ERROR; 225 if (!(st->facilities & FACIL_TRUCK_STOP)) return CMD_ERROR;
225 } 226 }
226 break; 227 break;
683 if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src) 684 if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src)
684 return CMD_ERROR; 685 return CMD_ERROR;
685 686
686 /* Trucks can't share orders with busses (and visa versa) */ 687 /* Trucks can't share orders with busses (and visa versa) */
687 if (src->type == VEH_ROAD) { 688 if (src->type == VEH_ROAD) {
688 if (src->cargo_type != dst->cargo_type && (src->cargo_type == CT_PASSENGERS || dst->cargo_type == CT_PASSENGERS)) 689 if (src->cargo_type != dst->cargo_type && (IsCargoInClass(src->cargo_type, CC_PASSENGERS) || IsCargoInClass(dst->cargo_type, CC_PASSENGERS)))
689 return CMD_ERROR; 690 return CMD_ERROR;
690 } 691 }
691 692
692 /* Is the vehicle already in the shared list? */ 693 /* Is the vehicle already in the shared list? */
693 { 694 {
736 TileIndex required_dst = INVALID_TILE; 737 TileIndex required_dst = INVALID_TILE;
737 738
738 FOR_VEHICLE_ORDERS(src, order) { 739 FOR_VEHICLE_ORDERS(src, order) {
739 if (order->type == OT_GOTO_STATION) { 740 if (order->type == OT_GOTO_STATION) {
740 const Station *st = GetStation(order->dest); 741 const Station *st = GetStation(order->dest);
741 if (dst->cargo_type == CT_PASSENGERS) { 742 if (IsCargoInClass(dst->cargo_type, CC_PASSENGERS)) {
742 if (st->bus_stops != NULL) required_dst = st->bus_stops->xy; 743 if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
743 } else { 744 } else {
744 if (st->truck_stops != NULL) required_dst = st->truck_stops->xy; 745 if (st->truck_stops != NULL) required_dst = st->truck_stops->xy;
745 } 746 }
746 /* This station has not the correct road-bay, so we can't copy! */ 747 /* This station has not the correct road-bay, so we can't copy! */
951 default: NOT_REACHED(); 952 default: NOT_REACHED();
952 case VEH_TRAIN: return st->train_tile; 953 case VEH_TRAIN: return st->train_tile;
953 case VEH_AIRCRAFT: return st->airport_tile; 954 case VEH_AIRCRAFT: return st->airport_tile;
954 case VEH_SHIP: return st->dock_tile; 955 case VEH_SHIP: return st->dock_tile;
955 case VEH_ROAD: 956 case VEH_ROAD:
956 if (v->cargo_type == CT_PASSENGERS) { 957 if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
957 return (st->bus_stops != NULL) ? st->bus_stops->xy : 0; 958 return (st->bus_stops != NULL) ? st->bus_stops->xy : 0;
958 } else { 959 } else {
959 return (st->truck_stops != NULL) ? st->truck_stops->xy : 0; 960 return (st->truck_stops != NULL) ? st->truck_stops->xy : 0;
960 } 961 }
961 } 962 }