2202 int32 bridge_len = GetTunnelBridgeLength(arf.bridge_end_tile, _players_ai[p->index].cur_tile_a); |
2202 int32 bridge_len = GetTunnelBridgeLength(arf.bridge_end_tile, _players_ai[p->index].cur_tile_a); |
2203 |
2203 |
2204 /* Figure out which (rail)bridge type to build |
2204 /* Figure out which (rail)bridge type to build |
2205 * start with best bridge, then go down to worse and worse bridges |
2205 * start with best bridge, then go down to worse and worse bridges |
2206 * unnecessary to check for worst bridge (i=0), since AI will always build |
2206 * unnecessary to check for worst bridge (i=0), since AI will always build |
2207 * that. AI is so fucked up that fixing this small thing will probably not |
2207 * that. |
2208 * solve a thing |
|
2209 */ |
2208 */ |
2210 for (i = MAX_BRIDGES - 1; i != 0; i--) { |
2209 for (i = MAX_BRIDGES - 1; i != 0; i--) { |
2211 if (CheckBridge_Stuff(i, bridge_len)) { |
2210 if (CheckBridge_Stuff(i, bridge_len)) { |
2212 CommandCost cost = DoCommand(arf.bridge_end_tile, _players_ai[p->index].cur_tile_a, i | (_players_ai[p->index].railtype_to_use << 8), DC_AUTO, CMD_BUILD_BRIDGE); |
2211 CommandCost cost = DoCommand(arf.bridge_end_tile, _players_ai[p->index].cur_tile_a, i | (_players_ai[p->index].railtype_to_use << 8), DC_AUTO, CMD_BUILD_BRIDGE); |
2213 if (CmdSucceeded(cost) && cost.GetCost() < (p->player_money >> 5)) break; |
2212 if (CmdSucceeded(cost) && cost.GetCost() < (p->player_money >> 1) && cost.GetCost() < ((p->player_money + _economy.max_loan - p->current_loan) >> 5)) break; |
2214 } |
2213 } |
2215 } |
2214 } |
2216 |
2215 |
2217 // Build it |
2216 // Build it |
2218 DoCommand(arf.bridge_end_tile, _players_ai[p->index].cur_tile_a, i | (_players_ai[p->index].railtype_to_use << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE); |
2217 DoCommand(arf.bridge_end_tile, _players_ai[p->index].cur_tile_a, i | (_players_ai[p->index].railtype_to_use << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE); |
3093 bridge_len = GetTunnelBridgeLength(tile, _players_ai[p->index].cur_tile_a); // tile |
3092 bridge_len = GetTunnelBridgeLength(tile, _players_ai[p->index].cur_tile_a); // tile |
3094 |
3093 |
3095 /* Figure out what (road)bridge type to build |
3094 /* Figure out what (road)bridge type to build |
3096 * start with best bridge, then go down to worse and worse bridges |
3095 * start with best bridge, then go down to worse and worse bridges |
3097 * unnecessary to check for worse bridge (i=0), since AI will always build that. |
3096 * unnecessary to check for worse bridge (i=0), since AI will always build that. |
3098 *AI is so fucked up that fixing this small thing will probably not solve a thing |
|
3099 */ |
3097 */ |
3100 for (i = 10; i != 0; i--) { |
3098 for (i = MAX_BRIDGES - 1; i != 0; i--) { |
3101 if (CheckBridge_Stuff(i, bridge_len)) { |
3099 if (CheckBridge_Stuff(i, bridge_len)) { |
3102 CommandCost cost = DoCommand(tile, _players_ai[p->index].cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE); |
3100 CommandCost cost = DoCommand(tile, _players_ai[p->index].cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE); |
3103 if (CmdSucceeded(cost) && cost.GetCost() < (p->player_money >> 5)) break; |
3101 if (CmdSucceeded(cost) && cost.GetCost() < (p->player_money >> 1) && cost.GetCost() < ((p->player_money + _economy.max_loan - p->current_loan) >> 5)) break; |
3104 } |
3102 } |
3105 } |
3103 } |
3106 |
3104 |
3107 // Build it |
3105 // Build it |
3108 DoCommand(tile, _players_ai[p->index].cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE); |
3106 DoCommand(tile, _players_ai[p->index].cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE); |