mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Fix deadlock on user reconnect.
Also adds a space before chat messages.
This commit is contained in:
parent
0d56992c22
commit
8312253e77
@ -1685,9 +1685,9 @@ pub const Connection = struct { // MARK: Connection
|
||||
const id = std.mem.readInt(u32, data[1..5], .big);
|
||||
if(self.handShakeState.load(.monotonic) == Protocols.handShake.stepComplete and id == 0) { // Got a new "first" packet from client. So the client tries to reconnect, but we still think it's connected.
|
||||
if(self.user) |user| {
|
||||
user.reinitialize();
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
user.reinitialize();
|
||||
self.reinitialize();
|
||||
} else {
|
||||
std.log.err("Server reconnected?", .{});
|
||||
|
@ -460,7 +460,7 @@ pub fn messageFrom(msg: []const u8, source: *User) void { // MARK: message
|
||||
std.log.info("User \"{s}\" executed command \"{s}\"", .{source.name, msg}); // TODO use color \033[0;32m
|
||||
command.execute(msg[1..], source);
|
||||
} else {
|
||||
const newMessage = std.fmt.allocPrint(main.stackAllocator.allocator, "[{s}§#ffffff]{s}", .{source.name, msg}) catch unreachable;
|
||||
const newMessage = std.fmt.allocPrint(main.stackAllocator.allocator, "[{s}§#ffffff] {s}", .{source.name, msg}) catch unreachable;
|
||||
defer main.stackAllocator.free(newMessage);
|
||||
main.server.mutex.lock();
|
||||
defer main.server.mutex.unlock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user