Merge branch 'master' into jgrpp
# Conflicts: # src/base_media_func.h # src/cargopacket.h # src/gfxinit.cpp # src/industry_cmd.cpp # src/window_gui.h
This commit is contained in:
@@ -25,7 +25,7 @@ extern void CheckExternalFiles();
|
||||
item = metadata->GetItem(name, false); \
|
||||
if (item == nullptr || !item->value.has_value() || item->value->empty()) { \
|
||||
DEBUG(grf, 0, "Base " SET_TYPE "set detail loading: %s field missing.", name); \
|
||||
DEBUG(grf, 0, " Is %s readable for the user running OpenTTD?", full_filename); \
|
||||
DEBUG(grf, 0, " Is %s readable for the user running OpenTTD?", full_filename.c_str()); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ extern void CheckExternalFiles();
|
||||
* @return true if loading was successful.
|
||||
*/
|
||||
template <class T, size_t Tnum_files, bool Tsearch_in_tars>
|
||||
bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const char *path, const char *full_filename, bool allow_empty_filename)
|
||||
bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const std::string &path, const std::string &full_filename, bool allow_empty_filename)
|
||||
{
|
||||
IniGroup *metadata = ini->GetGroup("metadata");
|
||||
IniItem *item;
|
||||
@@ -76,25 +76,25 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
/* Find the filename first. */
|
||||
item = files->GetItem(BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], false);
|
||||
if (item == nullptr || (!item->value.has_value() && !allow_empty_filename)) {
|
||||
DEBUG(grf, 0, "No " SET_TYPE " file for: %s (in %s)", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename);
|
||||
DEBUG(grf, 0, "No " SET_TYPE " file for: %s (in %s)", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item->value.has_value()) {
|
||||
file->filename = nullptr;
|
||||
file->filename.clear();
|
||||
/* If we list no file, that file must be valid */
|
||||
this->valid_files++;
|
||||
this->found_files++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *filename = item->value->c_str();
|
||||
file->filename = str_fmt("%s%s", path, filename);
|
||||
const std::string &filename = item->value.value();
|
||||
file->filename = path + filename;
|
||||
|
||||
/* Then find the MD5 checksum */
|
||||
item = md5s->GetItem(filename, false);
|
||||
if (item == nullptr || !item->value.has_value()) {
|
||||
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename, full_filename);
|
||||
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename.c_str(), full_filename.c_str());
|
||||
return false;
|
||||
}
|
||||
const char *c = item->value->c_str();
|
||||
@@ -107,7 +107,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
} else if ('A' <= *c && *c <= 'F') {
|
||||
j = *c - 'A' + 10;
|
||||
} else {
|
||||
DEBUG(grf, 0, "Malformed MD5 checksum specified for: %s (in %s)", filename, full_filename);
|
||||
DEBUG(grf, 0, "Malformed MD5 checksum specified for: %s (in %s)", filename.c_str(), full_filename.c_str());
|
||||
return false;
|
||||
}
|
||||
if (i % 2 == 0) {
|
||||
@@ -121,10 +121,10 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
item = origin->GetItem(filename, false);
|
||||
if (item == nullptr) item = origin->GetItem("default", false);
|
||||
if (item == nullptr || !item->value.has_value()) {
|
||||
DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
|
||||
file->missing_warning = stredup("");
|
||||
DEBUG(grf, 1, "No origin warning message specified for: %s", filename.c_str());
|
||||
file->missing_warning.clear();
|
||||
} else {
|
||||
file->missing_warning = stredup(item->value->c_str());
|
||||
file->missing_warning = item->value.value();
|
||||
}
|
||||
|
||||
file->check_result = T::CheckMD5(file, BASESET_DIR);
|
||||
@@ -138,12 +138,12 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
break;
|
||||
|
||||
case MD5File::CR_MISMATCH:
|
||||
DEBUG(grf, 1, "MD5 checksum mismatch for: %s (in %s)", filename, full_filename);
|
||||
DEBUG(grf, 1, "MD5 checksum mismatch for: %s (in %s)", filename.c_str(), full_filename.c_str());
|
||||
this->found_files++;
|
||||
break;
|
||||
|
||||
case MD5File::CR_NO_FILE:
|
||||
DEBUG(grf, 1, "The file %s specified in %s is missing", filename, full_filename);
|
||||
DEBUG(grf, 1, "The file %s specified in %s is missing", filename.c_str(), full_filename.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
||||
path.clear();
|
||||
}
|
||||
|
||||
if (set->FillSetDetails(ini, path.c_str(), filename.c_str())) {
|
||||
if (set->FillSetDetails(ini, path, filename)) {
|
||||
Tbase_set *duplicate = nullptr;
|
||||
for (Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != nullptr; c = c->next) {
|
||||
if (c->name == set->name || c->shortname == set->shortname) {
|
||||
@@ -282,7 +282,7 @@ template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci,
|
||||
if (s->GetNumMissing() != 0) continue;
|
||||
|
||||
if (s->shortname != ci->unique_id) continue;
|
||||
if (!md5sum) return s->files[0].filename;
|
||||
if (!md5sum) return s->files[0].filename.c_str();
|
||||
|
||||
byte md5[16];
|
||||
memset(md5, 0, sizeof(md5));
|
||||
@@ -291,7 +291,7 @@ template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci,
|
||||
md5[j] ^= s->files[i].hash[j];
|
||||
}
|
||||
}
|
||||
if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return s->files[0].filename;
|
||||
if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return s->files[0].filename.c_str();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user