| 181 | } |
| 182 | |
| 183 | bool CSoundBuffer::Load(bool bLooping, CSound *pSound) |
| 184 | { |
| 185 | GUARD_HEAP; |
| 186 | FUNCTION_PROFILER( m_pSoundSystem->GetSystem(),PROFILE_SOUND ); |
| 187 | if (m_Data.m_pData) |
| 188 | { |
| 189 | if (pSound) |
| 190 | pSound->OnBufferLoaded(); |
| 191 | return true; // already loaded |
| 192 | } |
| 193 | if (LoadFailure()) |
| 194 | { |
| 195 | if (pSound) |
| 196 | pSound->OnBufferLoadFailed(); |
| 197 | return false; //already tried to open the file before |
| 198 | } |
| 199 | m_vecLoadReqToAdd.push_back(pSound); |
| 200 | UpdateCallbacks(); |
| 201 | if (!NotLoaded()) |
| 202 | return true; |
| 203 | if (m_Props.sName.empty()) |
| 204 | return false; |
| 205 | m_bLooping=bLooping; |
| 206 | //priority for streaming files |
| 207 | if (m_Props.nFlags & FLAG_SOUND_STREAM) |
| 208 | { |
| 209 | // add the game path since this file is not opened via the pak |
| 210 | // file system |
| 211 | GUARD_HEAP; |
| 212 | CS_STREAM *pSoundStream=NULL; |
| 213 | |
| 214 | // check for a MOD first |
| 215 | const char *szPrefix=NULL; |
| 216 | #ifndef _ISNOTFARCRY |
| 217 | IGameMods *pMods=m_pSoundSystem->GetSystem()->GetIGame()->GetModsInterface(); |
| 218 | if (pMods) |
| 219 | szPrefix=pMods->GetModPath(m_Props.sName.c_str()); |
| 220 | #endif |
| 221 | |
| 222 | if (szPrefix) |
| 223 | { |
| 224 | #ifndef CS_VERSION_372 |
| 225 | pSoundStream=CS_Stream_OpenFile(szPrefix, GetFModFlags(m_bLooping), 0); |
| 226 | #else |
| 227 | // for 3.7 |
| 228 | pSoundStream=CS_Stream_Open(szPrefix, GetFModFlags(m_bLooping), 0,0); |
| 229 | #endif |
| 230 | if (!pSoundStream) |
| 231 | { |
| 232 | // if not found in the MOD folder, fallback to the default one and |
| 233 | // try to open it from there |
| 234 | |
| 235 | // for 3.7 support |
| 236 | const char * pFileName = m_Props.sName.c_str(); |
| 237 | #ifndef CS_VERSION_372 |
| 238 | pSoundStream=CS_Stream_OpenFile(pFileName, GetFModFlags(m_bLooping), 0); |
| 239 | #else |
| 240 | pSoundStream=CS_Stream_Open(pFileName, GetFModFlags(m_bLooping), 0,0); |
no test coverage detected