equal
deleted
inserted
replaced
2246 } |
2246 } |
2247 |
2247 |
2248 /* Extend the list size for BuildDepotVehicleList() */ |
2248 /* Extend the list size for BuildDepotVehicleList() */ |
2249 static inline void ExtendVehicleListSize(const Vehicle ***engine_list, uint16 *engine_list_length, uint16 step_size) |
2249 static inline void ExtendVehicleListSize(const Vehicle ***engine_list, uint16 *engine_list_length, uint16 step_size) |
2250 { |
2250 { |
2251 *engine_list_length = min(*engine_list_length + step_size, GetVehicleArraySize()); |
2251 *engine_list_length = min(*engine_list_length + step_size, GetMaxVehicleIndex() + 1); |
2252 *engine_list = realloc((void*)*engine_list, (*engine_list_length) * sizeof((*engine_list)[0])); |
2252 *engine_list = realloc((void*)*engine_list, (*engine_list_length) * sizeof((*engine_list)[0])); |
2253 } |
2253 } |
2254 |
2254 |
2255 /** Generates a list of vehicles inside a depot |
2255 /** Generates a list of vehicles inside a depot |
2256 * Will enlarge allocated space for the list if they are too small, so it's ok to call with (pointer to NULL array, pointer to uninitised uint16, pointer to 0) |
2256 * Will enlarge allocated space for the list if they are too small, so it's ok to call with (pointer to NULL array, pointer to uninitised uint16, pointer to 0) |
2389 FOR_ALL_VEHICLES(v) { |
2389 FOR_ALL_VEHICLES(v) { |
2390 if (v->type == type && v->owner == owner && ( |
2390 if (v->type == type && v->owner == owner && ( |
2391 (type == VEH_Train && IsFrontEngine(v)) || |
2391 (type == VEH_Train && IsFrontEngine(v)) || |
2392 (type != VEH_Train && v->subtype <= subtype))) { |
2392 (type != VEH_Train && v->subtype <= subtype))) { |
2393 /* TODO find a better estimate on the total number of vehicles for current player */ |
2393 /* TODO find a better estimate on the total number of vehicles for current player */ |
2394 if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetVehicleArraySize()/4); |
2394 if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetNumVehicles()/4); |
2395 (*sort_list)[n++] = v; |
2395 (*sort_list)[n++] = v; |
2396 } |
2396 } |
2397 } |
2397 } |
2398 break; |
2398 break; |
2399 } |
2399 } |