@@ -51,16 +51,21 @@ pub fn cubyzDirStr() []const u8 {
5151}
5252
5353fn flawedInit () ! void {
54+ if (main .settings .launchConfig .cubyzDir .len != 0 ) {
55+ cubyzDir_ = try std .fs .cwd ().makeOpenPath (main .settings .launchConfig .cubyzDir , .{});
56+ cubyzDirStr_ = main .globalAllocator .dupe (u8 , main .settings .launchConfig .cubyzDir );
57+ return ;
58+ }
5459 const homePath = try std .process .getEnvVarOwned (main .stackAllocator .allocator , if (builtin .os .tag == .windows ) "USERPROFILE" else "HOME" );
5560 defer main .stackAllocator .free (homePath );
5661 var homeDir = try std .fs .openDirAbsolute (homePath , .{});
5762 defer homeDir .close ();
5863 if (builtin .os .tag == .windows ) {
5964 cubyzDir_ = try homeDir .makeOpenPath ("Saved Games/Cubyz" , .{});
60- cubyzDirStr_ = std .mem .concat (main .stackAllocator .allocator , u8 , &.{homePath , "/Saved Games/Cubyz" }) catch unreachable ;
65+ cubyzDirStr_ = std .mem .concat (main .globalAllocator .allocator , u8 , &.{homePath , "/Saved Games/Cubyz" }) catch unreachable ;
6166 } else {
6267 cubyzDir_ = try homeDir .makeOpenPath (".cubyz" , .{});
63- cubyzDirStr_ = std .mem .concat (main .stackAllocator .allocator , u8 , &.{homePath , "/.cubyz" }) catch unreachable ;
68+ cubyzDirStr_ = std .mem .concat (main .globalAllocator .allocator , u8 , &.{homePath , "/.cubyz" }) catch unreachable ;
6469 }
6570}
6671
@@ -75,7 +80,7 @@ pub fn deinit() void {
7580 cubyzDir_ .? .close ();
7681 }
7782 if (cubyzDirStr_ .ptr != "." .ptr ) {
78- main .stackAllocator .free (cubyzDirStr_ );
83+ main .globalAllocator .free (cubyzDirStr_ );
7984 }
8085}
8186
0 commit comments