# HG changeset patch # User rubidium # Date 1206680252 0 # Node ID c00ebaa5bf908eb61694c5b9408dd32b0980cb19 # Parent 02376670f6b622987b2ebc03d22657ef4c6d4452 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them. diff -r 02376670f6b6 -r c00ebaa5bf90 src/cargotype.h --- a/src/cargotype.h Fri Mar 28 03:23:49 2008 +0000 +++ b/src/cargotype.h Fri Mar 28 04:57:32 2008 +0000 @@ -59,6 +59,8 @@ void SetupCargoForClimate(LandscapeID l); /* Retrieve cargo details for the given cargo ID */ const CargoSpec *GetCargo(CargoID c); +/* Get the cargo icon for a given cargo ID */ +SpriteID GetCargoSprite(CargoID i); /* Get the cargo ID with the cargo label */ CargoID GetCargoIDByLabel(CargoLabel cl); CargoID GetCargoIDByBitnum(uint8 bitnum); diff -r 02376670f6b6 -r c00ebaa5bf90 src/station_gui.cpp --- a/src/station_gui.cpp Fri Mar 28 03:23:49 2008 +0000 +++ b/src/station_gui.cpp Fri Mar 28 04:57:32 2008 +0000 @@ -682,19 +682,8 @@ { WIDGETS_END}, }; -/** - * Draws icons of wainting cargo in the StationView window - * - * @param i type of cargo - * @param waiting number of wainting units - * @param x x on-screen coordinate where to start with drawing icons - * @param y y coordinate - */ -static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width) +SpriteID GetCargoSprite(CargoID i) { - uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow - if (num == 0) return; - const CargoSpec *cs = GetCargo(i); SpriteID sprite; @@ -707,6 +696,24 @@ if (sprite == 0) sprite = SPR_CARGO_GOODS; + return sprite; +} + +/** + * Draws icons of waiting cargo in the StationView window + * + * @param i type of cargo + * @param waiting number of waiting units + * @param x x on-screen coordinate where to start with drawing icons + * @param y y coordinate + */ +static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width) +{ + uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow + if (num == 0) return; + + SpriteID sprite = GetCargoSprite(i); + do { DrawSprite(sprite, PAL_NONE, x, y); x += 10;