1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Hotfix: erase stored music position once it has been used

Fixes infinite loop on attempts to resume music track from position
larger than music duration
This commit is contained in:
Ivan Savenko 2022-11-20 23:38:09 +02:00
parent 4912f4d5ae
commit 61eca7e3be

View File

@ -588,6 +588,11 @@ bool MusicEntry::play()
float timeToStart = owner->trackPositions[currentName];
startPosition = std::round(timeToStart * 1000);
// erase stored position:
// if music track will be interrupted again - new position will be written in stop() method
// if music track is not interrupted and will finish by timeout/end of file - it will restart from begginning as it should
owner->trackPositions.erase( owner->trackPositions.find(currentName) );
if (Mix_FadeInMusicPos(music, 1, 1000, timeToStart) == -1)
{
logGlobal->error("Unable to play music (%s)", Mix_GetError());