Skip to content

Commit

Permalink
fix(SaveGame): check for nullptr in LoadWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Feb 24, 2024
1 parent a6e62ec commit 5dfde14
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ZenKit/SaveGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,16 @@ public bool Save(string path, World world, string worldName)
return Native.ZkSaveGame_save(_handle, path, world.Handle, worldName);
}

public World LoadWorld()
public World? LoadWorld()
{
var handle = Native.ZkSaveGame_loadCurrentWorld(_handle);
return new World(handle);
return handle == UIntPtr.Zero ? null : new World(handle);
}

public World LoadWorld(string name)
public World? LoadWorld(string name)
{
var handle = Native.ZkSaveGame_loadWorld(_handle, name);
return new World(handle);
return handle == UIntPtr.Zero ? null : new World(handle);
}
}
}

0 comments on commit 5dfde14

Please sign in to comment.