Skip to content

Commit

Permalink
Small cleanup. Use range-based for.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr committed Jan 5, 2018
1 parent e218d87 commit 32e600b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
42 changes: 17 additions & 25 deletions src/xrEngine/editor_environment_levels_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,37 @@ manager::~manager()
::ide().destroy(m_property_holder);
}

void manager::fill_levels(CInifile& config, LPCSTR prefix, LPCSTR category)
void manager::fill_levels(CInifile& config, LPCSTR section, LPCSTR category)
{
string_path section_id;
xr_strcpy(section_id, "level_maps_");
xr_strcat(section_id, prefix);
CInifile::Items const& section = config.r_section(section_id).Data;

CInifile::Items::const_iterator i = section.begin();
CInifile::Items::const_iterator e = section.end();
for (; i != e; ++i)
for (const auto &i : config.r_section(section).Data)
{
if (!(*i).first.size())
if (!i.first.size())
continue;

VERIFY(config.section_exist((*i).first));
if (!config.line_exist((*i).first, "weathers"))
VERIFY(config.section_exist(i.first));
if (!config.line_exist(i.first, "weathers"))
{
m_levels.insert(std::make_pair((*i).first.c_str(), std::make_pair(category, s_default_weather_id)));
m_levels.insert(std::make_pair(i.first.c_str(), std::make_pair(category, s_default_weather_id)));
continue;
}

LPCSTR weather_id = config.r_string((*i).first, "weathers");
m_levels.insert(std::make_pair((*i).first.c_str(), std::make_pair(category, weather_id)));
LPCSTR weather_id = config.r_string(i.first, "weathers");
m_levels.insert(std::make_pair(i.first.c_str(), std::make_pair(category, weather_id)));
}
}

void manager::load()
{
string_path file_name;

// Îáðàòèòå âíèìàíèå: äàííûå ôàéëû áóäóò ïåðåçàïèñàíû ïðè çàêðûòèè.
// Òàêæå: êîììåíòàðèè áóäóò óäàëåíû è âñå ñåêöèè îòñîðòèðîâàíû.
m_config_single = CInifile::Create(FS.update_path(file_name, "$game_config$", "game_maps_single.ltx"), false);

m_config_mp = CInifile::Create(FS.update_path(file_name, "$game_config$", "game_maps_mp.ltx"), false);
m_config_mp = CInifile::Create(FS.update_path(file_name, "$game_config$", "game_maps_mp.ltx" ), false);

VERIFY(m_levels.empty());
fill_levels(*m_config_single, "single", "single");
fill_levels(*m_config_mp, "mp", "multiplayer");
fill_levels(*m_config_single, "level_maps_single", "single");
fill_levels(*m_config_mp , "level_maps_mp" , "multiplayer");
}

LPCSTR const* manager::collection() { return (&*m_weathers.weather_ids().begin()); }
Expand All @@ -92,15 +86,13 @@ void manager::fill()
collection_size_getter_type collection_size_getter;
collection_size_getter.bind(this, &manager::collection_size);

levels_container_type::iterator i = m_levels.begin();
levels_container_type::iterator e = m_levels.end();
for (; i != e; ++i)
for (auto &i : m_levels)
{
string_path description;
xr_strcpy(description, "weather for level ");
xr_strcat(description, (*i).first.c_str());
m_property_holder->add_property((*i).first.c_str(), (*i).second.first, description, (*i).second.second.c_str(),
(*i).second.second, collection_getter, collection_size_getter,
xr_strcat(description, i.first.c_str());
m_property_holder->add_property(i.first.c_str(), i.second.first, description, i.second.second.c_str(),
i.second.second, collection_getter, collection_size_getter,
XRay::Editor::property_holder_base::value_editor_combo_box, XRay::Editor::property_holder_base::cannot_enter_text);
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/editor_environment_levels_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class manager : private Noncopyable
void fill();

private:
void fill_levels(CInifile& config, LPCSTR prefix, LPCSTR category);
void fill_levels(CInifile& config, LPCSTR section, LPCSTR category);

private:
LPCSTR const* xr_stdcall collection();
Expand Down

0 comments on commit 32e600b

Please sign in to comment.