diff --git a/source/funkin/backend/system/CommandLineHandler.hx b/source/funkin/backend/system/CommandLineHandler.hx index 4050b049..3690b6a2 100644 --- a/source/funkin/backend/system/CommandLineHandler.hx +++ b/source/funkin/backend/system/CommandLineHandler.hx @@ -19,6 +19,7 @@ class CommandLineHandler { #end Sys.println("-nocolor | Disables colors in the terminal"); Sys.println("-nogpubitmap | Forces GPU only bitmaps off"); + Sys.println("-nocwdfix | Turns off automatic working directory fix"); Sys.exit(0); #if MOD_SUPPORT case "-m" | "-mod" | "-currentmod": @@ -59,6 +60,8 @@ class CommandLineHandler { Main.noTerminalColor = true; case "-nogpubitmap": Main.forceGPUOnlyBitmapsOff = true; + case "-nocwdfix": + Main.noCwdFix = true; case "-livereload": // do nothing default: diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index cad2266e..e1f22794 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -204,4 +204,13 @@ class Main extends Sprite MemoryUtil.clearMajor(); } + + public static var noCwdFix:Bool = false; + public static function fixWorkingDirectory() { + #if windows + if (!noCwdFix && !sys.FileSystem.exists('manifest/default.json')) { + Sys.setCwd(haxe.io.Path.directory(Sys.programPath())); + } + #end + } } diff --git a/source/lime/system/System.hx b/source/lime/system/System.hx index 34599615..59b71a83 100644 --- a/source/lime/system/System.hx +++ b/source/lime/system/System.hx @@ -536,6 +536,7 @@ class System #if (sys && !macro) funkin.backend.utils.NativeAPI.registerAsDPICompatible(); funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args()); + funkin.backend.system.Main.fixWorkingDirectory(); #end if (__applicationEntryPoint == null)