Skip to content

Commit

Permalink
Don't use optional::value since MacOS < 10.14 doesn't like it
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 17, 2021
1 parent f8bf44e commit f323deb
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/game_launcher.cpp
Expand Up @@ -660,7 +660,7 @@ bool game_launcher::load_game()

savegame::loadgame load(savegame::save_index_class::default_saves_dir(), state_);
if(load_data_) {
load.data() = std::move(load_data_.value());
load.data() = std::move(*load_data_);
clear_loaded_game();
}

Expand Down
2 changes: 1 addition & 1 deletion src/generators/cave_map_generator.cpp
Expand Up @@ -101,7 +101,7 @@ cave_map_generator::cave_map_generator_job::cave_map_generator_job(const cave_ma
"message", "Use the Lua cave generator instead, with scenario_generation=lua and create_scenario= (see wiki for details).",
},
});
uint32_t seed = randomseed ? randomseed.value() : seed_rng::next_seed();
uint32_t seed = randomseed ? *randomseed : seed_rng::next_seed();
rng_.seed(seed);
LOG_NG << "creating random cave with seed: " << seed << '\n';
flipx_ = static_cast<int>(rng_() % 100) < params.flipx_chance_;
Expand Down
2 changes: 1 addition & 1 deletion src/generators/default_map_generator.cpp
Expand Up @@ -81,7 +81,7 @@ std::string default_map_generator::generate_map(std::map<map_location,std::strin
{
uint32_t seed;
if(randomseed) {
seed = randomseed.value();
seed = *randomseed;
} else {
seed = seed_rng::next_seed();
}
Expand Down
4 changes: 2 additions & 2 deletions src/help/help_impl.cpp
Expand Up @@ -1507,10 +1507,10 @@ void push_tab_pair(std::vector<help::item> &v, const std::string &s, const std::
help::item item(s, font::line_width(s, normal_font_size));
if (image) {
// If the image doesn't exist, don't add padding.
auto width = image_width(image.value());
auto width = image_width(*image);
padding = (width ? padding : 0);

item.first = "<img>src='" + image.value() + "'</img>" + (padding ? jump(padding) : "") + s;
item.first = "<img>src='" + *image + "'</img>" + (padding ? jump(padding) : "") + s;
item.second += width + padding;
}
v.emplace_back(item);
Expand Down
24 changes: 12 additions & 12 deletions src/lexical_cast.hpp
Expand Up @@ -147,7 +147,7 @@ struct lexical_caster
std::stringstream sstr;

if(!(sstr << value && sstr >> result)) {
if(fallback) { return fallback.value(); }
if(fallback) { return *fallback; }

throw bad_lexical_cast();
} else {
Expand Down Expand Up @@ -200,7 +200,7 @@ struct lexical_caster<
DEBUG_THROW("specialized - To long long - From (const) char*");

if(fallback) {
return lexical_cast_default<long long>(std::string(value), fallback.value());
return lexical_cast_default<long long>(std::string(value), *fallback);
} else {
return lexical_cast<long long>(std::string(value));
}
Expand Down Expand Up @@ -231,7 +231,7 @@ struct lexical_caster<
}

if(fallback) {
return fallback.value();
return *fallback;
} else {
throw bad_lexical_cast();
}
Expand All @@ -256,7 +256,7 @@ struct lexical_caster<
DEBUG_THROW("specialized - To signed - From (const) char*");

if(fallback) {
return lexical_cast_default<To>(std::string(value), fallback.value());
return lexical_cast_default<To>(std::string(value), *fallback);
} else {
return lexical_cast<To>(std::string(value));
}
Expand Down Expand Up @@ -289,7 +289,7 @@ struct lexical_caster<
}

if(fallback) {
return fallback.value();
return *fallback;
} else {
throw bad_lexical_cast();
}
Expand All @@ -314,7 +314,7 @@ struct lexical_caster<
DEBUG_THROW("specialized - To floating point - From (const) char*");

if(fallback) {
return lexical_cast_default<To>(std::string(value), fallback.value());
return lexical_cast_default<To>(std::string(value), *fallback);
} else {
return lexical_cast<To>(std::string(value));
}
Expand All @@ -340,7 +340,7 @@ struct lexical_caster<
// Explicitly reject hexadecimal values. Unit tests of the config class require that.
if(value.find_first_of("Xx") != std::string::npos) {
if(fallback) {
return fallback.value();
return *fallback;
} else {
throw bad_lexical_cast();
}
Expand All @@ -356,7 +356,7 @@ struct lexical_caster<
}

if(fallback) {
return fallback.value();
return *fallback;
} else {
throw bad_lexical_cast();
}
Expand Down Expand Up @@ -384,7 +384,7 @@ struct lexical_caster<
"specialized - To unsigned long long - From (const) char*");

if(fallback) {
return lexical_cast_default<unsigned long long>(std::string(value), fallback.value());
return lexical_cast_default<unsigned long long>(std::string(value), *fallback);
} else {
return lexical_cast<unsigned long long>(std::string(value));
}
Expand Down Expand Up @@ -415,7 +415,7 @@ struct lexical_caster<
}

