@ -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);
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();
@ -57,6 +57,4 @@ void GamelogTestGRF();
bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id);
void GamelogGetOriginalGRFMD5Checksum(uint32 grfid, byte *md5sum);
#endif /* GAMELOG_H */
@ -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);
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;
@ -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)
@ -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));
memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
if (HasBit(c->flags, GCF_COMPATIBLE)) GamelogGetOriginalGRFMD5Checksum(c->ident.grfid, ci->md5sum);
*cv.Append() = ci;
ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);