ai.c
changeset 1562 a5507e041d97
parent 1335 a635854c23b6
child 1576 a066e33fa297
equal deleted inserted replaced
1561:b52c96c6edcf 1562:a5507e041d97
  1974 				return;
  1974 				return;
  1975 			flag = true;
  1975 			flag = true;
  1976 		}
  1976 		}
  1977 
  1977 
  1978 		// Is building a (rail)bridge possible at this place (type doesn't matter)?
  1978 		// Is building a (rail)bridge possible at this place (type doesn't matter)?
  1979 		if (DoCommandByTile(tile_new, tile, arf->player->ai.railtype_to_use<<8,
  1979 		if (DoCommandByTile(tile_new, tile, 0 | arf->player->ai.railtype_to_use << 8,
  1980 			DC_AUTO, CMD_BUILD_BRIDGE) == CMD_ERROR)
  1980 			DC_AUTO, CMD_BUILD_BRIDGE) == CMD_ERROR)
  1981 				return;
  1981 				return;
  1982 		AiBuildRailRecursive(arf, tile_new, dir2);
  1982 		AiBuildRailRecursive(arf, tile_new, dir2);
  1983 
  1983 
  1984 		// At the bottom depth, check if the new path is better than the old one.
  1984 		// At the bottom depth, check if the new path is better than the old one.
  2137 		/*	Figure out what (rail)bridge type to build
  2137 		/*	Figure out what (rail)bridge type to build
  2138 				start with best bridge, then go down to worse and worse bridges
  2138 				start with best bridge, then go down to worse and worse bridges
  2139 				unnecessary to check for worse bridge (i=0), since AI will always build that.
  2139 				unnecessary to check for worse bridge (i=0), since AI will always build that.
  2140 				AI is so fucked up that fixing this small thing will probably not solve a thing
  2140 				AI is so fucked up that fixing this small thing will probably not solve a thing
  2141 		*/
  2141 		*/
  2142 		for(i = 10 + (p->ai.railtype_to_use << 8); i != 0; i--) {
  2142 		for (i = MAX_BRIDGES - 1; i != 0; i--) {
  2143 			if (CheckBridge_Stuff(i, bridge_len)) {
  2143 			if (CheckBridge_Stuff(i, bridge_len)) {
  2144 				int32 cost = DoCommandByTile(arf.bridge_end_tile, p->ai.cur_tile_a, i, DC_AUTO, CMD_BUILD_BRIDGE);
  2144 				int32 cost = DoCommandByTile(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO, CMD_BUILD_BRIDGE);
  2145 				if (cost != CMD_ERROR && cost < (p->player_money >> 5))
  2145 				if (cost != CMD_ERROR && cost < (p->player_money >> 5))
  2146 					break;
  2146 					break;
  2147 			}
  2147 			}
  2148 		}
  2148 		}
  2149 
  2149 
  2150 		// Build it
  2150 		// Build it
  2151 		DoCommandByTile(arf.bridge_end_tile, p->ai.cur_tile_a, i, DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
  2151 		DoCommandByTile(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
  2152 
  2152 
  2153 		p->ai.cur_tile_a = arf.bridge_end_tile;
  2153 		p->ai.cur_tile_a = arf.bridge_end_tile;
  2154 		p->ai.state_counter = 0;
  2154 		p->ai.state_counter = 0;
  2155 	} else if (arf.best_ptr[0]&0x40) {
  2155 	} else if (arf.best_ptr[0]&0x40) {
  2156 		// tunnel
  2156 		// tunnel