| 201 | } |
| 202 | |
| 203 | void 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 | { |
nothing calls this directly
no test coverage detected