Conversation
|
I ended up refactoring the changes from #2136 because they implemented something in save_creation.zig that isn't gui dependent but they made it gui dependent. It's possible the user can enter a seed in the launchConfig, too. So I moved I can make this a separate PR if desired. But, I didn't see why I should hardcode a method of obtaining the seed in headless as a stopgap. |
IntegratedQuantum
left a comment
There was a problem hiding this comment.
also you got more conflicts
|
ok this one should be ready to go again EDIT: Nevermind... Presets. My brain is too melted to figure it out tonight. |
|
Okay! now it's done! I'm really not sure how I feel about having added |
|
Maybe we should consider just removing the "no seed" check. After all this is only something that will break when the player manually goes into the file and removes the seed. |
I'd agree with that. I think the code that called |
|
I've changed We could instead give it a new seed to work with, but I think it makes more sense to try to avoid potential corruption. I also deduplicated the code used in autoEnterWorld on the client and headless for the server. |
src/server/world.zig
Outdated
| pub fn exists(worldPath: []const u8) !bool { | ||
| const saveDirectory = std.fs.path.join(main.stackAllocator.allocator, &.{"saves", worldPath, "world.zig.zon"}) catch unreachable; | ||
| defer main.stackAllocator.free(saveDirectory); | ||
| files.cubyzDir().dir.access(saveDirectory, .{}) catch |err| { |
There was a problem hiding this comment.
Actually you can use cubyzDir().hasFile().
There was a problem hiding this comment.
I can do that, but we lose out on providing the user an error, since we don't log it in hasFile or hasDir.
There was a problem hiding this comment.
For example if there's a filesystem access error, rather than just the file simply not existing, hasDir or hasFile would tell the game to create the world over again. That's potentially dangerous when there's a filesystem issue preventing access, even if it's transient. Because now we'll create a world overtop of an existing one if the issue is resolved between that check and tryCreateWorld starting to write files.
There was a problem hiding this comment.
Yeah, it be reasonable to adjust hasFile and hasDir to return an error.
src/main.zig
Outdated
| else | ||
| null; | ||
|
|
||
| const worldExists: ?bool = if (headless or settings.launchConfig.autoEnterWorld.len > 0) server.world_zig.exists(settings.launchConfig.autoEnterWorld) catch |err| { |
There was a problem hiding this comment.
Doesn't need to be a variable, instead it should be handled together with the block above, by printing an error and returning.
There was a problem hiding this comment.
Can't handle any errors if I use hasDir or hasFile as they currently exist.
Refactored chooseSeed to be part of the world settings.
Fixes #2250
Allows for creating a world headlessly.