From 70283bfcb4fafab66c075d2271bcd419fa331fca Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 10 Jun 2022 16:56:12 -0700 Subject: [PATCH] ecs: zig fmt Signed-off-by: Stephen Gutekanst --- ecs/build.zig | 2 +- ecs/src/entities.zig | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ecs/build.zig b/ecs/build.zig index c28fee4e..6792bb6f 100644 --- a/ecs/build.zig +++ b/ecs/build.zig @@ -15,4 +15,4 @@ pub const pkg = std.build.Pkg{ .name = "ecs", .source = .{ .path = "src/main.zig" }, .dependencies = &[_]std.build.Pkg{}, -}; \ No newline at end of file +}; diff --git a/ecs/src/entities.zig b/ecs/src/entities.zig index ec20f185..3c169bcc 100644 --- a/ecs/src/entities.zig +++ b/ecs/src/entities.zig @@ -222,8 +222,8 @@ pub const ArchetypeStorage = struct { pub fn getRaw(storage: *ArchetypeStorage, row_index: u32, name: []const u8) []u8 { for (storage.columns) |column| { if (!std.mem.eql(u8, column.name, name)) continue; - const start = column.offset+(column.size*row_index); - return storage.block[start..start+(column.size)]; + const start = column.offset + (column.size * row_index); + return storage.block[start .. start + (column.size)]; } @panic("no such component"); } @@ -240,17 +240,17 @@ pub const ArchetypeStorage = struct { }; if (!ok) @panic("setRaw with non-matching column"); } - mem.copy(u8, storage.block[column.offset+(row_index*column.size)..], component); + mem.copy(u8, storage.block[column.offset + (row_index * column.size) ..], component); } /// Swap-removes the specified row with the last row in the table. pub fn remove(storage: *ArchetypeStorage, row_index: u32) void { if (storage.len > 1) { for (storage.columns) |column| { - const dstStart = column.offset+(column.size*row_index); - const dst = storage.block[dstStart..dstStart+(column.size)]; - const srcStart = column.offset+(column.size*(storage.len-1)); - const src = storage.block[srcStart..srcStart+(column.size)]; + const dstStart = column.offset + (column.size * row_index); + const dst = storage.block[dstStart .. dstStart + (column.size)]; + const srcStart = column.offset + (column.size * (storage.len - 1)); + const src = storage.block[srcStart .. srcStart + (column.size)]; std.mem.copy(u8, dst, src); } } @@ -458,7 +458,7 @@ pub const Entities = struct { // A swap removal will be performed, update the entity stored in the last row of the // archetype table to point to the row the entity we are removing is currently located. if (archetype.len > 1) { - const last_row_entity_id = archetype.get(entities.allocator, archetype.len-1, "id", EntityID).?; + const last_row_entity_id = archetype.get(entities.allocator, archetype.len - 1, "id", EntityID).?; try entities.entities.put(entities.allocator, last_row_entity_id, Pointer{ .archetype_index = ptr.archetype_index, .row_index = ptr.row_index, @@ -499,12 +499,12 @@ pub const Entities = struct { // pointer. Refresh it now: archetype = entities.archetypeByID(entity); - const columns = entities.allocator.alloc(Column, archetype.columns.len+1) catch |err| { + const columns = entities.allocator.alloc(Column, archetype.columns.len + 1) catch |err| { assert(entities.archetypes.swapRemove(new_hash)); return err; }; mem.copy(Column, columns, archetype.columns); - columns[columns.len-1] = .{ + columns[columns.len - 1] = .{ .name = name, .typeId = typeId(@TypeOf(component)), .size = @sizeOf(@TypeOf(component)), @@ -608,7 +608,7 @@ pub const Entities = struct { // pointer. Refresh it now: archetype = entities.archetypeByID(entity); - const columns = entities.allocator.alloc(Column, archetype.columns.len-1) catch |err| { + const columns = entities.allocator.alloc(Column, archetype.columns.len - 1) catch |err| { assert(entities.archetypes.swapRemove(new_hash)); return err; };