Changeset - r19914:eca70d0d4b75
[Not reviewed]
master
0 1 0
rubidium - 12 years ago 2012-12-29 10:35:33
rubidium@openttd.org
(svn r24870) -Change: make the duplicate base set message slightly more verbose, and mention files with wrong md5 checksums or files that are missing explicitly
1 file changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/base_media_func.h
Show inline comments
 
@@ -128,30 +128,34 @@ bool BaseSet<T, Tnum_files, Tsearch_in_t
 
		item = filename == NULL ? NULL : origin->GetItem(filename, false);
 
		if (item == NULL) item = origin->GetItem("default", false);
 
		if (item == NULL) {
 
			DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
 
			file->missing_warning = strdup("");
 
		} else {
 
			file->missing_warning = strdup(item->value);
 
		}
 

	
 
		switch (T::CheckMD5(file, BASESET_DIR)) {
 
			case MD5File::CR_MATCH:
 
				this->valid_files++;
 
				/* FALL THROUGH */
 
				this->found_files++;
 
				break;
 

	
 
			case MD5File::CR_MISMATCH:
 
				DEBUG(grf, 1, "MD5 checksum mismatch for: %s (in %s)", filename, full_filename);
 
				this->found_files++;
 
				break;
 

	
 
			case MD5File::CR_NO_FILE:
 
				DEBUG(grf, 1, "The file %s specified in %s is missing", filename, full_filename);
 
				break;
 
		}
 
	}
 

	
 
	return true;
 
}
 

	
 
template <class Tbase_set>
 
bool BaseMedia<Tbase_set>::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
 
{
 
	bool ret = false;
 
	DEBUG(grf, 1, "Checking %s for base " SET_TYPE " set", filename);
 
@@ -171,40 +175,42 @@ bool BaseMedia<Tbase_set>::AddFile(const
 
	if (set->FillSetDetails(ini, path, filename)) {
 
		Tbase_set *duplicate = NULL;
 
		for (Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != NULL; c = c->next) {
 
			if (strcmp(c->name, set->name) == 0 || c->shortname == set->shortname) {
 
				duplicate = c;
 
				break;
 
			}
 
		}
 
		if (duplicate != NULL) {
 
			/* The more complete set takes precedence over the version number. */
 
			if ((duplicate->valid_files == set->valid_files && duplicate->version >= set->version) ||
 
					duplicate->valid_files > set->valid_files) {
 
				DEBUG(grf, 1, "Not adding %s (%i) as base " SET_TYPE " set (duplicate)", set->name, set->version);
 
				DEBUG(grf, 1, "Not adding %s (%i) as base " SET_TYPE " set (duplicate, %s)", set->name, set->version,
 
						duplicate->valid_files > set->valid_files ? "less valid files" : "lower version");
 
				set->next = BaseMedia<Tbase_set>::duplicate_sets;
 
				BaseMedia<Tbase_set>::duplicate_sets = set;
 
			} else {
 
				Tbase_set **prev = &BaseMedia<Tbase_set>::available_sets;
 
				while (*prev != duplicate) prev = &(*prev)->next;
 

	
 
				*prev = set;
 
				set->next = duplicate->next;
 

	
 
				/* If the duplicate set is currently used (due to rescanning this can happen)
 
				 * update the currently used set to the new one. This will 'lie' about the
 
				 * version number until a new game is started which isn't a big problem */
 
				if (BaseMedia<Tbase_set>::used_set == duplicate) BaseMedia<Tbase_set>::used_set = set;
 

	
 
				DEBUG(grf, 1, "Removing %s (%i) as base " SET_TYPE " set (duplicate)", duplicate->name, duplicate->version);
 
				DEBUG(grf, 1, "Removing %s (%i) as base " SET_TYPE " set (duplicate, %s)", duplicate->name, duplicate->version,
 
						duplicate->valid_files < set->valid_files ? "less valid files" : "lower version");
 
				duplicate->next = BaseMedia<Tbase_set>::duplicate_sets;
 
				BaseMedia<Tbase_set>::duplicate_sets = duplicate;
 
				ret = true;
 
			}
 
		} else {
 
			Tbase_set **last = &BaseMedia<Tbase_set>::available_sets;
 
			while (*last != NULL) last = &(*last)->next;
 

	
 
			*last = set;
 
			ret = true;
 
		}
 
		if (ret) {
0 comments (0 inline, 0 general)