Changeset - r10890:d53fc8ed7a65
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-01-23 15:06:56
rubidium@openttd.org
(svn r15225) -Fix (r15126): searching for 'missing' NewGRFs gave the 'compatability loaded' NewGRF instead of the one that we're actually looking for
3 files changed with 30 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/gamelog.cpp
Show inline comments
 
@@ -645,24 +645,51 @@ void GamelogGRFUpdate(const GRFConfig *o
 
			} else {
 
				GamelogGRFMove(nl->grf[n++]->grfid, -(int)oi);
 
			}
 
		} else {
 
			if (memcmp(og->md5sum, ng->md5sum, sizeof(og->md5sum)) != 0) {
 
				/* md5sum changed, probably loading 'compatible' GRF */
 
				GamelogGRFCompatible(nl->grf[n]);
 
			}
 

	
 
			if (og->num_params != ng->num_params || memcmp(og->param, ng->param, og->num_params * sizeof(og->param[0])) != 0) {
 
				GamelogGRFParameters(ol->grf[o]->grfid);
 
			}
 

	
 
			o++;
 
			n++;
 
		}
 
	}
 

	
 
	while (o < ol->n) GamelogGRFRemove(ol->grf[o++]->grfid); // remaining GRFs were removed ...
 
	while (n < nl->n) GamelogGRFAdd   (nl->grf[n++]);    // ... or added
 

	
 
	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();
 
}
src/gamelog.h
Show inline comments
 
@@ -25,25 +25,27 @@ void GamelogReset();
 

	
 
typedef void GamelogPrintProc(const char *s);
 
void GamelogPrint(GamelogPrintProc *proc); // needed for WIN32 / WINCE crash.log
 

	
 
void GamelogPrintDebug(int level);
 
void GamelogPrintConsole();
 

	
 
void GamelogRevision();
 
void GamelogMode();
 
void GamelogOldver();
 
void GamelogPatch(const char *name, int32 oldval, int32 newval);
 

	
 
void GamelogGRFUpdate(const GRFConfig *oldg, const GRFConfig *newg);
 
void GamelogGRFAddList(const GRFConfig *newg);
 
void GamelogGRFRemove(uint32 grfid);
 
void GamelogGRFAdd(const GRFConfig *newg);
 
void GamelogGRFCompatible(const GRFIdentifier *newg);
 

	
 
void GamelogTestRevision();
 
void GamelogTestMode();
 
void GamelogTestGRF();
 

	
 
bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id);
 

	
 
void GamelogGetOriginalGRFMD5Checksum(uint32 grfid, byte *md5sum);
 

	
 
#endif /* GAMELOG_H */
src/newgrf_gui.cpp
Show inline comments
 
@@ -596,48 +596,49 @@ struct NewGRFWindow : public Window {
 

	
 
			case SNGRFS_TOGGLE_PALETTE:
 
				if (this->sel != NULL) {
 
					this->sel->windows_paletted ^= true;
 
					this->SetDirty();
 
				}
 
				break;
 

	
 
			case SNGRFS_CONTENT_DOWNLOAD:
 
				if (!_network_available) {
 
					ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
 
				} else {
 
#if defined(ENABLE_NETWORK)
 
				/* Only show the things in the current list, or everything when nothing's selected */
 
					ContentVector cv;
 
					for (const GRFConfig *c = this->list; c != NULL; c = c->next) {
 
						if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue;
 

	
 
						ContentInfo *ci = new ContentInfo();
 
						ci->type = CONTENT_TYPE_NEWGRF;
 
						ci->state = ContentInfo::DOES_NOT_EXIST;
 
						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);
 
#endif
 
				}
 
				break;
 

	
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		if (index == -1) {
 
			ClearGRFConfigList(&this->list);
 
			this->preset = -1;
 
		} else {
 
			GRFConfig *c = LoadGRFPresetFromConfig(_grf_preset_list[index]);
 

	
 
			if (c != NULL) {
 
				this->sel = NULL;
 
				ClearGRFConfigList(&this->list);
 
				this->list = c;
 
				this->preset = index;
 
			}
0 comments (0 inline, 0 general)