MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FindSound

Function FindSound

engine/Poseidon/UI/OptionsUI.cpp:419–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417 return;
418
419 RString candidate = WithLangSuffix(pars.name, RString(GetSelectedVoiceLanguage().c_str()));
420 if (candidate.GetLength() > 0 && QIFStreamB::FileExist(candidate))
421 pars.name = candidate;
422}
423
424const ParamEntry* FindSound(RString name, SoundPars& pars)
425{
426 // ignore @ - not used now
427 if (name[0] == '@')
428 {
429 name = (const char*)name + 1;
430 }
431
432 // find in mission
433 const ParamEntry* cls = ExtParsMission.FindEntry("CfgSounds");
434 const ParamEntry* entry = cls ? cls->FindEntry(name) : nullptr;
435 if (entry)
436 {
437 GetValue(pars, (*entry) >> "sound");
438 if (pars.name.GetLength() > 0)
439 {
440 pars.name = GetMissionDirectory() + pars.name;
441 // Per-language voice override: prefer "<base>.<voiceLang>.<ext>" if it exists.
442 // Resolved at play time so a runtime voice-language switch picks up the new
443 // file on the next say/playSound — currently-playing audio is unaffected.
444 PreferExistingVoiceLanguageOverride(pars);
445 }
446 return entry;
447 }
448
449 // find in campaign
450 cls = ExtParsCampaign.FindEntry("CfgSounds");
451 entry = cls ? cls->FindEntry(name) : nullptr;
452 if (entry)
453 {
454 GetValue(pars, (*entry) >> "sound");
455 if (pars.name.GetLength() > 0)
456 {
457 pars.name = BaseDirectory + RString("dtaExt\\") + pars.name;
458 PreferExistingVoiceLanguageOverride(pars);
459 }
460 return entry;
461 }
462
463 // find in config
464 cls = Pars.FindEntry("CfgSounds");
465 entry = cls ? cls->FindEntry(name) : nullptr;
466 if (entry)
467 {
468 GetValue(pars, (*entry) >> "sound");
469 return entry;
470 }
471
472 // Single point of truth for an unresolvable sound key: report it here, where
473 // the logical name is still in hand, then let callers play nothing. (Routed
474 // through LOG_WARN rather than WarningMessage — the latter is a no-op in the
475 // shipping app frame, which is why a bad `say`/sound surfaced only as the
476 // file server's context-free "Empty or nullptr name not allowed".)

Callers 7

StartSoundMethod · 0.85
LoadSoundMethod · 0.85
PreloadMissionAudioMethod · 0.85
PlaySoundMethod · 0.85
SoundLengthFunction · 0.85

Calls 6

GetValueFunction · 0.85
GetMissionDirectoryFunction · 0.85
RStringClass · 0.50
FindEntryMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected