From 410cfe972d6df9de4d4d128375cf8380c4f06d92 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:28:01 +0200 Subject: [PATCH] fix: fix the user song offsets being applied incorrectly --- source/funkin/Conductor.hx | 2 +- source/funkin/play/PlayState.hx | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index ff72b1e125..803b9e1b36 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -413,7 +413,7 @@ class Conductor } // Take into account instrumental and file format song offsets. - songPos += applyOffsets ? (instrumentalOffset + formatOffset + audioVisualOffset) : 0; + songPos += applyOffsets ? (combinedOffset) : 0; var oldMeasure:Float = this.currentMeasure; var oldBeat:Float = this.currentBeat; diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 14b9429d76..d28ae6535a 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1457,11 +1457,34 @@ class PlayState extends MusicBeatSubState if (FlxG.sound.music != null) { var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); + var playerVoicesError:Float = 0; + var opponentVoicesError:Float = 0; - if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(vocals.checkSyncError(correctSync)) > 5)) + if (vocals != null) + { + @:privateAccess // todo: maybe make the groups public :thinking: + { + vocals.playerVoices.forEachAlive(function(voice:FunkinSound) { + var currentRawVoiceTime:Float = voice.time + vocals.playerVoicesOffset; + if (Math.abs(currentRawVoiceTime - correctSync) > Math.abs(playerVoicesError)) playerVoicesError = currentRawVoiceTime - correctSync; + }); + + vocals.opponentVoices.forEachAlive(function(voice:FunkinSound) { + var currentRawVoiceTime:Float = voice.time + vocals.opponentVoicesOffset; + if (Math.abs(currentRawVoiceTime - correctSync) > Math.abs(opponentVoicesError)) opponentVoicesError = currentRawVoiceTime - correctSync; + }); + } + } + + if (!startingSong + && (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(playerVoicesError) > 5 || Math.abs(opponentVoicesError) > 5)) { trace("VOCALS NEED RESYNC"); - if (vocals != null) trace(vocals.checkSyncError(correctSync)); + if (vocals != null) + { + trace(playerVoicesError); + trace(opponentVoicesError); + } trace(FlxG.sound.music.time); trace(correctSync); resyncVocals();