44
55float psHUDSoundVolume = 1 .0f ;
66float psHUDStepSoundVolume = 1 .0f ;
7+
78void InitHudSoundSettings ()
89{
910 psHUDSoundVolume = pSettings->r_float (" hud_sound" , " hud_sound_vol_k" );
@@ -12,7 +13,7 @@ void InitHudSoundSettings()
1213
1314void HUD_SOUND_ITEM::LoadSound (LPCSTR section, LPCSTR line, HUD_SOUND_ITEM& hud_snd, int type)
1415{
15- hud_snd.m_activeSnd = NULL ;
16+ hud_snd.m_activeSnd = nullptr ;
1617 hud_snd.sounds .clear ();
1718
1819 string256 sound_line;
@@ -39,7 +40,7 @@ void HUD_SOUND_ITEM::LoadSound(LPCSTR section, LPCSTR line, ref_sound& snd, int
3940 _GetItem (str, 0 , buf_str);
4041 snd.create (buf_str, st_Effect, type);
4142
42- if (volume != NULL )
43+ if (volume != nullptr )
4344 {
4445 *volume = 1 .f ;
4546 if (count > 1 )
@@ -50,7 +51,7 @@ void HUD_SOUND_ITEM::LoadSound(LPCSTR section, LPCSTR line, ref_sound& snd, int
5051 }
5152 }
5253
53- if (delay != NULL )
54+ if (delay != nullptr )
5455 {
5556 *delay = 0 ;
5657 if (count > 2 )
@@ -64,12 +65,12 @@ void HUD_SOUND_ITEM::LoadSound(LPCSTR section, LPCSTR line, ref_sound& snd, int
6465
6566void HUD_SOUND_ITEM::DestroySound (HUD_SOUND_ITEM& hud_snd)
6667{
67- xr_vector<SSnd>::iterator it = hud_snd.sounds . begin ();
68- for (; it != hud_snd. sounds . end (); ++it)
69- (*it). snd . destroy ();
68+ for ( auto & sound : hud_snd.sounds )
69+ sound. snd . destroy ();
70+
7071 hud_snd.sounds .clear ();
7172
72- hud_snd.m_activeSnd = NULL ;
73+ hud_snd.m_activeSnd = nullptr ;
7374}
7475
7576void HUD_SOUND_ITEM::PlaySound (
@@ -78,7 +79,7 @@ void HUD_SOUND_ITEM::PlaySound(
7879 if (hud_snd.sounds .empty ())
7980 return ;
8081
81- hud_snd.m_activeSnd = NULL ;
82+ hud_snd.m_activeSnd = nullptr ;
8283 StopSound (hud_snd);
8384
8485 u32 flags = b_hud_mode ? sm_2D : 0 ;
@@ -100,22 +101,19 @@ void HUD_SOUND_ITEM::PlaySound(
100101
101102void HUD_SOUND_ITEM::StopSound (HUD_SOUND_ITEM& hud_snd)
102103{
103- xr_vector<SSnd>::iterator it = hud_snd.sounds . begin ();
104- for (; it != hud_snd. sounds . end (); ++it)
105- (*it). snd . stop ();
106- hud_snd.m_activeSnd = NULL ;
104+ for ( auto & sound : hud_snd.sounds )
105+ sound. snd . stop ();
106+
107+ hud_snd.m_activeSnd = nullptr ;
107108}
108109
109110// ----------------------------------------------------------
110111HUD_SOUND_COLLECTION::~HUD_SOUND_COLLECTION ()
111112{
112- xr_vector<HUD_SOUND_ITEM>::iterator it = m_sound_items.begin ();
113- xr_vector<HUD_SOUND_ITEM>::iterator it_e = m_sound_items.end ();
114-
115- for (; it != it_e; ++it)
113+ for (auto & sound_item : m_sound_items)
116114 {
117- HUD_SOUND_ITEM::StopSound (*it );
118- HUD_SOUND_ITEM::DestroySound (*it );
115+ HUD_SOUND_ITEM::StopSound (sound_item );
116+ HUD_SOUND_ITEM::DestroySound (sound_item );
119117 }
120118
121119 m_sound_items.clear ();
@@ -127,23 +125,17 @@ HUD_SOUND_ITEM* HUD_SOUND_COLLECTION::FindSoundItem(LPCSTR alias, bool b_assert)
127125
128126 if (it != m_sound_items.end ())
129127 return &*it;
130- else
131- {
132- R_ASSERT3 (!b_assert, " sound item not found in collection" , alias);
133- return NULL ;
134- }
128+
129+ R_ASSERT3 (!b_assert, " sound item not found in collection" , alias);
130+ return nullptr ;
135131}
136132
137133void HUD_SOUND_COLLECTION::PlaySound (
138134 LPCSTR alias, const Fvector& position, const IGameObject* parent, bool hud_mode, bool looped, u8 index)
139135{
140- xr_vector<HUD_SOUND_ITEM>::iterator it = m_sound_items.begin ();
141- xr_vector<HUD_SOUND_ITEM>::iterator it_e = m_sound_items.end ();
142- for (; it != it_e; ++it)
143- {
144- if (it->m_b_exclusive )
145- HUD_SOUND_ITEM::StopSound (*it);
146- }
136+ for (auto & sound_item : m_sound_items)
137+ if (sound_item.m_b_exclusive )
138+ HUD_SOUND_ITEM::StopSound (sound_item);
147139
148140 HUD_SOUND_ITEM* snd_item = FindSoundItem (alias, true );
149141 HUD_SOUND_ITEM::PlaySound (*snd_item, position, parent, hud_mode, looped, index);
@@ -164,13 +156,8 @@ void HUD_SOUND_COLLECTION::SetPosition(LPCSTR alias, const Fvector& pos)
164156
165157void HUD_SOUND_COLLECTION::StopAllSounds ()
166158{
167- xr_vector<HUD_SOUND_ITEM>::iterator it = m_sound_items.begin ();
168- xr_vector<HUD_SOUND_ITEM>::iterator it_e = m_sound_items.end ();
169-
170- for (; it != it_e; ++it)
171- {
172- HUD_SOUND_ITEM::StopSound (*it);
173- }
159+ for (auto & sound_item : m_sound_items)
160+ HUD_SOUND_ITEM::StopSound (sound_item);
174161}
175162
176163void HUD_SOUND_COLLECTION::LoadSound (LPCSTR section, LPCSTR line, LPCSTR alias, bool exclusive, int type)
@@ -192,76 +179,47 @@ void HUD_SOUND_COLLECTION::LoadSound(LPCSTR section, LPCSTR line, LPCSTR alias,
192179#ifdef LAYERED_SND_SHOOT
193180HUD_SOUND_COLLECTION_LAYERED::~HUD_SOUND_COLLECTION_LAYERED ()
194181{
195- xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin ();
196- xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end ();
197-
198- for (; it != it_e; ++it)
199- {
200- it->~HUD_SOUND_COLLECTION ();
201- }
182+ for (auto & sound_item : m_sound_items)
183+ sound_item.~HUD_SOUND_COLLECTION ();
202184
203185 m_sound_items.clear ();
204186}
205187
206188void HUD_SOUND_COLLECTION_LAYERED::StopAllSounds ()
207189{
208- xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin ();
209- xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end ();
210-
211- for (; it != it_e; ++it)
212- {
213- it->StopAllSounds ();
214- }
190+ for (auto & sound_item : m_sound_items)
191+ sound_item.StopAllSounds ();
215192}
216193
217194void HUD_SOUND_COLLECTION_LAYERED::StopSound (pcstr alias)
218195{
219- xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin ();
220- xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end ();
221-
222- for (; it != it_e; ++it)
223- {
224- if (it->m_alias == alias)
225- it->StopSound (alias);
226- }
196+ for (auto & sound_item : m_sound_items)
197+ if (sound_item.m_alias == alias)
198+ sound_item.StopSound (alias);
227199}
228200
229201void HUD_SOUND_COLLECTION_LAYERED::SetPosition (pcstr alias, const Fvector& pos)
230202{
231- xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin ();
232- xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end ();
233-
234- for (; it != it_e; ++it)
235- {
236- if (it->m_alias == alias)
237- it->SetPosition (alias, pos);
238- }
203+ for (auto & sound_item : m_sound_items)
204+ if (sound_item.m_alias == alias)
205+ sound_item.SetPosition (alias, pos);
239206}
240207
241208void HUD_SOUND_COLLECTION_LAYERED::PlaySound (pcstr alias, const Fvector& position, const IGameObject* parent,
242209 bool hud_mode, bool looped, u8 index)
243210{
244- xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin ();
245- xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end ();
246-
247- for (; it != it_e; ++it)
248- {
249- if (it->m_alias == alias)
250- it->PlaySound (alias, position, parent, hud_mode, looped, index);
251- }
211+ for (auto & sound_item : m_sound_items)
212+ if (sound_item.m_alias == alias)
213+ sound_item.PlaySound (alias, position, parent, hud_mode, looped, index);
252214}
253215
254216
255217HUD_SOUND_ITEM* HUD_SOUND_COLLECTION_LAYERED::FindSoundItem (pcstr alias, bool b_assert)
256218{
257- xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin ();
258- xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end ();
219+ for (auto & sound_item : m_sound_items)
220+ if (sound_item.m_alias == alias)
221+ return sound_item.FindSoundItem (alias, b_assert);
259222
260- for (; it != it_e; ++it)
261- {
262- if (it->m_alias == alias)
263- return it->FindSoundItem (alias, b_assert);
264- }
265223 return nullptr ;
266224}
267225
0 commit comments