4
4
5
5
float psHUDSoundVolume = 1 .0f ;
6
6
float psHUDStepSoundVolume = 1 .0f ;
7
+
7
8
void InitHudSoundSettings ()
8
9
{
9
10
psHUDSoundVolume = pSettings->r_float (" hud_sound" , " hud_sound_vol_k" );
@@ -12,7 +13,7 @@ void InitHudSoundSettings()
12
13
13
14
void HUD_SOUND_ITEM::LoadSound (LPCSTR section, LPCSTR line, HUD_SOUND_ITEM& hud_snd, int type)
14
15
{
15
- hud_snd.m_activeSnd = NULL ;
16
+ hud_snd.m_activeSnd = nullptr ;
16
17
hud_snd.sounds .clear ();
17
18
18
19
string256 sound_line;
@@ -39,7 +40,7 @@ void HUD_SOUND_ITEM::LoadSound(LPCSTR section, LPCSTR line, ref_sound& snd, int
39
40
_GetItem (str, 0 , buf_str);
40
41
snd.create (buf_str, st_Effect, type);
41
42
42
- if (volume != NULL )
43
+ if (volume != nullptr )
43
44
{
44
45
*volume = 1 .f ;
45
46
if (count > 1 )
@@ -50,7 +51,7 @@ void HUD_SOUND_ITEM::LoadSound(LPCSTR section, LPCSTR line, ref_sound& snd, int
50
51
}
51
52
}
52
53
53
- if (delay != NULL )
54
+ if (delay != nullptr )
54
55
{
55
56
*delay = 0 ;
56
57
if (count > 2 )
@@ -64,12 +65,12 @@ void HUD_SOUND_ITEM::LoadSound(LPCSTR section, LPCSTR line, ref_sound& snd, int
64
65
65
66
void HUD_SOUND_ITEM::DestroySound (HUD_SOUND_ITEM& hud_snd)
66
67
{
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
+
70
71
hud_snd.sounds .clear ();
71
72
72
- hud_snd.m_activeSnd = NULL ;
73
+ hud_snd.m_activeSnd = nullptr ;
73
74
}
74
75
75
76
void HUD_SOUND_ITEM::PlaySound (
@@ -78,7 +79,7 @@ void HUD_SOUND_ITEM::PlaySound(
78
79
if (hud_snd.sounds .empty ())
79
80
return ;
80
81
81
- hud_snd.m_activeSnd = NULL ;
82
+ hud_snd.m_activeSnd = nullptr ;
82
83
StopSound (hud_snd);
83
84
84
85
u32 flags = b_hud_mode ? sm_2D : 0 ;
@@ -100,22 +101,19 @@ void HUD_SOUND_ITEM::PlaySound(
100
101
101
102
void HUD_SOUND_ITEM::StopSound (HUD_SOUND_ITEM& hud_snd)
102
103
{
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 ;
107
108
}
108
109
109
110
// ----------------------------------------------------------
110
111
HUD_SOUND_COLLECTION::~HUD_SOUND_COLLECTION ()
111
112
{
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)
116
114
{
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 );
119
117
}
120
118
121
119
m_sound_items.clear ();
@@ -127,23 +125,17 @@ HUD_SOUND_ITEM* HUD_SOUND_COLLECTION::FindSoundItem(LPCSTR alias, bool b_assert)
127
125
128
126
if (it != m_sound_items.end ())
129
127
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 ;
135
131
}
136
132
137
133
void HUD_SOUND_COLLECTION::PlaySound (
138
134
LPCSTR alias, const Fvector& position, const IGameObject* parent, bool hud_mode, bool looped, u8 index)
139
135
{
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);
147
139
148
140
HUD_SOUND_ITEM* snd_item = FindSoundItem (alias, true );
149
141
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)
164
156
165
157
void HUD_SOUND_COLLECTION::StopAllSounds ()
166
158
{
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);
174
161
}
175
162
176
163
void 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,
192
179
#ifdef LAYERED_SND_SHOOT
193
180
HUD_SOUND_COLLECTION_LAYERED::~HUD_SOUND_COLLECTION_LAYERED ()
194
181
{
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 ();
202
184
203
185
m_sound_items.clear ();
204
186
}
205
187
206
188
void HUD_SOUND_COLLECTION_LAYERED::StopAllSounds ()
207
189
{
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 ();
215
192
}
216
193
217
194
void HUD_SOUND_COLLECTION_LAYERED::StopSound (pcstr alias)
218
195
{
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);
227
199
}
228
200
229
201
void HUD_SOUND_COLLECTION_LAYERED::SetPosition (pcstr alias, const Fvector& pos)
230
202
{
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);
239
206
}
240
207
241
208
void HUD_SOUND_COLLECTION_LAYERED::PlaySound (pcstr alias, const Fvector& position, const IGameObject* parent,
242
209
bool hud_mode, bool looped, u8 index)
243
210
{
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);
252
214
}
253
215
254
216
255
217
HUD_SOUND_ITEM* HUD_SOUND_COLLECTION_LAYERED::FindSoundItem (pcstr alias, bool b_assert)
256
218
{
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);
259
222
260
- for (; it != it_e; ++it)
261
- {
262
- if (it->m_alias == alias)
263
- return it->FindSoundItem (alias, b_assert);
264
- }
265
223
return nullptr ;
266
224
}
267
225
0 commit comments