src/newgrf_config.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
    95 	if (!HASBIT((*config)->flags, GCF_COPY)) {
    95 	if (!HASBIT((*config)->flags, GCF_COPY)) {
    96 		free((*config)->filename);
    96 		free((*config)->filename);
    97 		free((*config)->full_path);
    97 		free((*config)->full_path);
    98 		free((*config)->name);
    98 		free((*config)->name);
    99 		free((*config)->info);
    99 		free((*config)->info);
   100 		free((*config)->error);
   100 
       
   101 		if ((*config)->error != NULL) {
       
   102 			free((*config)->error->custom_message);
       
   103 			free((*config)->error->data);
       
   104 			free((*config)->error);
       
   105 		}
   101 	}
   106 	}
   102 	free(*config);
   107 	free(*config);
   103 	*config = NULL;
   108 	*config = NULL;
   104 }
   109 }
   105 
   110 
   132 		if (src->name      != NULL) c->name      = strdup(src->name);
   137 		if (src->name      != NULL) c->name      = strdup(src->name);
   133 		if (src->info      != NULL) c->info      = strdup(src->info);
   138 		if (src->info      != NULL) c->info      = strdup(src->info);
   134 		if (src->error     != NULL) {
   139 		if (src->error     != NULL) {
   135 			c->error = CallocT<GRFError>(1);
   140 			c->error = CallocT<GRFError>(1);
   136 			memcpy(c->error, src->error, sizeof(GRFError));
   141 			memcpy(c->error, src->error, sizeof(GRFError));
       
   142 			if (src->error->data != NULL) c->error->data = strdup(src->error->data);
       
   143 			if (src->error->custom_message != NULL) c->error->custom_message = strdup(src->error->custom_message);
   137 		}
   144 		}
   138 
   145 
   139 		*dst = c;
   146 		*dst = c;
   140 		dst = &c->next;
   147 		dst = &c->next;
   141 	}
   148 	}
   354 
   361 
   355 
   362 
   356 /* Scan for all NewGRFs */
   363 /* Scan for all NewGRFs */
   357 void ScanNewGRFFiles()
   364 void ScanNewGRFFiles()
   358 {
   365 {
   359 	uint num;
   366 	Searchpath sp;
       
   367 	char path[MAX_PATH];
       
   368 	uint num = 0;
   360 
   369 
   361 	ClearGRFConfigList(&_all_grfs);
   370 	ClearGRFConfigList(&_all_grfs);
   362 
   371 
   363 	DEBUG(grf, 1, "Scanning for NewGRFs");
   372 	DEBUG(grf, 1, "Scanning for NewGRFs");
   364 	num  = ScanPath(_paths.data_dir, strlen(_paths.data_dir));
   373 	FOR_ALL_SEARCHPATHS(sp) {
   365 	if (_paths.second_data_dir != NULL) {
   374 		FioAppendDirectory(path, MAX_PATH, sp, DATA_DIR);
   366 		num += ScanPath(_paths.second_data_dir, strlen(_paths.second_data_dir));
   375 		num += ScanPath(path, strlen(path));
   367 	}
   376 	}
   368 	DEBUG(grf, 1, "Scan complete, found %d files", num);
   377 	DEBUG(grf, 1, "Scan complete, found %d files", num);
   369 }
   378 }
   370 
   379 
   371 
   380