order_gui.c
changeset 4389 18d6ccfb5335
parent 4351 c9799dd53eec
child 4408 db2afc41002a
equal deleted inserted replaced
4388:c8a66d26e146 4389:18d6ccfb5335
   132 			SetDParam(1, 6);
   132 			SetDParam(1, 6);
   133 
   133 
   134 			switch (order->type) {
   134 			switch (order->type) {
   135 				case OT_GOTO_STATION:
   135 				case OT_GOTO_STATION:
   136 					SetDParam(1, StationOrderStrings[order->flags]);
   136 					SetDParam(1, StationOrderStrings[order->flags]);
   137 					SetDParam(2, order->station);
   137 					SetDParam(2, order->dest.station);
   138 					break;
   138 					break;
   139 
   139 
   140 				case OT_GOTO_DEPOT: {
   140 				case OT_GOTO_DEPOT: {
   141 					StringID s = STR_NULL;
   141 					StringID s = STR_NULL;
   142 
   142 
   143 					if (v->type == VEH_Aircraft) {
   143 					if (v->type == VEH_Aircraft) {
   144 						s = STR_GO_TO_AIRPORT_HANGAR;
   144 						s = STR_GO_TO_AIRPORT_HANGAR;
   145 						SetDParam(2, order->station);
   145 						SetDParam(2, order->dest.depot);
   146 					} else {
   146 					} else {
   147 						SetDParam(2, GetDepot(order->station)->town_index);
   147 						SetDParam(2, GetDepot(order->dest.depot)->town_index);
   148 
   148 
   149 						switch (v->type) {
   149 						switch (v->type) {
   150 							case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
   150 							case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
   151 							case VEH_Road:  s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
   151 							case VEH_Road:  s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
   152 							case VEH_Ship:  s = STR_GO_TO_SHIP_DEPOT; break;
   152 							case VEH_Ship:  s = STR_GO_TO_SHIP_DEPOT; break;
   160 					break;
   160 					break;
   161 				}
   161 				}
   162 
   162 
   163 				case OT_GOTO_WAYPOINT:
   163 				case OT_GOTO_WAYPOINT:
   164 					SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
   164 					SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
   165 					SetDParam(2, order->station);
   165 					SetDParam(2, order->dest.waypoint);
   166 					break;
   166 					break;
   167 
   167 
   168 				default: break;
   168 				default: break;
   169 			}
   169 			}
   170 
   170 
   172 			SetDParam(0, i + 1);
   172 			SetDParam(0, i + 1);
   173 			if (order->type != OT_DUMMY) {
   173 			if (order->type != OT_DUMMY) {
   174 				DrawString(2, y, str, color);
   174 				DrawString(2, y, str, color);
   175 			} else {
   175 			} else {
   176 				SetDParam(1, STR_INVALID_ORDER);
   176 				SetDParam(1, STR_INVALID_ORDER);
   177 				SetDParam(2, order->station);
   177 				SetDParam(2, order->dest.station);
   178 				DrawString(2, y, str, color);
   178 				DrawString(2, y, str, color);
   179 			}
   179 			}
   180 			y += 10;
   180 			y += 10;
   181 		}
   181 		}
   182 
   182 
   203 		case MP_RAILWAY:
   203 		case MP_RAILWAY:
   204 			if (v->type == VEH_Train && IsTileOwner(tile, _local_player)) {
   204 			if (v->type == VEH_Train && IsTileOwner(tile, _local_player)) {
   205 				if (IsRailDepot(tile)) {
   205 				if (IsRailDepot(tile)) {
   206 					order.type = OT_GOTO_DEPOT;
   206 					order.type = OT_GOTO_DEPOT;
   207 					order.flags = OF_PART_OF_ORDERS;
   207 					order.flags = OF_PART_OF_ORDERS;
   208 					order.station = GetDepotByTile(tile)->index;
   208 					order.dest.depot = GetDepotByTile(tile)->index;
   209 					return order;
   209 					return order;
   210 				}
   210 				}
   211 			}
   211 			}
   212 			break;
   212 			break;
   213 
   213 
   214 		case MP_STREET:
   214 		case MP_STREET:
   215 			if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
   215 			if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
   216 				order.type = OT_GOTO_DEPOT;
   216 				order.type = OT_GOTO_DEPOT;
   217 				order.flags = OF_PART_OF_ORDERS;
   217 				order.flags = OF_PART_OF_ORDERS;
   218 				order.station = GetDepotByTile(tile)->index;
   218 				order.dest.depot = GetDepotByTile(tile)->index;
   219 				return order;
   219 				return order;
   220 			}
   220 			}
   221 			break;
   221 			break;
   222 
   222 
   223 		case MP_STATION:
   223 		case MP_STATION:
   224 			if (v->type != VEH_Aircraft) break;
   224 			if (v->type != VEH_Aircraft) break;
   225 			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
   225 			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
   226 				order.type = OT_GOTO_DEPOT;
   226 				order.type = OT_GOTO_DEPOT;
   227 				order.flags = OF_PART_OF_ORDERS;
   227 				order.flags = OF_PART_OF_ORDERS;
   228 				order.station = GetStationIndex(tile);
   228 				order.dest.station = GetStationIndex(tile);
   229 				return order;
   229 				return order;
   230 			}
   230 			}
   231 			break;
   231 			break;
   232 
   232 
   233 		case MP_WATER:
   233 		case MP_WATER:
   236 					IsTileOwner(tile, _local_player)) {
   236 					IsTileOwner(tile, _local_player)) {
   237 				TileIndex tile2 = GetOtherShipDepotTile(tile);
   237 				TileIndex tile2 = GetOtherShipDepotTile(tile);
   238 
   238 
   239 				order.type = OT_GOTO_DEPOT;
   239 				order.type = OT_GOTO_DEPOT;
   240 				order.flags = OF_PART_OF_ORDERS;
   240 				order.flags = OF_PART_OF_ORDERS;
   241 				order.station = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
   241 				order.dest.depot = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
   242 				return order;
   242 				return order;
   243 			}
   243 			}
   244 
   244 
   245 			default:
   245 			default:
   246 				break;
   246 				break;
   252 			v->type == VEH_Train &&
   252 			v->type == VEH_Train &&
   253 			IsTileOwner(tile, _local_player) &&
   253 			IsTileOwner(tile, _local_player) &&
   254 			IsRailWaypoint(tile)) {
   254 			IsRailWaypoint(tile)) {
   255 		order.type = OT_GOTO_WAYPOINT;
   255 		order.type = OT_GOTO_WAYPOINT;
   256 		order.flags = 0;
   256 		order.flags = 0;
   257 		order.station = GetWaypointByTile(tile)->index;
   257 		order.dest.waypoint = GetWaypointByTile(tile)->index;
   258 		return order;
   258 		return order;
   259 	}
   259 	}
   260 
   260 
   261 	if (IsTileType(tile, MP_STATION)) {
   261 	if (IsTileType(tile, MP_STATION)) {
   262 		StationID st_index = GetStationIndex(tile);
   262 		StationID st_index = GetStationIndex(tile);
   270 			(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) ||
   270 			(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) ||
   271 			(facil=FACIL_TRUCK_STOP, 1);
   271 			(facil=FACIL_TRUCK_STOP, 1);
   272 			if (st->facilities & facil) {
   272 			if (st->facilities & facil) {
   273 				order.type = OT_GOTO_STATION;
   273 				order.type = OT_GOTO_STATION;
   274 				order.flags = 0;
   274 				order.flags = 0;
   275 				order.station = st_index;
   275 				order.dest.station = st_index;
   276 				return order;
   276 				return order;
   277 			}
   277 			}
   278 		}
   278 		}
   279 	}
   279 	}
   280 
   280 
   281 	// not found
   281 	// not found
   282 	order.type = OT_NOTHING;
   282 	order.type = OT_NOTHING;
   283 	order.flags = 0;
   283 	order.flags = 0;
   284 	order.station = INVALID_STATION;
   284 	order.dest.station = INVALID_STATION;
   285 	return order;
   285 	return order;
   286 }
   286 }
   287 
   287 
   288 static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
   288 static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
   289 {
   289 {
   408 			if (_ctrl_pressed && sel < v->num_orders) {
   408 			if (_ctrl_pressed && sel < v->num_orders) {
   409 				const Order *ord = GetVehicleOrder(v, sel);
   409 				const Order *ord = GetVehicleOrder(v, sel);
   410 				TileIndex xy;
   410 				TileIndex xy;
   411 
   411 
   412 				switch (ord->type) {
   412 				switch (ord->type) {
   413 					case OT_GOTO_STATION:  xy = GetStation(ord->station)->xy ; break;
   413 					case OT_GOTO_STATION:  xy = GetStation(ord->dest.station)->xy ; break;
   414 					case OT_GOTO_DEPOT:    xy = GetDepot(ord->station)->xy;    break;
   414 					case OT_GOTO_DEPOT:    xy = GetDepot(ord->dest.depot)->xy;    break;
   415 					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break;
   415 					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest.waypoint)->xy; break;
   416 					default:               xy = 0; break;
   416 					default:               xy = 0; break;
   417 				}
   417 				}
   418 
   418 
   419 				if (xy != 0) ScrollMainWindowToTile(xy);
   419 				if (xy != 0) ScrollMainWindowToTile(xy);
   420 				return;
   420 				return;