mirror of https://github.com/OpenTTD/OpenTTD
Add: [BaseSet] Allow basesets to set minor and patch versions in obg/obs/obm files.
parent
d30fee4a99
commit
6db13df3b5
|
@ -63,7 +63,7 @@ struct BaseSet {
|
|||
std::string url; ///< URL for information about the base set
|
||||
TranslatedStrings description; ///< Description of the base set
|
||||
uint32_t shortname = 0; ///< Four letter short variant of the name
|
||||
uint32_t version = 0; ///< The version of this base set
|
||||
std::vector<uint32_t> version; ///< The version of this base set
|
||||
bool fallback = false; ///< This set is a fallback set, i.e. it should be used only as last resort
|
||||
|
||||
std::array<MD5File, BaseSet<T>::NUM_FILES> files{}; ///< All files part of this set
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "string_func.h"
|
||||
#include "error_func.h"
|
||||
#include "core/string_consumer.hpp"
|
||||
#include "3rdparty/fmt/ranges.h"
|
||||
|
||||
extern void CheckExternalFiles();
|
||||
|
||||
|
@ -91,12 +92,16 @@ bool BaseSet<T>::FillSetDetails(const IniFile &ini, const std::string &path, con
|
|||
|
||||
item = this->GetMandatoryItem(full_filename, *metadata, "version");
|
||||
if (item == nullptr) return false;
|
||||
auto value = ParseInteger(*item->value);
|
||||
if (!value.has_value()) {
|
||||
this->LogError(full_filename, fmt::format("metadata.version field is invalid: {}", *item->value));
|
||||
return false;
|
||||
for (StringConsumer consumer{*item->value};;) {
|
||||
auto value = consumer.TryReadIntegerBase<uint32_t>(10);
|
||||
bool valid = value.has_value();
|
||||
if (valid) this->version.push_back(*value);
|
||||
if (valid && !consumer.AnyBytesLeft()) break;
|
||||
if (!valid || !consumer.ReadIf(".")) {
|
||||
this->LogError(full_filename, fmt::format("metadata.version field is invalid: {}", *item->value));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this->version = *value;
|
||||
|
||||
item = metadata->GetItem("fallback");
|
||||
this->fallback = (item != nullptr && item->value && *item->value != "0" && *item->value != "false");
|
||||
|
@ -224,7 +229,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
|||
/* 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(misc, 1, "Not adding {} ({}) as base {} set (duplicate, {})", set->name, set->version,
|
||||
Debug(misc, 1, "Not adding {} ({}) as base {} set (duplicate, {})", set->name, fmt::join(set->version, "."),
|
||||
BaseSet<Tbase_set>::SET_TYPE,
|
||||
duplicate->valid_files > set->valid_files ? "less valid files" : "lower version");
|
||||
set->next = BaseMedia<Tbase_set>::duplicate_sets;
|
||||
|
@ -244,7 +249,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
|||
* 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(misc, 1, "Removing {} ({}) as base {} set (duplicate, {})", duplicate->name, duplicate->version,
|
||||
Debug(misc, 1, "Removing {} ({}) as base {} set (duplicate, {})", duplicate->name, fmt::join(duplicate->version, "."),
|
||||
BaseSet<Tbase_set>::SET_TYPE,
|
||||
duplicate->valid_files < set->valid_files ? "less valid files" : "lower version");
|
||||
duplicate->next = BaseMedia<Tbase_set>::duplicate_sets;
|
||||
|
@ -259,7 +264,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
|||
ret = true;
|
||||
}
|
||||
if (ret) {
|
||||
Debug(misc, 1, "Adding {} ({}) as base {} set", set->name, set->version, BaseSet<Tbase_set>::SET_TYPE);
|
||||
Debug(misc, 1, "Adding {} ({}) as base {} set", set->name, fmt::join(set->version, "."), BaseSet<Tbase_set>::SET_TYPE);
|
||||
}
|
||||
} else {
|
||||
delete set;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "debug.h"
|
||||
#include "fileio_func.h"
|
||||
#include "screenshot_type.h"
|
||||
#include "3rdparty/fmt/ranges.h"
|
||||
|
||||
#include <png.h>
|
||||
|
||||
|
@ -83,7 +84,7 @@ public:
|
|||
|
||||
std::string message;
|
||||
message.reserve(1024);
|
||||
format_append(message, "Graphics set: {} ({})\n", BaseGraphics::GetUsedSet()->name, BaseGraphics::GetUsedSet()->version);
|
||||
format_append(message, "Graphics set: {} ({})\n", BaseGraphics::GetUsedSet()->name, fmt::join(BaseGraphics::GetUsedSet()->version, "."));
|
||||
message += "NewGRFs:\n";
|
||||
if (_game_mode != GM_MENU) {
|
||||
for (const auto &c : _grfconfig) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "timer/timer_game_tick.h"
|
||||
#include "timer/timer_game_calendar.h"
|
||||
#include "timer/timer_game_economy.h"
|
||||
#include "3rdparty/fmt/ranges.h"
|
||||
|
||||
#include "currency.h"
|
||||
#include "fontcache.h"
|
||||
|
@ -274,7 +275,7 @@ void SurveyConfiguration(nlohmann::json &survey)
|
|||
survey["video_info"] = VideoDriver::GetInstance()->GetInfoString();
|
||||
}
|
||||
if (BaseGraphics::GetUsedSet() != nullptr) {
|
||||
survey["graphics_set"] = fmt::format("{}.{}", BaseGraphics::GetUsedSet()->name, BaseGraphics::GetUsedSet()->version);
|
||||
survey["graphics_set"] = fmt::format("{}.{}", BaseGraphics::GetUsedSet()->name, fmt::join(BaseGraphics::GetUsedSet()->version, "."));
|
||||
const GRFConfig *extra_cfg = BaseGraphics::GetUsedSet()->GetExtraConfig();
|
||||
if (extra_cfg != nullptr && !extra_cfg->param.empty()) {
|
||||
survey["graphics_set_parameters"] = std::span<const uint32_t>(extra_cfg->param);
|
||||
|
@ -283,10 +284,10 @@ void SurveyConfiguration(nlohmann::json &survey)
|
|||
}
|
||||
}
|
||||
if (BaseMusic::GetUsedSet() != nullptr) {
|
||||
survey["music_set"] = fmt::format("{}.{}", BaseMusic::GetUsedSet()->name, BaseMusic::GetUsedSet()->version);
|
||||
survey["music_set"] = fmt::format("{}.{}", BaseMusic::GetUsedSet()->name, fmt::join(BaseMusic::GetUsedSet()->version, "."));
|
||||
}
|
||||
if (BaseSounds::GetUsedSet() != nullptr) {
|
||||
survey["sound_set"] = fmt::format("{}.{}", BaseSounds::GetUsedSet()->name, BaseSounds::GetUsedSet()->version);
|
||||
survey["sound_set"] = fmt::format("{}.{}", BaseSounds::GetUsedSet()->name, fmt::join(BaseSounds::GetUsedSet()->version, "."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue