changeset 12191:98caf4f386d6 draft

(svn r16604) -Codechange: Use FS_BEGIN for iterating over fonts.
author alberth <alberth@openttd.org>
date Sat, 20 Jun 2009 15:05:59 +0000
parents 0e10ecaebf0c
children 8d5108aed6b0
files src/fontcache.cpp src/gfx_type.h
diffstat 2 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -631,14 +631,13 @@
 /** Clear the complete cache */
 static void ResetGlyphCache()
 {
-	for (int i = 0; i < FS_END; i++) {
+	for (FontSize i = FS_BEGIN; i < FS_END; i++) {
 		if (_glyph_ptr[i] == NULL) continue;
 
 		for (int j = 0; j < 256; j++) {
 			if (_glyph_ptr[i][j] == NULL) continue;
 
 			for (int k = 0; k < 256; k++) {
-				if (_glyph_ptr[i][j][k].sprite == NULL) continue;
 				free(_glyph_ptr[i][j][k].sprite);
 			}
 
@@ -842,11 +841,11 @@
 
 void InitializeUnicodeGlyphMap()
 {
-	for (FontSize size = FS_NORMAL; size != FS_END; size++) {
+	for (FontSize size = FS_BEGIN; size != FS_END; size++) {
 		/* Clear out existing glyph map if it exists */
 		if (_unicode_glyph_map[size] != NULL) {
 			for (uint i = 0; i < 256; i++) {
-				if (_unicode_glyph_map[size][i] != NULL) free(_unicode_glyph_map[size][i]);
+				free(_unicode_glyph_map[size][i]);
 			}
 			free(_unicode_glyph_map[size]);
 			_unicode_glyph_map[size] = NULL;
--- a/src/gfx_type.h
+++ b/src/gfx_type.h
@@ -148,10 +148,12 @@
 
 /** Available font sizes */
 enum FontSize {
-	FS_NORMAL,
-	FS_SMALL,
-	FS_LARGE,
+	FS_NORMAL, ///< Index of the normal font in the font tables.
+	FS_SMALL,  ///< Index of the small font in the font tables.
+	FS_LARGE,  ///< Index of the large font in the font tables.
 	FS_END,
+
+	FS_BEGIN = FS_NORMAL, ///< First font.
 };
 DECLARE_POSTFIX_INCREMENT(FontSize);