Always use explicit direction

This commit is contained in:
IntegratedQuantum 2025-07-27 14:48:27 +02:00
parent be9069c8df
commit b882e81c73
6 changed files with 25 additions and 25 deletions

View File

@ -58,11 +58,11 @@ const GuiCommandQueue = struct { // MARK: GuiCommandQueue
} }
fn scheduleCommand(command: Command) void { fn scheduleCommand(command: Command) void {
commands.push(command); commands.pushBack(command);
} }
fn executeCommands() void { fn executeCommands() void {
while(commands.pop()) |command| { while(commands.popFront()) |command| {
switch(command.action) { switch(command.action) {
.open => { .open => {
executeOpenWindowCommand(command.window); executeOpenWindowCommand(command.window);

View File

@ -121,7 +121,7 @@ pub fn deinit() void {
label.deinit(); label.deinit();
} }
history.deinit(); history.deinit();
while(messageQueue.pop()) |msg| { while(messageQueue.popFront()) |msg| {
main.globalAllocator.free(msg); main.globalAllocator.free(msg);
} }
messageHistory.deinit(); messageHistory.deinit();
@ -190,7 +190,7 @@ pub fn onClose() void {
while(history.popOrNull()) |label| { while(history.popOrNull()) |label| {
label.deinit(); label.deinit();
} }
while(messageQueue.pop()) |msg| { while(messageQueue.popFront()) |msg| {
main.globalAllocator.free(msg); main.globalAllocator.free(msg);
} }
messageHistory.clear(); messageHistory.clear();
@ -206,7 +206,7 @@ pub fn onClose() void {
pub fn update() void { pub fn update() void {
if(!messageQueue.isEmpty()) { if(!messageQueue.isEmpty()) {
const currentTime: i32 = @truncate(std.time.milliTimestamp()); const currentTime: i32 = @truncate(std.time.milliTimestamp());
while(messageQueue.pop()) |msg| { while(messageQueue.popFront()) |msg| {
history.append(Label.init(.{0, 0}, 256, msg, .left)); history.append(Label.init(.{0, 0}, 256, msg, .left));
main.globalAllocator.free(msg); main.globalAllocator.free(msg);
expirationTime.append(currentTime +% messageTimeout); expirationTime.append(currentTime +% messageTimeout);
@ -243,7 +243,7 @@ pub fn render() void {
} }
pub fn addMessage(msg: []const u8) 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 { pub fn sendMessage(_: usize) void {

View File

@ -237,7 +237,7 @@ pub const ItemDropManager = struct { // MARK: ItemDropManager
} }
self.emptyMutex.unlock(); 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 { 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.emptyMutex.unlock();
self.changeQueue.push(.{.add = .{i, drop}}); self.changeQueue.pushBack(.{.add = .{i, drop}});
} }
fn processChanges(self: *ItemDropManager) void { fn processChanges(self: *ItemDropManager) void {
while(self.changeQueue.pop()) |data| { while(self.changeQueue.popFront()) |data| {
switch(data) { switch(data) {
.add => |addData| { .add => |addData| {
self.internalAdd(addData[0], addData[1]); self.internalAdd(addData[0], addData[1]);
@ -506,7 +506,7 @@ pub const ClientItemDropManager = struct { // MARK: ClientItemDropManager
self.super.emptyMutex.lock(); self.super.emptyMutex.lock();
self.super.isEmpty.set(i); self.super.isEmpty.set(i);
self.super.emptyMutex.unlock(); self.super.emptyMutex.unlock();
self.super.changeQueue.push(.{.remove = i}); self.super.changeQueue.pushBack(.{.remove = i});
} }
pub fn loadFrom(self: *ClientItemDropManager, zon: ZonElement) void { pub fn loadFrom(self: *ClientItemDropManager, zon: ZonElement) void {

View File

@ -110,12 +110,12 @@ pub fn deinit() void {
} }
updatableList.clearAndFree(); updatableList.clearAndFree();
while(mapUpdatableList.pop()) |map| { while(mapUpdatableList.popFront()) |map| {
map.deferredDeinit(); map.deferredDeinit();
} }
mapUpdatableList.deinit(); mapUpdatableList.deinit();
priorityMeshUpdateList.deinit(); priorityMeshUpdateList.deinit();
while(blockUpdateList.pop()) |blockUpdate| { while(blockUpdateList.popFront()) |blockUpdate| {
blockUpdate.deinitManaged(main.globalAllocator); blockUpdate.deinitManaged(main.globalAllocator);
} }
blockUpdateList.deinit(); blockUpdateList.deinit();
@ -745,7 +745,7 @@ pub fn updateMeshes(targetTime: i64) void { // MARK: updateMeshes()=
mutex.lock(); mutex.lock();
defer mutex.unlock(); defer mutex.unlock();
while(priorityMeshUpdateList.pop()) |pos| { while(priorityMeshUpdateList.popFront()) |pos| {
const mesh = getMesh(pos) orelse continue; const mesh = getMesh(pos) orelse continue;
if(!mesh.needsMeshUpdate) { if(!mesh.needsMeshUpdate) {
continue; continue;
@ -756,7 +756,7 @@ pub fn updateMeshes(targetTime: i64) void { // MARK: updateMeshes()=
mesh.uploadData(); mesh.uploadData();
if(std.time.milliTimestamp() >= targetTime) break; // Update at least one mesh. if(std.time.milliTimestamp() >= targetTime) break; // Update at least one mesh.
} }
while(mapUpdatableList.pop()) |map| { while(mapUpdatableList.popFront()) |map| {
if(!isMapInRenderDistance(map.pos)) { if(!isMapInRenderDistance(map.pos)) {
map.deferredDeinit(); map.deferredDeinit();
} else { } else {
@ -814,7 +814,7 @@ fn batchUpdateBlocks() void {
defer regenerateMeshList.deinit(); defer regenerateMeshList.deinit();
// First of all process all the block updates: // First of all process all the block updates:
while(blockUpdateList.pop()) |blockUpdate| { while(blockUpdateList.popFront()) |blockUpdate| {
defer blockUpdate.deinitManaged(main.globalAllocator); defer blockUpdate.deinitManaged(main.globalAllocator);
const pos = chunk.ChunkPosition{.wx = blockUpdate.x, .wy = blockUpdate.y, .wz = blockUpdate.z, .voxelSize = 1}; const pos = chunk.ChunkPosition{.wx = blockUpdate.x, .wy = blockUpdate.y, .wz = blockUpdate.z, .voxelSize = 1};
if(getMesh(pos)) |mesh| { if(getMesh(pos)) |mesh| {
@ -839,7 +839,7 @@ pub fn addToUpdateList(mesh: *chunk_meshing.ChunkMesh) void {
mutex.lock(); mutex.lock();
defer mutex.unlock(); defer mutex.unlock();
if(mesh.finishedMeshing) { if(mesh.finishedMeshing) {
priorityMeshUpdateList.push(mesh.pos); priorityMeshUpdateList.pushBack(mesh.pos);
mesh.needsMeshUpdate = true; mesh.needsMeshUpdate = true;
} }
} }
@ -910,7 +910,7 @@ pub const MeshGenerationTask = struct { // MARK: MeshGenerationTask
// MARK: updaters // MARK: updaters
pub fn updateBlock(update: BlockUpdate) void { 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 { 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 { pub fn updateLightMap(map: *LightMap.LightMapFragment) void {
mapUpdatableList.push(map); mapUpdatableList.pushBack(map);
} }
// MARK: Block breaking animation // MARK: Block breaking animation

View File

@ -336,7 +336,7 @@ fn init(name: []const u8, singlePlayerPort: ?u16) void { // MARK: init()
fn deinit() void { fn deinit() void {
users.clearAndFree(); users.clearAndFree();
while(userDeinitList.pop()) |user| { while(userDeinitList.popFront()) |user| {
user.deinit(); user.deinit();
} }
userDeinitList.deinit(); userDeinitList.deinit();
@ -390,7 +390,7 @@ fn getInitialEntityList(allocator: main.heap.NeverFailingAllocator) []const u8 {
fn update() void { // MARK: update() fn update() void { // MARK: update()
world.?.update(); world.?.update();
while(userConnectList.pop()) |user| { while(userConnectList.popFront()) |user| {
connectInternal(user); connectInternal(user);
} }
@ -429,7 +429,7 @@ fn update() void { // MARK: update()
} }
} }
while(userDeinitList.pop()) |user| { while(userDeinitList.popFront()) |user| {
user.decreaseRefCount(); user.decreaseRefCount();
} }
} }
@ -462,7 +462,7 @@ pub fn stop() void {
pub fn disconnect(user: *User) void { // MARK: disconnect() pub fn disconnect(user: *User) void { // MARK: disconnect()
if(!user.connected.load(.unordered)) return; if(!user.connected.load(.unordered)) return;
removePlayer(user); removePlayer(user);
userDeinitList.push(user); userDeinitList.pushBack(user);
user.connected.store(false, .unordered); user.connected.store(false, .unordered);
} }
@ -497,7 +497,7 @@ pub fn removePlayer(user: *User) void { // MARK: removePlayer()
} }
pub fn connect(user: *User) void { pub fn connect(user: *User) void {
userConnectList.push(user); userConnectList.pushBack(user);
} }
pub fn connectInternal(user: *User) void { pub fn connectInternal(user: *User) void {

View File

@ -596,13 +596,13 @@ pub fn ConcurrentQueue(comptime T: type) type { // MARK: ConcurrentQueue
self.super.deinit(); self.super.deinit();
} }
pub fn push(self: *Self, elem: T) void { pub fn pushBack(self: *Self, elem: T) void {
self.mutex.lock(); self.mutex.lock();
defer self.mutex.unlock(); defer self.mutex.unlock();
self.super.pushBack(elem); self.super.pushBack(elem);
} }
pub fn pop(self: *Self) ?T { pub fn popFront(self: *Self) ?T {
self.mutex.lock(); self.mutex.lock();
defer self.mutex.unlock(); defer self.mutex.unlock();
return self.super.popFront(); return self.super.popFront();