From 11367162d3da0fa799c2e320d9413851c795b11c Mon Sep 17 00:00:00 2001 From: Vinywar123 Date: Sun, 25 Oct 2026 16:26:34 -0700 Subject: [PATCH 1/3] Update protocols.zig --- src/network/protocols.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/protocols.zig b/src/network/protocols.zig index a0b3373700..81cda03d08 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -623,6 +623,9 @@ pub const generic_update = struct { // MARK: generic_update }; pub fn clientReceive(conn: *Connection, reader: *utils.BinaryReader) !void { + const oldContext = main.sync.threadContext; + defer main.sync.threadContext = oldContext; + main.sync.threadContext = .client; switch (try reader.readEnum(UpdateType)) { .gamemode => { main.sync.setGamemode(null, try reader.readEnum(main.game.Gamemode)); From e8bded3bd2706e77391e5017d5f0cb606c3d6fba Mon Sep 17 00:00:00 2001 From: Vinywar123 Date: Mon, 26 Oct 2026 12:06:47 -0700 Subject: [PATCH 2/3] moved to onReceive --- src/network/protocols.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/network/protocols.zig b/src/network/protocols.zig index 81cda03d08..b0af24c238 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -47,6 +47,12 @@ pub fn init() void { // MARK: init() pub fn onReceive(conn: *Connection, protocolIndex: u8, data: []const u8) !void { // MARK: onReceive() if (conn.handShakeState.raw != .complete and protocolIndex != handshake.id) return error.HandshakeIncomplete; + const oldContext = main.sync.threadContext; + defer main.sync.threadContext = oldContext; + main.sync.threadContext = switch (conn.isServerSide()) { + .server => .server, + .client => .client, + }; const protocolReceive = blk: { if (conn.isServerSide()) break :blk serverReceiveList[protocolIndex] orelse return error.Invalid; break :blk clientReceiveList[protocolIndex] orelse return error.Invalid; @@ -623,9 +629,6 @@ pub const generic_update = struct { // MARK: generic_update }; pub fn clientReceive(conn: *Connection, reader: *utils.BinaryReader) !void { - const oldContext = main.sync.threadContext; - defer main.sync.threadContext = oldContext; - main.sync.threadContext = .client; switch (try reader.readEnum(UpdateType)) { .gamemode => { main.sync.setGamemode(null, try reader.readEnum(main.game.Gamemode)); From 22905aef617e93acde50a50f9c2cb5510f25b392 Mon Sep 17 00:00:00 2001 From: Vinywar123 Date: Mon, 26 Oct 2026 12:19:03 -0700 Subject: [PATCH 3/3] Update protocols.zig --- src/network/protocols.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/protocols.zig b/src/network/protocols.zig index b0af24c238..2d9ebc6ddf 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -50,8 +50,8 @@ pub fn onReceive(conn: *Connection, protocolIndex: u8, data: []const u8) !void { const oldContext = main.sync.threadContext; defer main.sync.threadContext = oldContext; main.sync.threadContext = switch (conn.isServerSide()) { - .server => .server, - .client => .client, + true => .server, + false => .client, }; const protocolReceive = blk: { if (conn.isServerSide()) break :blk serverReceiveList[protocolIndex] orelse return error.Invalid;