File diff r15195:d002b61d3001 → r15196:77940844856f
src/newgrf_config.cpp
Show inline comments
 
@@ -431,53 +431,49 @@ void ScanNewGRFFiles()
 
	QSortT(to_sort, num, &GRFSorter);
 

	
 
	for (i = 1; i < num; i++) {
 
		to_sort[i - 1]->next = to_sort[i];
 
	}
 
	to_sort[num - 1]->next = NULL;
 
	_all_grfs = to_sort[0];
 

	
 
	free(to_sort);
 

	
 
#ifdef ENABLE_NETWORK
 
	NetworkAfterNewGRFScan();
 
#endif
 
}
 

	
 

	
 
/** Find a NewGRF in the scanned list.
 
 * @param grfid GRFID to look for,
 
 * @param md5sum Expected MD5 sum (set to \c NULL if not relevant).
 
 * @return The matching grf, if it exists in #_all_grfs, else \c NULL.
 
 */
 
const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum)
 
{
 
	for (const GRFConfig *c = _all_grfs; c != NULL; c = c->next) {
 
		if (c->ident.grfid == grfid) {
 
			if (md5sum == NULL) return c;
 

	
 
			if (memcmp(md5sum, c->ident.md5sum, sizeof(c->ident.md5sum)) == 0) return c;
 
		}
 
		if (c->ident.HasGrfIdentifier(grfid, md5sum)) return c;
 
	}
 

	
 
	return NULL;
 
}
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */
 
struct UnknownGRF : public GRFIdentifier {
 
	UnknownGRF *next;
 
	char   name[NETWORK_GRF_NAME_LENGTH];
 
};
 

	
 
/**
 
 * Finds the name of a NewGRF in the list of names for unknown GRFs. An
 
 * unknown GRF is a GRF where the .grf is not found during scanning.
 
 *
 
 * The names are resolved via UDP calls to servers that should know the name,
 
 * though the replies may not come. This leaves "<Unknown>" as name, though
 
 * that shouldn't matter _very_ much as they need GRF crawler or so to look
 
 * up the GRF anyway and that works better with the GRF ID.
 
 *
 
 * @param grfid  the GRF ID part of the 'unique' GRF identifier
 
 * @param md5sum the MD5 checksum part of the 'unique' GRF identifier