diff options
author | tron <tron@openttd.org> | 2006-06-14 11:26:56 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-06-14 11:26:56 +0000 |
commit | 7d2efe3d846823b4305c573f47dae3e1d6ceed46 (patch) | |
tree | 46066d1d805df24d9679ca7ca56827dc36d8d413 | |
parent | d2f6cb9e2d26d8119bc59f5b8cfa52d20f7cd795 (diff) | |
download | openttd-7d2efe3d846823b4305c573f47dae3e1d6ceed46.tar.xz |
(svn r5263) Use the flag which denotes if it's a plane or helicopter instead of magical engine numbers
-rw-r--r-- | ai/default/default.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index 7d2fe5cab..5173b0ed2 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -197,11 +197,7 @@ static EngineID AiChooseAircraftToBuild(int32 money, byte flag) continue; } - if (flag & 1) { - if (i<253) continue; - } else { - if (i>=253) continue; - } + if ((AircraftVehInfo(i)->subtype & AIR_CTOL) != flag) continue; ret = DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT); if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) { @@ -246,7 +242,9 @@ static EngineID AiChooseRoadVehToReplaceWith(const Player* p, const Vehicle* v) static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v) { int32 avail_money = p->player_money + v->value; - return AiChooseAircraftToBuild(avail_money, v->engine_type>=253?1:0); + return AiChooseAircraftToBuild( + avail_money, AircraftVehInfo(v->engine_type)->subtype & AIR_CTOL + ); } static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v) @@ -3453,7 +3451,7 @@ static void AiStateBuildAircraftVehicles(Player *p) tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs)); - veh = AiChooseAircraftToBuild(p->player_money, p->ai.build_kind!=0 ? 1 : 0); + veh = AiChooseAircraftToBuild(p->player_money, p->ai.build_kind != 0 ? 0 : AIR_CTOL); if (veh == INVALID_ENGINE) return; /* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type |