(svn r8105) -Codechange: Change FindGRFConfig so that if md5sum parameter is omitted (or NULL)
authorDarkvater
Sat, 13 Jan 2007 17:23:02 +0000
changeset 5897 016df903f3bb
parent 5896 b1f465cc40db
child 5898 2ee7d23291fa
(svn r8105) -Codechange: Change FindGRFConfig so that if md5sum parameter is omitted (or NULL)
only a check for GRFID is done and not on md5sum as well. Remove blanksum in the function as it's obsoleted
src/newgrf_config.cpp
src/newgrf_config.h
--- a/src/newgrf_config.cpp	Sat Jan 13 16:23:24 2007 +0000
+++ b/src/newgrf_config.cpp	Sat Jan 13 17:23:02 2007 +0000
@@ -312,15 +312,13 @@
 }
 
 
-/* Find a NewGRF in the scanned list */
-const GRFConfig *FindGRFConfig(uint32 grfid, uint8 *md5sum)
+/* Find a NewGRF in the scanned list, if md5sum is NULL, we don't care about it*/
+const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum)
 {
-	GRFConfig *c;
-	static const uint8 blanksum[sizeof(c->md5sum)] = { 0 };
+	for (const GRFConfig *c = _all_grfs; c != NULL; c = c->next) {
+		if (c->grfid == grfid) {
+			if (md5sum == NULL) return c;
 
-	for (c = _all_grfs; c != NULL; c = c->next) {
-		if (c->grfid == grfid) {
-			if (memcmp(blanksum, c->md5sum, sizeof(c->md5sum)) == 0) CalcGRFMD5Sum(c);
 			if (memcmp(md5sum, c->md5sum, sizeof(c->md5sum)) == 0) return c;
 		}
 	}
--- a/src/newgrf_config.h	Sat Jan 13 16:23:24 2007 +0000
+++ b/src/newgrf_config.h	Sat Jan 13 17:23:02 2007 +0000
@@ -41,7 +41,7 @@
 extern GRFConfig *_grfconfig_static;
 
 void ScanNewGRFFiles(void);
-const GRFConfig *FindGRFConfig(uint32 grfid, uint8 *md5sum);
+const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
 GRFConfig *GetGRFConfig(uint32 grfid);
 GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
 void AppendStaticGRFConfigs(GRFConfig **dst);