equal
deleted
inserted
replaced
83 // We need to calculate the direction with the parent of the parent.. so we skip |
83 // We need to calculate the direction with the parent of the parent.. so we skip |
84 // the first pieces and the last piece |
84 // the first pieces and the last piece |
85 if (part < 1) part = 1; |
85 if (part < 1) part = 1; |
86 // When we are done, stop it |
86 // When we are done, stop it |
87 if (part >= PathFinderInfo->route_length - 1) { PathFinderInfo->position = -2; return 0; } |
87 if (part >= PathFinderInfo->route_length - 1) { PathFinderInfo->position = -2; return 0; } |
88 |
88 |
89 |
89 |
90 if (PathFinderInfo->rail_or_road) { |
90 if (PathFinderInfo->rail_or_road) { |
91 // Tunnel code |
91 // Tunnel code |
92 if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) { |
92 if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) { |
93 cost += DoCommandByTile(route[part], 0, 0, flag, CMD_BUILD_TUNNEL); |
93 cost += DoCommandByTile(route[part], 0, 0, flag, CMD_BUILD_TUNNEL); |
94 PathFinderInfo->position++; |
94 PathFinderInfo->position++; |
196 // We want to return the last position, so we go back one |
196 // We want to return the last position, so we go back one |
197 } |
197 } |
198 if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--; |
198 if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--; |
199 PathFinderInfo->position = part; |
199 PathFinderInfo->position = part; |
200 } |
200 } |
201 |
201 |
202 return cost; |
202 return cost; |
203 } |
203 } |
204 |
204 |
205 // This functions tries to find the best vehicle for this type of cargo |
205 // This functions tries to find the best vehicle for this type of cargo |
206 // It returns vehicle_id or -1 if not found |
206 // It returns vehicle_id or -1 if not found |
230 |
230 |
231 // Builds the best vehicle possible |
231 // Builds the best vehicle possible |
232 int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) { |
232 int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) { |
233 int i = AiNew_PickVehicle(p); |
233 int i = AiNew_PickVehicle(p); |
234 if (i == -1) return CMD_ERROR; |
234 if (i == -1) return CMD_ERROR; |
235 |
235 |
236 if (p->ainew.tbt == AI_TRAIN) { |
236 if (p->ainew.tbt == AI_TRAIN) { |
237 return CMD_ERROR; |
237 return CMD_ERROR; |
238 } else { |
238 } else { |
239 return DoCommandByTile(tile, i, 0, flag, CMD_BUILD_ROAD_VEH); |
239 return DoCommandByTile(tile, i, 0, flag, CMD_BUILD_ROAD_VEH); |
240 } |
240 } |