172 dir = AiNew_GetRoadDirection(route[part-1], route[part], route[part+1]); |
172 dir = AiNew_GetRoadDirection(route[part-1], route[part], route[part+1]); |
173 // Is it the same as the last one? |
173 // Is it the same as the last one? |
174 if (old_dir != -1 && old_dir != dir) break; |
174 if (old_dir != -1 && old_dir != dir) break; |
175 old_dir = dir; |
175 old_dir = dir; |
176 // There is already some road, and it is a bridge.. don't build!!! |
176 // There is already some road, and it is a bridge.. don't build!!! |
177 if (!IS_TILETYPE(route[part], MP_TUNNELBRIDGE)) { |
177 if (!IsTileType(route[part], MP_TUNNELBRIDGE)) { |
178 // Build the tile |
178 // Build the tile |
179 res = DoCommandByTile(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD); |
179 res = DoCommandByTile(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD); |
180 // Currently, we ignore CMD_ERRORs! |
180 // Currently, we ignore CMD_ERRORs! |
181 if (res == CMD_ERROR && flag == DC_EXEC && !IS_TILETYPE(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) { |
181 if (res == CMD_ERROR && flag == DC_EXEC && !IsTileType(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) { |
182 // Problem.. let's just abort it all! |
182 // Problem.. let's just abort it all! |
183 DEBUG(ai,0)("Darn, the route could not be builded.. aborting!"); |
183 DEBUG(ai,0)("Darn, the route could not be builded.. aborting!"); |
184 p->ainew.state = AI_STATE_NOTHING; |
184 p->ainew.state = AI_STATE_NOTHING; |
185 return 0; |
185 return 0; |
186 } else { |
186 } else { |