equal
deleted
inserted
replaced
165 ti.z = z; |
165 ti.z = z; |
166 |
166 |
167 return (Vehicle*)VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ); |
167 return (Vehicle*)VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ); |
168 } |
168 } |
169 |
169 |
170 Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z) |
170 Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed) |
171 { |
171 { |
172 int x1 = TileX(from); |
172 int x1 = TileX(from); |
173 int y1 = TileY(from); |
173 int y1 = TileY(from); |
174 int x2 = TileX(to); |
174 int x2 = TileX(to); |
175 int y2 = TileY(to); |
175 int y2 = TileY(to); |
179 if (x1 > x2 || y1 > y2) { |
179 if (x1 > x2 || y1 > y2) { |
180 intswap(x1,x2); |
180 intswap(x1,x2); |
181 intswap(y1,y2); |
181 intswap(y1,y2); |
182 } |
182 } |
183 FOR_ALL_VEHICLES(veh) { |
183 FOR_ALL_VEHICLES(veh) { |
|
184 if (without_crashed && (veh->vehstatus & VS_CRASHED) != 0) continue; |
184 if ((veh->type == VEH_Train || veh->type == VEH_Road) && (z==0xFF || veh->z_pos == z)) { |
185 if ((veh->type == VEH_Train || veh->type == VEH_Road) && (z==0xFF || veh->z_pos == z)) { |
185 if ((veh->x_pos>>4) >= x1 && (veh->x_pos>>4) <= x2 && |
186 if ((veh->x_pos>>4) >= x1 && (veh->x_pos>>4) <= x2 && |
186 (veh->y_pos>>4) >= y1 && (veh->y_pos>>4) <= y2) { |
187 (veh->y_pos>>4) >= y1 && (veh->y_pos>>4) <= y2) { |
187 return veh; |
188 return veh; |
188 } |
189 } |