Moved game version stuff from game_config.hpp to version.hpp
They're still in the game_config namespace but are now in a more logical header.
game_config::version has been replaced with wesnoth_version.str(), save for one case
where it was replaced with wesnoth_version directly (it was a comparison against another
version_info object; no need to compare against a string...).
Also cleaned up a bunch of game_config.hpp includes.
(cherry-picked from commit b8d051cb72
)
This commit is contained in:
parent
0a409c391f
commit
553cacd88e
25 changed files with 51 additions and 48 deletions
|
@ -17,7 +17,6 @@
|
|||
#include "addon/manager.hpp"
|
||||
#include "config.hpp"
|
||||
#include "font/pango/escape.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "image.hpp"
|
||||
#include "log.hpp"
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "team.hpp"
|
||||
#include "units/unit.hpp"
|
||||
#include "tod_manager.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
static lg::log_domain log_ai_testing("ai/testing");
|
||||
#define DBG_AI_TESTING LOG_STREAM(debug, log_ai_testing)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "filesystem.hpp"
|
||||
#include "formatter.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "color_range.hpp"
|
||||
|
||||
#include "game_config.hpp"
|
||||
#include "map/map.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "deprecation.hpp"
|
||||
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "preferences/general.hpp"
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace wb {
|
|||
#include "animated.hpp"
|
||||
#include "display_context.hpp"
|
||||
#include "font/standard_colors.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "image.hpp" //only needed for enums (!)
|
||||
#include "key.hpp"
|
||||
#include "time_of_day.hpp"
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
#include "game_classification.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "log.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define ERR_NG LOG_STREAM(err, log_engine)
|
||||
|
@ -96,7 +96,7 @@ config game_classification::to_config() const
|
|||
{
|
||||
config cfg;
|
||||
cfg["label"] = label;
|
||||
cfg["version"] = game_config::version;
|
||||
cfg["version"] = game_config::wesnoth_version.str();
|
||||
cfg["campaign_type"] = campaign_type.to_string();
|
||||
cfg["campaign_define"] = campaign_define;
|
||||
cfg["campaign_extra_defines"] = utils::join(campaign_xtra_defines);
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#include "version.hpp"
|
||||
#include "wesconfig.h"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#ifdef LOAD_REVISION
|
||||
#include "revision.h"
|
||||
#endif
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
|
@ -33,24 +30,9 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
namespace game_config
|
||||
{
|
||||
|
||||
//
|
||||
// Path and revision info
|
||||
// Path info
|
||||
//
|
||||
const std::string version = VERSION;
|
||||
|
||||
const version_info wesnoth_version(VERSION);
|
||||
const version_info min_savegame_version(MIN_SAVEGAME_VERSION);
|
||||
const version_info test_version("test");
|
||||
|
||||
#ifdef REVISION
|
||||
const std::string revision = VERSION " (" REVISION ")";
|
||||
#elif defined(VCS_SHORT_HASH) && defined(VCS_WC_MODIFIED)
|
||||
const std::string revision = std::string(VERSION) + " (" + VCS_SHORT_HASH + (VCS_WC_MODIFIED ? "-Modified" : "-Clean") + ")";
|
||||
#else
|
||||
const std::string revision = VERSION;
|
||||
#endif
|
||||
|
||||
#ifdef WESNOTH_PATH
|
||||
std::string path = WESNOTH_PATH;
|
||||
#else
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#pragma once
|
||||
|
||||
class config;
|
||||
class version_info;
|
||||
class color_range;
|
||||
|
||||
#include "color.hpp"
|
||||
|
@ -38,8 +37,6 @@ namespace game_config
|
|||
extern unsigned int tile_size;
|
||||
extern unsigned lobby_network_timer;
|
||||
extern unsigned lobby_refresh;
|
||||
extern const std::string version;
|
||||
extern const std::string revision;
|
||||
extern const std::string default_title_string;
|
||||
extern std::string default_terrain;
|
||||
|
||||
|
@ -189,9 +186,5 @@ namespace game_config
|
|||
color_t red_to_green(int val, bool for_text = true);
|
||||
color_t blue_to_white(int val, bool for_text = true);
|
||||
|
||||
extern const version_info wesnoth_version;
|
||||
extern const version_info min_savegame_version;
|
||||
extern const version_info test_version;
|
||||
|
||||
std::string get_default_title_string();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "game_end_exceptions.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "game_config.hpp"
|
||||
|
||||
transient_end_level::transient_end_level()
|
||||
: carryover_report(true)
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
#include "config.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "game_config_manager.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "version.hpp"
|
||||
#include "wesnothd_connection_error.hpp"
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
|
@ -123,7 +123,7 @@ config initial_level_config(saved_game& state)
|
|||
}
|
||||
|
||||
// This will force connecting clients to be using the same version number as us.
|
||||
level["version"] = game_config::version;
|
||||
level["version"] = game_config::wesnoth_version.str();
|
||||
return level;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ std::pair<wesnothd_connection_ptr, config> open_connection(std::string host)
|
|||
|
||||
utils::string_map i18n_symbols;
|
||||
i18n_symbols["required_version"] = version;
|
||||
i18n_symbols["your_version"] = game_config::version;
|
||||
i18n_symbols["your_version"] = game_config::wesnoth_version.str();
|
||||
|
||||
const std::string errorstring = VGETTEXT("The server accepts versions '$required_version', but you are using version '$your_version'", i18n_symbols);
|
||||
throw wesnothd_error(errorstring);
|
||||
|
@ -155,7 +155,7 @@ std::pair<wesnothd_connection_ptr, config> open_connection(std::string host)
|
|||
if(data.has_child("version")) {
|
||||
config cfg;
|
||||
config res;
|
||||
cfg["version"] = game_config::version;
|
||||
cfg["version"] = game_config::wesnoth_version.str();
|
||||
res.add_child("version", std::move(cfg));
|
||||
sock->send_data(res);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "gui/widgets/unit_preview_pane.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "help/help.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "play_controller.hpp"
|
||||
#include "units/types.hpp"
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include "map/location.hpp"
|
||||
#include "terrain/translation.hpp"
|
||||
#include "game_config.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <unordered_map>
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "config.hpp" // for config
|
||||
#include "cursor.hpp" // for set, CURSOR_TYPE::NORMAL, etc
|
||||
#include "game_board.hpp" // for game_board, etc
|
||||
#include "game_config.hpp" // for red_to_green
|
||||
#include "game_events/pump.hpp" // for fire
|
||||
#include "gettext.hpp" // for _
|
||||
#include "gui/dialogs/transient_message.hpp" // for show_transient_message
|
||||
|
|
|
@ -217,7 +217,7 @@ bool loadgame::check_version_compatibility()
|
|||
|
||||
bool loadgame::check_version_compatibility(const version_info & save_version)
|
||||
{
|
||||
if (save_version == game_config::version) {
|
||||
if (save_version == game_config::wesnoth_version) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ void savegame::write_game(config_writer &out)
|
|||
{
|
||||
log_scope("write_game");
|
||||
|
||||
out.write_key_val("version", game_config::version);
|
||||
out.write_key_val("version", game_config::wesnoth_version.str());
|
||||
|
||||
gamestate_.write_general_info(out);
|
||||
out.open_child("statistics");
|
||||
|
|
|
@ -287,7 +287,7 @@ static int intf_deprecated_message(lua_State* L) {
|
|||
const DEP_LEVEL level = DEP_LEVEL(luaL_checkinteger(L, 2));
|
||||
const std::string ver_str = lua_isnoneornil(L, 3) ? "" : luaL_checkstring(L, 3);
|
||||
const std::string detail = luaW_checktstring(L, 4);
|
||||
const version_info ver = ver_str.empty() ? game_config::version : ver_str;
|
||||
const version_info ver = ver_str.empty() ? game_config::wesnoth_version.str() : ver_str;
|
||||
const std::string msg = deprecated_message(elem, level, ver, detail);
|
||||
if(level < DEP_LEVEL::INDEFINITE || level >= DEP_LEVEL::REMOVED) {
|
||||
// Invalid deprecation level or level 4 deprecation should raise an interpreter error
|
||||
|
@ -834,7 +834,7 @@ int lua_kernel_base::impl_game_config_get(lua_State* L)
|
|||
return_int_attrib("rest_heal_amount", game_config::rest_heal_amount);
|
||||
return_int_attrib("recall_cost", game_config::recall_cost);
|
||||
return_int_attrib("kill_experience", game_config::kill_experience);
|
||||
return_string_attrib("version", game_config::version);
|
||||
return_string_attrib("version", game_config::wesnoth_version.str());
|
||||
return_bool_attrib("debug", game_config::debug);
|
||||
return_bool_attrib("debug_lua", game_config::debug_lua);
|
||||
return_bool_attrib("mp_debug", game_config::mp_debug);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "buffered_istream.hpp"
|
||||
#include "config.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "log.hpp"
|
||||
#include "serialization/binary_or_text.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
|
|
|
@ -445,7 +445,7 @@ void server::load_config() {
|
|||
if (versions.empty() == false) {
|
||||
accepted_versions_ = utils::split(versions);
|
||||
} else {
|
||||
accepted_versions_.push_back(game_config::version);
|
||||
accepted_versions_.push_back(game_config::wesnoth_version.str());
|
||||
accepted_versions_.push_back("test");
|
||||
}
|
||||
|
||||
|
@ -2801,7 +2801,7 @@ int main(int argc, char** argv) {
|
|||
<< " -V, --version Returns the server version.\n";
|
||||
return 0;
|
||||
} else if (val == "--version" || val == "-V") {
|
||||
std::cout << "Battle for Wesnoth server " << game_config::version
|
||||
std::cout << "Battle for Wesnoth server " << game_config::wesnoth_version.str()
|
||||
<< "\n";
|
||||
return 0;
|
||||
} else if (val == "--daemon" || val == "-d") {
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "game_config.hpp"
|
||||
#include "pathutils.hpp"
|
||||
#include "terrain/translation.hpp"
|
||||
#include "variable.hpp"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "animated.hpp"
|
||||
#include "color.hpp"
|
||||
#include "config.hpp"
|
||||
#include "halo.hpp"
|
||||
#include "units/frame.hpp"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "units/frame_private.hpp"
|
||||
|
||||
#include "color.hpp"
|
||||
#include "halo.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
|
|
|
@ -13,8 +13,14 @@
|
|||
*/
|
||||
|
||||
#include "version.hpp"
|
||||
|
||||
#include "lexical_cast.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "wesconfig.h"
|
||||
|
||||
#ifdef LOAD_REVISION
|
||||
#include "revision.h"
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
|
@ -22,6 +28,22 @@
|
|||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace game_config
|
||||
{
|
||||
const version_info wesnoth_version(VERSION);
|
||||
const version_info min_savegame_version(MIN_SAVEGAME_VERSION);
|
||||
const version_info test_version("test");
|
||||
|
||||
#ifdef REVISION
|
||||
const std::string revision = VERSION " (" REVISION ")";
|
||||
#elif defined(VCS_SHORT_HASH) && defined(VCS_WC_MODIFIED)
|
||||
const std::string revision = std::string(VERSION) + " (" + VCS_SHORT_HASH + (VCS_WC_MODIFIED ? "-Modified" : "-Clean") + ")";
|
||||
#else
|
||||
const std::string revision = VERSION;
|
||||
#endif
|
||||
|
||||
} // namespace game_config
|
||||
|
||||
version_info::version_info()
|
||||
: nums_(3,0), special_(""), special_separator_('\0')
|
||||
{
|
||||
|
|
|
@ -204,3 +204,13 @@ enum VERSION_COMP_OP {
|
|||
|
||||
VERSION_COMP_OP parse_version_op(const std::string& op_str);
|
||||
bool do_version_check(const version_info& a, VERSION_COMP_OP op, const version_info& b);
|
||||
|
||||
namespace game_config
|
||||
{
|
||||
extern const version_info wesnoth_version;
|
||||
extern const version_info min_savegame_version;
|
||||
extern const version_info test_version;
|
||||
|
||||
extern const std::string revision;
|
||||
|
||||
} // namespace game_config
|
||||
|
|
|
@ -471,7 +471,7 @@ static int process_command_args(const commandline_options& cmdline_opts)
|
|||
}
|
||||
|
||||
if(cmdline_opts.version) {
|
||||
std::cout << "Battle for Wesnoth" << " " << game_config::version << "\n\n";
|
||||
std::cout << "Battle for Wesnoth" << " " << game_config::wesnoth_version.str() << "\n\n";
|
||||
std::cout << "Library versions:\n" << game_config::library_versions_report() << '\n';
|
||||
std::cout << "Optional features:\n" << game_config::optional_features_report();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue