================== S_RegisterSound Creates a default buzz sound if the file can't be loaded ================== */
| 1004 | ================== |
| 1005 | */ |
| 1006 | sfxHandle_t S_RegisterSound( const char *name) |
| 1007 | { |
| 1008 | sfx_t *sfx; |
| 1009 | |
| 1010 | if (!s_soundStarted) { |
| 1011 | return 0; |
| 1012 | } |
| 1013 | |
| 1014 | if ( strlen( name ) >= MAX_QPATH ) { |
| 1015 | Com_Printf( S_COLOR_RED"Sound name exceeds MAX_QPATH - %s\n", name ); |
| 1016 | return 0; |
| 1017 | } |
| 1018 | |
| 1019 | sfx = S_FindName( name ); |
| 1020 | |
| 1021 | SND_TouchSFX(sfx); |
| 1022 | |
| 1023 | if ( sfx->bDefaultSound ) |
| 1024 | return 0; |
| 1025 | |
| 1026 | #ifdef USE_OPENAL |
| 1027 | if (s_UseOpenAL) |
| 1028 | { |
| 1029 | if ((sfx->pSoundData) || (sfx->Buffer)) |
| 1030 | return sfx - s_knownSfx; |
| 1031 | } |
| 1032 | else |
| 1033 | #endif |
| 1034 | { |
| 1035 | if ( sfx->pSoundData ) |
| 1036 | { |
| 1037 | return sfx - s_knownSfx; |
| 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | sfx->bInMemory = false; |
| 1042 | |
| 1043 | S_memoryLoad(sfx); |
| 1044 | |
| 1045 | if ( sfx->bDefaultSound ) { |
| 1046 | #ifndef FINAL_BUILD |
| 1047 | Com_DPrintf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->sSoundName ); |
| 1048 | #endif |
| 1049 | return 0; |
| 1050 | } |
| 1051 | |
| 1052 | return sfx - s_knownSfx; |
| 1053 | } |
| 1054 | |
| 1055 | void S_memoryLoad(sfx_t *sfx) |
| 1056 | { |
no test coverage detected