From b882e81c73728f46e23e1af0643172c24e613c6c Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Sun, 27 Jul 2025 14:48:27 +0200 Subject: [PATCH] Always use explicit direction --- src/gui/gui.zig | 4 ++-- src/gui/windows/chat.zig | 8 ++++---- src/itemdrop.zig | 8 ++++---- src/renderer/mesh_storage.zig | 16 ++++++++-------- src/server/server.zig | 10 +++++----- src/utils.zig | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/gui/gui.zig b/src/gui/gui.zig index b336f9dc..900d89e3 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -58,11 +58,11 @@ const GuiCommandQueue = struct { // MARK: GuiCommandQueue } fn scheduleCommand(command: Command) void { - commands.push(command); + commands.pushBack(command); } fn executeCommands() void { - while(commands.pop()) |command| { + while(commands.popFront()) |command| { switch(command.action) { .open => { executeOpenWindowCommand(command.window); diff --git a/src/gui/windows/chat.zig b/src/gui/windows/chat.zig index 9e85046a..de20bb6c 100644 --- a/src/gui/windows/chat.zig +++ b/src/gui/windows/chat.zig @@ -121,7 +121,7 @@ pub fn deinit() void { label.deinit(); } history.deinit(); - while(messageQueue.pop()) |msg| { + while(messageQueue.popFront()) |msg| { main.globalAllocator.free(msg); } messageHistory.deinit(); @@ -190,7 +190,7 @@ pub fn onClose() void { while(history.popOrNull()) |label| { label.deinit(); } - while(messageQueue.pop()) |msg| { + while(messageQueue.popFront()) |msg| { main.globalAllocator.free(msg); } messageHistory.clear(); @@ -206,7 +206,7 @@ pub fn onClose() void { pub fn update() void { if(!messageQueue.isEmpty()) { const currentTime: i32 = @truncate(std.time.milliTimestamp()); - while(messageQueue.pop()) |msg| { + while(messageQueue.popFront()) |msg| { history.append(Label.init(.{0, 0}, 256, msg, .left)); main.globalAllocator.free(msg); expirationTime.append(currentTime +% messageTimeout); @@ -243,7 +243,7 @@ pub fn render() void { } pub fn addMessage(msg: []const u8) void { - messageQueue.push(main.globalAllocator.dupe(u8, msg)); + messageQueue.pushBack(main.globalAllocator.dupe(u8, msg)); } pub fn sendMessage(_: usize) void { diff --git a/src/itemdrop.zig b/src/itemdrop.zig index cf750a94..678578d4 100644 --- a/src/itemdrop.zig +++ b/src/itemdrop.zig @@ -237,7 +237,7 @@ pub const ItemDropManager = struct { // MARK: ItemDropManager } self.emptyMutex.unlock(); - self.changeQueue.push(.{.add = .{i, drop}}); + self.changeQueue.pushBack(.{.add = .{i, drop}}); } fn addWithIndex(self: *ItemDropManager, i: u16, pos: Vec3d, vel: Vec3d, rot: Vec3f, itemStack: ItemStack, despawnTime: i32, pickupCooldown: i32) void { @@ -269,11 +269,11 @@ pub const ItemDropManager = struct { // MARK: ItemDropManager } self.emptyMutex.unlock(); - self.changeQueue.push(.{.add = .{i, drop}}); + self.changeQueue.pushBack(.{.add = .{i, drop}}); } fn processChanges(self: *ItemDropManager) void { - while(self.changeQueue.pop()) |data| { + while(self.changeQueue.popFront()) |data| { switch(data) { .add => |addData| { self.internalAdd(addData[0], addData[1]); @@ -506,7 +506,7 @@ pub const ClientItemDropManager = struct { // MARK: ClientItemDropManager self.super.emptyMutex.lock(); self.super.isEmpty.set(i); self.super.emptyMutex.unlock(); - self.super.changeQueue.push(.{.remove = i}); + self.super.changeQueue.pushBack(.{.remove = i}); } pub fn loadFrom(self: *ClientItemDropManager, zon: ZonElement) void { diff --git a/src/renderer/mesh_storage.zig b/src/renderer/mesh_storage.zig index e90cd62d..a5595f5e 100644 --- a/src/renderer/mesh_storage.zig +++ b/src/renderer/mesh_storage.zig @@ -110,12 +110,12 @@ pub fn deinit() void { } updatableList.clearAndFree(); - while(mapUpdatableList.pop()) |map| { + while(mapUpdatableList.popFront()) |map| { map.deferredDeinit(); } mapUpdatableList.deinit(); priorityMeshUpdateList.deinit(); - while(blockUpdateList.pop()) |blockUpdate| { + while(blockUpdateList.popFront()) |blockUpdate| { blockUpdate.deinitManaged(main.globalAllocator); } blockUpdateList.deinit(); @@ -745,7 +745,7 @@ pub fn updateMeshes(targetTime: i64) void { // MARK: updateMeshes()= mutex.lock(); defer mutex.unlock(); - while(priorityMeshUpdateList.pop()) |pos| { + while(priorityMeshUpdateList.popFront()) |pos| { const mesh = getMesh(pos) orelse continue; if(!mesh.needsMeshUpdate) { continue; @@ -756,7 +756,7 @@ pub fn updateMeshes(targetTime: i64) void { // MARK: updateMeshes()= mesh.uploadData(); if(std.time.milliTimestamp() >= targetTime) break; // Update at least one mesh. } - while(mapUpdatableList.pop()) |map| { + while(mapUpdatableList.popFront()) |map| { if(!isMapInRenderDistance(map.pos)) { map.deferredDeinit(); } else { @@ -814,7 +814,7 @@ fn batchUpdateBlocks() void { defer regenerateMeshList.deinit(); // First of all process all the block updates: - while(blockUpdateList.pop()) |blockUpdate| { + while(blockUpdateList.popFront()) |blockUpdate| { defer blockUpdate.deinitManaged(main.globalAllocator); const pos = chunk.ChunkPosition{.wx = blockUpdate.x, .wy = blockUpdate.y, .wz = blockUpdate.z, .voxelSize = 1}; if(getMesh(pos)) |mesh| { @@ -839,7 +839,7 @@ pub fn addToUpdateList(mesh: *chunk_meshing.ChunkMesh) void { mutex.lock(); defer mutex.unlock(); if(mesh.finishedMeshing) { - priorityMeshUpdateList.push(mesh.pos); + priorityMeshUpdateList.pushBack(mesh.pos); mesh.needsMeshUpdate = true; } } @@ -910,7 +910,7 @@ pub const MeshGenerationTask = struct { // MARK: MeshGenerationTask // MARK: updaters pub fn updateBlock(update: BlockUpdate) void { - blockUpdateList.push(BlockUpdate.initManaged(main.globalAllocator, update)); + blockUpdateList.pushBack(BlockUpdate.initManaged(main.globalAllocator, update)); } pub fn updateChunkMesh(mesh: *chunk.Chunk) void { @@ -918,7 +918,7 @@ pub fn updateChunkMesh(mesh: *chunk.Chunk) void { } pub fn updateLightMap(map: *LightMap.LightMapFragment) void { - mapUpdatableList.push(map); + mapUpdatableList.pushBack(map); } // MARK: Block breaking animation diff --git a/src/server/server.zig b/src/server/server.zig index b98a76bd..c4bf6685 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -336,7 +336,7 @@ fn init(name: []const u8, singlePlayerPort: ?u16) void { // MARK: init() fn deinit() void { users.clearAndFree(); - while(userDeinitList.pop()) |user| { + while(userDeinitList.popFront()) |user| { user.deinit(); } userDeinitList.deinit(); @@ -390,7 +390,7 @@ fn getInitialEntityList(allocator: main.heap.NeverFailingAllocator) []const u8 { fn update() void { // MARK: update() world.?.update(); - while(userConnectList.pop()) |user| { + while(userConnectList.popFront()) |user| { connectInternal(user); } @@ -429,7 +429,7 @@ fn update() void { // MARK: update() } } - while(userDeinitList.pop()) |user| { + while(userDeinitList.popFront()) |user| { user.decreaseRefCount(); } } @@ -462,7 +462,7 @@ pub fn stop() void { pub fn disconnect(user: *User) void { // MARK: disconnect() if(!user.connected.load(.unordered)) return; removePlayer(user); - userDeinitList.push(user); + userDeinitList.pushBack(user); user.connected.store(false, .unordered); } @@ -497,7 +497,7 @@ pub fn removePlayer(user: *User) void { // MARK: removePlayer() } pub fn connect(user: *User) void { - userConnectList.push(user); + userConnectList.pushBack(user); } pub fn connectInternal(user: *User) void { diff --git a/src/utils.zig b/src/utils.zig index 9a3a61f8..2b171342 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -596,13 +596,13 @@ pub fn ConcurrentQueue(comptime T: type) type { // MARK: ConcurrentQueue self.super.deinit(); } - pub fn push(self: *Self, elem: T) void { + pub fn pushBack(self: *Self, elem: T) void { self.mutex.lock(); defer self.mutex.unlock(); self.super.pushBack(elem); } - pub fn pop(self: *Self) ?T { + pub fn popFront(self: *Self) ?T { self.mutex.lock(); defer self.mutex.unlock(); return self.super.popFront();