src/newgrf_config.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
--- a/src/newgrf_config.cpp	Wed Jun 13 12:05:56 2007 +0000
+++ b/src/newgrf_config.cpp	Tue Jun 19 07:21:01 2007 +0000
@@ -97,7 +97,12 @@
 		free((*config)->full_path);
 		free((*config)->name);
 		free((*config)->info);
-		free((*config)->error);
+
+		if ((*config)->error != NULL) {
+			free((*config)->error->custom_message);
+			free((*config)->error->data);
+			free((*config)->error);
+		}
 	}
 	free(*config);
 	*config = NULL;
@@ -134,6 +139,8 @@
 		if (src->error     != NULL) {
 			c->error = CallocT<GRFError>(1);
 			memcpy(c->error, src->error, sizeof(GRFError));
+			if (src->error->data != NULL) c->error->data = strdup(src->error->data);
+			if (src->error->custom_message != NULL) c->error->custom_message = strdup(src->error->custom_message);
 		}
 
 		*dst = c;
@@ -356,14 +363,16 @@
 /* Scan for all NewGRFs */
 void ScanNewGRFFiles()
 {
-	uint num;
+	Searchpath sp;
+	char path[MAX_PATH];
+	uint num = 0;
 
 	ClearGRFConfigList(&_all_grfs);
 
 	DEBUG(grf, 1, "Scanning for NewGRFs");
-	num  = ScanPath(_paths.data_dir, strlen(_paths.data_dir));
-	if (_paths.second_data_dir != NULL) {
-		num += ScanPath(_paths.second_data_dir, strlen(_paths.second_data_dir));
+	FOR_ALL_SEARCHPATHS(sp) {
+		FioAppendDirectory(path, MAX_PATH, sp, DATA_DIR);
+		num += ScanPath(path, strlen(path));
 	}
 	DEBUG(grf, 1, "Scan complete, found %d files", num);
 }