ai/default/default.c
changeset 2737 f16e0a808897
parent 2684 8aba54c245cc
child 2753 15012faaa68a
equal deleted inserted replaced
2736:1ea068235989 2737:f16e0a808897
  1675 
  1675 
  1676 	for (i = 0; (p = _default_rail_track_data[i]) != NULL; i++) {
  1676 	for (i = 0; (p = _default_rail_track_data[i]) != NULL; i++) {
  1677 		if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 &&
  1677 		if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 &&
  1678 				(p->dir == 0xFF || p->dir == dir || ((p->dir - 1) & 3) == dir)) {
  1678 				(p->dir == 0xFF || p->dir == dir || ((p->dir - 1) & 3) == dir)) {
  1679 			*cost = AiDoBuildDefaultRailTrack(tile, p->data, DC_NO_TOWN_RATING);
  1679 			*cost = AiDoBuildDefaultRailTrack(tile, p->data, DC_NO_TOWN_RATING);
  1680 			if (*cost != CMD_ERROR && AiCheckTrackResources(tile, p->data, cargo))
  1680 			if (!CmdFailed(*cost) && AiCheckTrackResources(tile, p->data, cargo))
  1681 				return i;
  1681 				return i;
  1682 		}
  1682 		}
  1683 	}
  1683 	}
  1684 
  1684 
  1685 	return -1;
  1685 	return -1;
  1802 				r = AiDoBuildDefaultRailTrack(
  1802 				r = AiDoBuildDefaultRailTrack(
  1803 					aib->use_tile,
  1803 					aib->use_tile,
  1804 					_default_rail_track_data[rule]->data,
  1804 					_default_rail_track_data[rule]->data,
  1805 					DC_EXEC | DC_NO_TOWN_RATING
  1805 					DC_EXEC | DC_NO_TOWN_RATING
  1806 				);
  1806 				);
  1807 				assert(r != CMD_ERROR);
  1807 				assert(!CmdFailed(r));
  1808 			}
  1808 			}
  1809 		} while (++aib,--j);
  1809 		} while (++aib,--j);
  1810 	}
  1810 	}
  1811 
  1811 
  1812 	// check if we're done with all of them
  1812 	// check if we're done with all of them
  2527 	_want_road_truck_station = (cargo & 0x7F) != CT_PASSENGERS;
  2527 	_want_road_truck_station = (cargo & 0x7F) != CT_PASSENGERS;
  2528 
  2528 
  2529 	for(i=0; (p = _road_default_block_data[i]) != NULL; i++) {
  2529 	for(i=0; (p = _road_default_block_data[i]) != NULL; i++) {
  2530 		if (p->dir == direction) {
  2530 		if (p->dir == direction) {
  2531 			*cost = AiDoBuildDefaultRoadBlock(tile, p->data, 0);
  2531 			*cost = AiDoBuildDefaultRoadBlock(tile, p->data, 0);
  2532 			if (*cost != CMD_ERROR && AiCheckRoadResources(tile, p->data, cargo))
  2532 			if (!CmdFailed(*cost) && AiCheckRoadResources(tile, p->data, cargo))
  2533 				return i;
  2533 				return i;
  2534 		}
  2534 		}
  2535 	}
  2535 	}
  2536 
  2536 
  2537 	return -1;
  2537 	return -1;
  2688 				r = AiDoBuildDefaultRoadBlock(
  2688 				r = AiDoBuildDefaultRoadBlock(
  2689 					aib->use_tile,
  2689 					aib->use_tile,
  2690 					_road_default_block_data[rule]->data,
  2690 					_road_default_block_data[rule]->data,
  2691 					DC_EXEC | DC_NO_TOWN_RATING
  2691 					DC_EXEC | DC_NO_TOWN_RATING
  2692 				);
  2692 				);
  2693 				assert(r != CMD_ERROR);
  2693 				assert(!CmdFailed(r));
  2694 			}
  2694 			}
  2695 		} while (++aib,--j);
  2695 		} while (++aib,--j);
  2696 	} while (--i);
  2696 	} while (--i);
  2697 
  2697 
  2698 	// check if we're done with all of them
  2698 	// check if we're done with all of them
  3390 		// airports where they can't land.
  3390 		// airports where they can't land.
  3391 		if (heli && GetAirport(p->attr)->acc_planes == AIRCRAFT_ONLY)
  3391 		if (heli && GetAirport(p->attr)->acc_planes == AIRCRAFT_ONLY)
  3392 			continue;
  3392 			continue;
  3393 
  3393 
  3394 		*cost = AiDoBuildDefaultAirportBlock(tile, p, 0);
  3394 		*cost = AiDoBuildDefaultAirportBlock(tile, p, 0);
  3395 		if (*cost != CMD_ERROR && AiCheckAirportResources(tile, p, cargo))
  3395 		if (!CmdFailed(*cost) && AiCheckAirportResources(tile, p, cargo))
  3396 			return i;
  3396 			return i;
  3397 	}
  3397 	}
  3398 	return -1;
  3398 	return -1;
  3399 }
  3399 }
  3400 
  3400 
  3461 				r = AiDoBuildDefaultAirportBlock(
  3461 				r = AiDoBuildDefaultAirportBlock(
  3462 					aib->use_tile,
  3462 					aib->use_tile,
  3463 					_airport_default_block_data[rule],
  3463 					_airport_default_block_data[rule],
  3464 					DC_EXEC | DC_NO_TOWN_RATING
  3464 					DC_EXEC | DC_NO_TOWN_RATING
  3465 				);
  3465 				);
  3466 				assert(r != CMD_ERROR);
  3466 				assert(!CmdFailed(r));
  3467 			}
  3467 			}
  3468 		} while (++aib,--j);
  3468 		} while (++aib,--j);
  3469 	} while (--i);
  3469 	} while (--i);
  3470 
  3470 
  3471 	// check if we're done with all of them
  3471 	// check if we're done with all of them