(svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().

pull/155/head
frosch 14 years ago
parent 1fd5333070
commit 54a7c3243e

@ -276,6 +276,7 @@ void ResetGRFConfig(bool defaults)
/** Check if all GRFs in the GRF config from a savegame can be loaded. /** 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:<br> * @return will return any of the following 3 values:<br>
* <ul> * <ul>
* <li> GLC_ALL_GOOD: No problems occured, all GRF files were found and loaded * <li> GLC_ALL_GOOD: No problems occured, all GRF files were found and loaded
@ -283,11 +284,11 @@ void ResetGRFConfig(bool defaults)
* compatible GRF with the same grfid was found and used instead * compatible GRF with the same grfid was found and used instead
* <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all * <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all
* </ul> */ * </ul> */
GRFListCompatibility IsGoodGRFConfigList() GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
{ {
GRFListCompatibility res = GLC_ALL_GOOD; 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); const GRFConfig *f = FindGRFConfig(c->ident.grfid, c->ident.md5sum);
if (f == NULL) { if (f == NULL) {
char buf[256]; char buf[256];
@ -302,7 +303,6 @@ GRFListCompatibility IsGoodGRFConfigList()
/* Non-found has precedence over compatibility load */ /* Non-found has precedence over compatibility load */
if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE; if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE;
GamelogGRFCompatible(&f->ident);
goto compatible_grf; goto compatible_grf;
} }
@ -310,8 +310,6 @@ GRFListCompatibility IsGoodGRFConfigList()
md5sumToString(buf, lastof(buf), c->ident.md5sum); md5sumToString(buf, lastof(buf), c->ident.md5sum);
DEBUG(grf, 0, "NewGRF %08X (%s) not found; checksum %s", BSWAP32(c->ident.grfid), c->filename, buf); 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; c->status = GCS_NOT_FOUND;
res = GLC_NOT_FOUND; res = GLC_NOT_FOUND;
} else { } else {

@ -119,7 +119,7 @@ void AppendStaticGRFConfigs(GRFConfig **dst);
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
void ClearGRFConfigList(GRFConfig **config); void ClearGRFConfigList(GRFConfig **config);
void ResetGRFConfig(bool defaults); void ResetGRFConfig(bool defaults);
GRFListCompatibility IsGoodGRFConfigList(); GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig);
bool FillGRFDetails(GRFConfig *config, bool is_static); bool FillGRFDetails(GRFConfig *config, bool is_static);
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last); char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
GRFConfig *DuplicateGRFConfig(const GRFConfig *c); GRFConfig *DuplicateGRFConfig(const GRFConfig *c);

@ -546,7 +546,15 @@ bool AfterLoadGame()
if (_settings_game.vehicle.road_side) _settings_game.vehicle.road_side = 1; 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 */ /* 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) { if (_networking && gcf_res != GLC_ALL_GOOD) {
SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH); SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH);
/* Restore the signals */ /* Restore the signals */

Loading…
Cancel
Save