Add and use is_dev_version() to version_info.

This commit is contained in:
Pentarctagon 2021-03-24 09:32:05 -05:00
parent e4a803360d
commit 124adb308f
No known key found for this signature in database
GPG key ID: 9456BC54A21DBFA0
3 changed files with 11 additions and 2 deletions

View file

@ -18,7 +18,6 @@
#include "log.hpp"
#include "preferences/general.hpp"
#include "game_version.hpp"
#include "utils/math.hpp"
// Set the default severity with the second parameter.
// -1 means the default is to never log on this domain.
@ -81,7 +80,7 @@ std::string deprecated_message(
FORCE_LOG_TO(out_log, log_deprecate) << message << '\n';
// show deprecation warnings if enabled or if this is a development (odd numbered) release
if(preferences::get("show_deprecation", false) || is_odd(game_config::wesnoth_version.minor_version())) {
if(preferences::get("show_deprecation", false) || game_config::wesnoth_version.is_dev_version()) {
lg::wml_error() << message << '\n';
}
}

View file

@ -14,6 +14,7 @@
#include "game_version.hpp"
#include "utils/math.hpp"
#include "lexical_cast.hpp"
#include "serialization/string_utils.hpp"
#include "wesconfig.h"
@ -169,6 +170,10 @@ bool version_info::is_canonical() const {
return nums_.size() <= 3;
}
bool version_info::is_dev_version() const {
return is_canonical() && is_odd(minor_version());
}
namespace {
template<template<typename> class Fcn>
bool version_comparison_internal(const version_info& l, const version_info& r)

View file

@ -59,6 +59,11 @@ public:
*/
bool is_canonical() const;
/**
* Whether this version represents a development version of Wesnoth aka whether the minor version odd.
*/
bool is_dev_version() const;
/**
* Serializes the version number into string form.
*