(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
authortron
Sun, 18 Dec 2005 08:01:05 +0000
changeset 2766 7658ddad65b9
parent 2765 b00f2d3d7964
child 2767 3282c77ffc27
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
newgrf.c
newgrf.h
settings_gui.c
--- a/newgrf.c	Sat Dec 17 14:26:43 2005 +0000
+++ b/newgrf.c	Sun Dec 18 08:01:05 2005 +0000
@@ -35,7 +35,6 @@
 
 static GRFFile *_cur_grffile;
 GRFFile *_first_grffile;
-int _grffile_count;
 static int _cur_spriteid;
 static int _cur_stage;
 
--- a/newgrf.h	Sat Dec 17 14:26:43 2005 +0000
+++ b/newgrf.h	Sun Dec 18 08:01:05 2005 +0000
@@ -40,7 +40,6 @@
 	uint param_end; /// one more than the highest set parameter
 };
 
-extern int _grffile_count;
 extern GRFFile *_first_grffile;
 
 
--- a/settings_gui.c	Sat Dec 17 14:26:43 2005 +0000
+++ b/settings_gui.c	Sun Dec 18 08:01:05 2005 +0000
@@ -1221,7 +1221,7 @@
 
 			y += w->vscroll.pos;
 
-			if (y >= _grffile_count) return;
+			if (y >= w->vscroll.count) return;
 
 			_sel_grffile = _first_grffile;
 			// get selected grf-file
@@ -1281,20 +1281,18 @@
 
 void ShowNewgrf(void)
 {
+	const GRFFile* c;
 	Window *w;
+	uint count;
+
 	DeleteWindowById(WC_GAME_OPTIONS, 0);
 	w = AllocateWindowDesc(&_newgrf_desc);
 
-	{ // little helper function to calculate _grffile_count
-	  // should be REMOVED once _grffile_count is calculated at loading
-		const GRFFile* c;
-
-		_grffile_count = 0;
-		for (c = _first_grffile; c != NULL; c = c->next) _grffile_count++;
-	}
+	count = 0;
+	for (c = _first_grffile; c != NULL; c = c->next) count++;
 
 	w->vscroll.cap = 12;
-	w->vscroll.count = _grffile_count;
+	w->vscroll.count = count;
 	w->vscroll.pos = 0;
 	w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
 }