@@ -94,8 +94,8 @@ pub fn tryCreateWorld(worldName: []const u8, worldSettings: Settings) !void {
9494 {
9595 const settings = main .ZonElement .initObject (main .stackAllocator );
9696
97- settings .put ("default_gamemode " , @tagName (worldSettings .defaultGamemode ));
98- settings .put ("cheats " , worldSettings .allowCheats );
97+ settings .put ("defaultGamemode " , @tagName (worldSettings .defaultGamemode ));
98+ settings .put ("allowCheats " , worldSettings .allowCheats );
9999 settings .put ("testingMode" , worldSettings .testingMode );
100100 settings .put ("seed" , worldSettings .seed );
101101
@@ -402,7 +402,7 @@ pub const ChunkManager = struct { // MARK: ChunkManager
402402 }
403403};
404404
405- pub const worldDataVersion : u32 = 3 ;
405+ pub const worldDataVersion : u32 = 4 ;
406406
407407pub const ServerWorld = struct { // MARK: ServerWorld
408408 pub const dayCycle : u31 = 12000 ; // Length of one in-game day in units of 100ms. Midnight is at DAY_CYCLE/2. Sunrise and sunset each take about 1/16 of the day. Currently set to 20 minutes
@@ -532,7 +532,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld
532532 }
533533
534534 pub fn loadWorldConfig (self : * ServerWorld , arena : NeverFailingAllocator , dir : main.files.Dir , worldData : ZonElement ) ! void { // MARK: loadWorldConfig
535- if (worldData .get (u32 , "version" , 0 ) == 2 ) {
535+ if (worldData .get (u32 , "version" , 0 ) == 2 ) { // TODO: #2458
536536 std .log .info ("Migrating old world with world version 2 to version 3" , .{});
537537
538538 const gamerules = try dir .readToZon (arena , "gamerules.zig.zon" );
@@ -555,6 +555,20 @@ pub const ServerWorld = struct { // MARK: ServerWorld
555555 try dir .deleteFile ("generatorSettings.zig.zon" );
556556 }
557557
558+ if (worldData .get (u32 , "version" , 0 ) == 3 ) { // TODO: #2458
559+ // In version 0.1.0 these values were written incorrectly
560+ const settings = worldData .getChild ("settings" );
561+ if (settings .removeChild ("default_gamemode" )) | gamemode | {
562+ settings .put ("defaultGamemode" , gamemode );
563+ }
564+ if (settings .removeChild ("cheats" )) | allowCheats | {
565+ settings .put ("allowCheats" , allowCheats );
566+ }
567+
568+ worldData .put ("version" , 4 );
569+ try dir .writeZon ("world.zig.zon" , worldData );
570+ }
571+
558572 if (worldData .get (u32 , "version" , 0 ) != worldDataVersion ) {
559573 std .log .err ("Cannot read world file version {}. Expected version {}." , .{worldData .get (u32 , "version" , 0 ), worldDataVersion });
560574 return error .OldWorld ;
0 commit comments