diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 62781fddd6..7d56a0ba50 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -705,30 +705,3 @@ void GamelogGRFUpdate(const GRFConfig *oldc, const GRFConfig *newc) free(ol); free(nl); } - -/** - * Get the MD5 checksum of the original NewGRF that was loaded. - * @param grfid the GRF ID to search for - * @param md5sum the MD5 checksum to write to. - */ -void GamelogGetOriginalGRFMD5Checksum(uint32 grfid, byte *md5sum) -{ - const LoggedAction *la = &_gamelog_action[_gamelog_actions - 1]; - /* There should always be a "start game" action */ - assert(_gamelog_actions > 0); - - do { - const LoggedChange *lc = &la->change[la->changes - 1]; - /* There should always be at least one change per action */ - assert(la->changes > 0); - - do { - if (lc->ct == GLCT_GRFADD && lc->grfadd.grfid == grfid) { - memcpy(md5sum, lc->grfadd.md5sum, sizeof(lc->grfadd.md5sum)); - return; - } - } while (lc-- != la->change); - } while (la-- != _gamelog_action); - - NOT_REACHED(); -} diff --git a/src/gamelog.h b/src/gamelog.h index 9ca3120639..379189e048 100644 --- a/src/gamelog.h +++ b/src/gamelog.h @@ -57,6 +57,4 @@ void GamelogTestGRF(); bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id); -void GamelogGetOriginalGRFMD5Checksum(uint32 grfid, byte *md5sum); - #endif /* GAMELOG_H */ diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 2ed69815cb..a77a537eb9 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -299,7 +299,11 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig) if (f != NULL) { md5sumToString(buf, lastof(buf), c->ident.md5sum); DEBUG(grf, 1, "NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, buf); - SetBit(c->flags, GCF_COMPATIBLE); + if (!HasBit(c->flags, GCF_COMPATIBLE)) { + /* Preserve original_md5sum after it has been assigned */ + SetBit(c->flags, GCF_COMPATIBLE); + memcpy(c->original_md5sum, c->ident.md5sum, sizeof(c->original_md5sum)); + } /* Non-found has precedence over compatibility load */ if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE; diff --git a/src/newgrf_config.h b/src/newgrf_config.h index a62b028b4d..bdac1868ac 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -86,6 +86,7 @@ struct GRFConfig : ZeroedMemoryAllocator { ~GRFConfig(); GRFIdentifier ident; ///< grfid and md5sum to uniquely identify newgrfs + uint8 original_md5sum[16]; ///< MD5 checksum of original file if only a 'compatible' file was loaded char *filename; ///< Filename - either with or without full path char *name; ///< NOSAVE: GRF name (Action 0x08) char *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 9c9133a348..a3e6b5261b 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -604,9 +604,9 @@ struct NewGRFWindow : public QueryStringBaseWindow { ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR); } else { #if defined(ENABLE_NETWORK) - this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window + this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window - /* Only show the things in the current list, or everything when nothing's selected */ + /* Only show the things in the current list, or everything when nothing's selected */ ContentVector cv; for (const GRFConfig *c = this->actives; c != NULL; c = c->next) { if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue; @@ -616,8 +616,7 @@ struct NewGRFWindow : public QueryStringBaseWindow { ci->state = ContentInfo::DOES_NOT_EXIST; ttd_strlcpy(ci->name, c->GetName(), lengthof(ci->name)); ci->unique_id = BSWAP32(c->ident.grfid); - memcpy(ci->md5sum, c->ident.md5sum, sizeof(ci->md5sum)); - if (HasBit(c->flags, GCF_COMPATIBLE)) GamelogGetOriginalGRFMD5Checksum(c->ident.grfid, ci->md5sum); + memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum)); *cv.Append() = ci; } ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);