From c38f3ce380930c381464b1c39dc351061587b34f Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 5 Dec 2009 16:00:58 +0000 Subject: (svn r18410) -Codechange: Move GetCargoSprite() to CargoSpec::GetCargoIcon(). --- src/cargotype.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/cargotype.cpp') diff --git a/src/cargotype.cpp b/src/cargotype.cpp index 901326c18..6920cf17f 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -12,6 +12,7 @@ #include "stdafx.h" #include "cargotype.h" #include "core/bitmath_func.hpp" +#include "newgrf_cargo.h" #include "table/sprites.h" #include "table/strings.h" @@ -89,3 +90,19 @@ CargoID GetCargoIDByBitnum(uint8 bitnum) return CT_INVALID; } +/** Get sprite for showing cargo of this type. + * @return Sprite number to use. + */ +SpriteID CargoSpec::GetCargoIcon() const +{ + SpriteID sprite = this->sprite; + if (sprite == 0xFFFF) { + /* A value of 0xFFFF indicates we should draw a custom icon */ + sprite = GetCustomCargoSprite(this); + } + + if (sprite == 0) sprite = SPR_CARGO_GOODS; + + return sprite; +} + -- cgit v1.2.3-54-g00ecf