|
@@ -748,27 +748,25 @@ void DoScanNewGRFFiles(void *callback)
|
|
|
num = i;
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
_modal_progress_work_mutex->EndCritical();
|
|
|
_modal_progress_paint_mutex->BeginCritical();
|
|
|
|
|
|
/* Yes... these are the NewGRF windows */
|
|
|
InvalidateWindowClassesData(WC_SAVELOAD, 0, true);
|
|
|
InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE, GOID_NEWGRF_RESCANNED, true);
|
|
|
if (callback != NULL) ((NewGRFScanCallback*)callback)->OnNewGRFsScanned();
|
|
|
|
|
|
DeleteWindowByClass(WC_MODAL_PROGRESS);
|
|
|
SetModalProgress(false);
|
|
@@ -817,26 +815,24 @@ const GRFConfig *FindGRFConfig(uint32 gr
|
|
|
if (md5sum != NULL || mode == FGCM_ANY) return c;
|
|
|
/* Skip incompatible stuff, unless explicitly allowed */
|
|
|
if (mode != FGCM_NEWEST && HasBit(c->flags, GCF_INVALID)) continue;
|
|
|
/* check version compatibility */
|
|
|
if (mode == FGCM_COMPATIBLE && (c->version < desired_version || c->min_loadable_version > desired_version)) continue;
|
|
|
/* remember the newest one as "the best" */
|
|
|
if (best == NULL || c->version > best->version) best = c;
|
|
|
}
|
|
|
|
|
|
return best;
|
|
|
}
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
/** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */
|
|
|
struct UnknownGRF : public GRFIdentifier {
|
|
|
UnknownGRF *next; ///< The next unknown GRF.
|
|
|
GRFTextWrapper *name; ///< Name of the GRF.
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 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
|
|
@@ -868,27 +864,24 @@ GRFTextWrapper *FindUnknownGRFName(uint3
|
|
|
grf->grfid = grfid;
|
|
|
grf->next = unknown_grfs;
|
|
|
grf->name = new GRFTextWrapper();
|
|
|
grf->name->AddRef();
|
|
|
|
|
|
AddGRFTextToList(&grf->name->text, UNKNOWN_GRF_NAME_PLACEHOLDER);
|
|
|
memcpy(grf->md5sum, md5sum, sizeof(grf->md5sum));
|
|
|
|
|
|
unknown_grfs = grf;
|
|
|
return grf->name;
|
|
|
}
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Retrieve a NewGRF from the current config by its grfid.
|
|
|
* @param grfid grf to look for.
|
|
|
* @param mask GRFID mask to allow for partial matching.
|
|
|
* @return The grf config, if it exists, else \c NULL.
|
|
|
*/
|
|
|
GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask)
|
|
|
{
|
|
|
GRFConfig *c;
|
|
|
|
|
|
for (c = _grfconfig; c != NULL; c = c->next) {
|
|
|
if ((c->ident.grfid & mask) == (grfid & mask)) return c;
|