| 169 | } |
| 170 | |
| 171 | static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_type) |
| 172 | { |
| 173 | int max_extend_left = 0; |
| 174 | int max_extend_right = 0; |
| 175 | uint max_height = 0; |
| 176 | |
| 177 | for (const Engine *e : Engine::IterateType(type)) { |
| 178 | if (!e->IsEnabled()) continue; |
| 179 | |
| 180 | EngineID eid = e->index; |
| 181 | uint x, y; |
| 182 | int x_offs, y_offs; |
| 183 | |
| 184 | switch (type) { |
| 185 | default: NOT_REACHED(); |
| 186 | case VEH_TRAIN: GetTrainSpriteSize( eid, x, y, x_offs, y_offs, image_type); break; |
| 187 | case VEH_ROAD: GetRoadVehSpriteSize( eid, x, y, x_offs, y_offs, image_type); break; |
| 188 | case VEH_SHIP: GetShipSpriteSize( eid, x, y, x_offs, y_offs, image_type); break; |
| 189 | case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y, x_offs, y_offs, image_type); break; |
| 190 | } |
| 191 | if (y > max_height) max_height = y; |
| 192 | if (-x_offs > max_extend_left) max_extend_left = -x_offs; |
| 193 | if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs; |
| 194 | } |
| 195 | |
| 196 | int min_extend = ScaleSpriteTrad(16); |
| 197 | int max_extend = ScaleSpriteTrad(98); |
| 198 | |
| 199 | switch (image_type) { |
| 200 | case EIT_IN_DEPOT: |
| 201 | _base_block_sizes_depot[type].height = std::max<uint>(ScaleSpriteTrad(GetVehicleHeight(type)), max_height); |
| 202 | _base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, min_extend, max_extend); |
| 203 | _base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, min_extend, max_extend); |
| 204 | break; |
| 205 | case EIT_PURCHASE: |
| 206 | _base_block_sizes_purchase[type].height = std::max<uint>(ScaleSpriteTrad(GetVehicleHeight(type)), max_height); |
| 207 | _base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, min_extend, max_extend); |
| 208 | _base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, min_extend, max_extend); |
| 209 | break; |
| 210 | |
| 211 | default: NOT_REACHED(); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle sprites in the current game. |
no test coverage detected