Skip to content

Commit 32e600b

Browse files
committed
Small cleanup. Use range-based for.
1 parent e218d87 commit 32e600b

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

src/xrEngine/editor_environment_levels_manager.cpp

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,37 @@ manager::~manager()
3838
::ide().destroy(m_property_holder);
3939
}
4040

41-
void manager::fill_levels(CInifile& config, LPCSTR prefix, LPCSTR category)
41+
void manager::fill_levels(CInifile& config, LPCSTR section, LPCSTR category)
4242
{
43-
string_path section_id;
44-
xr_strcpy(section_id, "level_maps_");
45-
xr_strcat(section_id, prefix);
46-
CInifile::Items const& section = config.r_section(section_id).Data;
47-
48-
CInifile::Items::const_iterator i = section.begin();
49-
CInifile::Items::const_iterator e = section.end();
50-
for (; i != e; ++i)
43+
for (const auto &i : config.r_section(section).Data)
5144
{
52-
if (!(*i).first.size())
45+
if (!i.first.size())
5346
continue;
5447

55-
VERIFY(config.section_exist((*i).first));
56-
if (!config.line_exist((*i).first, "weathers"))
48+
VERIFY(config.section_exist(i.first));
49+
if (!config.line_exist(i.first, "weathers"))
5750
{
58-
m_levels.insert(std::make_pair((*i).first.c_str(), std::make_pair(category, s_default_weather_id)));
51+
m_levels.insert(std::make_pair(i.first.c_str(), std::make_pair(category, s_default_weather_id)));
5952
continue;
6053
}
6154

62-
LPCSTR weather_id = config.r_string((*i).first, "weathers");
63-
m_levels.insert(std::make_pair((*i).first.c_str(), std::make_pair(category, weather_id)));
55+
LPCSTR weather_id = config.r_string(i.first, "weathers");
56+
m_levels.insert(std::make_pair(i.first.c_str(), std::make_pair(category, weather_id)));
6457
}
6558
}
6659

6760
void manager::load()
6861
{
6962
string_path file_name;
7063

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

7569
VERIFY(m_levels.empty());
76-
fill_levels(*m_config_single, "single", "single");
77-
fill_levels(*m_config_mp, "mp", "multiplayer");
70+
fill_levels(*m_config_single, "level_maps_single", "single");
71+
fill_levels(*m_config_mp , "level_maps_mp" , "multiplayer");
7872
}
7973

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

95-
levels_container_type::iterator i = m_levels.begin();
96-
levels_container_type::iterator e = m_levels.end();
97-
for (; i != e; ++i)
89+
for (auto &i : m_levels)
9890
{
9991
string_path description;
10092
xr_strcpy(description, "weather for level ");
101-
xr_strcat(description, (*i).first.c_str());
102-
m_property_holder->add_property((*i).first.c_str(), (*i).second.first, description, (*i).second.second.c_str(),
103-
(*i).second.second, collection_getter, collection_size_getter,
93+
xr_strcat(description, i.first.c_str());
94+
m_property_holder->add_property(i.first.c_str(), i.second.first, description, i.second.second.c_str(),
95+
i.second.second, collection_getter, collection_size_getter,
10496
XRay::Editor::property_holder_base::value_editor_combo_box, XRay::Editor::property_holder_base::cannot_enter_text);
10597
}
10698

src/xrEngine/editor_environment_levels_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class manager : private Noncopyable
4343
void fill();
4444

4545
private:
46-
void fill_levels(CInifile& config, LPCSTR prefix, LPCSTR category);
46+
void fill_levels(CInifile& config, LPCSTR section, LPCSTR category);
4747

4848
private:
4949
LPCSTR const* xr_stdcall collection();

0 commit comments

Comments
 (0)