@@ -27,7 +27,7 @@ using editor::environment::effects::effect;
2727
2828template <>
2929void property_collection<ambient::effect_container_type, ambient>::display_name(
30- u32 const & item_index, LPSTR const & buffer, u32 const & buffer_size)
30+ u32 const & item_index, pstr const & buffer, u32 const & buffer_size)
3131{
3232 xr_strcpy (buffer, buffer_size, m_container[item_index]->id ().c_str ());
3333}
@@ -42,7 +42,7 @@ XRay::Editor::property_holder_base* property_collection<ambient::effect_containe
4242
4343template <>
4444void property_collection<ambient::sound_container_type, ambient>::display_name(
45- u32 const & item_index, LPSTR const & buffer, u32 const & buffer_size)
45+ u32 const & item_index, pstr const & buffer, u32 const & buffer_size)
4646{
4747 xr_strcpy (buffer, buffer_size, m_container[item_index]->id ().c_str ());
4848}
@@ -85,7 +85,7 @@ void ambient::load(
8585
8686 {
8787 VERIFY (m_effects_ids.empty ());
88- LPCSTR effects_string = READ_IF_EXISTS (&ambients_config, r_string, m_load_section, " effects" , " " );
88+ pcstr effects_string = READ_IF_EXISTS (&ambients_config, r_string, m_load_section, " effects" , " " );
8989 for (u32 i = 0 , n = _GetItemCount (effects_string); i < n; ++i)
9090 {
9191 string_path temp;
@@ -97,7 +97,7 @@ void ambient::load(
9797
9898 {
9999 VERIFY (m_sound_channels_ids.empty ());
100- LPCSTR sounds_string = READ_IF_EXISTS (&ambients_config, r_string, m_load_section, " sound_channels" , " " );
100+ pcstr sounds_string = READ_IF_EXISTS (&ambients_config, r_string, m_load_section, " sound_channels" , " " );
101101 for (u32 i = 0 , n = _GetItemCount (sounds_string); i < n; ++i)
102102 {
103103 string_path temp;
@@ -111,25 +111,19 @@ void ambient::load(
111111void ambient::save (CInifile& config)
112112{
113113 u32 count = 1 ;
114- LPSTR temp = 0 ;
114+ pstr temp = 0 ;
115115 {
116- sound_container_type::const_iterator b = m_sound_channels_ids.begin (), i = b;
117- sound_container_type::const_iterator e = m_sound_channels_ids.end ();
118- for (; i != e; ++i)
119- count += (*i)->id ().size () + 2 ;
120-
121- temp = (LPSTR)_alloca (count * sizeof (char ));
122- *temp = 0 ;
123- for (i = b; i != e; ++i)
116+ for (const auto &i : m_sound_channels_ids)
117+ count += i->id ().size () + 2 ;
118+
119+ temp = (pstr)_alloca (count * sizeof (char ));
120+ *temp = ' \0 ' ;
121+ for (const auto &i : m_sound_channels_ids)
124122 {
125- if (i == b)
126- {
127- xr_strcpy (temp, count, (*i)->id ().c_str ());
128- continue ;
129- }
130-
131- xr_strcat (temp, count, " , " );
132- xr_strcat (temp, count, (*i)->id ().c_str ());
123+ xr_strcat (temp, count, i->id ().c_str ());
124+
125+ if (&i != &m_sound_channels_ids.back ())
126+ xr_strcat (temp, count, " , " );
133127 }
134128 }
135129
@@ -139,30 +133,23 @@ void ambient::save(CInifile& config)
139133
140134 {
141135 count = 1 ;
142- effect_container_type::const_iterator b = m_effects_ids.begin (), i = b;
143- effect_container_type::const_iterator e = m_effects_ids.end ();
144- for (; i != e; ++i)
145- count += (*i)->id ().size () + 2 ;
146-
147- temp = (LPSTR)_alloca (count * sizeof (char ));
148- *temp = 0 ;
149- for (i = b; i != e; ++i)
136+ for (const auto &i : m_effects_ids)
137+ count += i->id ().size () + 2 ;
138+
139+ temp = (pstr)_alloca (count * sizeof (char ));
140+ *temp = ' \0 ' ;
141+ for (const auto &i : m_effects_ids)
150142 {
151- if (i == b)
152- {
153- xr_strcpy (temp, count, (*i)->id ().c_str ());
154- continue ;
155- }
156-
157- xr_strcat (temp, count, " , " );
158- xr_strcat (temp, count, (*i)->id ().c_str ());
143+ xr_strcat (temp, count, i->id ().c_str ());
144+ if (&i != &m_effects_ids.back ())
145+ xr_strcat (temp, count, " , " );
159146 }
160147 }
161148 config.w_string (m_load_section.c_str (), " effects" , temp);
162149}
163150
164- LPCSTR ambient::id_getter () const { return (m_load_section.c_str ()); }
165- void ambient::id_setter (LPCSTR value_)
151+ pcstr ambient::id_getter () const { return (m_load_section.c_str ()); }
152+ void ambient::id_setter (pcstr value_)
166153{
167154 shared_str value = value_;
168155 if (m_load_section._get () == value._get ())
@@ -211,15 +198,15 @@ ::editor::environment::sound_channels::manager const& ambient::sounds_manager()
211198 return (m_manager.sounds_manager ());
212199}
213200
214- ambient::SEffect* ambient::create_effect (CInifile& config, LPCSTR id)
201+ ambient::SEffect* ambient::create_effect (CInifile& config, pcstr id)
215202{
216203 effect* result = new effect (m_manager.effects_manager (), id);
217204 result->load (config);
218205 result->fill (m_effects_collection);
219206 return (result);
220207}
221208
222- ambient::SSndChannel* ambient::create_sound_channel (CInifile& config, LPCSTR id)
209+ ambient::SSndChannel* ambient::create_sound_channel (CInifile& config, pcstr id)
223210{
224211 channel* result = new channel (m_manager.sounds_manager (), id);
225212 result->load (config);
0 commit comments