diff --git a/src/xrEngine/editor_environment_ambients_ambient.cpp b/src/xrEngine/editor_environment_ambients_ambient.cpp index 7253851aea6..affeacf29cd 100644 --- a/src/xrEngine/editor_environment_ambients_ambient.cpp +++ b/src/xrEngine/editor_environment_ambients_ambient.cpp @@ -27,7 +27,7 @@ using editor::environment::effects::effect; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id().c_str()); } @@ -42,7 +42,7 @@ XRay::Editor::property_holder_base* property_collection void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id().c_str()); } @@ -85,7 +85,7 @@ void ambient::load( { VERIFY(m_effects_ids.empty()); - LPCSTR effects_string = READ_IF_EXISTS(&ambients_config, r_string, m_load_section, "effects", ""); + pcstr effects_string = READ_IF_EXISTS(&ambients_config, r_string, m_load_section, "effects", ""); for (u32 i = 0, n = _GetItemCount(effects_string); i < n; ++i) { string_path temp; @@ -97,7 +97,7 @@ void ambient::load( { VERIFY(m_sound_channels_ids.empty()); - LPCSTR sounds_string = READ_IF_EXISTS(&ambients_config, r_string, m_load_section, "sound_channels", ""); + pcstr sounds_string = READ_IF_EXISTS(&ambients_config, r_string, m_load_section, "sound_channels", ""); for (u32 i = 0, n = _GetItemCount(sounds_string); i < n; ++i) { string_path temp; @@ -111,25 +111,19 @@ void ambient::load( void ambient::save(CInifile& config) { u32 count = 1; - LPSTR temp = 0; + pstr temp = 0; { - sound_container_type::const_iterator b = m_sound_channels_ids.begin(), i = b; - sound_container_type::const_iterator e = m_sound_channels_ids.end(); - for (; i != e; ++i) - count += (*i)->id().size() + 2; - - temp = (LPSTR)_alloca(count * sizeof(char)); - *temp = 0; - for (i = b; i != e; ++i) + for (const auto &i : m_sound_channels_ids) + count += i->id().size() + 2; + + temp = (pstr)_alloca(count * sizeof(char)); + *temp = '\0'; + for (const auto &i : m_sound_channels_ids) { - if (i == b) - { - xr_strcpy(temp, count, (*i)->id().c_str()); - continue; - } - - xr_strcat(temp, count, ", "); - xr_strcat(temp, count, (*i)->id().c_str()); + xr_strcat(temp, count, i->id().c_str()); + + if (&i != &m_sound_channels_ids.back()) + xr_strcat(temp, count, ", "); } } @@ -139,30 +133,23 @@ void ambient::save(CInifile& config) { count = 1; - effect_container_type::const_iterator b = m_effects_ids.begin(), i = b; - effect_container_type::const_iterator e = m_effects_ids.end(); - for (; i != e; ++i) - count += (*i)->id().size() + 2; - - temp = (LPSTR)_alloca(count * sizeof(char)); - *temp = 0; - for (i = b; i != e; ++i) + for (const auto &i : m_effects_ids) + count += i->id().size() + 2; + + temp = (pstr)_alloca(count * sizeof(char)); + *temp = '\0'; + for (const auto &i : m_effects_ids) { - if (i == b) - { - xr_strcpy(temp, count, (*i)->id().c_str()); - continue; - } - - xr_strcat(temp, count, ", "); - xr_strcat(temp, count, (*i)->id().c_str()); + xr_strcat(temp, count, i->id().c_str()); + if (&i != &m_effects_ids.back()) + xr_strcat(temp, count, ", "); } } config.w_string(m_load_section.c_str(), "effects", temp); } -LPCSTR ambient::id_getter() const { return (m_load_section.c_str()); } -void ambient::id_setter(LPCSTR value_) +pcstr ambient::id_getter() const { return (m_load_section.c_str()); } +void ambient::id_setter(pcstr value_) { shared_str value = value_; if (m_load_section._get() == value._get()) @@ -211,7 +198,7 @@ ::editor::environment::sound_channels::manager const& ambient::sounds_manager() return (m_manager.sounds_manager()); } -ambient::SEffect* ambient::create_effect(CInifile& config, LPCSTR id) +ambient::SEffect* ambient::create_effect(CInifile& config, pcstr id) { effect* result = new effect(m_manager.effects_manager(), id); result->load(config); @@ -219,7 +206,7 @@ ambient::SEffect* ambient::create_effect(CInifile& config, LPCSTR id) return (result); } -ambient::SSndChannel* ambient::create_sound_channel(CInifile& config, LPCSTR id) +ambient::SSndChannel* ambient::create_sound_channel(CInifile& config, pcstr id) { channel* result = new channel(m_manager.sounds_manager(), id); result->load(config); diff --git a/src/xrEngine/editor_environment_ambients_ambient.hpp b/src/xrEngine/editor_environment_ambients_ambient.hpp index 5588883af67..224ccae056d 100644 --- a/src/xrEngine/editor_environment_ambients_ambient.hpp +++ b/src/xrEngine/editor_environment_ambients_ambient.hpp @@ -49,14 +49,14 @@ class ambient : public CEnvAmbient, public XRay::Editor::property_holder_holder, void save(CInifile& config); void fill(XRay::Editor::property_holder_collection* collection); inline shared_str const& id() const { return m_load_section; } - virtual SEffect* create_effect(CInifile& config, LPCSTR id); - virtual SSndChannel* create_sound_channel(CInifile& config, LPCSTR id); + virtual SEffect* create_effect(CInifile& config, pcstr id); + virtual SSndChannel* create_sound_channel(CInifile& config, pcstr id); virtual EffectVec& effects(); virtual SSndChannelVec& get_snd_channels(); private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); public: effects::manager const& effects_manager() const; diff --git a/src/xrEngine/editor_environment_ambients_effect_id.cpp b/src/xrEngine/editor_environment_ambients_effect_id.cpp index 3c45862a764..f553c79dfd0 100644 --- a/src/xrEngine/editor_environment_ambients_effect_id.cpp +++ b/src/xrEngine/editor_environment_ambients_effect_id.cpp @@ -29,7 +29,7 @@ effect_id::~effect_id() ::ide().destroy(m_property_holder); } -LPCSTR const* effect_id::collection() { return (&*m_manager.effects_ids().begin()); } +pcstr const* effect_id::collection() { return (&*m_manager.effects_ids().begin()); } u32 effect_id::collection_size() { return (m_manager.effects_ids().size()); } void effect_id::fill(XRay::Editor::property_holder_collection* collection) { diff --git a/src/xrEngine/editor_environment_ambients_effect_id.hpp b/src/xrEngine/editor_environment_ambients_effect_id.hpp index aa66d10ece7..12f44ba2342 100644 --- a/src/xrEngine/editor_environment_ambients_effect_id.hpp +++ b/src/xrEngine/editor_environment_ambients_effect_id.hpp @@ -39,7 +39,7 @@ class effect_id : public XRay::Editor::property_holder_holder, private Noncopyab virtual property_holder_type* object(); private: - LPCSTR const* xr_stdcall collection(); + pcstr const* xr_stdcall collection(); u32 xr_stdcall collection_size(); private: diff --git a/src/xrEngine/editor_environment_ambients_manager.cpp b/src/xrEngine/editor_environment_ambients_manager.cpp index 0ec6b3ad549..cae1e2126fd 100644 --- a/src/xrEngine/editor_environment_ambients_manager.cpp +++ b/src/xrEngine/editor_environment_ambients_manager.cpp @@ -22,7 +22,7 @@ using editor::environment::detail::logical_string_predicate; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id().c_str()); } @@ -60,13 +60,10 @@ void manager::load() typedef CInifile::Root sections_type; sections_type& sections = m_manager.m_ambients_config->sections(); m_ambients.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) + for (const auto &i : sections) { - ambient* object = new ambient(*this, (*i)->Name); - object->load( - *m_manager.m_ambients_config, *m_manager.m_sound_channels_config, *m_manager.m_effects_config, (*i)->Name); + ambient* object = new ambient(*this, i->Name); + object->load(*m_manager.m_ambients_config, *m_manager.m_sound_channels_config, *m_manager.m_effects_config, i->Name); object->fill(m_collection); m_ambients.push_back(object); } @@ -75,13 +72,10 @@ void manager::load() void manager::save() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\ambients.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\ambients.ltx"), false, false, true); - ambient_container_type::iterator i = m_ambients.begin(); - ambient_container_type::iterator e = m_ambients.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_ambients) + i->save(*config); xr_delete(config); } @@ -117,11 +111,9 @@ manager::ambients_ids_type const& manager::ambients_ids() const m_ambients_ids.resize(m_ambients.size()); - ambient_container_type::const_iterator i = m_ambients.begin(); - ambient_container_type::const_iterator e = m_ambients.end(); - ambients_ids_type::iterator j = m_ambients_ids.begin(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id().c_str()); + auto j = m_ambients_ids.begin(); + for (const auto &i : m_ambients) + *j++ = xr_strdup(i->id().c_str()); std::sort(m_ambients_ids.begin(), m_ambients_ids.end(), logical_string_predicate()); @@ -130,11 +122,9 @@ manager::ambients_ids_type const& manager::ambients_ids() const ambient* manager::get_ambient(shared_str const& id) const { - ambient_container_type::const_iterator i = m_ambients.begin(); - ambient_container_type::const_iterator e = m_ambients.end(); - for (; i != e; ++i) - if ((*i)->id() == id) - return (*i); + for (const auto &i : m_ambients) + if (i->id() == id) + return i; NODEFAULT; #ifdef DEBUG diff --git a/src/xrEngine/editor_environment_ambients_manager.hpp b/src/xrEngine/editor_environment_ambients_manager.hpp index 219af715b70..7364e99669e 100644 --- a/src/xrEngine/editor_environment_ambients_manager.hpp +++ b/src/xrEngine/editor_environment_ambients_manager.hpp @@ -59,7 +59,7 @@ class manager : private Noncopyable public: typedef xr_vector ambient_container_type; - typedef xr_vector ambients_ids_type; + typedef xr_vector ambients_ids_type; public: ambients_ids_type const& ambients_ids() const; diff --git a/src/xrEngine/editor_environment_ambients_sound_id.cpp b/src/xrEngine/editor_environment_ambients_sound_id.cpp index d9602c2611d..dc0fbad8ef5 100644 --- a/src/xrEngine/editor_environment_ambients_sound_id.cpp +++ b/src/xrEngine/editor_environment_ambients_sound_id.cpp @@ -25,7 +25,7 @@ sound_id::~sound_id() ::ide().destroy(m_property_holder); } -LPCSTR const* sound_id::collection() { return (&*m_manager.channels_ids().begin()); } +pcstr const* sound_id::collection() { return (&*m_manager.channels_ids().begin()); } u32 sound_id::collection_size() { return (m_manager.channels_ids().size()); } void sound_id::fill(XRay::Editor::property_holder_collection* collection) { diff --git a/src/xrEngine/editor_environment_ambients_sound_id.hpp b/src/xrEngine/editor_environment_ambients_sound_id.hpp index b8cd9c09bce..fff9b5c8e67 100644 --- a/src/xrEngine/editor_environment_ambients_sound_id.hpp +++ b/src/xrEngine/editor_environment_ambients_sound_id.hpp @@ -39,7 +39,7 @@ class sound_id : public XRay::Editor::property_holder_holder, private Noncopyabl virtual property_holder_type* object(); private: - LPCSTR const* xr_stdcall collection(); + pcstr const* xr_stdcall collection(); u32 xr_stdcall collection_size(); private: diff --git a/src/xrEngine/editor_environment_detail.cpp b/src/xrEngine/editor_environment_detail.cpp index 3454d7e3dca..88aa35a4abd 100644 --- a/src/xrEngine/editor_environment_detail.cpp +++ b/src/xrEngine/editor_environment_detail.cpp @@ -16,7 +16,7 @@ using editor::environment::detail::logical_string_predicate; -static HRESULT AnsiToUnicode(LPCSTR pszA, LPVOID buffer, u32 const& buffer_size) +static HRESULT AnsiToUnicode(pcstr pszA, LPVOID buffer, u32 const& buffer_size) { VERIFY(pszA); VERIFY(buffer); @@ -31,7 +31,7 @@ static HRESULT AnsiToUnicode(LPCSTR pszA, LPVOID buffer, u32 const& buffer_size) return (HRESULT_FROM_WIN32(GetLastError())); } -bool logical_string_predicate::operator()(LPCSTR const& first, LPCSTR const& second) const +bool logical_string_predicate::operator()(pcstr const& first, pcstr const& second) const { u32 buffer_size0 = (xr_strlen(first) + 1) * 2; LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); @@ -57,7 +57,7 @@ bool logical_string_predicate::operator()(shared_str const& first, shared_str co return (StrCmpLogicalW(buffer0, buffer1) < 0); } -shared_str editor::environment::detail::real_path(LPCSTR folder, LPCSTR path) +shared_str editor::environment::detail::real_path(pcstr folder, pcstr path) { string_path result; FS.update_path(result, folder, path); diff --git a/src/xrEngine/editor_environment_detail.hpp b/src/xrEngine/editor_environment_detail.hpp index f4e5fb17250..a26694c54a5 100644 --- a/src/xrEngine/editor_environment_detail.hpp +++ b/src/xrEngine/editor_environment_detail.hpp @@ -19,11 +19,11 @@ namespace detail { struct logical_string_predicate { - bool operator()(LPCSTR const& first, LPCSTR const& second) const; + bool operator()(pcstr const& first, pcstr const& second) const; bool operator()(shared_str const& first, shared_str const& second) const; }; // struct logical_string_predicate -shared_str real_path(LPCSTR folder, LPCSTR path); +shared_str real_path(pcstr folder, pcstr path); } // namespace detail } // namespace environment diff --git a/src/xrEngine/editor_environment_effects_effect.cpp b/src/xrEngine/editor_environment_effects_effect.cpp index 0c651b7aace..88b15cab441 100644 --- a/src/xrEngine/editor_environment_effects_effect.cpp +++ b/src/xrEngine/editor_environment_effects_effect.cpp @@ -41,6 +41,10 @@ void effect::load(CInifile& config) particles = config.r_string(m_id, "particles"); m_sound = config.r_string(m_id, "sound"); wind_gust_factor = config.r_float(m_id, "wind_gust_factor"); + wind_blast_in_time = config.r_float(m_id, "wind_blast_in_time"); + wind_blast_out_time = config.r_float(m_id, "wind_blast_out_time"); + wind_blast_strength = config.r_float(m_id, "wind_blast_strength"); + wind_blast_direction.setHP(deg2rad(config.r_float(m_id, "wind_blast_longitude")), 0.f); } void effect::save(CInifile& config) @@ -56,8 +60,8 @@ void effect::save(CInifile& config) config.w_float(m_id.c_str(), "wind_blast_longitude", rad2deg(wind_blast_direction.getH())); } -LPCSTR effect::id_getter() const { return (m_id.c_str()); } -void effect::id_setter(LPCSTR value_) +pcstr effect::id_getter() const { return (m_id.c_str()); } +void effect::id_setter(pcstr value_) { shared_str value = value_; if (m_id._get() == value._get()) @@ -66,8 +70,8 @@ void effect::id_setter(LPCSTR value_) m_id = m_manager.unique_id(value); } -LPCSTR effect::sound_getter() { return (m_sound.c_str()); } -void effect::sound_setter(LPCSTR value) +pcstr effect::sound_getter() { return (m_sound.c_str()); } +void effect::sound_setter(pcstr value) { m_sound = value; sound.destroy(); diff --git a/src/xrEngine/editor_environment_effects_effect.hpp b/src/xrEngine/editor_environment_effects_effect.hpp index ff672825528..e2e96b44261 100644 --- a/src/xrEngine/editor_environment_effects_effect.hpp +++ b/src/xrEngine/editor_environment_effects_effect.hpp @@ -33,16 +33,16 @@ class effect : public CEnvAmbient::SEffect, public XRay::Editor::property_holder void load(CInifile& config); void save(CInifile& config); void fill(XRay::Editor::property_holder_collection* collection); - inline LPCSTR id() const { return m_id.c_str(); } + inline pcstr id() const { return m_id.c_str(); } private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); float xr_stdcall wind_blast_longitude_getter() const; void xr_stdcall wind_blast_longitude_setter(float value); - LPCSTR xr_stdcall sound_getter(); - void xr_stdcall sound_setter(LPCSTR value); + pcstr xr_stdcall sound_getter(); + void xr_stdcall sound_setter(pcstr value); private: typedef XRay::Editor::property_holder_base property_holder_type; diff --git a/src/xrEngine/editor_environment_effects_manager.cpp b/src/xrEngine/editor_environment_effects_manager.cpp index 5b94ad324f1..8d62ff499b9 100644 --- a/src/xrEngine/editor_environment_effects_manager.cpp +++ b/src/xrEngine/editor_environment_effects_manager.cpp @@ -13,7 +13,7 @@ using editor::environment::detail::logical_string_predicate; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id()); } @@ -41,19 +41,17 @@ manager::~manager() void manager::load() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\effects.ltx"), TRUE, TRUE, FALSE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\effects.ltx"), true, true, false); VERIFY(m_effects.empty()); typedef CInifile::Root sections_type; sections_type& sections = config->sections(); m_effects.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) + + for (const auto &i : sections) { - effect* object = new effect(*this, (*i)->Name); + effect* object = new effect(*this, i->Name); object->load(*config); object->fill(m_collection); m_effects.push_back(object); @@ -65,13 +63,10 @@ void manager::load() void manager::save() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\effects.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\effects.ltx"), false, false, true); - effect_container_type::iterator i = m_effects.begin(); - effect_container_type::iterator e = m_effects.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_effects) + i->save(*config); xr_delete(config); } @@ -93,11 +88,9 @@ manager::effects_ids_type const& manager::effects_ids() const m_effects_ids.resize(m_effects.size()); - effect_container_type::const_iterator i = m_effects.begin(); - effect_container_type::const_iterator e = m_effects.end(); - effects_ids_type::iterator j = m_effects_ids.begin(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id()); + auto j = m_effects_ids.begin(); + for (const auto &i : m_effects) + *j++ = xr_strdup(i->id()); std::sort(m_effects_ids.begin(), m_effects_ids.end(), logical_string_predicate()); diff --git a/src/xrEngine/editor_environment_effects_manager.hpp b/src/xrEngine/editor_environment_effects_manager.hpp index b4c26678337..eefdd5b9aa1 100644 --- a/src/xrEngine/editor_environment_effects_manager.hpp +++ b/src/xrEngine/editor_environment_effects_manager.hpp @@ -46,7 +46,7 @@ class manager : private Noncopyable inline ::editor::environment::manager& environment() const { return m_environment; } public: typedef xr_vector effect_container_type; - typedef xr_vector effects_ids_type; + typedef xr_vector effects_ids_type; public: effects_ids_type const& effects_ids() const; diff --git a/src/xrEngine/editor_environment_levels_manager.cpp b/src/xrEngine/editor_environment_levels_manager.cpp index 2706de00dbb..e62d5cb11ec 100644 --- a/src/xrEngine/editor_environment_levels_manager.cpp +++ b/src/xrEngine/editor_environment_levels_manager.cpp @@ -18,8 +18,8 @@ using editor::environment::levels::manager; -static LPCSTR s_default_weather_id = "[default]"; -static LPCSTR s_level_section_id = "levels"; +static pcstr s_default_weather_id = "[default]"; +static pcstr s_level_section_id = "levels"; manager::manager(::editor::environment::weathers::manager* weathers) : m_weathers(*weathers), m_property_holder(0) {} manager::~manager() @@ -38,7 +38,7 @@ manager::~manager() ::ide().destroy(m_property_holder); } -void manager::fill_levels(CInifile& config, LPCSTR section, LPCSTR category) +void manager::fill_levels(CInifile& config, pcstr section, pcstr category) { for (const auto &i : config.r_section(section).Data) { @@ -52,7 +52,7 @@ void manager::fill_levels(CInifile& config, LPCSTR section, LPCSTR category) continue; } - LPCSTR weather_id = config.r_string(i.first, "weathers"); + pcstr weather_id = config.r_string(i.first, "weathers"); m_levels.insert(std::make_pair(i.first.c_str(), std::make_pair(category, weather_id))); } } @@ -71,7 +71,7 @@ void manager::load() fill_levels(*m_config_mp , "level_maps_mp" , "multiplayer"); } -LPCSTR const* manager::collection() { return (&*m_weathers.weather_ids().begin()); } +pcstr const* manager::collection() { return (&*m_weathers.weather_ids().begin()); } u32 manager::collection_size() { return (m_weathers.weather_ids().size()); } void manager::fill() { diff --git a/src/xrEngine/editor_environment_levels_manager.hpp b/src/xrEngine/editor_environment_levels_manager.hpp index 6e48c833726..acbd4f513ac 100644 --- a/src/xrEngine/editor_environment_levels_manager.hpp +++ b/src/xrEngine/editor_environment_levels_manager.hpp @@ -43,10 +43,10 @@ class manager : private Noncopyable void fill(); private: - void fill_levels(CInifile& config, LPCSTR section, LPCSTR category); + void fill_levels(CInifile& config, pcstr section, pcstr category); private: - LPCSTR const* xr_stdcall collection(); + pcstr const* xr_stdcall collection(); u32 xr_stdcall collection_size(); private: @@ -58,7 +58,7 @@ class manager : private Noncopyable } }; // struct predicate - typedef AssociativeVector, predicate> levels_container_type; + typedef AssociativeVector, predicate> levels_container_type; private: levels_container_type m_levels; diff --git a/src/xrEngine/editor_environment_manager.cpp b/src/xrEngine/editor_environment_manager.cpp index 40cd3c93a16..a314d89d72b 100644 --- a/src/xrEngine/editor_environment_manager.cpp +++ b/src/xrEngine/editor_environment_manager.cpp @@ -83,12 +83,12 @@ void manager::load_internal() void manager::save() { m_weathers->save(); - // m_suns->save (); + //m_suns->save(); // На текущий момент сохраняются/загружаются не все параметры. m_ambients->save(); m_effects->save(); m_sound_channels->save(); m_thunderbolts->save(); - // m_levels->save (); + //m_levels->save(); // На текущий момент сохранение происходит во время выхода из редактора. } void manager::fill() @@ -110,13 +110,10 @@ void manager::load_weathers() { m_weathers->load(); - // sorting weather envs - auto _I = WeatherCycles.begin(); - auto _E = WeatherCycles.end(); - for (; _I != _E; _I++) + for (auto &i : WeatherCycles) { - R_ASSERT3(_I->second.size() > 1, "Environment in weather must >=2", *_I->first); - std::sort(_I->second.begin(), _I->second.end(), sort_env_etl_pred); + R_ASSERT3(i.second.size() > 1, "Environment in weather must >=2", *i.first); + std::sort(i.second.begin(), i.second.end(), sort_env_etl_pred); } R_ASSERT2(!WeatherCycles.empty(), "Empty weathers."); SetWeather((*WeatherCycles.begin()).first.c_str()); @@ -135,13 +132,12 @@ manager::shader_ids_type const& manager::shader_ids() const u32 count = stream->r_u32(); m_shader_ids.resize(count); - shader_ids_type::iterator i = m_shader_ids.begin(); - shader_ids_type::iterator e = m_shader_ids.end(); - for (; i != e; ++i) + + for (auto &i : m_shader_ids) { string_path buffer; stream->r_stringZ(buffer, sizeof(buffer)); - *i = xr_strdup(buffer); + i = xr_strdup(buffer); } stream->close(); @@ -175,11 +171,10 @@ manager::light_animator_ids_type const& manager::light_animator_ids() const typedef LAItemVec container_type; container_type const& light_animators = LALib.Objects(); m_light_animator_ids.resize(light_animators.size()); - container_type::const_iterator i = light_animators.begin(); - container_type::const_iterator e = light_animators.end(); - light_animator_ids_type::iterator j = m_light_animator_ids.begin(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->cName.c_str()); + + auto j = m_light_animator_ids.begin(); + for (const auto &i : light_animators) + *j++ = xr_strdup(i->cName.c_str()); std::sort(m_light_animator_ids.begin(), m_light_animator_ids.end(), logical_string_predicate()); @@ -189,8 +184,7 @@ manager::light_animator_ids_type const& manager::light_animator_ids() const void manager::create_mixer() { VERIFY(!CurrentEnv); - editor::environment::weathers::time* object = - new editor::environment::weathers::time(this, (editor::environment::weathers::weather const*)0, ""); + editor::environment::weathers::time* object = new editor::environment::weathers::time(this, (editor::environment::weathers::weather const*)0, ""); CurrentEnv = object; object->fill(0); } @@ -209,7 +203,7 @@ SThunderboltDesc* manager::thunderbolt_description(CInifile& config, shared_str return (m_thunderbolts->description(config, section)); } -SThunderboltCollection* manager::thunderbolt_collection(CInifile* pIni, CInifile* thunderbolts, LPCSTR section) +SThunderboltCollection* manager::thunderbolt_collection(CInifile* pIni, CInifile* thunderbolts, pcstr section) { return (m_thunderbolts->get_collection(section)); } @@ -224,12 +218,9 @@ CLensFlareDescriptor* manager::add_flare(xr_vector& colle { #if 0 // return (m_suns->get_flare(id)); - typedef xr_vector container_type; - container_type::iterator i = collection.begin(); - container_type::iterator e = collection.end(); - for (; i != e; ++i) - if ((*i)->section == id) - return (*i); + for (const auto &i : collection) + if (i->section == id) + return i; NODEFAULT; #ifdef DEBUG diff --git a/src/xrEngine/editor_environment_manager.hpp b/src/xrEngine/editor_environment_manager.hpp index 80d05e20e7e..83a9e9c3bfa 100644 --- a/src/xrEngine/editor_environment_manager.hpp +++ b/src/xrEngine/editor_environment_manager.hpp @@ -67,9 +67,9 @@ class manager; class manager : public ::CEnvironment { public: - typedef xr_vector shader_ids_type; - typedef xr_vector particle_ids_type; - typedef xr_vector light_animator_ids_type; + typedef xr_vector shader_ids_type; + typedef xr_vector particle_ids_type; + typedef xr_vector light_animator_ids_type; public: manager(); @@ -80,7 +80,7 @@ class manager : public ::CEnvironment virtual void create_mixer(); virtual CEnvAmbient* AppendEnvAmb(const shared_str& sect); virtual SThunderboltDesc* thunderbolt_description(CInifile& config, shared_str const& section); - virtual SThunderboltCollection* thunderbolt_collection(CInifile* pIni, CInifile* thunderbolts, LPCSTR section); + virtual SThunderboltCollection* thunderbolt_collection(CInifile* pIni, CInifile* thunderbolts, pcstr section); virtual SThunderboltCollection* thunderbolt_collection( xr_vector& collection, shared_str const& id); virtual CLensFlareDescriptor* add_flare(xr_vector& collection, shared_str const& id); diff --git a/src/xrEngine/editor_environment_manager_properties.cpp b/src/xrEngine/editor_environment_manager_properties.cpp index 0780a23539e..3ffc061d445 100644 --- a/src/xrEngine/editor_environment_manager_properties.cpp +++ b/src/xrEngine/editor_environment_manager_properties.cpp @@ -11,9 +11,9 @@ struct test_property static test_property s_test_property; static test_property s_test_property_limited; -LPCSTR s_properties[] = {"integer_property_0", "integer_property_1", "integer_property_2"}; +pcstr s_properties[] = {"integer_property_0", "integer_property_1", "integer_property_2"}; -std::pair s_properties_enum[] = {std::make_pair(10, "integer_property_0"), +std::pair s_properties_enum[] = {std::make_pair(10, "integer_property_0"), std::make_pair(20, "integer_property_1"), std::make_pair(30, "integer_property_2")}; static test_property s_test_property_values; @@ -21,11 +21,11 @@ static test_property s_test_property_enum; struct test_property2 { - LPSTR m_property; + pstr m_property; test_property2() : m_property(xr_strdup("")) {} - LPCSTR xr_stdcall getter() { return m_property; } - void xr_stdcall setter(LPCSTR value) + pcstr xr_stdcall getter() { return m_property; } + void xr_stdcall setter(pcstr value) { xr_free(m_property); m_property = xr_strdup(value); @@ -34,7 +34,7 @@ struct test_property2 static test_property2 s_test_property2; -LPCSTR s_properties3[] = {"one", "two", "three"}; +pcstr s_properties3[] = {"one", "two", "three"}; static test_property2 s_test_property3; @@ -49,7 +49,7 @@ struct test_property4 static test_property4 s_test_property4; -LPCSTR s_properties5[] = {"bad", "good"}; +pcstr s_properties5[] = {"bad", "good"}; static test_property4 s_test_property5; @@ -84,7 +84,7 @@ static test_property7 s_test_property7_limited; static test_property7 s_test_property7_values_enum; -std::pair s_properties7_enum[] = {std::make_pair(10.1f, "float_property_0"), +std::pair s_properties7_enum[] = {std::make_pair(10.1f, "float_property_0"), std::make_pair(20.1f, "float_property_1"), std::make_pair(30.1f, "float_property_2")}; using editor::environment::manager; diff --git a/src/xrEngine/editor_environment_sound_channels_channel.cpp b/src/xrEngine/editor_environment_sound_channels_channel.cpp index 485967fd555..bb6421e0415 100644 --- a/src/xrEngine/editor_environment_sound_channels_channel.cpp +++ b/src/xrEngine/editor_environment_sound_channels_channel.cpp @@ -21,7 +21,7 @@ using editor::environment::sound_channels::manager; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id()); } @@ -59,7 +59,7 @@ void channel::load(CInifile& config) inherited::load(config, m_load_section.c_str()); VERIFY(m_sounds.empty()); - LPCSTR sounds = config.r_string(m_load_section, "sounds"); + pcstr sounds = config.r_string(m_load_section, "sounds"); string_path sound; for (u32 i = 0, n = _GetItemCount(sounds); i < n; ++i) { @@ -79,30 +79,24 @@ void channel::save(CInifile& config) config.w_s32(m_load_section.c_str(), "period3", m_sound_period.w); u32 count = 1; - sound_container_type::const_iterator b = m_sounds.begin(), i = b; - sound_container_type::const_iterator e = m_sounds.end(); - for (; i != e; ++i) - count += xr_strlen((*i)->id()) + 2; - - LPSTR temp = (LPSTR)_alloca(count * sizeof(char)); - *temp = 0; - for (i = b; i != e; ++i) + for (const auto &i : m_sounds) + count += xr_strlen(i->id()) + 2; + + pstr temp = (pstr)_alloca(count * sizeof(char)); + *temp = '\0'; + for (const auto &i : m_sounds) { - if (i == b) - { - xr_strcpy(temp, count, (*i)->id()); - continue; - } - - xr_strcat(temp, count, ", "); - xr_strcat(temp, count, (*i)->id()); + xr_strcat(temp, count, i->id()); + + if (&i != &m_sounds.back()) + xr_strcat(temp, count, ", "); } config.w_string(m_load_section.c_str(), "sounds", temp); } -LPCSTR channel::id_getter() const { return (m_load_section.c_str()); } -void channel::id_setter(LPCSTR value_) +pcstr channel::id_getter() const { return (m_load_section.c_str()); } +void channel::id_setter(pcstr value_) { shared_str value = value_; if (m_load_section._get() == value._get()) diff --git a/src/xrEngine/editor_environment_sound_channels_channel.hpp b/src/xrEngine/editor_environment_sound_channels_channel.hpp index 1316cb384b1..57808acc359 100644 --- a/src/xrEngine/editor_environment_sound_channels_channel.hpp +++ b/src/xrEngine/editor_environment_sound_channels_channel.hpp @@ -36,12 +36,12 @@ class channel : public CEnvAmbient::SSndChannel, public XRay::Editor::property_h void load(CInifile& config); void save(CInifile& config); void fill(XRay::Editor::property_holder_collection* collection); - inline LPCSTR id() const { return m_load_section.c_str(); } + inline pcstr id() const { return m_load_section.c_str(); } virtual sounds_type& sounds(); private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); public: typedef xr_vector sound_container_type; diff --git a/src/xrEngine/editor_environment_sound_channels_manager.cpp b/src/xrEngine/editor_environment_sound_channels_manager.cpp index 5ee8a197dff..c3226dda35e 100644 --- a/src/xrEngine/editor_environment_sound_channels_manager.cpp +++ b/src/xrEngine/editor_environment_sound_channels_manager.cpp @@ -20,7 +20,7 @@ using editor::environment::detail::logical_string_predicate; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id()); } @@ -48,19 +48,17 @@ manager::~manager() void manager::load() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\sound_channels.ltx"), TRUE, TRUE, FALSE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\sound_channels.ltx"), true, true, false); VERIFY(m_channels.empty()); typedef CInifile::Root sections_type; sections_type& sections = config->sections(); m_channels.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) + + for (const auto &i : sections) { - channel* object = new channel(*this, (*i)->Name); + channel* object = new channel(*this, i->Name); object->load(*config); object->fill(m_collection); m_channels.push_back(object); @@ -72,13 +70,10 @@ void manager::load() void manager::save() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\sound_channels.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\sound_channels.ltx"), false, false, true); - channel_container_type::iterator i = m_channels.begin(); - channel_container_type::iterator e = m_channels.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_channels) + i->save(*config); xr_delete(config); } @@ -100,11 +95,9 @@ manager::channels_ids_type const& manager::channels_ids() const m_channels_ids.resize(m_channels.size()); - channel_container_type::const_iterator i = m_channels.begin(); - channel_container_type::const_iterator e = m_channels.end(); - channels_ids_type::iterator j = m_channels_ids.begin(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id()); + auto j = m_channels_ids.begin(); + for (const auto &i : m_channels) + *j++ = xr_strdup(i->id()); std::sort(m_channels_ids.begin(), m_channels_ids.end(), logical_string_predicate()); diff --git a/src/xrEngine/editor_environment_sound_channels_manager.hpp b/src/xrEngine/editor_environment_sound_channels_manager.hpp index 450962b9d1d..fc5a88d3676 100644 --- a/src/xrEngine/editor_environment_sound_channels_manager.hpp +++ b/src/xrEngine/editor_environment_sound_channels_manager.hpp @@ -42,7 +42,7 @@ class manager : private Noncopyable public: typedef xr_vector channel_container_type; - typedef xr_vector channels_ids_type; + typedef xr_vector channels_ids_type; public: channels_ids_type const& channels_ids() const; diff --git a/src/xrEngine/editor_environment_sound_channels_source.hpp b/src/xrEngine/editor_environment_sound_channels_source.hpp index a8ccb4efb6f..27f7ad50630 100644 --- a/src/xrEngine/editor_environment_sound_channels_source.hpp +++ b/src/xrEngine/editor_environment_sound_channels_source.hpp @@ -26,7 +26,7 @@ class source : public XRay::Editor::property_holder_holder, private Noncopyable source(shared_str const& source); ~source(); void fill(XRay::Editor::property_holder_collection* collection); - inline LPCSTR id() const { return m_source.c_str(); } + inline pcstr id() const { return m_source.c_str(); } private: typedef XRay::Editor::property_holder_base property_holder_type; diff --git a/src/xrEngine/editor_environment_suns_flares.cpp b/src/xrEngine/editor_environment_suns_flares.cpp index 0682e373434..56549c9094a 100644 --- a/src/xrEngine/editor_environment_suns_flares.cpp +++ b/src/xrEngine/editor_environment_suns_flares.cpp @@ -22,7 +22,7 @@ using editor::environment::suns::flare; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { float position = m_container[item_index]->m_position; xr_sprintf(buffer, buffer_size, "flare [%f]", position); @@ -77,7 +77,7 @@ void flares::load(CInifile& config, shared_str const& section) min_flare_count); u32 const buffer_size = max_string_count * sizeof(char); - LPSTR result = (LPSTR)_alloca(buffer_size); + pstr result = (pstr)_alloca(buffer_size); for (u32 i = 0; i < min_flare_count; ++i) { flare* object = new flare(); diff --git a/src/xrEngine/editor_environment_suns_manager.cpp b/src/xrEngine/editor_environment_suns_manager.cpp index ec6b3cd03a3..50514eb17fb 100644 --- a/src/xrEngine/editor_environment_suns_manager.cpp +++ b/src/xrEngine/editor_environment_suns_manager.cpp @@ -24,7 +24,7 @@ using editor::environment::detail::logical_string_predicate; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id().c_str()); } @@ -54,16 +54,14 @@ manager::~manager() void manager::load() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\suns.ltx"), TRUE, TRUE, FALSE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\suns.ltx"), true, true, false); typedef CInifile::Root sections_type; sections_type& sections = config->sections(); m_suns.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) - add(*config, (*i)->Name); + + for (const auto &i : sections) + add(*config, i->Name); xr_delete(config); } @@ -71,13 +69,10 @@ void manager::load() void manager::save() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\suns.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\suns.ltx"), false, false, true); - container_type::const_iterator i = m_suns.begin(); - container_type::const_iterator e = m_suns.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_suns) + i->save(*config); xr_delete(config); } @@ -126,11 +121,9 @@ manager::suns_ids_type const& manager::suns_ids() const m_suns_ids.resize(m_suns.size() + 1); m_suns_ids[0] = xr_strdup(""); - container_type::const_iterator i = m_suns.begin(); - container_type::const_iterator e = m_suns.end(); - suns_ids_type::iterator j = m_suns_ids.begin() + 1; - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id().c_str()); + auto j = m_suns_ids.begin() + 1; + for (const auto &i : m_suns) + *j++ = xr_strdup(i->id().c_str()); std::sort(m_suns_ids.begin(), m_suns_ids.end(), logical_string_predicate()); @@ -147,7 +140,7 @@ struct predicate CLensFlareDescriptor* manager::get_flare(shared_str const& id) const { - // container_type::const_iterator found = std::find_if(m_suns.begin(), m_suns.end(), predicate(id)); + // auto found = std::find_if(m_suns.begin(), m_suns.end(), predicate(id)); // VERIFY (found != m_suns.end()); // return ((*found)->); return (0); diff --git a/src/xrEngine/editor_environment_suns_manager.hpp b/src/xrEngine/editor_environment_suns_manager.hpp index 9f99ad6e3ef..27ff3273dd2 100644 --- a/src/xrEngine/editor_environment_suns_manager.hpp +++ b/src/xrEngine/editor_environment_suns_manager.hpp @@ -50,7 +50,7 @@ class manager : private Noncopyable public: typedef xr_vector container_type; - typedef xr_vector suns_ids_type; + typedef xr_vector suns_ids_type; public: suns_ids_type const& suns_ids() const; diff --git a/src/xrEngine/editor_environment_suns_sun.cpp b/src/xrEngine/editor_environment_suns_sun.cpp index c7d5005fcd4..6dabc76df79 100644 --- a/src/xrEngine/editor_environment_suns_sun.cpp +++ b/src/xrEngine/editor_environment_suns_sun.cpp @@ -52,8 +52,8 @@ void sun::save(CInifile& config) config.w_string(m_id.c_str(), "sun_texture", m_texture.c_str()); } -LPCSTR sun::id_getter() const { return (m_id.c_str()); } -void sun::id_setter(LPCSTR value_) +pcstr sun::id_getter() const { return (m_id.c_str()); } +void sun::id_setter(pcstr value_) { shared_str value = value_; if (m_id._get() == value._get()) diff --git a/src/xrEngine/editor_environment_suns_sun.hpp b/src/xrEngine/editor_environment_suns_sun.hpp index 0db770eecd6..b23767e199f 100644 --- a/src/xrEngine/editor_environment_suns_sun.hpp +++ b/src/xrEngine/editor_environment_suns_sun.hpp @@ -34,8 +34,8 @@ class sun : public CLensFlare, public XRay::Editor::property_holder_holder, priv void fill(XRay::Editor::property_holder_collection* collection); private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); public: inline shared_str const& id() const { return m_id; } diff --git a/src/xrEngine/editor_environment_thunderbolts_collection.cpp b/src/xrEngine/editor_environment_thunderbolts_collection.cpp index a618e52a71f..309b880dbf5 100644 --- a/src/xrEngine/editor_environment_thunderbolts_collection.cpp +++ b/src/xrEngine/editor_environment_thunderbolts_collection.cpp @@ -21,7 +21,7 @@ using editor::environment::thunderbolts::manager; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id()); } @@ -58,29 +58,25 @@ void collection::load(CInifile& config) { CInifile::Sect& items = config.r_section(section); m_ids.reserve(items.Data.size()); - typedef CInifile::Items items_type; - items_type::const_iterator i = items.Data.begin(); - items_type::const_iterator e = items.Data.end(); - for (; i != e; ++i) + + for (const auto &i : items.Data) { - thunderbolt_id* object = new thunderbolt_id(m_manager, (*i).first); + thunderbolt_id* object = new thunderbolt_id(m_manager, i.first); object->fill(m_collection); m_ids.push_back(object); - palette.push_back(m_manager.description(config, (*i).first)); + palette.push_back(m_manager.description(config, i.first)); } } void collection::save(CInifile& config) { - container_type::const_iterator i = m_ids.begin(); - container_type::const_iterator e = m_ids.end(); - for (; i != e; ++i) - config.w_string(section.c_str(), (*i)->id(), ""); + for (const auto &i : m_ids) + config.w_string(section.c_str(), i->id(), ""); } -LPCSTR collection::id_getter() const { return (section.c_str()); } -void collection::id_setter(LPCSTR value_) +pcstr collection::id_getter() const { return (section.c_str()); } +void collection::id_setter(pcstr value_) { shared_str value = value_; if (section._get() == value._get()) diff --git a/src/xrEngine/editor_environment_thunderbolts_collection.hpp b/src/xrEngine/editor_environment_thunderbolts_collection.hpp index c0797332087..d829fcd35c2 100644 --- a/src/xrEngine/editor_environment_thunderbolts_collection.hpp +++ b/src/xrEngine/editor_environment_thunderbolts_collection.hpp @@ -33,10 +33,10 @@ class collection : public SThunderboltCollection, public XRay::Editor::property_ void load(CInifile& config); void save(CInifile& config); void fill(XRay::Editor::property_holder_collection* collection); - inline LPCSTR id() const { return section.c_str(); } + inline pcstr id() const { return section.c_str(); } private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); private: typedef XRay::Editor::property_holder_base property_holder_type; diff --git a/src/xrEngine/editor_environment_thunderbolts_gradient.cpp b/src/xrEngine/editor_environment_thunderbolts_gradient.cpp index 8fa2c0bfd17..3821db9b64b 100644 --- a/src/xrEngine/editor_environment_thunderbolts_gradient.cpp +++ b/src/xrEngine/editor_environment_thunderbolts_gradient.cpp @@ -25,7 +25,7 @@ gradient::~gradient() ::ide().destroy(m_property_holder); } -void gradient::load(CInifile& config, shared_str const& section_id, LPCSTR prefix) +void gradient::load(CInifile& config, shared_str const& section_id, pcstr prefix) { string_path temp; shader = config.r_string(section_id, strconcat(sizeof(temp), temp, prefix, "_shader")); @@ -35,7 +35,7 @@ void gradient::load(CInifile& config, shared_str const& section_id, LPCSTR prefi m_pFlare->CreateShader(*shader, *texture); } -void gradient::save(CInifile& config, shared_str const& section_id, LPCSTR prefix) +void gradient::save(CInifile& config, shared_str const& section_id, pcstr prefix) { string_path temp; config.w_string(section_id.c_str(), strconcat(sizeof(temp), temp, prefix, "_shader"), shader.c_str()); @@ -44,22 +44,22 @@ void gradient::save(CInifile& config, shared_str const& section_id, LPCSTR prefi config.w_fvector2(section_id.c_str(), strconcat(sizeof(temp), temp, prefix, "_radius"), fRadius); } -LPCSTR gradient::shader_getter() const { return (shader.c_str()); } -void gradient::shader_setter(LPCSTR value) +pcstr gradient::shader_getter() const { return (shader.c_str()); } +void gradient::shader_setter(pcstr value) { shader = value; m_pFlare->CreateShader(*shader, *texture); } -LPCSTR gradient::texture_getter() const { return (texture.c_str()); } -void gradient::texture_setter(LPCSTR value) +pcstr gradient::texture_getter() const { return (texture.c_str()); } +void gradient::texture_setter(pcstr value) { texture = value; m_pFlare->CreateShader(*shader, *texture); } void gradient::fill( - ::editor::environment::manager& environment, LPCSTR name, LPCSTR description, XRay::Editor::property_holder_base& holder) + ::editor::environment::manager& environment, pcstr name, pcstr description, XRay::Editor::property_holder_base& holder) { VERIFY(!m_property_holder); m_property_holder = ::ide().create_property_holder(name); diff --git a/src/xrEngine/editor_environment_thunderbolts_gradient.hpp b/src/xrEngine/editor_environment_thunderbolts_gradient.hpp index 23e4cc0b2d9..877f73cc272 100644 --- a/src/xrEngine/editor_environment_thunderbolts_gradient.hpp +++ b/src/xrEngine/editor_environment_thunderbolts_gradient.hpp @@ -28,17 +28,17 @@ class gradient : public SThunderboltDesc::SFlare, private Noncopyable public: gradient(); ~gradient(); - void load(CInifile& config, shared_str const& section_id, LPCSTR prefix); - void save(CInifile& config, shared_str const& section_id, LPCSTR prefix); + void load(CInifile& config, shared_str const& section_id, pcstr prefix); + void save(CInifile& config, shared_str const& section_id, pcstr prefix); void fill( - ::editor::environment::manager& environment, LPCSTR name, LPCSTR description, XRay::Editor::property_holder_base& holder); + ::editor::environment::manager& environment, pcstr name, pcstr description, XRay::Editor::property_holder_base& holder); private: - LPCSTR xr_stdcall shader_getter() const; - void xr_stdcall shader_setter(LPCSTR value); + pcstr xr_stdcall shader_getter() const; + void xr_stdcall shader_setter(pcstr value); - LPCSTR xr_stdcall texture_getter() const; - void xr_stdcall texture_setter(LPCSTR value); + pcstr xr_stdcall texture_getter() const; + void xr_stdcall texture_setter(pcstr value); private: XRay::Editor::property_holder_base* m_property_holder; diff --git a/src/xrEngine/editor_environment_thunderbolts_manager.cpp b/src/xrEngine/editor_environment_thunderbolts_manager.cpp index dd85c35e3bb..6d09accf8c5 100644 --- a/src/xrEngine/editor_environment_thunderbolts_manager.cpp +++ b/src/xrEngine/editor_environment_thunderbolts_manager.cpp @@ -27,7 +27,7 @@ using editor::environment::detail::logical_string_predicate; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id()); } @@ -42,7 +42,7 @@ XRay::Editor::property_holder_base* property_collection void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id()); } @@ -85,17 +85,15 @@ void manager::load_thunderbolts() VERIFY(m_thunderbolts.empty()); string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\thunderbolts.ltx"), TRUE, TRUE, FALSE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\thunderbolts.ltx"), true, true, false); typedef CInifile::Root sections_type; sections_type& sections = config->sections(); m_thunderbolts.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) + + for (const auto &i : sections) { - thunderbolt* object = new thunderbolt(this, (*i)->Name); + thunderbolt* object = new thunderbolt(this, i->Name); object->load(*config); object->fill(m_environment, m_thunderbolt_collection); m_thunderbolts.push_back(object); @@ -107,13 +105,10 @@ void manager::load_thunderbolts() void manager::save_thunderbolts() { string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\thunderbolts.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\thunderbolts.ltx"), false, false, true); - thunderbolt_container_type::const_iterator i = m_thunderbolts.begin(); - thunderbolt_container_type::const_iterator e = m_thunderbolts.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_thunderbolts) + i->save(*config); xr_delete(config); } @@ -123,17 +118,15 @@ void manager::load_collections() VERIFY(m_collections.empty()); string_path file_name; - CInifile* config = new CInifile( - FS.update_path(file_name, "$game_config$", "environment\\thunderbolt_collections.ltx"), TRUE, TRUE, FALSE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\thunderbolt_collections.ltx"), true, true, false); typedef CInifile::Root sections_type; sections_type& sections = config->sections(); m_collections.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) + + for (const auto &i : sections) { - collection* object = new collection(*this, (*i)->Name); + collection* object = new collection(*this, i->Name); object->load(*config); object->fill(m_thunderbolt_collection); m_collections.push_back(object); @@ -145,13 +138,10 @@ void manager::load_collections() void manager::save_collections() { string_path file_name; - CInifile* config = new CInifile( - FS.update_path(file_name, "$game_config$", "environment\\thunderbolt_collections.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\thunderbolt_collections.ltx"), false, false, true); - collection_container_type::const_iterator i = m_collections.begin(); - collection_container_type::const_iterator e = m_collections.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_collections) + i->save(*config); xr_delete(config); } @@ -168,8 +158,7 @@ void manager::save() save_collections(); string_path file_name; - CInifile* config = - new CInifile(FS.update_path(file_name, "$game_config$", "environment\\environment.ltx"), FALSE, FALSE, TRUE); + CInifile* config = new CInifile(FS.update_path(file_name, "$game_config$", "environment\\environment.ltx"), false, false, true); CEnvironment& environment = g_pGamePersistent->Environment(); @@ -253,11 +242,9 @@ manager::thunderbolts_ids_type const& manager::thunderbolts_ids() const m_thunderbolts_ids.resize(m_thunderbolts.size()); - thunderbolt_container_type::const_iterator i = m_thunderbolts.begin(); - thunderbolt_container_type::const_iterator e = m_thunderbolts.end(); - thunderbolts_ids_type::iterator j = m_thunderbolts_ids.begin(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id()); + auto j = m_thunderbolts_ids.begin(); + for (const auto &i : m_thunderbolts) + *j++ = xr_strdup(i->id()); std::sort(m_thunderbolts_ids.begin(), m_thunderbolts_ids.end(), logical_string_predicate()); @@ -274,11 +261,9 @@ manager::thunderbolts_ids_type const& manager::collections_ids() const m_collections_ids.resize(m_collections.size() + 1); m_collections_ids[0] = xr_strdup(""); - collection_container_type::const_iterator i = m_collections.begin(); - collection_container_type::const_iterator e = m_collections.end(); - collections_ids_type::iterator j = m_collections_ids.begin() + 1; - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id()); + auto j = m_collections_ids.begin() + 1; + for (const auto &i : m_collections) + *j++ = xr_strdup(i->id()); std::sort(m_collections_ids.begin(), m_collections_ids.end(), logical_string_predicate()); @@ -304,11 +289,9 @@ shared_str manager::unique_collection_id(shared_str const& id) const SThunderboltDesc* manager::description(CInifile& config, shared_str const& section) const { - thunderbolt_container_type::const_iterator i = m_thunderbolts.begin(); - thunderbolt_container_type::const_iterator e = m_thunderbolts.end(); - for (; i != e; ++i) - if ((*i)->id() == section) - return (*i); + for (const auto &i : m_thunderbolts) + if (i->id() == section) + return i; NODEFAULT; #ifdef DEBUG @@ -318,11 +301,9 @@ SThunderboltDesc* manager::description(CInifile& config, shared_str const& secti SThunderboltCollection* manager::get_collection(shared_str const& section) { - collection_container_type::iterator i = m_collections.begin(); - collection_container_type::iterator e = m_collections.end(); - for (; i != e; ++i) - if ((*i)->id() == section) - return (*i); + for (const auto &i : m_collections) + if (i->id() == section) + return i; NODEFAULT; #ifdef DEBUG diff --git a/src/xrEngine/editor_environment_thunderbolts_manager.hpp b/src/xrEngine/editor_environment_thunderbolts_manager.hpp index 98b62c994c4..a2c8f775d21 100644 --- a/src/xrEngine/editor_environment_thunderbolts_manager.hpp +++ b/src/xrEngine/editor_environment_thunderbolts_manager.hpp @@ -55,8 +55,8 @@ class manager : private Noncopyable public: typedef xr_vector thunderbolt_container_type; typedef xr_vector collection_container_type; - typedef xr_vector thunderbolts_ids_type; - typedef xr_vector collections_ids_type; + typedef xr_vector thunderbolts_ids_type; + typedef xr_vector collections_ids_type; public: thunderbolts_ids_type const& thunderbolts_ids() const; diff --git a/src/xrEngine/editor_environment_thunderbolts_thunderbolt.cpp b/src/xrEngine/editor_environment_thunderbolts_thunderbolt.cpp index 56f94cf8b07..f0251fe7b64 100644 --- a/src/xrEngine/editor_environment_thunderbolts_thunderbolt.cpp +++ b/src/xrEngine/editor_environment_thunderbolts_thunderbolt.cpp @@ -64,8 +64,8 @@ void thunderbolt::save(CInifile& config) config.w_string(m_id.c_str(), "sound", m_sound.c_str()); } -LPCSTR thunderbolt::id_getter() const { return (m_id.c_str()); } -void thunderbolt::id_setter(LPCSTR value_) +pcstr thunderbolt::id_getter() const { return (m_id.c_str()); } +void thunderbolt::id_setter(pcstr value_) { shared_str value = value_; if (m_id._get() == value._get()) diff --git a/src/xrEngine/editor_environment_thunderbolts_thunderbolt.hpp b/src/xrEngine/editor_environment_thunderbolts_thunderbolt.hpp index bebbecaf888..7a64bc47433 100644 --- a/src/xrEngine/editor_environment_thunderbolts_thunderbolt.hpp +++ b/src/xrEngine/editor_environment_thunderbolts_thunderbolt.hpp @@ -37,13 +37,13 @@ class thunderbolt : public SThunderboltDesc, public XRay::Editor::property_holde void load(CInifile& config); void save(CInifile& config); void fill(::editor::environment::manager& environment, XRay::Editor::property_holder_collection* collection); - inline LPCSTR id() const { return m_id.c_str(); } + inline pcstr id() const { return m_id.c_str(); } virtual void create_top_gradient(CInifile& pIni, shared_str const& sect); virtual void create_center_gradient(CInifile& pIni, shared_str const& sect); private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); private: typedef XRay::Editor::property_holder_base property_holder_type; diff --git a/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.cpp b/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.cpp index c944df77c15..d89e2eb916e 100644 --- a/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.cpp +++ b/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.cpp @@ -29,7 +29,7 @@ thunderbolt_id::~thunderbolt_id() ::ide().destroy(m_property_holder); } -LPCSTR const* thunderbolt_id::collection() { return (&*m_manager.thunderbolts_ids().begin()); } +pcstr const* thunderbolt_id::collection() { return (&*m_manager.thunderbolts_ids().begin()); } u32 thunderbolt_id::collection_size() { return (m_manager.thunderbolts_ids().size()); } void thunderbolt_id::fill(XRay::Editor::property_holder_collection* collection) { diff --git a/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.hpp b/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.hpp index 77f2ee20f08..59d4e1c08c7 100644 --- a/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.hpp +++ b/src/xrEngine/editor_environment_thunderbolts_thunderbolt_id.hpp @@ -28,7 +28,7 @@ class thunderbolt_id : public XRay::Editor::property_holder_holder, private Nonc thunderbolt_id(manager const& manager, shared_str const& thunderbolt); virtual ~thunderbolt_id(); void fill(XRay::Editor::property_holder_collection* collection); - inline LPCSTR id() const { return m_id.c_str(); } + inline pcstr id() const { return m_id.c_str(); } private: typedef XRay::Editor::property_holder_base property_holder_type; @@ -36,7 +36,7 @@ class thunderbolt_id : public XRay::Editor::property_holder_holder, private Nonc virtual property_holder_type* object(); private: - LPCSTR const* xr_stdcall collection(); + pcstr const* xr_stdcall collection(); u32 xr_stdcall collection_size(); private: diff --git a/src/xrEngine/editor_environment_weathers_manager.cpp b/src/xrEngine/editor_environment_weathers_manager.cpp index 19afed7cfe1..1a586b78117 100644 --- a/src/xrEngine/editor_environment_weathers_manager.cpp +++ b/src/xrEngine/editor_environment_weathers_manager.cpp @@ -25,7 +25,7 @@ using editor::environment::detail::logical_string_predicate; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id().c_str()); } @@ -54,31 +54,29 @@ manager::~manager() void manager::load() { - typedef xr_vector file_list_type; - file_list_type* file_list = FS.file_list_open("$game_weathers$", ""); + xr_vector* file_list = FS.file_list_open("$game_weathers$", ""); VERIFY(file_list); xr_string id; - file_list_type::const_iterator i = file_list->begin(); - file_list_type::const_iterator e = file_list->end(); - for (; i != e; ++i) + + for (const auto &i : *file_list) { - u32 length = xr_strlen(*i); + u32 length = xr_strlen(i); if (length <= 4) continue; - if ((*i)[length - 4] != '.') + if (i[length - 4] != '.') continue; - if ((*i)[length - 3] != 'l') + if (i[length - 3] != 'l') continue; - if ((*i)[length - 2] != 't') + if (i[length - 2] != 't') continue; - if ((*i)[length - 1] != 'x') + if (i[length - 1] != 'x') continue; - id = *i; + id = i; id[length - 4] = 0; weather* object = new weather(&m_manager, id.c_str()); object->load(); @@ -91,56 +89,48 @@ void manager::load() void manager::save() { - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) - (*i)->save(); + for (const auto &i : m_weathers) + i->save(); } -LPCSTR const* manager::weathers_getter() const { return (&*weather_ids().begin()); } +pcstr const* manager::weathers_getter() const { return (&*weather_ids().begin()); } u32 manager::weathers_size_getter() const { return (weather_ids().size()); } struct predicate { shared_str value; - inline predicate(LPCSTR const& value_) : value(value_) {} + inline predicate(pcstr const& value_) : value(value_) {} inline bool operator()(weather const* weather) const { return (value._get() == weather->id()._get()); } }; // struct predicate -LPCSTR const* manager::frames_getter(LPCSTR weather_id) const +pcstr const* manager::frames_getter(pcstr weather_id) const { delete_data(m_times_ids); - weather_container_type::const_iterator found = - std::find_if(m_weathers.begin(), m_weathers.end(), predicate(weather_id)); + auto found = std::find_if(m_weathers.begin(), m_weathers.end(), predicate(weather_id)); if (found == m_weathers.end()) return (0); - typedef weather::container_type container_type; - container_type const& times = (*found)->times(); + weather::container_type const& times = (*found)->times(); m_times_ids.resize(times.size()); - times_ids_type::iterator j = m_times_ids.begin(); - container_type::const_iterator i = times.begin(); - container_type::const_iterator e = times.end(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id().c_str()); + + auto j = m_times_ids.begin(); + for (const auto &i : times) + *j++ = xr_strdup(i->id().c_str()); return (&*m_times_ids.begin()); } -u32 manager::frames_size_getter(LPCSTR weather_id) const +u32 manager::frames_size_getter(pcstr weather_id) const { - weather_container_type::const_iterator found = - std::find_if(m_weathers.begin(), m_weathers.end(), predicate(weather_id)); + auto found = std::find_if(m_weathers.begin(), m_weathers.end(), predicate(weather_id)); if (found == m_weathers.end()) return (0); -#pragma todo( \ - \ -"Dima to Dima: dangerous scheme: it depends on the call sequence (frames_getter should be called berfore frames_size_getter to get correct results)") +#pragma todo("Dima to Dima: dangerous scheme: it depends on the call sequence (frames_getter should be called berfore frames_size_getter to get correct results)") return (m_times_ids.size()); } @@ -179,11 +169,9 @@ manager::weather_ids_type const& manager::weather_ids() const m_weather_ids.resize(m_weathers.size()); - weather_container_type::const_iterator i = m_weathers.begin(); - weather_container_type::const_iterator e = m_weathers.end(); - weather_ids_type::iterator j = m_weather_ids.begin(); - for (; i != e; ++i, ++j) - *j = xr_strdup((*i)->id().c_str()); + auto j = m_weather_ids.begin(); + for (const auto &i : m_weathers) + *j++ = xr_strdup(i->id().c_str()); std::sort(m_weather_ids.begin(), m_weather_ids.end(), logical_string_predicate()); @@ -200,7 +188,7 @@ shared_str manager::unique_id(shared_str const& id) const bool manager::save_current_blend(char* buffer, u32 const& buffer_size) { - CInifile temp(0, FALSE, FALSE, FALSE); + CInifile temp(nullptr, false, false, false); using editor::environment::weathers::time; time* frame = static_cast(m_manager.CurrentEnv); @@ -222,14 +210,12 @@ bool manager::paste_current_time_frame(char const* buffer, u32 const& buffer_siz if (!m_manager.Current[0]) return (false); - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) + for (const auto &i : m_weathers) { - if (m_manager.CurrentWeatherName._get() != (*i)->id()._get()) + if (m_manager.CurrentWeatherName._get() != i->id()._get()) continue; - return ((*i)->paste_time_frame(m_manager.Current[0]->m_identifier, buffer, buffer_size)); + return (i->paste_time_frame(m_manager.Current[0]->m_identifier, buffer, buffer_size)); } return (false); @@ -240,14 +226,12 @@ bool manager::paste_target_time_frame(char const* buffer, u32 const& buffer_size if (!m_manager.Current[1]) return (false); - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) + for (const auto &i : m_weathers) { - if (m_manager.CurrentWeatherName._get() != (*i)->id()._get()) + if (m_manager.CurrentWeatherName._get() != i->id()._get()) continue; - return ((*i)->paste_time_frame(m_manager.Current[1]->m_identifier, buffer, buffer_size)); + return (i->paste_time_frame(m_manager.Current[1]->m_identifier, buffer, buffer_size)); } return (false); @@ -255,14 +239,12 @@ bool manager::paste_target_time_frame(char const* buffer, u32 const& buffer_size bool manager::add_time_frame(char const* buffer, u32 const& buffer_size) { - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) + for (const auto &i : m_weathers) { - if (m_manager.CurrentWeatherName._get() != (*i)->id()._get()) + if (m_manager.CurrentWeatherName._get() != i->id()._get()) continue; - return ((*i)->add_time_frame(buffer, buffer_size)); + return (i->add_time_frame(buffer, buffer_size)); } return (false); @@ -273,14 +255,12 @@ void manager::reload_current_time_frame() if (!m_manager.Current[0]) return; - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) + for (const auto &i : m_weathers) { - if (m_manager.CurrentWeatherName._get() != (*i)->id()._get()) + if (m_manager.CurrentWeatherName._get() != i->id()._get()) continue; - (*i)->reload_time_frame(m_manager.Current[0]->m_identifier); + i->reload_time_frame(m_manager.Current[0]->m_identifier); return; } } @@ -290,28 +270,24 @@ void manager::reload_target_time_frame() if (!m_manager.Current[1]) return; - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) + for (const auto &i : m_weathers) { - if (m_manager.CurrentWeatherName._get() != (*i)->id()._get()) + if (m_manager.CurrentWeatherName._get() != i->id()._get()) continue; - (*i)->reload_time_frame(m_manager.Current[1]->m_identifier); + i->reload_time_frame(m_manager.Current[1]->m_identifier); return; } } void manager::reload_current_weather() { - weather_container_type::iterator i = m_weathers.begin(); - weather_container_type::iterator e = m_weathers.end(); - for (; i != e; ++i) + for (const auto &i : m_weathers) { - if (m_manager.CurrentWeatherName._get() != (*i)->id()._get()) + if (m_manager.CurrentWeatherName._get() != i->id()._get()) continue; - (*i)->reload(); + i->reload(); return; } } diff --git a/src/xrEngine/editor_environment_weathers_manager.hpp b/src/xrEngine/editor_environment_weathers_manager.hpp index 29716424a0c..8b9eb4afb4f 100644 --- a/src/xrEngine/editor_environment_weathers_manager.hpp +++ b/src/xrEngine/editor_environment_weathers_manager.hpp @@ -51,8 +51,8 @@ class manager : private Noncopyable bool add_time_frame(char const* buffer, u32 const& buffer_size); public: - typedef xr_vector weather_ids_type; - typedef xr_vector times_ids_type; + typedef xr_vector weather_ids_type; + typedef xr_vector times_ids_type; typedef xr_vector weather_container_type; public: @@ -63,10 +63,10 @@ class manager : private Noncopyable typedef property_collection collection_type; private: - LPCSTR const* xr_stdcall weathers_getter() const; + pcstr const* xr_stdcall weathers_getter() const; u32 xr_stdcall weathers_size_getter() const; - LPCSTR const* xr_stdcall frames_getter(LPCSTR weather_id) const; - u32 xr_stdcall frames_size_getter(LPCSTR weather_id) const; + pcstr const* xr_stdcall frames_getter(pcstr weather_id) const; + u32 xr_stdcall frames_size_getter(pcstr weather_id) const; private: weather_container_type m_weathers; diff --git a/src/xrEngine/editor_environment_weathers_time.cpp b/src/xrEngine/editor_environment_weathers_time.cpp index fab17df92bc..024a4564529 100644 --- a/src/xrEngine/editor_environment_weathers_time.cpp +++ b/src/xrEngine/editor_environment_weathers_time.cpp @@ -96,7 +96,7 @@ void time::load(CInifile& config) // clouds_color = config.r_fvector4(m_identifier, "clouds_color"); - // LPCSTR clouds = config.r_string(m_identifier, "clouds_color"); + // pcstr clouds = config.r_string(m_identifier, "clouds_color"); // VERIFY (_GetItemCount(clouds) == 5); // string256 temp; // ((Fvector&)clouds_color).mul(.5f*(float)atof(_GetItem(clouds,4,temp))); @@ -134,8 +134,8 @@ void time::save(CInifile& config) config.w_fvector4(m_identifier.c_str(), "clouds_color", clouds_color); } -LPCSTR time::id_getter() const { return (m_identifier.c_str()); } -void time::id_setter(LPCSTR value_) +pcstr time::id_getter() const { return (m_identifier.c_str()); } +void time::id_setter(pcstr value_) { shared_str value = value_; if (m_identifier._get() == value._get()) @@ -147,11 +147,11 @@ void time::id_setter(LPCSTR value_) m_identifier = value; } -LPCSTR const* time::ambients_collection() { return (&*m_manager.ambients().ambients_ids().begin()); } +pcstr const* time::ambients_collection() { return (&*m_manager.ambients().ambients_ids().begin()); } u32 time::ambients_collection_size() { return (m_manager.ambients().ambients_ids().size()); } -LPCSTR const* time::suns_collection() { return (&*m_manager.suns().suns_ids().begin()); } +pcstr const* time::suns_collection() { return (&*m_manager.suns().suns_ids().begin()); } u32 time::suns_collection_size() { return (m_manager.suns().suns_ids().size()); } -LPCSTR const* time::thunderbolts_collection() { return (&*m_manager.thunderbolts().collections_ids().begin()); } +pcstr const* time::thunderbolts_collection() { return (&*m_manager.thunderbolts().collections_ids().begin()); } u32 time::thunderbolts_collection_size() { return (m_manager.thunderbolts().collections_ids().size()); } float time::sun_altitude_getter() const { @@ -181,8 +181,8 @@ void time::sun_longitude_setter(float value) sun_dir.setHP(y, deg2rad(value)); } -LPCSTR time::ambient_getter() const { return (m_ambient.c_str()); } -void time::ambient_setter(LPCSTR value) +pcstr time::ambient_getter() const { return (m_ambient.c_str()); } +void time::ambient_setter(pcstr value) { if (m_ambient._get() == shared_str(value)._get()) return; @@ -191,8 +191,8 @@ void time::ambient_setter(LPCSTR value) env_ambient = m_manager.AppendEnvAmb(value); } -LPCSTR time::sun_getter() const { return (m_sun.c_str()); } -void time::sun_setter(LPCSTR value) +pcstr time::sun_getter() const { return (m_sun.c_str()); } +void time::sun_setter(pcstr value) { if (m_sun._get() == shared_str(value)._get()) return; @@ -201,8 +201,8 @@ void time::sun_setter(LPCSTR value) lens_flare_id = m_manager.eff_LensFlare->AppendDef(m_manager, m_manager.m_suns_config, value); } -LPCSTR time::thunderbolt_getter() const { return (m_thunderbolt_collection.c_str()); } -void time::thunderbolt_setter(LPCSTR value) +pcstr time::thunderbolt_getter() const { return (m_thunderbolt_collection.c_str()); } +void time::thunderbolt_setter(pcstr value) { if (m_thunderbolt_collection._get() == shared_str(value)._get()) return; @@ -212,8 +212,8 @@ void time::thunderbolt_setter(LPCSTR value) m_manager, m_manager.m_thunderbolt_collections_config, m_manager.m_thunderbolts_config, value); } -LPCSTR time::sky_texture_getter() const { return (sky_texture_name.c_str()); } -void time::sky_texture_setter(LPCSTR value) +pcstr time::sky_texture_getter() const { return (sky_texture_name.c_str()); } +void time::sky_texture_setter(pcstr value) { if (sky_texture_name._get() == shared_str(value)._get()) return; @@ -226,8 +226,8 @@ void time::sky_texture_setter(LPCSTR value) m_pDescriptor->OnDeviceCreate(*this); } -LPCSTR time::clouds_texture_getter() const { return (clouds_texture_name.c_str()); } -void time::clouds_texture_setter(LPCSTR value) +pcstr time::clouds_texture_getter() const { return (clouds_texture_name.c_str()); } +void time::clouds_texture_setter(pcstr value) { if (clouds_texture_name._get() == shared_str(value)._get()) return; diff --git a/src/xrEngine/editor_environment_weathers_time.hpp b/src/xrEngine/editor_environment_weathers_time.hpp index b8d57502211..ec54e811257 100644 --- a/src/xrEngine/editor_environment_weathers_time.hpp +++ b/src/xrEngine/editor_environment_weathers_time.hpp @@ -47,16 +47,16 @@ class time : public CEnvDescriptorMixer, public XRay::Editor::property_holder_ho CEnvironment* parent, CEnvDescriptor& A, CEnvDescriptor& B, float f, CEnvModifier& M, float m_power); private: - LPCSTR const* xr_stdcall ambients_collection(); + pcstr const* xr_stdcall ambients_collection(); u32 xr_stdcall ambients_collection_size(); - LPCSTR const* xr_stdcall suns_collection(); + pcstr const* xr_stdcall suns_collection(); u32 xr_stdcall suns_collection_size(); - LPCSTR const* xr_stdcall thunderbolts_collection(); + pcstr const* xr_stdcall thunderbolts_collection(); u32 xr_stdcall thunderbolts_collection_size(); private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); float xr_stdcall sun_altitude_getter() const; void xr_stdcall sun_altitude_setter(float value); float xr_stdcall sun_longitude_getter() const; @@ -65,16 +65,16 @@ class time : public CEnvDescriptorMixer, public XRay::Editor::property_holder_ho void xr_stdcall sky_rotation_setter(float value); float xr_stdcall wind_direction_getter() const; void xr_stdcall wind_direction_setter(float value); - LPCSTR xr_stdcall ambient_getter() const; - void xr_stdcall ambient_setter(LPCSTR value); - LPCSTR xr_stdcall sun_getter() const; - void xr_stdcall sun_setter(LPCSTR value); - LPCSTR xr_stdcall thunderbolt_getter() const; - void xr_stdcall thunderbolt_setter(LPCSTR value); - LPCSTR xr_stdcall sky_texture_getter() const; - void xr_stdcall sky_texture_setter(LPCSTR value); - LPCSTR xr_stdcall clouds_texture_getter() const; - void xr_stdcall clouds_texture_setter(LPCSTR value); + pcstr xr_stdcall ambient_getter() const; + void xr_stdcall ambient_setter(pcstr value); + pcstr xr_stdcall sun_getter() const; + void xr_stdcall sun_setter(pcstr value); + pcstr xr_stdcall thunderbolt_getter() const; + void xr_stdcall thunderbolt_setter(pcstr value); + pcstr xr_stdcall sky_texture_getter() const; + void xr_stdcall sky_texture_setter(pcstr value); + pcstr xr_stdcall clouds_texture_getter() const; + void xr_stdcall clouds_texture_setter(pcstr value); private: shared_str m_ambient; diff --git a/src/xrEngine/editor_environment_weathers_weather.cpp b/src/xrEngine/editor_environment_weathers_weather.cpp index 2672f704a67..4c3404b9935 100644 --- a/src/xrEngine/editor_environment_weathers_weather.cpp +++ b/src/xrEngine/editor_environment_weathers_weather.cpp @@ -22,7 +22,7 @@ using editor::environment::weathers::time; template <> void property_collection::display_name( - u32 const& item_index, LPSTR const& buffer, u32 const& buffer_size) + u32 const& item_index, pstr const& buffer, u32 const& buffer_size) { xr_strcpy(buffer, buffer_size, m_container[item_index]->id().c_str()); } @@ -65,11 +65,10 @@ void weather::load() typedef CInifile::Root sections_type; sections_type& sections = config->sections(); m_times.reserve(sections.size()); - sections_type::const_iterator i = sections.begin(); - sections_type::const_iterator e = sections.end(); - for (; i != e; ++i) + + for (const auto &i : sections) { - time* object = new time(&m_manager, this, (*i)->Name); + time* object = new time(&m_manager, this, i->Name); object->load(*config); object->fill(m_collection); m_times.push_back(object); @@ -84,18 +83,16 @@ void weather::save() string_path file_name; FS.update_path(file_name, "$game_weathers$", m_id.c_str()); xr_strcat(file_name, ".ltx"); - CInifile* config = new CInifile(file_name, FALSE, FALSE, TRUE); + CInifile* config = new CInifile(file_name, false, false, true); - container_type::iterator i = m_times.begin(); - container_type::iterator e = m_times.end(); - for (; i != e; ++i) - (*i)->save(*config); + for (const auto &i : m_times) + i->save(*config); CInifile::Destroy(config); } -LPCSTR weather::id_getter() const { return (m_id.c_str()); } -void weather::id_setter(LPCSTR value_) +pcstr weather::id_getter() const { return (m_id.c_str()); } +void weather::id_setter(pcstr value_) { shared_str value = value_; if (m_id._get() == value._get()) @@ -135,7 +132,7 @@ static inline bool is_digit(char const& test) bool weather::valid_id(shared_str const& id_) const { - LPCSTR id = id_.c_str(); + pcstr id = id_.c_str(); if (!is_digit(id[0])) return (false); @@ -261,15 +258,13 @@ shared_str weather::generate_unique_id() const bool weather::save_time_frame(shared_str const& frame_id, char* buffer, u32 const& buffer_size) { - container_type::iterator i = m_times.begin(); - container_type::iterator e = m_times.end(); - for (; i != e; ++i) + for (const auto &i : m_times) { - if (frame_id._get() != (*i)->id()._get()) + if (frame_id._get() != i->id()._get()) continue; - CInifile temp(0, FALSE, FALSE, FALSE); - (*i)->save(temp); + CInifile temp(nullptr, false, false, false); + i->save(temp); CMemoryWriter writer; temp.save_as(writer); @@ -286,11 +281,9 @@ bool weather::save_time_frame(shared_str const& frame_id, char* buffer, u32 cons bool weather::paste_time_frame(shared_str const& frame_id, char const* buffer, u32 const& buffer_size) { - container_type::iterator i = m_times.begin(); - container_type::iterator e = m_times.end(); - for (; i != e; ++i) + for (const auto &i : m_times) { - if (frame_id._get() != (*i)->id()._get()) + if (frame_id._get() != i->id()._get()) continue; IReader reader(const_cast(buffer), buffer_size); @@ -298,7 +291,7 @@ bool weather::paste_time_frame(shared_str const& frame_id, char const* buffer, u if (temp.sections().empty()) return (false); - (*i)->load_from((*temp.sections().begin())->Name, temp, shared_str((*i)->id())); + i->load_from((*temp.sections().begin())->Name, temp, shared_str(i->id())); return (true); } @@ -313,10 +306,8 @@ bool weather::add_time_frame(char const* buffer, u32 const& buffer_size) return (false); shared_str const& section = (*temp.sections().begin())->Name; - container_type::const_iterator i = m_times.begin(); - container_type::const_iterator e = m_times.end(); - for (; i != e; ++i) - if (section._get() == (*i)->id()._get()) + for (const auto &i : m_times) + if (section._get() == i->id()._get()) return (false); time* object = new time(&m_manager, this, section); @@ -331,7 +322,7 @@ bool weather::add_time_frame(char const* buffer, u32 const& buffer_size) } }; // struct id - container_type::iterator found = std::lower_bound(m_times.begin(), m_times.end(), section, &id::predicate); + auto found = std::lower_bound(m_times.begin(), m_times.end(), section, &id::predicate); u32 index = u32(found - m_times.begin()); m_times.insert(found, object); @@ -346,17 +337,15 @@ void weather::reload_time_frame(shared_str const& frame_id) xr_strcat(file_name, ".ltx"); CInifile* config = CInifile::Create(file_name); - container_type::iterator i = m_times.begin(); - container_type::iterator e = m_times.end(); - for (; i != e; ++i) + for (const auto &i : m_times) { - if (frame_id._get() != (*i)->id()._get()) + if (frame_id._get() != i->id()._get()) continue; - if (!config->section_exist((*i)->id())) + if (!config->section_exist(i->id())) return; - (*i)->load_from((*i)->id(), *config, (*i)->id()); + i->load_from(i->id(), *config, i->id()); CInifile::Destroy(config); return; } diff --git a/src/xrEngine/editor_environment_weathers_weather.hpp b/src/xrEngine/editor_environment_weathers_weather.hpp index 155f8e44138..b6a71b6a668 100644 --- a/src/xrEngine/editor_environment_weathers_weather.hpp +++ b/src/xrEngine/editor_environment_weathers_weather.hpp @@ -55,8 +55,8 @@ class weather : public XRay::Editor::property_holder_holder, private Noncopyable shared_str generate_unique_id(shared_str const& start) const; private: - LPCSTR xr_stdcall id_getter() const; - void xr_stdcall id_setter(LPCSTR value); + pcstr xr_stdcall id_getter() const; + void xr_stdcall id_setter(pcstr value); public: typedef xr_vector container_type;