(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.

pull/155/head
frosch 14 years ago
parent 54a7c3243e
commit 52c4af211a

@ -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();
}

@ -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);
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;

@ -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)

@ -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);

Loading…
Cancel
Save