Avoid copy initialization of arrays (use direct instead)

This commit is contained in:
Charles Dang 2017-04-21 03:09:37 +11:00
parent e90d11d02a
commit 323516d3d8
19 changed files with 33 additions and 33 deletions

View file

@ -21,7 +21,7 @@
const unsigned short default_campaignd_port = 15008;
namespace {
const std::string addon_type_strings[] = {
const std::string addon_type_strings[] {
"unknown", "core", "campaign", "scenario", "campaign_sp_mp", "campaign_mp",
"scenario_mp", "map_pack", "era", "faction", "mod_mp", /*"gui", */ "media",
"other", ""

View file

@ -142,7 +142,7 @@ static component *find_component(component *root, const std::string &path, path_
//match path elements in [modify_ai] tag
boost::regex re(R"""(([^\.^\[]+)(\[(\d*)\]|\[([^\]]+)\]|()))""");
const int sub_matches[] = {1,3,4};
const int sub_matches[] {1,3,4};
boost::sregex_token_iterator i(path.begin(), path.end(), re, sub_matches);
boost::sregex_token_iterator j;

View file

@ -484,7 +484,7 @@ void commandline_options::parse_log_domains_(const std::string &domains_string,
}
void commandline_options::parse_log_strictness (const std::string & severity ) {
static lg::logger const *loggers[] = { &lg::err(), &lg::warn(), &lg::info(), &lg::debug() };
static lg::logger const *loggers[] { &lg::err(), &lg::warn(), &lg::info(), &lg::debug() };
for (const lg::logger * l : loggers ) {
if (severity == l->get_name()) {
lg::set_strict_severity(*l);

View file

@ -1203,7 +1203,7 @@ void display::drawing_buffer_add(const drawing_layer layer,
// public into the definition of drawing_layer
//
// The drawing is done per layer_group, the range per group is [low, high).
const display::drawing_layer display::drawing_buffer_key::layer_groups[] = {
const display::drawing_layer display::drawing_buffer_key::layer_groups[] {
LAYER_TERRAIN_BG,
LAYER_UNIT_FIRST,
LAYER_UNIT_MOVE_DEFAULT,

View file

@ -413,7 +413,7 @@ void game_config_manager::load_addons_cfg()
cache_.get_config(addon.main_cfg, umc_cfg);
// Annotate "era", "modification", and scenario tags with addon_id info
const char * tags_with_addon_id [] = { "era", "modification", "multiplayer", "scenario", "campaign", nullptr };
const char * tags_with_addon_id [] { "era", "modification", "multiplayer", "scenario", "campaign", nullptr };
for (const char ** type = tags_with_addon_id; *type; type++)
{

View file

@ -42,7 +42,7 @@ static lg::log_domain log_mp_connect_engine("mp/connect/engine");
static lg::log_domain log_network("network");
#define LOG_NW LOG_STREAM(info, log_network)
static const std::string controller_names[] = {
static const std::string controller_names[] {
"human",
"human",
"ai",
@ -50,7 +50,7 @@ static const std::string controller_names[] = {
"reserved"
};
static const std::string attributes_to_trim[] = {
static const std::string attributes_to_trim[] {
"side",
"type",
"gender",

View file

@ -29,7 +29,7 @@ lua_map_generator::lua_map_generator(const config & cfg)
, lk_()
, generator_data_(cfg)
{
const char* required[] = {"id", "config_name", "create_map"};
const char* required[] {"id", "config_name", "create_map"};
for (std::string req : required) {
if (!cfg.has_attribute(req)) {
if(req == "create_map" && cfg.has_attribute("create_scenario")) {

View file

@ -35,7 +35,7 @@ namespace {
hk_scopes scope_editor(1 << SCOPE_EDITOR);
hk_scopes scope_main(1 << SCOPE_MAIN_MENU);
// this contains all static hotkeys
hotkey_command_temp hotkey_list_[] = {
hotkey_command_temp hotkey_list_[] {
{ HOTKEY_SCROLL_UP, "scroll-up", N_("Scroll Up"), false, scope_game | scope_editor, HKCAT_GENERAL, "" },
{ HOTKEY_SCROLL_DOWN, "scroll-down", N_("Scroll Down"), false, scope_game | scope_editor, HKCAT_GENERAL, "" },
{ HOTKEY_SCROLL_LEFT, "scroll-left", N_("Scroll Left"), false, scope_game | scope_editor, HKCAT_GENERAL, "" },

View file

@ -170,7 +170,7 @@ static void wesnoth_setlocale(int category, const std::string& slocale,
* The "" is the last item to work-around a problem in glibc picking
* the non utf8 locale instead an utf8 version if available.
*/
char const *encoding[] = { ".utf-8", ".UTF-8", "" };
char const *encoding[] { ".utf-8", ".UTF-8", "" };
for (int j = 0; j != 3; ++j)
{
locale = lang + encoding[j] + extra;

View file

@ -104,7 +104,7 @@ static void verify(const unit_map& units, const config& cfg) {
u->write(u_cfg);
bool is_ok = true;
static const std::string fields[] = {"type","hitpoints","experience","side",""};
static const std::string fields[] {"type","hitpoints","experience","side",""};
for(const std::string* str = fields; str->empty() == false; ++str) {
if (u_cfg[*str] != un[*str]) {
errbuf << "ERROR IN FIELD '" << *str << "' for unit at "

View file

@ -464,7 +464,7 @@ static int intf_create_animator(lua_State* L)
{
new(L) unit_animator;
if(luaL_newmetatable(L, animatorKey)) {
luaL_Reg metafuncs[] = {
luaL_Reg metafuncs[] {
{"__gc", impl_animator_collect},
{"__index", impl_animator_get},
{"add", impl_add_animation},
@ -1474,7 +1474,7 @@ int game_lua_kernel::intf_get_end_level_data(lua_State* L)
auto data = play_controller_.get_end_level_data_const();
new(L) end_level_data(data);
if(luaL_newmetatable(L, "end level data")) {
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "__index", &impl_end_level_data_get},
{ "__newindex", &dispatch<&game_lua_kernel::impl_end_level_data_set>},
{ "__gc", &impl_end_level_data_collect},
@ -4060,7 +4060,7 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
cmd_log_ << "Registering game-specific wesnoth lib functions...\n";
// Put some callback functions in the scripting environment.
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "add_known_unit", &intf_add_known_unit },
{ "add_modification", &intf_add_modification },
{ "advance_unit", &intf_advance_unit },
@ -4196,7 +4196,7 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
lua_cpp::set_functions(L, cpp_callbacks);
if(play_controller_.get_classification().campaign_type == game_classification::CAMPAIGN_TYPE::TEST) {
static luaL_Reg const test_callbacks[] = {
static luaL_Reg const test_callbacks[] {
{ "fire_wml_menu_item", &dispatch<&game_lua_kernel::intf_fire_wml_menu_item > },
{ nullptr, nullptr }
};
@ -4376,7 +4376,7 @@ void game_lua_kernel::set_game_display(game_display * gd) {
/// These are the child tags of [scenario] (and the like) that are handled
/// elsewhere (in the C++ code).
/// Any child tags not in this list will be passed to Lua's on_load event.
static char const *handled_file_tags[] = {
static char const *handled_file_tags[] {
"color_palette", "color_range", "display", "end_level_data", "era",
"event", "generator", "label", "lua", "map", "menu_item",
"modification", "music", "options", "side", "sound_source",

View file

@ -383,7 +383,7 @@ std::string register_gettext_metatable(lua_State *L)
{
luaL_newmetatable(L, gettextKey);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "__call", &impl_gettext},
{ nullptr, nullptr }
};
@ -402,7 +402,7 @@ std::string register_tstring_metatable(lua_State *L)
{
luaL_newmetatable(L, tstringKey);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "__concat", &impl_tstring_concat},
{ "__gc", &impl_tstring_collect},
{ "__tostring", &impl_tstring_tostring},
@ -426,7 +426,7 @@ std::string register_vconfig_metatable(lua_State *L)
{
luaL_newmetatable(L, vconfigKey);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "__gc", &impl_vconfig_collect},
{ "__index", &impl_vconfig_get},
{ "__len", &impl_vconfig_size},

View file

@ -275,7 +275,7 @@ lua_kernel_base::lua_kernel_base()
// Debug and OS are not, but most of their functions will be disabled below.
cmd_log_ << "Adding standard libs...\n";
static const luaL_Reg safe_libs[] = {
static const luaL_Reg safe_libs[] {
{ "", luaopen_base },
{ "table", luaopen_table },
{ "string", luaopen_string },
@ -344,7 +344,7 @@ lua_kernel_base::lua_kernel_base()
// Add some callback from the wesnoth lib
cmd_log_ << "Registering basic wesnoth API...\n";
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "compare_versions", &intf_compare_versions },
{ "have_file", &lua_fileops::intf_have_file },
{ "read_file", &lua_fileops::intf_read_file },
@ -403,7 +403,7 @@ lua_kernel_base::lua_kernel_base()
// Get some callbacks for map locations
cmd_log_ << "Adding map_location table...\n";
static luaL_Reg const map_callbacks[] = {
static luaL_Reg const map_callbacks[] {
{ "get_direction", &lua_map_location::intf_get_direction },
{ "vector_sum", &lua_map_location::intf_vector_sum },
{ "vector_diff", &lua_map_location::intf_vector_diff },
@ -430,7 +430,7 @@ lua_kernel_base::lua_kernel_base()
cmd_log_ << "Adding name generator metatable...\n";
luaL_newmetatable(L, Gen);
static luaL_Reg const generator[] = {
static luaL_Reg const generator[] {
{ "__call", &impl_name_generator_call},
{ "__gc", &impl_name_generator_collect},
{ nullptr, nullptr}

View file

@ -95,7 +95,7 @@ namespace lua_race {
{
luaL_newmetatable(L, Race);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "__index", &impl_race_get},
{ nullptr, nullptr }
};

View file

@ -81,7 +81,7 @@ void load_tables(lua_State* L)
{
luaL_newmetatable(L, Rng);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "create", &impl_rng_create},
{ "__gc", &impl_rng_destroy},
{ "seed", &impl_rng_seed},

View file

@ -198,7 +198,7 @@ namespace lua_team {
{
luaL_newmetatable(L, Team);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "__index", &impl_side_get},
{ "__newindex", &impl_side_set},
{ "__eq", &impl_side_equal},

View file

@ -132,7 +132,7 @@ mapgen_lua_kernel::mapgen_lua_kernel()
lua_settop(L, 0);
static luaL_Reg const callbacks[] = {
static luaL_Reg const callbacks[] {
{ "find_path", &intf_find_path },
{ "random", &intf_random },
{ nullptr, nullptr }

View file

@ -518,8 +518,8 @@ int unit_type::experience_needed(bool with_acceleration) const
/*
const char* unit_type::alignment_description(unit_type::ALIGNMENT align, unit_race::GENDER gender)
{
static const char* aligns[] = { N_("lawful"), N_("neutral"), N_("chaotic"), N_("liminal") };
static const char* aligns_female[] = { N_("female^lawful"), N_("female^neutral"), N_("female^chaotic"), N_("female^liminal") };
static const char* aligns[] { N_("lawful"), N_("neutral"), N_("chaotic"), N_("liminal") };
static const char* aligns_female[] { N_("female^lawful"), N_("female^neutral"), N_("female^chaotic"), N_("female^liminal") };
const char** tlist = (gender == unit_race::MALE ? aligns : aligns_female);
return (translation::sgettext(tlist[align]));
@ -759,7 +759,7 @@ const config & unit_type::build_unit_cfg() const
// Remove "pure" unit_type attributes (attributes that do not get directly
// copied to units; some do get copied, but under different keys).
static char const *unit_type_attrs[] = { "attacks", "base_ids", "die_sound",
static char const *unit_type_attrs[] { "attacks", "base_ids", "die_sound",
"experience", "flies", "healed_sound", "hide_help", "hitpoints",
"id", "ignore_race_traits", "inherit", "movement", "movement_type",
"name", "num_traits", "variation_id", "variation_name", "recall_cost",
@ -1048,7 +1048,7 @@ void unit_type_data::set_config(config &cfg)
{
const std::string& ter_type = terrain["id"];
config temp_cfg;
static const std::string terrain_info_tags[] = {"movement", "vision", "jamming", "defense"};
static const std::string terrain_info_tags[] {"movement", "vision", "jamming", "defense"};
for (const std::string &tag : terrain_info_tags) {
if (!terrain.has_child(tag)) {
continue;

View file

@ -666,10 +666,10 @@ static int do_gameloop(const std::vector<std::string>& args)
plugins_manager plugins_man(new application_lua_kernel);
plugins_context::Reg const callbacks[] = {
plugins_context::Reg const callbacks[] {
{ "play_multiplayer", std::bind(&game_launcher::play_multiplayer, game.get(), game_launcher::MP_CONNECT)},
};
plugins_context::aReg const accessors[] = {
plugins_context::aReg const accessors[] {
{ "command_line", std::bind(&commandline_options::to_config, &cmdline_opts)},
};