Sneaky C-style arrays be hiding

Also dropped some unused code in unit_type.

And there's still one in language.cpp, but I'm not entirely sure if it's safe to
drop the last empty entry there so I left it.
This commit is contained in:
Charles Dang 2018-06-29 14:52:50 +11:00
parent 3c01a4350b
commit de8077add6
2 changed files with 29 additions and 21 deletions

View file

@ -112,6 +112,7 @@
#include "utils/functional.hpp" // for bind_t, bind
#include <boost/range/algorithm/copy.hpp> // boost::copy
#include <boost/range/adaptors.hpp> // boost::adaptors::filtered
#include <array>
#include <cassert> // for assert
#include <cstring> // for strcmp
#include <iterator> // for distance, advance
@ -4453,19 +4454,38 @@ 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[] {
"color_palette", "color_range", "display", "end_level_data", "era",
"event", "generator", "label", "lua", "map", "menu_item",
"modification", "music", "options", "side", "sound_source",
"story", "terrain_graphics", "time", "time_area", "tunnel",
"undo_stack", "variables"
};
static const std::array<std::string, 23> 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",
"story",
"terrain_graphics",
"time",
"time_area",
"tunnel",
"undo_stack",
"variables"
}};
static bool is_handled_file_tag(const std::string &s)
static bool is_handled_file_tag(const std::string& s)
{
for (char const *t : handled_file_tags) {
for(const std::string& t : handled_file_tags) {
if (s == t) return true;
}
return false;
}

View file

@ -553,18 +553,6 @@ int unit_type::experience_needed(bool with_acceleration) const
return experience_needed_;
}
#if 0
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") };
const char** tlist = (gender == unit_race::MALE ? aligns : aligns_female);
return (translation::sgettext(tlist[align]));
}
#endif
bool unit_type::has_ability_by_id(const std::string& ability) const
{
if(const config& abil = cfg_.child("abilities")) {