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

Method StartSound

engine/Poseidon/Audio/DynSound.cpp:82–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void SoundObject::StartSound()
83{
84 SoundPars pars;
85 FindSound(_soundName, pars);
86
87 // Nothing resolved means no audio to play: either FindSound already reported
88 // an unknown key, or the entry is subtitle-only (titles, empty sound[] file).
89 // Either way play nothing — the same guard DynSoundObject::Simulate uses
90 // (pars.name[0]) — so an empty name never reaches the loader. Titles, if any,
91 // still run via SimulateTitles().
92 if (pars.name.GetLength() == 0)
93 {
94 return;
95 }
96
97 if (_hasObject)
98 {
99 Object* source = _object;
100 if (_looped)
101 {
102 _sound =
103 GSoundScene->OpenAndPlay(pars.name, source->WorldPosition(), source->WorldSpeed(), pars.vol, pars.freq);
104 }
105 else
106 {
107 _sound = GSoundScene->OpenAndPlayOnce(pars.name, source->WorldPosition(), source->WorldSpeed(), pars.vol,
108 pars.freq);
109 }
110 source->AttachWave(_sound, pars.freq);
111 }
112 else
113 {
114 if (_looped)
115 {
116 _sound = GSoundScene->OpenAndPlay2D(pars.name, pars.vol, pars.freq, false);
117 }
118 else
119 {
120 _sound = GSoundScene->OpenAndPlayOnce2D(pars.name, pars.vol, pars.freq, false);
121 }
122 }
123}
124
125void SoundObject::LoadSound()
126{

Callers

nothing calls this directly

Calls 8

FindSoundFunction · 0.85
OpenAndPlayMethod · 0.80
OpenAndPlayOnceMethod · 0.80
OpenAndPlay2DMethod · 0.80
OpenAndPlayOnce2DMethod · 0.80
GetLengthMethod · 0.45
WorldSpeedMethod · 0.45
AttachWaveMethod · 0.45

Tested by

no test coverage detected