The Battle for Wesnoth  1.15.0-dev
Namespaces | Macros | Functions | Variables
wesnoth.cpp File Reference
#include "addon/manager.hpp"
#include "build_info.hpp"
#include "commandline_options.hpp"
#include "config.hpp"
#include "cursor.hpp"
#include "editor/editor_main.hpp"
#include "filesystem.hpp"
#include "floating_label.hpp"
#include "font/error.hpp"
#include "font/font_config.hpp"
#include "formula/formula.hpp"
#include "game_config.hpp"
#include "game_config_manager.hpp"
#include "game_end_exceptions.hpp"
#include "game_launcher.hpp"
#include "gettext.hpp"
#include "gui/core/event/handler.hpp"
#include "gui/dialogs/end_credits.hpp"
#include "gui/dialogs/loading_screen.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/title_screen.hpp"
#include "gui/gui.hpp"
#include "picture.hpp"
#include "log.hpp"
#include "preferences/general.hpp"
#include "scripting/application_lua_kernel.hpp"
#include "scripting/plugins/context.hpp"
#include "scripting/plugins/manager.hpp"
#include "sdl/exception.hpp"
#include "sdl/rect.hpp"
#include "serialization/binary_or_text.hpp"
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
#include "serialization/unicode_cast.hpp"
#include "serialization/schema_validator.hpp"
#include "sound.hpp"
#include "statistics.hpp"
#include "utils/functional.hpp"
#include "game_version.hpp"
#include "video.hpp"
#include "wesconfig.h"
#include "widgets/button.hpp"
#include "wml_exception.hpp"
#include <fenv.h>
#include <SDL.h>
#include <boost/iostreams/categories.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/program_options/errors.hpp>
#include <algorithm>
#include <cerrno>
#include <clocale>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <fstream>
#include <iostream>
#include <vector>

Go to the source code of this file.

Namespaces

 game
 

Macros

#define LOG_CONFIG   LOG_STREAM(info, log_config)
 
#define LOG_GENERAL   LOG_STREAM(info, lg::general())
 
#define LOG_PREPROC   LOG_STREAM(info, log_preprocessor)
 
#define error_exit(res)   return res
 

Functions

static void safe_exit (int res)
 
template<typename filter >
static void encode (const std::string &input_file, const std::string &output_file)
 
template<typename filter >
static void decode (const std::string &input_file, const std::string &output_file)
 
static void gzip_encode (const std::string &input_file, const std::string &output_file)
 
static void gzip_decode (const std::string &input_file, const std::string &output_file)
 
static void bzip2_encode (const std::string &input_file, const std::string &output_file)
 
static void bzip2_decode (const std::string &input_file, const std::string &output_file)
 
static void handle_preprocess_command (const commandline_options &cmdline_opts)
 
static int handle_validate_command (const std::string &file, abstract_validator &validator, const std::vector< std::string > &defines)
 
static int process_command_args (const commandline_options &cmdline_opts)
 Process commandline-arguments. More...
 
static void init_locale ()
 I would prefer to setup locale first so that early error messages can get localized, but we need the game_launcher initialized to have filesystem::get_intl_dir() to work. More...
 
static void warn_early_init_failure ()
 Print an alert and instructions to stderr about early initialization errors. More...
 
static void handle_lua_script_args (game_launcher *game, commandline_options &)
 Handles the lua script command line arguments if present. More...
 
static void check_fpu ()
 
static int do_gameloop (const std::vector< std::string > &args)
 Setups the game environment and enters the titlescreen or game loops. More...
 
static void wesnoth_terminate_handler (int)
 
int main (int argc, char **argv)
 

Variables

static lg::log_domain log_config ("config")
 
static lg::log_domain log_preprocessor ("preprocessor")
 

Macro Definition Documentation

◆ error_exit

#define error_exit (   res)    return res

Definition at line 1013 of file wesnoth.cpp.

Referenced by main().

◆ LOG_CONFIG

#define LOG_CONFIG   LOG_STREAM(info, log_config)

