mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Merge pull request #1411 from OpenMW/revert-1401-master
Reverts OpenMW/openmw#1401
This commit is contained in:
commit
2c11ed2454
2 changed files with 9 additions and 18 deletions
|
@ -271,6 +271,7 @@ namespace MWSound
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gets the combined volume settings for the given sound type
|
// Gets the combined volume settings for the given sound type
|
||||||
float SoundManager::volumeFromType(PlayType type) const
|
float SoundManager::volumeFromType(PlayType type) const
|
||||||
{
|
{
|
||||||
|
@ -297,6 +298,7 @@ namespace MWSound
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SoundManager::stopMusic()
|
void SoundManager::stopMusic()
|
||||||
{
|
{
|
||||||
if(mMusic)
|
if(mMusic)
|
||||||
|
@ -365,9 +367,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
mMusicFiles[mCurrentPlaylist] = filelist;
|
mMusicFiles[mCurrentPlaylist] = filelist;
|
||||||
mMusicToPlay.reserve(mMusicToPlay.size() + filelist.size());
|
|
||||||
for(int it = 0; it < filelist.size(); it++)
|
|
||||||
mMusicToPlay.push_back(it);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
filelist = mMusicFiles[mCurrentPlaylist];
|
filelist = mMusicFiles[mCurrentPlaylist];
|
||||||
|
@ -375,23 +375,15 @@ namespace MWSound
|
||||||
if(filelist.empty())
|
if(filelist.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Do a Fisher-Yates shuffle
|
int i = Misc::Rng::rollDice(filelist.size());
|
||||||
if(mMusicFiles.size() == 0)
|
|
||||||
|
// Don't play the same music track twice in a row
|
||||||
|
if (filelist[i] == mLastPlayedMusic)
|
||||||
{
|
{
|
||||||
mMusicToPlay.reserve(filelist.size());
|
i = (i+1) % filelist.size();
|
||||||
for (int it = 0; it < filelist.size(); it++)
|
|
||||||
mMusicToPlay.push_back(it);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = Misc::Rng::rollDice(mMusicToPlay.size());
|
advanceMusic(filelist[i]);
|
||||||
|
|
||||||
// Fix last played music being the same after another shuffle
|
|
||||||
if(filelist[mMusicToPlay[i]] == mLastPlayedMusic)
|
|
||||||
i = (i+1) % mMusicToPlay.size();
|
|
||||||
|
|
||||||
advanceMusic(filelist[mMusicToPlay[i]]);
|
|
||||||
mMusicToPlay[i] = mMusicToPlay.back();
|
|
||||||
mMusicToPlay.pop_back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundManager::isMusicPlaying()
|
bool SoundManager::isMusicPlaying()
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace MWSound
|
||||||
|
|
||||||
// Caches available music tracks by <playlist name, (sound files) >
|
// Caches available music tracks by <playlist name, (sound files) >
|
||||||
std::map<std::string, std::vector<std::string> > mMusicFiles;
|
std::map<std::string, std::vector<std::string> > mMusicFiles;
|
||||||
std::vector<int> mMusicToPlay; // The list of music files not played yet
|
|
||||||
std::string mLastPlayedMusic; // The music file that was last played
|
std::string mLastPlayedMusic; // The music file that was last played
|
||||||
|
|
||||||
float mMasterVolume;
|
float mMasterVolume;
|
||||||
|
|
Loading…
Reference in a new issue