summaryrefslogtreecommitdiff
path: root/src/cargotype.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-12-05 16:00:58 +0000
committeralberth <alberth@openttd.org>2009-12-05 16:00:58 +0000
commitc38f3ce380930c381464b1c39dc351061587b34f (patch)
tree6f42abae63c5bf7aa8b3fc9a9fb6bc51292c85c3 /src/cargotype.cpp
parent1e7403d372b7d967d7ecab848fa7fc74358d8820 (diff)
downloadopenttd-c38f3ce380930c381464b1c39dc351061587b34f.tar.xz
(svn r18410) -Codechange: Move GetCargoSprite() to CargoSpec::GetCargoIcon().
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r--src/cargotype.cpp17
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;
+}
+