From 54a7c3243e9b276d4df734785eda9c1eae39f688 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 13 Jun 2010 14:07:49 +0000 Subject: [PATCH] (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad(). --- src/newgrf_config.cpp | 8 +++----- src/newgrf_config.h | 2 +- src/saveload/afterload.cpp | 10 +++++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 8f4d70f19a..2ed69815cb 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -276,6 +276,7 @@ void ResetGRFConfig(bool defaults) /** Check if all GRFs in the GRF config from a savegame can be loaded. + * @param grfconfig GrfConfig to check * @return will return any of the following 3 values:
* */ -GRFListCompatibility IsGoodGRFConfigList() +GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig) { GRFListCompatibility res = GLC_ALL_GOOD; - for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { + for (GRFConfig *c = grfconfig; c != NULL; c = c->next) { const GRFConfig *f = FindGRFConfig(c->ident.grfid, c->ident.md5sum); if (f == NULL) { char buf[256]; @@ -302,7 +303,6 @@ GRFListCompatibility IsGoodGRFConfigList() /* Non-found has precedence over compatibility load */ if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE; - GamelogGRFCompatible(&f->ident); goto compatible_grf; } @@ -310,8 +310,6 @@ GRFListCompatibility IsGoodGRFConfigList() md5sumToString(buf, lastof(buf), c->ident.md5sum); DEBUG(grf, 0, "NewGRF %08X (%s) not found; checksum %s", BSWAP32(c->ident.grfid), c->filename, buf); - GamelogGRFRemove(c->ident.grfid); - c->status = GCS_NOT_FOUND; res = GLC_NOT_FOUND; } else { diff --git a/src/newgrf_config.h b/src/newgrf_config.h index e41fec1c0d..a62b028b4d 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -119,7 +119,7 @@ void AppendStaticGRFConfigs(GRFConfig **dst); void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); void ClearGRFConfigList(GRFConfig **config); void ResetGRFConfig(bool defaults); -GRFListCompatibility IsGoodGRFConfigList(); +GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig); bool FillGRFDetails(GRFConfig *config, bool is_static); char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last); GRFConfig *DuplicateGRFConfig(const GRFConfig *c); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 5b9553be36..c616ce6e7a 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -546,7 +546,15 @@ bool AfterLoadGame() if (_settings_game.vehicle.road_side) _settings_game.vehicle.road_side = 1; /* Check if all NewGRFs are present, we are very strict in MP mode */ - GRFListCompatibility gcf_res = IsGoodGRFConfigList(); + GRFListCompatibility gcf_res = IsGoodGRFConfigList(_grfconfig); + for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { + if (c->status == GCS_NOT_FOUND) { + GamelogGRFRemove(c->ident.grfid); + } else if (HasBit(c->flags, GCF_COMPATIBLE)) { + GamelogGRFCompatible(&c->ident); + } + } + if (_networking && gcf_res != GLC_ALL_GOOD) { SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH); /* Restore the signals */