summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-23 15:06:56 +0000
committerrubidium <rubidium@openttd.org>2009-01-23 15:06:56 +0000
commitd8b3a237dc3992a592ed7e3ec51591626acb9b87 (patch)
tree672c125cc095db3db691e298d451435923f66498
parent8783a0dc65391af915c6ac6880479b63fb7edc7e (diff)
downloadopenttd-d8b3a237dc3992a592ed7e3ec51591626acb9b87.tar.xz
(svn r15225) -Fix (r15126): searching for 'missing' NewGRFs gave the 'compatability loaded' NewGRF instead of the one that we're actually looking for
-rw-r--r--src/gamelog.cpp27
-rw-r--r--src/gamelog.h2
-rw-r--r--src/newgrf_gui.cpp1
3 files changed, 30 insertions, 0 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 145351ba9..81c4e59fa 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -666,3 +666,30 @@ 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 d2146d7a3..470a308be 100644
--- a/src/gamelog.h
+++ b/src/gamelog.h
@@ -46,4 +46,6 @@ void GamelogTestGRF();
bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id);
+void GamelogGetOriginalGRFMD5Checksum(uint32 grfid, byte *md5sum);
+
#endif /* GAMELOG_H */
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 3596f52ec..727440b08 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -617,6 +617,7 @@ struct NewGRFWindow : public Window {
ttd_strlcpy(ci->name, c->name != NULL ? c->name : c->filename, lengthof(ci->name));
ci->unique_id = BSWAP32(c->grfid);
memcpy(ci->md5sum, c->md5sum, sizeof(ci->md5sum));
+ if (HasBit(c->flags, GCF_COMPATIBLE)) GamelogGetOriginalGRFMD5Checksum(c->grfid, ci->md5sum);
*cv.Append() = ci;
}
ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);