mirror of https://github.com/OpenTTD/OpenTTD
Remove: the concept of UnknownGRFs
These were filled with "<Unknown>" (before 8a2da49
) and later their name would get filled via UDP requests to the server. These UDP packets do not exist anymore, so they will always remain "<Unknown>".
Remove that logic and just use the generic translated error GRF UNKNOWN string instead.
pull/9449/head
parent
3479e59eea
commit
09a7825d1e
|
@ -166,10 +166,7 @@ static void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config)
|
||||||
/* Find the matching GRF file */
|
/* Find the matching GRF file */
|
||||||
const GRFConfig *f = FindGRFConfig(config->ident.grfid, FGCM_EXACT, config->ident.md5sum);
|
const GRFConfig *f = FindGRFConfig(config->ident.grfid, FGCM_EXACT, config->ident.md5sum);
|
||||||
if (f == nullptr) {
|
if (f == nullptr) {
|
||||||
/* Don't know the GRF, so mark game incompatible and the (possibly)
|
AddGRFTextToList(config->name, GetString(STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN));
|
||||||
* already resolved name for this GRF (another server has sent the
|
|
||||||
* name of the GRF already */
|
|
||||||
config->name = FindUnknownGRFName(config->ident.grfid, config->ident.md5sum, true);
|
|
||||||
config->status = GCS_NOT_FOUND;
|
config->status = GCS_NOT_FOUND;
|
||||||
} else {
|
} else {
|
||||||
config->filename = f->filename;
|
config->filename = f->filename;
|
||||||
|
|
|
@ -125,10 +125,7 @@ void NetworkAfterNewGRFScan()
|
||||||
|
|
||||||
const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, c->ident.md5sum);
|
const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, c->ident.md5sum);
|
||||||
if (f == nullptr) {
|
if (f == nullptr) {
|
||||||
/* Don't know the GRF, so mark game incompatible and the (possibly)
|
/* Don't know the GRF (anymore), so mark game incompatible. */
|
||||||
* already resolved name for this GRF (another server has sent the
|
|
||||||
* name of the GRF already. */
|
|
||||||
c->name = FindUnknownGRFName(c->ident.grfid, c->ident.md5sum, true);
|
|
||||||
c->status = GCS_NOT_FOUND;
|
c->status = GCS_NOT_FOUND;
|
||||||
|
|
||||||
/* If we miss a file, we're obviously incompatible. */
|
/* If we miss a file, we're obviously incompatible. */
|
||||||
|
|
|
@ -753,53 +753,6 @@ const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */
|
|
||||||
struct UnknownGRF : public GRFIdentifier {
|
|
||||||
GRFTextWrapper name; ///< Name of the GRF.
|
|
||||||
|
|
||||||
UnknownGRF() = default;
|
|
||||||
UnknownGRF(const UnknownGRF &other) = default;
|
|
||||||
UnknownGRF(UnknownGRF &&other) = default;
|
|
||||||
UnknownGRF(uint32 grfid, const uint8 *_md5sum) : GRFIdentifier(grfid, _md5sum), name(new GRFTextList) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* @param create whether to create a new GRFConfig if the GRFConfig did not
|
|
||||||
* exist in the fake list of GRFConfigs.
|
|
||||||
* @return The GRFTextWrapper of the name of the GRFConfig with the given GRF ID
|
|
||||||
* and MD5 checksum or nullptr when it does not exist and create is false.
|
|
||||||
* This value must NEVER be freed by the caller.
|
|
||||||
*/
|
|
||||||
GRFTextWrapper FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create)
|
|
||||||
{
|
|
||||||
static std::vector<UnknownGRF> unknown_grfs;
|
|
||||||
|
|
||||||
for (const auto &grf : unknown_grfs) {
|
|
||||||
if (grf.grfid == grfid) {
|
|
||||||
if (memcmp(md5sum, grf.md5sum, sizeof(grf.md5sum)) == 0) return grf.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!create) return nullptr;
|
|
||||||
|
|
||||||
unknown_grfs.emplace_back(grfid, md5sum);
|
|
||||||
UnknownGRF &grf = unknown_grfs.back();
|
|
||||||
|
|
||||||
AddGRFTextToList(grf.name, UNKNOWN_GRF_NAME_PLACEHOLDER);
|
|
||||||
|
|
||||||
return grf.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a NewGRF from the current config by its grfid.
|
* Retrieve a NewGRF from the current config by its grfid.
|
||||||
* @param grfid grf to look for.
|
* @param grfid grf to look for.
|
||||||
|
|
|
@ -234,10 +234,6 @@ char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
|
||||||
/* In newgrf_gui.cpp */
|
/* In newgrf_gui.cpp */
|
||||||
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
|
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
|
||||||
|
|
||||||
/** For communication about GRFs over the network */
|
|
||||||
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
|
|
||||||
GRFTextWrapper FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
|
|
||||||
|
|
||||||
void UpdateNewGRFScanStatus(uint num, const char *name);
|
void UpdateNewGRFScanStatus(uint num, const char *name);
|
||||||
void UpdateNewGRFConfigPalette(int32 new_value = 0);
|
void UpdateNewGRFConfigPalette(int32 new_value = 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue