src/newgrf_config.cpp
changeset 6229 695400602ab0
parent 6183 59fa5aa7ea3a
child 6247 7d81e3a5d803
equal deleted inserted replaced
6228:a7b26082b00d 6229:695400602ab0
    58 
    58 
    59 /* Find the GRFID and calculate the md5sum */
    59 /* Find the GRFID and calculate the md5sum */
    60 bool FillGRFDetails(GRFConfig *config, bool is_static)
    60 bool FillGRFDetails(GRFConfig *config, bool is_static)
    61 {
    61 {
    62 	if (!FioCheckFileExists(config->filename)) {
    62 	if (!FioCheckFileExists(config->filename)) {
    63 		SETBIT(config->flags, GCF_NOT_FOUND);
    63 		config->status = GCS_NOT_FOUND;
    64 		return false;
    64 		return false;
    65 	}
    65 	}
    66 
    66 
    67 	/* Find and load the Action 8 information */
    67 	/* Find and load the Action 8 information */
    68 	/* 62 is the last file slot before sample.cat.
    68 	/* 62 is the last file slot before sample.cat.
   208 
   208 
   209 
   209 
   210 /** Check if all GRFs in the GRF config from a savegame can be loaded.
   210 /** Check if all GRFs in the GRF config from a savegame can be loaded.
   211  * @return will return any of the following 3 values:<br>
   211  * @return will return any of the following 3 values:<br>
   212  * <ul>
   212  * <ul>
   213  * <li> GCF_ACTIVATED: No problems occured, all GRF files were found and loaded
   213  * <li> GLC_ALL_GOOD: No problems occured, all GRF files were found and loaded
   214  * <li> GCF_COMPATIBLE: For one or more GRF's no exact match was found, but a
   214  * <li> GLC_COMPATIBLE: For one or more GRF's no exact match was found, but a
   215  *     compatible GRF with the same grfid was found and used instead
   215  *     compatible GRF with the same grfid was found and used instead
   216  * <li> GCF_NOT_FOUND: For one or more GRF's no match was found at all
   216  * <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all
   217  * </ul> */
   217  * </ul> */
   218 GCF_Flags IsGoodGRFConfigList(void)
   218 GRFListCompatibility IsGoodGRFConfigList(void)
   219 {
   219 {
   220 	GCF_Flags res = GCF_ACTIVATED;
   220 	GRFListCompatibility res = GLC_ALL_GOOD;
   221 
   221 
   222 	for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
   222 	for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
   223 		const GRFConfig *f = FindGRFConfig(c->grfid, c->md5sum);
   223 		const GRFConfig *f = FindGRFConfig(c->grfid, c->md5sum);
   224 		if (f == NULL) {
   224 		if (f == NULL) {
   225 			char buf[256];
   225 			char buf[256];
   231 				md5sumToString(buf, lastof(buf), c->md5sum);
   231 				md5sumToString(buf, lastof(buf), c->md5sum);
   232 				DEBUG(grf, 1, "NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", BSWAP32(c->grfid), c->filename, buf);
   232 				DEBUG(grf, 1, "NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", BSWAP32(c->grfid), c->filename, buf);
   233 				SETBIT(c->flags, GCF_COMPATIBLE);
   233 				SETBIT(c->flags, GCF_COMPATIBLE);
   234 
   234 
   235 				/* Non-found has precedence over compatibility load */
   235 				/* Non-found has precedence over compatibility load */
   236 				if (res != GCF_NOT_FOUND) res = GCF_COMPATIBLE;
   236 				if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE;
   237 				goto compatible_grf;
   237 				goto compatible_grf;
   238 			}
   238 			}
   239 
   239 
   240 			/* No compatible grf was found, mark it as disabled */
   240 			/* No compatible grf was found, mark it as disabled */
   241 			md5sumToString(buf, lastof(buf), c->md5sum);
   241 			md5sumToString(buf, lastof(buf), c->md5sum);
   242 			DEBUG(grf, 0, "NewGRF %08X (%s) not found; checksum %s", BSWAP32(c->grfid), c->filename, buf);
   242 			DEBUG(grf, 0, "NewGRF %08X (%s) not found; checksum %s", BSWAP32(c->grfid), c->filename, buf);
   243 
   243 
   244 			SETBIT(c->flags, GCF_NOT_FOUND);
   244 			c->status = GCS_NOT_FOUND;
   245 			res = GCF_NOT_FOUND;
   245 			res = GLC_NOT_FOUND;
   246 		} else {
   246 		} else {
   247 compatible_grf:
   247 compatible_grf:
   248 			DEBUG(grf, 1, "Loading GRF %08X from %s", BSWAP32(f->grfid), f->filename);
   248 			DEBUG(grf, 1, "Loading GRF %08X from %s", BSWAP32(f->grfid), f->filename);
   249 			/* The filename could be the filename as in the savegame. As we need
   249 			/* The filename could be the filename as in the savegame. As we need
   250 			 * to load the GRF here, we need the correct filename, so overwrite that
   250 			 * to load the GRF here, we need the correct filename, so overwrite that