Skip to content

Commit

Permalink
fix: multiplayer empty ip address join
Browse files Browse the repository at this point in the history
  • Loading branch information
somanshurath committed Dec 4, 2024
1 parent 0a8b9de commit 1461cdd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gui/windows/multiplayer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ fn join(_: usize) void {
ipAddress = "";
}
if(connection) |_connection| {
if (ipAddressEntry.currentString.items.len == 0) {
// TODO: Show error message in the GUI
std.log.err("IP address cannot be empty", .{});
return;
}
_connection.world = &main.game.testWorld;
main.globalAllocator.free(settings.lastUsedIPAddress);
settings.lastUsedIPAddress = main.globalAllocator.dupe(u8, ipAddressEntry.currentString.items);
settings.save();
main.game.world = &main.game.testWorld;
std.log.info("Connecting to world: {s}", .{ipAddressEntry.currentString.items});
main.game.testWorld.init(ipAddressEntry.currentString.items, _connection) catch |err| {
std.log.err("Encountered error while opening world: {s}", .{@errorName(err)});
};
Expand Down

0 comments on commit 1461cdd

Please sign in to comment.