summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-10-16 21:20:46 +0000
committerfrosch <frosch@openttd.org>2010-10-16 21:20:46 +0000
commitaa688689b1e282537680657c4e268391ef52c4b7 (patch)
tree3805536650587d2e8f25b6e562f9e548b339b086
parentc64d7346f895560083d81d1e7e523e277f37dc13 (diff)
downloadopenttd-aa688689b1e282537680657c4e268391ef52c4b7.tar.xz
(svn r20953) -Add: Resolve Grf filenames from the gamelog also using the md5sum.
-rw-r--r--src/gamelog.cpp72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 206425584..b331d253a 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -106,35 +106,33 @@ static void AddDebugText(char *buf, const char *s, ...)
/**
- * Prints GRF filename if found
- * @param buf The location in the _dbgofs buffer to draw
- * @param grfid GRF which filename to print
- */
-static void PrintGrfFilename(char *buf, uint grfid)
-{
- const GRFConfig *gc = FindGRFConfig(grfid);
-
- if (gc == NULL) return;
-
- AddDebugText(buf, ", filename: %s", gc->filename);
-}
-
-/**
* Prints GRF ID, checksum and filename if found
* @param buf The location in the _dbgofs buffer to draw
* @param grfid GRF ID
- * @param md5sum array of md5sum to print
+ * @param md5sum array of md5sum to print, if known
+ * @param gc GrfConfig, if known
*/
-static void PrintGrfInfo(char *buf, uint grfid, const uint8 *md5sum)
+static void PrintGrfInfo(char *buf, uint grfid, const uint8 *md5sum, const GRFConfig *gc)
{
char txt[40];
- md5sumToString(txt, lastof(txt), md5sum);
-
- AddDebugText(buf, "GRF ID %08X, checksum %s", BSWAP32(grfid), txt);
-
- PrintGrfFilename(buf, grfid);
+ if (md5sum != NULL) {
+ md5sumToString(txt, lastof(txt), md5sum);
+ AddDebugText(buf, "GRF ID %08X, checksum %s", BSWAP32(grfid), txt);
+ } else {
+ AddDebugText(buf, "GRF ID %08X", BSWAP32(grfid));
+ }
+ if (gc != NULL) {
+ AddDebugText(buf, ", filename: %s (md5sum matches)", gc->filename);
+ } else {
+ gc = FindGRFConfig(grfid);
+ if (gc != NULL) {
+ AddDebugText(buf, ", filename: %s (matches GRFID only)", gc->filename);
+ } else {
+ AddDebugText(buf, ", unknown GRF");
+ }
+ }
return;
}
@@ -236,50 +234,58 @@ void GamelogPrint(GamelogPrintProc *proc)
case GLCT_GRFADD: {
const GRFConfig *gc = FindGRFConfig(lc->grfadd.grfid, lc->grfadd.md5sum);
AddDebugText(buf, "Added NewGRF: ");
- PrintGrfInfo(buf, lc->grfadd.grfid, lc->grfadd.md5sum);
+ PrintGrfInfo(buf, lc->grfadd.grfid, lc->grfadd.md5sum, gc);
if (grf_names.Contains(lc->grfadd.grfid)) AddDebugText(buf, ". Gamelog inconsistency: GrfID was already added!");
grf_names[lc->grfadd.grfid] = gc;
break;
}
- case GLCT_GRFREM:
- AddDebugText(buf, "Removed NewGRF: %08X", BSWAP32(lc->grfrem.grfid));
- PrintGrfFilename(buf, lc->grfrem.grfid);
+ case GLCT_GRFREM: {
+ GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
+ AddDebugText(buf, "Removed NewGRF: ");
+ PrintGrfInfo(buf, lc->grfrem.grfid, NULL, gm != grf_names.End() ? gm->second : NULL);
if (!grf_names.Erase(lc->grfrem.grfid)) AddDebugText(buf, ". Gamelog inconsistency: GrfID was never added!");
break;
+ }
case GLCT_GRFCOMPAT: {
const GRFConfig *gc = FindGRFConfig(lc->grfadd.grfid, lc->grfadd.md5sum);
AddDebugText(buf, "Compatible NewGRF loaded: ");
- PrintGrfInfo(buf, lc->grfcompat.grfid, lc->grfcompat.md5sum);
+ PrintGrfInfo(buf, lc->grfcompat.grfid, lc->grfcompat.md5sum, gc);
if (!grf_names.Contains(lc->grfcompat.grfid)) AddDebugText(buf, ". Gamelog inconsistency: GrfID was never added!");
grf_names[lc->grfcompat.grfid] = gc;
break;
}
- case GLCT_GRFPARAM:
- AddDebugText(buf, "GRF parameter changed: %08X", BSWAP32(lc->grfparam.grfid));
- PrintGrfFilename(buf, lc->grfparam.grfid);
+ case GLCT_GRFPARAM: {
+ GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
+ AddDebugText(buf, "GRF parameter changed: ");
+ PrintGrfInfo(buf, lc->grfparam.grfid, NULL, gm != grf_names.End() ? gm->second : NULL);
if (!grf_names.Contains(lc->grfparam.grfid)) AddDebugText(buf, ". Gamelog inconsistency: GrfID was never added!");
break;
+ }
- case GLCT_GRFMOVE:
+ case GLCT_GRFMOVE: {
+ GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
AddDebugText(buf, "GRF order changed: %08X moved %d places %s",
BSWAP32(lc->grfmove.grfid), abs(lc->grfmove.offset), lc->grfmove.offset >= 0 ? "down" : "up" );
- PrintGrfFilename(buf, lc->grfmove.grfid);
+ PrintGrfInfo(buf, lc->grfmove.grfid, NULL, gm != grf_names.End() ? gm->second : NULL);
if (!grf_names.Contains(lc->grfmove.grfid)) AddDebugText(buf, ". Gamelog inconsistency: GrfID was never added!");
break;
+ }
- case GLCT_GRFBUG:
+ case GLCT_GRFBUG: {
+ GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
switch (lc->grfbug.bug) {
default: NOT_REACHED();
case GBUG_VEH_LENGTH:
AddDebugText(buf, "Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X", BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data);
- PrintGrfFilename(buf, lc->grfbug.grfid);
break;
}
+ PrintGrfInfo(buf, lc->grfbug.grfid, NULL, gm != grf_names.End() ? gm->second : NULL);
if (!grf_names.Contains(lc->grfbug.grfid)) AddDebugText(buf, ". Gamelog inconsistency: GrfID was never added!");
break;
+ }
case GLCT_EMERGENCY:
break;