MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / WeathersUpdate

Method WeathersUpdate

ogsr_engine/xrGame/GamePersistent.cpp:203–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203void CGamePersistent::WeathersUpdate()
204{
205 if (g_pGamePersistent->Environment().USED_COP_WEATHER)
206 {
207 if (g_pGameLevel)
208 {
209 const bool bIndoor = g_pGamePersistent->IsActorInHideout();
210
211 int data_set = (Random.randF() < (1.f - Environment().CurrentEnv->weight)) ? 0 : 1;
212
213 CEnvDescriptor* const current_env = Environment().Current[0];
214 VERIFY(current_env);
215
216 CEnvDescriptor* const _env = Environment().Current[data_set];
217 VERIFY(_env);
218
219 CEnvAmbient* env_amb = _env->env_ambient;
220 if (env_amb)
221 {
222 CEnvAmbient::SSndChannelVec& vec = current_env->env_ambient->get_snd_channels();
223 CEnvAmbient::SSndChannelVecIt I = vec.begin();
224 CEnvAmbient::SSndChannelVecIt E = vec.end();
225
226 for (u32 idx = 0; I != E; ++I, ++idx)
227 {
228 CEnvAmbient::SSndChannel& ch = **I;
229 R_ASSERT(idx < 40);
230 if (ambient_sound_next_time[idx] == 0) // first
231 {
232 ambient_sound_next_time[idx] = Device.dwTimeGlobal + ch.get_rnd_sound_first_time();
233 }
234 else if (Device.dwTimeGlobal > ambient_sound_next_time[idx])
235 {
236 ref_sound& snd = ch.get_rnd_sound();
237
238 Fvector pos;
239 float angle = ::Random.randF(PI_MUL_2);
240 pos.x = _cos(angle);
241 pos.y = 0;
242 pos.z = _sin(angle);
243 pos.normalize().mul(ch.get_rnd_sound_dist()).add(Device.vCameraPosition);
244 pos.y += 10.f;
245 snd.play_at_pos(0, pos);
246
247#ifdef DEBUG
248 if (!snd._handle() && strstr(Core.Params, "-nosound"))
249 continue;
250#endif // DEBUG
251
252 VERIFY(snd._handle());
253 u32 _length_ms = iFloor(snd.get_length_sec() * 1000.0f);
254 ambient_sound_next_time[idx] = Device.dwTimeGlobal + _length_ms + ch.get_rnd_sound_time();
255 // Msg("- Playing ambient sound channel [%s] file[%s]",ch.m_load_section.c_str(),snd._handle()->file_name());
256 }
257 }
258 /*
259 if (Device.dwTimeGlobal > ambient_sound_next_time)
260 {

Callers

nothing calls this directly

Calls 15

_cosFunction · 0.85
_sinFunction · 0.85
CreateFunction · 0.85
DestroyFunction · 0.85
EnvironmentMethod · 0.80
IsActorInHideoutMethod · 0.80
randFMethod · 0.80
get_rnd_sound_distMethod · 0.80
_handleMethod · 0.80
get_rnd_sound_timeMethod · 0.80
slerpMethod · 0.80

Tested by

no test coverage detected