equal
deleted
inserted
replaced
218 // We don't like roadconstructions, don't even true such a city |
218 // We don't like roadconstructions, don't even true such a city |
219 if (t->road_build_months != 0) return false; |
219 if (t->road_build_months != 0) return false; |
220 |
220 |
221 // Check if the rating in a city is high enough |
221 // Check if the rating in a city is high enough |
222 // If not, take a chance if we want to continue |
222 // If not, take a chance if we want to continue |
223 if (t->ratings[_current_player] < 0 && AI_CHANCE16(1,4)) return false; |
223 if (t->ratings[_current_player] < 0 && AI_CHANCE16(1, 4)) return false; |
224 |
224 |
225 if (t->max_pass - t->act_pass < AI_CHECKCITY_NEEDED_CARGO && !AI_CHANCE16(1,AI_CHECKCITY_CITY_CHANCE)) return false; |
225 if (t->max_pass - t->act_pass < AI_CHECKCITY_NEEDED_CARGO && !AI_CHANCE16(1, AI_CHECKCITY_CITY_CHANCE)) return false; |
226 |
226 |
227 // Check if we have build a station in this town the last 6 months |
227 // Check if we have build a station in this town the last 6 months |
228 // else we don't do it. This is done, because stat updates can be slow |
228 // else we don't do it. This is done, because stat updates can be slow |
229 // and sometimes it takes up to 4 months before the stats are corectly. |
229 // and sometimes it takes up to 4 months before the stats are corectly. |
230 // This way we don't get 12 busstations in one city of 100 population ;) |
230 // This way we don't get 12 busstations in one city of 100 population ;) |
273 const Industry* i = GetIndustry(ic); |
273 const Industry* i = GetIndustry(ic); |
274 const Station* st; |
274 const Station* st; |
275 int count = 0; |
275 int count = 0; |
276 int j = 0; |
276 int j = 0; |
277 |
277 |
278 if (i->town != NULL && i->town->ratings[_current_player] < 0 && AI_CHANCE16(1,4)) return false; |
278 if (i->town != NULL && i->town->ratings[_current_player] < 0 && AI_CHANCE16(1, 4)) return false; |
279 |
279 |
280 // No limits on delevering stations! |
280 // No limits on delevering stations! |
281 // Or for industry that does not give anything yet |
281 // Or for industry that does not give anything yet |
282 if (i->produced_cargo[0] == CT_INVALID || i->total_production[0] == 0) return true; |
282 if (i->produced_cargo[0] == CT_INVALID || i->total_production[0] == 0) return true; |
283 |
283 |
640 if (new_tile == 0 && p->ainew.tbt == AI_BUS) { |
640 if (new_tile == 0 && p->ainew.tbt == AI_BUS) { |
641 uint x, y, i = 0; |
641 uint x, y, i = 0; |
642 int r; |
642 int r; |
643 uint best; |
643 uint best; |
644 uint accepts[NUM_CARGO]; |
644 uint accepts[NUM_CARGO]; |
645 TileIndex found_spot[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE*4]; |
645 TileIndex found_spot[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE * 4]; |
646 uint found_best[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE*4]; |
646 uint found_best[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE * 4]; |
647 // To find a good spot we scan a range from the center, a get the point |
647 // To find a good spot we scan a range from the center, a get the point |
648 // where we get the most cargo and where it is buildable. |
648 // where we get the most cargo and where it is buildable. |
649 // TODO: also check for station of myself and make sure we are not |
649 // TODO: also check for station of myself and make sure we are not |
650 // taking eachothers passangers away (bad result when it does not) |
650 // taking eachothers passangers away (bad result when it does not) |
651 for (x = TileX(tile) - AI_FINDSTATION_TILE_RANGE; x <= TileX(tile) + AI_FINDSTATION_TILE_RANGE; x++) { |
651 for (x = TileX(tile) - AI_FINDSTATION_TILE_RANGE; x <= TileX(tile) + AI_FINDSTATION_TILE_RANGE; x++) { |
959 return; |
959 return; |
960 } |
960 } |
961 |
961 |
962 // Now we can build the route, check the direction of the stations! |
962 // Now we can build the route, check the direction of the stations! |
963 if (p->ainew.from_direction == AI_PATHFINDER_NO_DIRECTION) { |
963 if (p->ainew.from_direction == AI_PATHFINDER_NO_DIRECTION) { |
964 p->ainew.from_direction = AiNew_GetDirection(p->ainew.path_info.route[p->ainew.path_info.route_length-1], p->ainew.path_info.route[p->ainew.path_info.route_length-2]); |
964 p->ainew.from_direction = AiNew_GetDirection(p->ainew.path_info.route[p->ainew.path_info.route_length - 1], p->ainew.path_info.route[p->ainew.path_info.route_length - 2]); |
965 } |
965 } |
966 if (p->ainew.to_direction == AI_PATHFINDER_NO_DIRECTION) { |
966 if (p->ainew.to_direction == AI_PATHFINDER_NO_DIRECTION) { |
967 p->ainew.to_direction = AiNew_GetDirection(p->ainew.path_info.route[0], p->ainew.path_info.route[1]); |
967 p->ainew.to_direction = AiNew_GetDirection(p->ainew.path_info.route[0], p->ainew.path_info.route[1]); |
968 } |
968 } |
969 if (p->ainew.from_tile == AI_STATION_RANGE) |
969 if (p->ainew.from_tile == AI_STATION_RANGE) |
970 p->ainew.from_tile = p->ainew.path_info.route[p->ainew.path_info.route_length-1]; |
970 p->ainew.from_tile = p->ainew.path_info.route[p->ainew.path_info.route_length - 1]; |
971 if (p->ainew.to_tile == AI_STATION_RANGE) |
971 if (p->ainew.to_tile == AI_STATION_RANGE) |
972 p->ainew.to_tile = p->ainew.path_info.route[0]; |
972 p->ainew.to_tile = p->ainew.path_info.route[0]; |
973 |
973 |
974 p->ainew.state = AI_STATE_BUILD_STATION; |
974 p->ainew.state = AI_STATE_BUILD_STATION; |
975 p->ainew.temp = 0; |
975 p->ainew.temp = 0; |