diff options
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r-- | src/cargotype.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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; +} + |