if(fallback) {
return fallback.value();
return *fallback;
} else {
throw bad_lexical_cast();
}
Expand All @@ -440,7 +440,7 @@ struct lexical_caster<
DEBUG_THROW("specialized - To unsigned - From (const) char*");

if(fallback) {
return lexical_cast_default<To>(std::string(value), fallback.value());
return lexical_cast_default<To>(std::string(value), *fallback);
} else {
return lexical_cast<To>(std::string(value));
}
Expand Down Expand Up @@ -474,7 +474,7 @@ struct lexical_caster<
}

if(fallback) {
return fallback.value();
return *fallback;
} else {
throw bad_lexical_cast();
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/lua_audio.cpp
Expand Up @@ -98,7 +98,7 @@ static int impl_music_get(lua_State* L) {
if(strcmp(m, "current_i") == 0) {
auto current_index = sound::get_current_track_index();
if(current_index) {
lua_pushinteger(L, current_index.value() + 1);
lua_pushinteger(L, *current_index + 1);
} else {
lua_pushnil(L);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/mapgen_lua_kernel.cpp
Expand Up @@ -301,7 +301,7 @@ config mapgen_lua_kernel::create_scenario(const char * prog, const config & gene
uint32_t mapgen_lua_kernel::get_random_seed()
{
if(random_seed_) {
return random_seed_.value()++;
return (*random_seed_)++;
}
else {
return lua_kernel_base::get_random_seed();
Expand Down
6 changes: 3 additions & 3 deletions src/units/unit.cpp
Expand Up @@ -1437,15 +1437,15 @@ void unit::write(config& cfg, bool write_all) const
}

if(halo_) {
cfg["halo"] = halo_.value();
cfg["halo"] = *halo_;
}

if(ellipse_) {
cfg["ellipse"] = ellipse_.value();
cfg["ellipse"] = *ellipse_;
}

if(usage_) {
cfg["usage"] = usage_.value();
cfg["usage"] = *usage_;
}

write_upkeep(cfg["upkeep"]);
Expand Down
64 changes: 32 additions & 32 deletions src/wesnoth.cpp
Expand Up @@ -364,7 +364,7 @@ static int process_command_args(const commandline_options& cmdline_opts)
// Options that don't change behavior based on any others should be checked alphabetically below.

if(cmdline_opts.log) {
for(const auto& log_pair : cmdline_opts.log.value()) {
for(const auto& log_pair : *cmdline_opts.log) {
const std::string log_domain = log_pair.second;
const int severity = log_pair.first;
if(!lg::set_log_domain_severity(log_domain, severity)) {
Expand Down Expand Up @@ -1124,44 +1124,44 @@ int main(int argc, char** argv)
/**
* @page GUIToolkitWML GUIToolkitWML
* @tableofcontents
*
*
* @section State State
*
*
* A state contains the info what to do in a state. At the moment this is rather focussed on the drawing part, might change later. Keys:
* Key |Type |Default |Description
* Key |Type |Default |Description
* -----------------|------------------------------------|---------|-------------
* draw | @ref guivartype_section "section" |mandatory|Section with drawing directions for a canvas.
*
*
* @section WindowDefinition Window Definition
*
*
* A window defines how a window looks in the game.
* Key |Type |Default |Description
* Key |Type |Default |Description
* -----------------|------------------------------------|---------|-------------
* id | @ref guivartype_string "string" |mandatory|Unique id for this window.
* description | @ref guivartype_t_string "t_string"|mandatory|Unique translatable name for this window.
* resolution | @ref guivartype_section "section" |mandatory|The definitions of the window in various resolutions.
*
*
* @section Cell Cell
*
*
* Every grid cell has some cell configuration values and one widget in the grid cell.
* Here we describe the what is available more information about the usage can be found at @ref GUILayout.
*
* Key |Type |Default |Description
*
* Key |Type |Default |Description
* --------------------|----------------------------------------|---------|-------------
* id | @ref guivartype_string "string" |"" |A grid is a widget and can have an id. This isn't used that often, but is allowed.
* linked_group | @ref guivartype_string "string" |0 |.
*
*
* @section RowValues Row Values
*
*
* For every row the following variables are available:
* Key |Type |Default |Description
* Key |Type |Default |Description
* --------------------|----------------------------------------|---------|-------------
* grow_factor | @ref guivartype_unsigned "unsigned" |0 |The grow factor for a row.
*
*
* @section CellValues Cell Values
*
*
* For every column the following variables are available:
* Key |Type |Default |Description
* Key |Type |Default |Description
* --------------------|----------------------------------------|---------|-------------
* grow_factor | @ref guivartype_unsigned "unsigned" |0 |The grow factor for a column, this value is only read for the first row.
* border_size | @ref guivartype_unsigned "unsigned" |0 |The border size for this grid cell.
Expand All @@ -1175,7 +1175,7 @@ int main(int argc, char** argv)
/**
* @page GUILayout GUILayout
* @tableofcontents
*
*
* @section Abstract Abstract
*
* In the widget library the placement and sizes of elements is determined by
Expand Down Expand Up @@ -1375,7 +1375,7 @@ int main(int argc, char** argv)
/**
* @defgroup GUIWidgetWML GUIWidgetWML
* In various parts of the GUI there are several variables types in use. This section describes them.
*
*
* Below are the simple types which have one value or a short list of options:
* Variable |description
* ------------------------------------------------|-----------
Expand All @@ -1398,16 +1398,16 @@ int main(int argc, char** argv)
* @anchor guivartype_scrollbar_mode scrollbar_mode|How to show the scrollbar of a widget. Possible values:<ul><li>always - The scrollbar is always shown, regardless whether it's required or not.</li><li>never - The scrollbar is never shown, even not when needed. (Note when setting this mode dialogs might not properly fit anymore).</li><li>auto - Shows the scrollbar when needed. The widget will reserve space for the scrollbar, but only show when needed.</li><li>initial_auto - Like auto, but when the scrollbar is not needed the space is not reserved.</li></ul>Use auto when the list can be changed dynamically eg the game list in the lobby. For optimization you can also use auto when you really expect a scrollbar, but don't want it to be shown when not needed eg the language list will need a scrollbar on most screens.
* @anchor guivartype_resize_mode resize_mode |Determines how an image is resized. Possible values:<ul><li>scale - The image is scaled.</li><li>stretch - The first row or column of pixels is copied over the entire image. (Can only be used to scale resize in one direction, else falls back to scale.)</li><li>tile - The image is placed several times until the entire surface is filled. The last images are truncated.</li></ul>
* @anchor guivartype_grow_direction grow_direction|Determines how an image is resized. Possible values:<ul><li>scale - The image is scaled.</li><li>stretch - The first row or column of pixels is copied over the entire image. (Can only be used to scale resize in one direction, else falls back to scale.)</li><li>tile - The image is placed several times until the entire surface is filled. The last images are truncated.</li></ul>
*
*
* For more complex parts, there are sections. Sections contain of several lines of WML and can have sub sections. For example a grid has sub sections which contain various widgets. Here's the list of sections:
* Variable |description
* ------------------------------------------------|-----------
* @anchor guivartype_section section |A generic section. The documentation about the section should describe the section in further detail.
* @anchor guivartype_grid grid |A grid contains several widgets.
* @anchor guivartype_config config |.
*
*
* Every widget has some parts in common. First of all, every definition has the following fields:
* Key |Type |Default |Description
* Key |Type |Default |Description
* -------------|------------------------------------|---------|-----------
* id | @ref guivartype_string "string" |mandatory|Unique id for this gui (theme).
* description | @ref guivartype_t_string "t_string"|mandatory|Unique translatable name for this gui.
Expand All @@ -1417,29 +1417,29 @@ int main(int argc, char** argv)

/**
* @defgroup GUICanvasWML GUICanvasWML
*
*
* A canvas is a blank drawing area on which the user can draw several shapes.
* The drawing is done by adding WML structures to the canvas.
*
*
* @section PreCommit Pre-commit
*
*
* This section contains the pre commit functions.
* These functions will be executed before the drawn canvas is applied on top of the normal background.
* There should only be one pre commit section and its order regarding the other shapes doesn't matter.
* The function has effect on the entire canvas, it's not possible to affect only a small part of the canvas.
*
* The function has effect on the entire canvas, it's not possible to affect only a small part of the canvas.
*
* @subsection Blur Blur
*
* Blurs the background before applying the canvas. This doesn't make sense if the widget isn't semi-transparent.
*
*
* Blurs the background before applying the canvas. This doesn't make sense if the widget isn't semi-transparent.
*
* Keys:
* Key |Type |Default |Description
* Key |Type |Default |Description
* -------------|------------------------------------|---------|-----------
* depth | @ref guivartype_unsigned "unsigned"|0 |The depth to blur.
*/

/**
* @defgroup GUIWindowDefinitionWML GUIWindowDefinitionWML
*
*
* The window definition define how the windows shown in the dialog look.
*/

0 comments on commit f323deb

Please sign in to comment.