Browse Source

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
Ivan Savenko 2 years ago
parent
commit
61eca7e3be
1 changed files with 5 additions and 0 deletions
  1. 5 0
      client/CMusicHandler.cpp

+ 5 - 0
client/CMusicHandler.cpp

@@ -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());