mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Fix crash when deleting world in the world selection screen.
fixes #486
This commit is contained in:
parent
5340317043
commit
e48f0d2fdb
@ -23,6 +23,8 @@ const padding: f32 = 8;
|
||||
const width: f32 = 128;
|
||||
var buttonNameArena: main.utils.NeverFailingArenaAllocator = undefined;
|
||||
|
||||
var needsUpdate: bool = false;
|
||||
|
||||
pub fn openWorld(name: []const u8) void {
|
||||
std.log.info("Opening world {s}", .{name});
|
||||
main.server.thread = std.Thread.spawn(.{}, main.server.start, .{name}) catch |err| {
|
||||
@ -53,8 +55,7 @@ fn openWorldWrap(namePtr: usize) void { // TODO: Improve this situation. Maybe i
|
||||
|
||||
fn flawedDeleteWorld(name: []const u8) !void {
|
||||
try main.files.deleteDir("saves", name);
|
||||
onClose();
|
||||
onOpen();
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
fn deleteWorld(namePtr: usize) void {
|
||||
@ -92,6 +93,14 @@ fn parseEscapedFolderName(allocator: NeverFailingAllocator, name: []const u8) []
|
||||
return result.toOwnedSlice();
|
||||
}
|
||||
|
||||
pub fn update() void {
|
||||
if(needsUpdate) {
|
||||
needsUpdate = false;
|
||||
onClose();
|
||||
onOpen();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn onOpen() void {
|
||||
buttonNameArena = main.utils.NeverFailingArenaAllocator.init(main.globalAllocator);
|
||||
const list = VerticalList.init(.{padding, 16 + padding}, 300, 8);
|
||||
|
Loading…
x
Reference in New Issue
Block a user