summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-02-21 19:14:16 +0000
committerDarkvater <darkvater@openttd.org>2005-02-21 19:14:16 +0000
commit33ae18b8b330878e9bece0a93443c51b643976a8 (patch)
treeaea518eeb7cf5e9ee8ab2d9284938722b4fe9721
parentd865c55007321366d49b9b3d49eb0d61715dfc98 (diff)
downloadopenttd-33ae18b8b330878e9bece0a93443c51b643976a8.tar.xz
(svn r1895) - Fix: add assert for charwidth getter just in case
-rw-r--r--gfx.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/gfx.h b/gfx.h
index 58cf6dea9..965fd6e04 100644
--- a/gfx.h
+++ b/gfx.h
@@ -72,7 +72,11 @@ void ToggleFullScreen(const bool full_screen);
#define ASCII_LETTERSTART 32
VARDEF int _stringwidth_base;
VARDEF byte _stringwidth_table[0x2A0];
-static inline byte GetCharacterWidth(int key) { return _stringwidth_table[key - ASCII_LETTERSTART];}
+static inline byte GetCharacterWidth(uint key)
+{
+ assert(key >= ASCII_LETTERSTART && key - ASCII_LETTERSTART < lengthof(_stringwidth_table));
+ return _stringwidth_table[key - ASCII_LETTERSTART];
+}
VARDEF DrawPixelInfo _screen;
VARDEF DrawPixelInfo *_cur_dpi;