Definition at line 132 of file wesnoth.cpp.

Referenced by do_gameloop().

◆ LOG_GENERAL

#define LOG_GENERAL   LOG_STREAM(info, lg::general())

Definition at line 134 of file wesnoth.cpp.

Referenced by do_gameloop(), and safe_exit().

◆ LOG_PREPROC

#define LOG_PREPROC   LOG_STREAM(info, log_preprocessor)

Definition at line 137 of file wesnoth.cpp.

Referenced by handle_preprocess_command(), and handle_validate_command().

Function Documentation

◆ bzip2_decode()

static void bzip2_decode ( const std::string &  input_file,
const std::string &  output_file 
)
static

Definition at line 212 of file wesnoth.cpp.

Referenced by process_command_args().

◆ bzip2_encode()

static void bzip2_encode ( const std::string &  input_file,
const std::string &  output_file 
)
static

Definition at line 207 of file wesnoth.cpp.

Referenced by process_command_args().

◆ check_fpu()

static void check_fpu ( )
static

Definition at line 638 of file wesnoth.cpp.

Referenced by do_gameloop(), and handle_lua_script_args().

◆ decode()

template<typename filter >
static void decode ( const std::string &  input_file,
const std::string &  output_file 
)
static

Definition at line 178 of file wesnoth.cpp.

References e, in, safe_exit(), and game::error::what().

◆ do_gameloop()

static int do_gameloop ( const std::vector< std::string > &  args)
static

Setups the game environment and enters the titlescreen or game loops.

Definition at line 667 of file wesnoth.cpp.

References check_fpu(), config::child(), config::child_range(), filesystem::directory_name(), gui2::dialogs::loading_screen::display(), sound::empty_playlist(), statistics::fresh_stats(), gui2::dialogs::modal_dialog::get_retval(), handle_lua_script_args(), i, gui2::init(), init_fonts, init_locale(), preferences::joystick_support_enabled(), gui2::dialogs::title_screen::LAUNCH_GAME, load_config, font::load_font_config(), LOG_CONFIG, LOG_GENERAL, gui2::dialogs::title_screen::MAP_EDITOR, gui2::dialogs::title_screen::MP_CONNECT, game_launcher::MP_CONNECT, game_config::mp_debug, gui2::dialogs::title_screen::MP_HOST, game_launcher::MP_HOST, game_launcher::MP_LOCAL, gui2::dialogs::title_screen::MP_LOCAL, next, game_config_manager::NO_FORCE_RELOAD, cursor::NORMAL, game_launcher::play_multiplayer(), sound::play_music_config(), plugins_context::play_slice(), process_command_args(), gui2::dialogs::loading_screen::progress(), gui2::dialogs::title_screen::QUIT_GAME, gui2::dialogs::title_screen::REDRAW_BACKGROUND, refresh_addon_version_info_cache(), refresh_addons, game_launcher::RELOAD_DATA, gui2::dialogs::title_screen::RELOAD_GAME_DATA, safe_exit(), cursor::set(), plugins_context::set_callback(), game_config::set_debug(), image::set_team_colors(), gui2::dialogs::modal_dialog::show(), gui2::dialogs::title_screen::SHOW_ABOUT, editor::start(), sound::stop_music(), game_config::title_music, commandline_options::to_config(), image::update_from_preferences(), lg::using_own_console(), cursor::WAIT, warn_early_init_failure(), and game_config::wesnoth_program_dir.

Referenced by main().

◆ encode()

template<typename filter >
static void encode ( const std::string &  input_file,
const std::string &  output_file 
)
static

Definition at line 150 of file wesnoth.cpp.

References e, in, safe_exit(), and game::error::what().

◆ gzip_decode()

static void gzip_decode ( const std::string &  input_file,
const std::string &  output_file 
)
static

Definition at line 202 of file wesnoth.cpp.

Referenced by process_command_args().

◆ gzip_encode()

static void gzip_encode ( const std::string &  input_file,
const std::string &  output_file 
)
static

