equal
deleted
inserted
replaced
1568 |
1568 |
1569 i = 200; |
1569 i = 200; |
1570 for (;;) { |
1570 for (;;) { |
1571 r = (uint16)Random(); |
1571 r = (uint16)Random(); |
1572 |
1572 |
1573 if (_settings.ai.ai_disable_veh_train && |
1573 if (_settings_game.ai.ai_disable_veh_train && |
1574 _settings.ai.ai_disable_veh_roadveh && |
1574 _settings_game.ai.ai_disable_veh_roadveh && |
1575 _settings.ai.ai_disable_veh_aircraft && |
1575 _settings_game.ai.ai_disable_veh_aircraft && |
1576 _settings.ai.ai_disable_veh_ship) { |
1576 _settings_game.ai.ai_disable_veh_ship) { |
1577 return; |
1577 return; |
1578 } |
1578 } |
1579 |
1579 |
1580 if (r < 0x7626) { |
1580 if (r < 0x7626) { |
1581 if (_settings.ai.ai_disable_veh_train) continue; |
1581 if (_settings_game.ai.ai_disable_veh_train) continue; |
1582 AiWantTrainRoute(p); |
1582 AiWantTrainRoute(p); |
1583 } else if (r < 0xC4EA) { |
1583 } else if (r < 0xC4EA) { |
1584 if (_settings.ai.ai_disable_veh_roadveh) continue; |
1584 if (_settings_game.ai.ai_disable_veh_roadveh) continue; |
1585 AiWantRoadRoute(p); |
1585 AiWantRoadRoute(p); |
1586 } else if (r < 0xD89B) { |
1586 } else if (r < 0xD89B) { |
1587 if (_settings.ai.ai_disable_veh_aircraft) continue; |
1587 if (_settings_game.ai.ai_disable_veh_aircraft) continue; |
1588 AiWantAircraftRoute(p); |
1588 AiWantAircraftRoute(p); |
1589 } else { |
1589 } else { |
1590 /* Ships are not implemented in this (broken) AI */ |
1590 /* Ships are not implemented in this (broken) AI */ |
1591 } |
1591 } |
1592 |
1592 |
1601 } |
1601 } |
1602 } |
1602 } |
1603 |
1603 |
1604 static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) |
1604 static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) |
1605 { |
1605 { |
1606 uint rad = (_settings.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; |
1606 uint rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; |
1607 |
1607 |
1608 for (; p->mode != 4; p++) { |
1608 for (; p->mode != 4; p++) { |
1609 AcceptedCargo values; |
1609 AcceptedCargo values; |
1610 TileIndex tile2; |
1610 TileIndex tile2; |
1611 uint w; |
1611 uint w; |
2548 for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) { |
2548 for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) { |
2549 const AiBuildRec* aib = &_players_ai[p->index].src + _players_ai[p->index].order_list_blocks[i]; |
2549 const AiBuildRec* aib = &_players_ai[p->index].src + _players_ai[p->index].order_list_blocks[i]; |
2550 bool is_pass = ( |
2550 bool is_pass = ( |
2551 _players_ai[p->index].cargo_type == CT_PASSENGERS || |
2551 _players_ai[p->index].cargo_type == CT_PASSENGERS || |
2552 _players_ai[p->index].cargo_type == CT_MAIL || |
2552 _players_ai[p->index].cargo_type == CT_MAIL || |
2553 (_settings.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) |
2553 (_settings_game.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) |
2554 ); |
2554 ); |
2555 Order order; |
2555 Order order; |
2556 |
2556 |
2557 order.MakeGoToStation(AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule)); |
2557 order.MakeGoToStation(AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule)); |
2558 |
2558 |
2597 static bool AiCheckRoadResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) |
2597 static bool AiCheckRoadResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) |
2598 { |
2598 { |
2599 uint values[NUM_CARGO]; |
2599 uint values[NUM_CARGO]; |
2600 int rad; |
2600 int rad; |
2601 |
2601 |
2602 if (_settings.station.modified_catchment) { |
2602 if (_settings_game.station.modified_catchment) { |
2603 rad = CA_TRUCK; // Same as CA_BUS at the moment? |
2603 rad = CA_TRUCK; // Same as CA_BUS at the moment? |
2604 } else { // change that at some point? |
2604 } else { // change that at some point? |
2605 rad = 4; |
2605 rad = 4; |
2606 } |
2606 } |
2607 |
2607 |
3283 for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) { |
3283 for (i = 0; _players_ai[p->index].order_list_blocks[i] != 0xFF; i++) { |
3284 const AiBuildRec* aib = &_players_ai[p->index].src + _players_ai[p->index].order_list_blocks[i]; |
3284 const AiBuildRec* aib = &_players_ai[p->index].src + _players_ai[p->index].order_list_blocks[i]; |
3285 bool is_pass = ( |
3285 bool is_pass = ( |
3286 _players_ai[p->index].cargo_type == CT_PASSENGERS || |
3286 _players_ai[p->index].cargo_type == CT_PASSENGERS || |
3287 _players_ai[p->index].cargo_type == CT_MAIL || |
3287 _players_ai[p->index].cargo_type == CT_MAIL || |
3288 (_settings.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) |
3288 (_settings_game.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) |
3289 ); |
3289 ); |
3290 Order order; |
3290 Order order; |
3291 |
3291 |
3292 order.MakeGoToStation(AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule)); |
3292 order.MakeGoToStation(AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule)); |
3293 |
3293 |
3421 for (; p->mode == 0; p++) { |
3421 for (; p->mode == 0; p++) { |
3422 TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); |
3422 TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); |
3423 const AirportFTAClass* airport = GetAirport(p->attr); |
3423 const AirportFTAClass* airport = GetAirport(p->attr); |
3424 uint w = airport->size_x; |
3424 uint w = airport->size_x; |
3425 uint h = airport->size_y; |
3425 uint h = airport->size_y; |
3426 uint rad = _settings.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED; |
3426 uint rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED; |
3427 |
3427 |
3428 if (cargo & 0x80) { |
3428 if (cargo & 0x80) { |
3429 GetProductionAroundTiles(values, tile2, w, h, rad); |
3429 GetProductionAroundTiles(values, tile2, w, h, rad); |
3430 return values[cargo & 0x7F] != 0; |
3430 return values[cargo & 0x7F] != 0; |
3431 } else { |
3431 } else { |
3973 |
3973 |
3974 // Ugly hack to make sure the service interval of the AI is good, not looking |
3974 // Ugly hack to make sure the service interval of the AI is good, not looking |
3975 // to the patch-setting |
3975 // to the patch-setting |
3976 // Also, it takes into account the setting if the service-interval is in days |
3976 // Also, it takes into account the setting if the service-interval is in days |
3977 // or in % |
3977 // or in % |
3978 _ai_service_interval = _settings.vehicle.servint_ispercent ? 80 : 180; |
3978 _ai_service_interval = _settings_game.vehicle.servint_ispercent ? 80 : 180; |
3979 |
3979 |
3980 if (IsHumanPlayer(_current_player)) return; |
3980 if (IsHumanPlayer(_current_player)) return; |
3981 |
3981 |
3982 AiAdjustLoan(p); |
3982 AiAdjustLoan(p); |
3983 AiBuildCompanyHQ(p); |
3983 AiBuildCompanyHQ(p); |