From a4771d9340875c698f844c79e148af425e22f82d Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Fri, 29 Dec 2023 15:06:59 +0100 Subject: [PATCH] Hopefully fixed gpu images crash --- .../backend/system/OptimizedBitmapData.hx | 18 ++++++++++-------- source/funkin/game/PlayState.hx | 2 +- source/funkin/game/Stage.hx | 7 ++++--- source/funkin/game/Strum.hx | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/source/funkin/backend/system/OptimizedBitmapData.hx b/source/funkin/backend/system/OptimizedBitmapData.hx index ce494287..d79f6ad1 100644 --- a/source/funkin/backend/system/OptimizedBitmapData.hx +++ b/source/funkin/backend/system/OptimizedBitmapData.hx @@ -29,16 +29,18 @@ class OptimizedBitmapData extends BitmapData { __isValid = true; readable = true; - lock(); - getTexture(FlxG.stage.context3D); - getSurface(); + if(FlxG.stage.context3D != null) { + lock(); + getTexture(FlxG.stage.context3D); + getSurface(); - readable = true; - this.image = null; + readable = true; + this.image = null; - // @:privateAccess - // if (FlxG.bitmap.__doNotDelete) - // MemoryUtil.clearMinor(); + // @:privateAccess + // if (FlxG.bitmap.__doNotDelete) + // MemoryUtil.clearMinor(); + } } #end } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 790ef211..8a6d7d6d 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -681,7 +681,7 @@ class PlayState extends MusicBeatState MusicBeatState.skipTransIn = true; camFollow.setPosition(smoothTransitionData.camFollowX, smoothTransitionData.camFollowY); } else { - FlxG.camera.focusOn(camFollow.getPosition()); + FlxG.camera.focusOn(camFollow.getPosition(FlxPoint.weak())); } smoothTransitionData = null; diff --git a/source/funkin/game/Stage.hx b/source/funkin/game/Stage.hx index 21917ece..099a86a8 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -20,6 +20,8 @@ class Stage extends FlxBasic implements IBeatReceiver { public var state:FlxState; public var characterPoses:Map = []; + private var spritesParentFolder = ""; + public function getSprite(name:String) { return stageSprites[name]; } @@ -45,7 +47,6 @@ class Stage extends FlxBasic implements IBeatReceiver { } if (stageXML != null) { - var spritesParentFolder = ""; if (PlayState.instance != null) { if (stageXML.has.zoom) { var parsed:Null = Std.parseFloat(stageXML.att.zoom); @@ -55,7 +56,7 @@ class Stage extends FlxBasic implements IBeatReceiver { } if (stageXML.has.folder) { spritesParentFolder = stageXML.att.folder; - if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/"; + if (!spritesParentFolder.endsWith("/")) spritesParentFolder += "/"; } var elems = []; @@ -246,7 +247,7 @@ class Stage extends FlxBasic implements IBeatReceiver { var file:String = Path.withoutDirectory(Path.withoutExtension(path)); if (!list.contains(file)) list.push(file); } - + return list; } } diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index 0b3ca8ee..e2b6ccd0 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -160,6 +160,6 @@ class Strum extends FlxSprite { centerOrigin(); } public function getAnim() { - return animation.curAnim == null ? null : animation.curAnim.name; + return animation.name; } } \ No newline at end of file