Definition at line 197 of file wesnoth.cpp.

Referenced by process_command_args().

◆ handle_lua_script_args()

static void handle_lua_script_args ( game_launcher game,
commandline_options  
)
static

Handles the lua script command line arguments if present.

This function will only run once.

Definition at line 578 of file wesnoth.cpp.

References check_fpu(), and game_launcher::init_lua_script().

Referenced by do_gameloop().

◆ handle_preprocess_command()

static void handle_preprocess_command ( const commandline_options cmdline_opts)
static

◆ handle_validate_command()

static int handle_validate_command ( const std::string &  file,
abstract_validator validator,
const std::vector< std::string > &  defines 
)
static

◆ init_locale()

static void init_locale ( )
static

I would prefer to setup locale first so that early error messages can get localized, but we need the game_launcher initialized to have filesystem::get_intl_dir() to work.

Note: setlocale() does not take GUI language setting into account.

Definition at line 541 of file wesnoth.cpp.

References translation::bind_textdomain(), filesystem::get_intl_dir(), PACKAGE, and translation::set_default_textdomain().

Referenced by do_gameloop().

◆ main()

int main ( int  argc,
char **  argv 
)

◆ process_command_args()

static int process_command_args ( const commandline_options cmdline_opts)
static

Process commandline-arguments.

Definition at line 361 of file wesnoth.cpp.

References commandline_options::bunzip2, commandline_options::bzip2, bzip2_decode(), bzip2_encode(), commandline_options::data_dir, commandline_options::data_path, commandline_options::debug_lua, game_config::debug_lua, error(), game_config::full_build_report(), filesystem::get_cwd(), filesystem::get_user_config_dir(), filesystem::get_user_data_dir(), filesystem::get_wml_location(), commandline_options::gunzip, commandline_options::gzip, gzip_decode(), gzip_encode(), handle_preprocess_command(), handle_validate_command(), commandline_options::help, filesystem::is_bzip2_file(), filesystem::is_directory(), filesystem::is_gzip_file(), game_config::library_versions_report(), lg::list_logdomains(), commandline_options::log, commandline_options::log_precise_timestamps, commandline_options::logdomains, filesystem::normalize_path(), game_config::optional_features_report(), game_config::path, commandline_options::path, lg::precise_timestamps(), commandline_options::preprocess, commandline_options::preprocess_defines, commandline_options::render_image, commandline_options::report, commandline_options::rng_seed, commandline_options::screenshot, schema_validation::schema_validator::set_create_exceptions(), lg::set_log_domain_severity(), filesystem::set_user_config_dir(), filesystem::set_user_data_dir(), version_info::str(), commandline_options::strict_validation, strict_validation_enabled, commandline_options::userconfig_dir, commandline_options::userconfig_path, commandline_options::userdata_dir, commandline_options::userdata_path, commandline_options::validate_schema, commandline_options::validate_with, commandline_options::validate_wml, commandline_options::version, and game_config::wesnoth_version.

Referenced by do_gameloop().

◆ safe_exit()

static void safe_exit ( int  res)
static

Definition at line 142 of file wesnoth.cpp.

References LOG_GENERAL.

Referenced by decode(), do_gameloop(), encode(), and main().

◆ warn_early_init_failure()

static void warn_early_init_failure ( )
static

Print an alert and instructions to stderr about early initialization errors.

This is provided as an aid for users dealing with potential data dir configuration issues. The first code to read core WML has the responsibility to call this function in the event of a problem, to inform the user of the most likely possible cause and suggest a course of action to solve the issue.

Definition at line 565 of file wesnoth.cpp.

Referenced by do_gameloop().

◆ wesnoth_terminate_handler()

static void wesnoth_terminate_handler ( int  )
static

Definition at line 997 of file wesnoth.cpp.

Referenced by main().

Variable Documentation

◆ log_config

lg::log_domain log_config("config")
static

◆ log_preprocessor

lg::log_domain log_preprocessor("preprocessor")
static