From 6fd67ee268558d2c11eadc74ac35fd462095c3b8 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Sat, 24 Dec 2022 02:16:41 +0100 Subject: [PATCH] fixed memory leak --- buildnumber.txt | 2 +- disable-casesensitive.ps1 | 1 + enable-casesensitive.ps1 | 1 + source/funkin/game/PlayState.hx | 15 ++++++++++++--- source/funkin/menus/PauseSubState.hx | 2 ++ source/funkin/system/Conductor.hx | 15 ++++++++++++--- source/funkin/system/FramerateField.hx | 1 + 7 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 disable-casesensitive.ps1 create mode 100644 enable-casesensitive.ps1 diff --git a/buildnumber.txt b/buildnumber.txt index cfc3b26d..e27694a4 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1731 \ No newline at end of file +1739 \ No newline at end of file diff --git a/disable-casesensitive.ps1 b/disable-casesensitive.ps1 new file mode 100644 index 00000000..f4f54139 --- /dev/null +++ b/disable-casesensitive.ps1 @@ -0,0 +1 @@ +(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ disable} \ No newline at end of file diff --git a/enable-casesensitive.ps1 b/enable-casesensitive.ps1 new file mode 100644 index 00000000..db15cb6c --- /dev/null +++ b/enable-casesensitive.ps1 @@ -0,0 +1 @@ +(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ enable} \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index e2536bbc..c697b21e 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -204,10 +204,9 @@ class PlayState extends MusicBeatState override public function create() { instance = this; - - PauseSubState.script = ""; if (FlxG.sound.music != null) FlxG.sound.music.stop(); + PauseSubState.script = ""; (scripts = new ScriptPack("PlayState")).setParent(this); camGame = camera; @@ -215,7 +214,6 @@ class PlayState extends MusicBeatState camHUD.bgColor.alpha = 0; downscroll = Options.downscroll; - // camGame.widescreen = true; persistentUpdate = true; persistentDraw = true; @@ -289,6 +287,17 @@ class PlayState extends MusicBeatState } } + /** + * PRECACHING + */ + + for(content in Paths.getFolderContent('images/game/score/', true, true)) + FlxG.bitmap.add(content); + + /** + * END OF PRECACHING + */ + scripts.load(); scripts.call("create"); diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index 86c2e1be..d7ac5d32 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -152,8 +152,10 @@ class PauseSubState extends MusicBeatSubstate } override function destroy() { + FlxG.cameras.remove(camera, true); pauseScript.call("destroy"); if (pauseMusic != null) pauseMusic.destroy(); + pauseScript.destroy(); super.destroy(); } diff --git a/source/funkin/system/Conductor.hx b/source/funkin/system/Conductor.hx index ed420b9a..f43d8372 100644 --- a/source/funkin/system/Conductor.hx +++ b/source/funkin/system/Conductor.hx @@ -1,5 +1,7 @@ package funkin.system; +import flixel.math.FlxMath; +import openfl.Lib; import flixel.FlxState; import funkin.interfaces.IBeatReceiver; import flixel.FlxG; @@ -71,7 +73,9 @@ class Conductor public static var curBeatFloat:Float = 0; - @:dox(hide) public static var lastSongPos:Float; + @:dox(hide) public static var lastSongPos:Float = 0; + @:dox(hide) public static var lastSongPosTime:Float = 0; + @:dox(hide) public static var speed:Float = 0; @:dox(hide) public static var offset:Float = 0; @:dox(hide) public static var safeZoneOffset:Float = 175; // is calculated in create(), is safeFrames in milliseconds @@ -85,6 +89,7 @@ class Conductor public static function reset() { songPosition = lastSongPos = curBeatFloat = curStepFloat = curBeat = curStep = 0; + speed = 1; bpmChangeMap = []; changeBPM(0); } @@ -126,7 +131,7 @@ class Conductor } public static function init() { - FlxG.signals.preUpdate.add(update); + FlxG.signals.postUpdate.add(update); FlxG.signals.preStateCreate.add(onStateSwitch); reset(); } @@ -140,11 +145,15 @@ class Conductor if (FlxG.sound.music == null || !FlxG.sound.music.playing) return; if (FlxG.state != null && FlxG.state is MusicBeatState && cast(FlxG.state, MusicBeatState).cancelConductorUpdate) return; + + var lastPos = lastSongPos; if (lastSongPos != (lastSongPos = FlxG.sound.music.time)) { // update conductor + var timeUntilUpdate = -(lastSongPosTime - (lastSongPosTime = Lib.getTimer())); + speed = FlxMath.bound(FlxMath.lerp(speed, timeUntilUpdate / (lastSongPos - lastPos), FlxMath.bound(Math.abs(speed - 1), 0, 1)), 0, 2); songPosition = lastSongPos; } else { - songPosition += elapsed * 1000; + songPosition += elapsed * 1000 * speed; } if (bpm > 0) { diff --git a/source/funkin/system/FramerateField.hx b/source/funkin/system/FramerateField.hx index 63cdcce0..078896f4 100644 --- a/source/funkin/system/FramerateField.hx +++ b/source/funkin/system/FramerateField.hx @@ -75,6 +75,7 @@ class FramerateField extends TextField { text.push('=== CONDUCTOR INFO ==='); text.push('Current Song Position: ${Conductor.songPosition} (${Conductor.curBeat} beats - ${Conductor.curStep} steps)'); text.push('Current BPM: ${Conductor.bpm}'); + text.push('Current speed: ${FlxMath.roundDecimal(Conductor.speed, 2)}x'); text.push('=== SYSTEM INFO ==='); text.push('System: ${lime.system.System.platformLabel} ${lime.system.System.platformVersion}'); text.push('Objs in state: ${FlxG.state.members.length}');