diff options
author | frosch <frosch@openttd.org> | 2010-06-13 14:11:32 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-06-13 14:11:32 +0000 |
commit | 56fbbdeafd2321a1e1d3a9349d5d07cdaf4d64a7 (patch) | |
tree | 414041a43fec98d9e845ef00638e00ee4a476bda | |
parent | 641fc68aa80fc24fa277ae3dc62eec2969bdd26b (diff) | |
download | openttd-56fbbdeafd2321a1e1d3a9349d5d07cdaf4d64a7.tar.xz |
(svn r19972) -Change: Use the md5sum from the previous save of the game for BaNaNaS instead of the initial (when the grf was added) md5sum from the gamelog. Neither method is 'better', but this way it is independent from the gamelog.
-rw-r--r-- | src/gamelog.cpp | 27 | ||||
-rw-r--r-- | src/gamelog.h | 2 | ||||
-rw-r--r-- | src/newgrf_config.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_config.h | 1 | ||||
-rw-r--r-- | src/newgrf_gui.cpp | 7 |
5 files changed, 9 insertions, 34 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 62781fddd..7d56a0ba5 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 9ca312063..379189e04 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 2ed69815c..a77a537eb 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 a62b028b4..bdac1868a 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 9c9133a34..a3e6b5261 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); |