partial sound loading should be more resiliant

This commit is contained in:
Cameron Taylor 2024-06-05 15:02:29 -04:00
parent 3534ba6224
commit 5bcc0f9b25
2 changed files with 16 additions and 6 deletions
source/funkin

View file

@ -357,6 +357,11 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
var shouldLoadPartial = params.partialParams?.loadPartial ?? false;
// even if we arent' trying to partial load a song, we want to error out any songs in progress,
// so we don't get overlapping music if someone were to load a new song while a partial one is loading!
emptyPartialQueue();
if (shouldLoadPartial)
{
var music = FunkinSound.loadPartial(pathToUse, params.partialParams?.start ?? 0.0, params.partialParams?.end ?? 1.0, params?.startingVolume ?? 1.0,
@ -364,12 +369,6 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
if (music != null)
{
while (partialQueue.length > 0)
{
@:nullSafety(Off)
partialQueue.pop().error("Cancel loading partial sound");
}
partialQueue.push(music);
@:nullSafety(Off)
@ -406,6 +405,15 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
}
}
public static function emptyPartialQueue():Void
{
while (partialQueue.length > 0)
{
@:nullSafety(Off)
partialQueue.pop().error("Cancel loading partial sound");
}
}
static var partialQueue:Array<Promise<Null<FunkinSound>>> = [];
/**

View file

@ -1769,6 +1769,8 @@ class FreeplayState extends MusicBeatSubState
funnyScroll3.visible = false;
new FlxTimer().start(1, function(tmr:FlxTimer) {
FunkinSound.emptyPartialQueue();
Paths.setCurrentLevel(cap.songData.levelId);
LoadingState.loadPlayState(
{