ai/default/default.c
changeset 4024 6b3809fd45e0
parent 4015 4f67e077e30e
child 4077 d4d440dd8925
equal deleted inserted replaced
4023:5d84c056a2b1 4024:6b3809fd45e0
   195 
   195 
   196 		if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D) {
   196 		if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D) {
   197 			continue;
   197 			continue;
   198 		}
   198 		}
   199 
   199 
   200 		if (flag & 1) {
   200 		if ((AircraftVehInfo(i)->subtype & AIR_CTOL) != flag) continue;
   201 			if (i<253) continue;
       
   202 		} else {
       
   203 			if (i>=253) continue;
       
   204 		}
       
   205 
   201 
   206 		ret = DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT);
   202 		ret = DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT);
   207 		if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) {
   203 		if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) {
   208 			best_veh_cost = ret;
   204 			best_veh_cost = ret;
   209 			best_veh_index = i;
   205 			best_veh_index = i;
   244 }
   240 }
   245 
   241 
   246 static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
   242 static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
   247 {
   243 {
   248 	int32 avail_money = p->player_money + v->value;
   244 	int32 avail_money = p->player_money + v->value;
   249 	return AiChooseAircraftToBuild(avail_money, v->engine_type>=253?1:0);
   245 	return AiChooseAircraftToBuild(
       
   246 		avail_money, AircraftVehInfo(v->engine_type)->subtype & AIR_CTOL
       
   247 	);
   250 }
   248 }
   251 
   249 
   252 static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v)
   250 static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v)
   253 {
   251 {
   254 	int32 avail_money = p->player_money + v->value;
   252 	int32 avail_money = p->player_money + v->value;
  3451 	ptr = _airport_default_block_data[p->ai.src.cur_building_rule];
  3449 	ptr = _airport_default_block_data[p->ai.src.cur_building_rule];
  3452 	for (; ptr->mode != 0; ptr++) {}
  3450 	for (; ptr->mode != 0; ptr++) {}
  3453 
  3451 
  3454 	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
  3452 	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
  3455 
  3453 
  3456 	veh = AiChooseAircraftToBuild(p->player_money, p->ai.build_kind!=0 ? 1 : 0);
  3454 	veh = AiChooseAircraftToBuild(p->player_money, p->ai.build_kind != 0 ? 0 : AIR_CTOL);
  3457 	if (veh == INVALID_ENGINE) return;
  3455 	if (veh == INVALID_ENGINE) return;
  3458 
  3456 
  3459 	/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
  3457 	/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
  3460 	 * and offset to the FIRST depot because the AI picks the st->xy tile */
  3458 	 * and offset to the FIRST depot because the AI picks the st->xy tile */
  3461 	tile += ToTileIndexDiff(GetAirport(GetStationByTile(tile)->airport_type)->airport_depots[0]);
  3459 	tile += ToTileIndexDiff(GetAirport(GetStationByTile(tile)->airport_type)->airport_depots[0]);