MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / InitDepotWindowBlockSizes

Function InitDepotWindowBlockSizes

src/depot_gui.cpp:219–252  ·  view source on GitHub ↗

* 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. * @note Calling this function once for each game is enough. */

Source from the content-addressed store, hash-verified

217 * @note Calling this function once for each game is enough.
218 */
219void InitDepotWindowBlockSizes()
220{
221 for (VehicleType vt = VEH_BEGIN; vt < VEH_COMPANY_END; vt++) {
222 InitBlocksizeForVehicles(vt, EIT_IN_DEPOT);
223 InitBlocksizeForVehicles(vt, EIT_PURCHASE);
224 }
225
226 _consistent_train_width = TRAININFO_DEFAULT_VEHICLE_WIDTH;
227 bool first = true;
228 for (const Engine *e : Engine::IterateType(VEH_TRAIN)) {
229 if (!e->IsEnabled()) continue;
230
231 uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
232 if (e->GetGRF() != nullptr && IsCustomVehicleSpriteNum(e->VehInfo<RailVehicleInfo>().image_index)) {
233 w = e->GetGRF()->traininfo_vehicle_width;
234 if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
235 /* Hopeless.
236 * This is a NewGRF vehicle that uses TRAININFO_DEFAULT_VEHICLE_WIDTH.
237 * If the vehicles are shorter than 8/8 we have fractional lengths, which are not consistent after rounding.
238 */
239 _consistent_train_width = 0;
240 break;
241 }
242 }
243
244 if (first) {
245 _consistent_train_width = w;
246 first = false;
247 } else if (w != _consistent_train_width) {
248 _consistent_train_width = 0;
249 break;
250 }
251 }
252}
253
254static void DepotSellAllConfirmationCallback(Window *w, bool confirmed);
255const Sprite *GetAircraftSprite(EngineID engine);

Callers 2

InitWindowSystemFunction · 0.85
ReInitAllWindowsFunction · 0.85

Calls 4

InitBlocksizeForVehiclesFunction · 0.85
IsCustomVehicleSpriteNumFunction · 0.85
IsEnabledMethod · 0.45
GetGRFMethod · 0.45

Tested by

no test coverage detected