diff --git a/zig-ecs/src/ecs/registry.zig b/zig-ecs/src/ecs/registry.zig index 8511bcc..94d431b 100644 --- a/zig-ecs/src/ecs/registry.zig +++ b/zig-ecs/src/ecs/registry.zig @@ -411,7 +411,7 @@ pub const Registry = struct { std.debug.assert(@typeInfo(T) != .Pointer); return if (self.contexts.get(utils.typeId(T))) |ptr| - return if (ptr.value > 0) @intToPtr(*T, ptr.value) else null + return if (ptr > 0) @intToPtr(*T, ptr) else null else null; } diff --git a/zig-ecs/src/ecs/type_store.zig b/zig-ecs/src/ecs/type_store.zig index 38d0668..a16704d 100644 --- a/zig-ecs/src/ecs/type_store.zig +++ b/zig-ecs/src/ecs/type_store.zig @@ -29,7 +29,7 @@ pub const TypeStore = struct { } pub fn get(self: *TypeStore, comptime T: type) *T { - if (self.map.getValue(utils.typeId(T))) |bytes| { + if (self.map.get(utils.typeId(T))) |bytes| { return @ptrCast(*T, @alignCast(@alignOf(T), bytes)); } unreachable; @@ -48,7 +48,7 @@ pub const TypeStore = struct { } pub fn remove(self: *TypeStore, comptime T: type) void { - if (self.map.getValue(utils.typeId(T))) |bytes| { + if (self.map.get(utils.typeId(T))) |bytes| { self.allocator.free(bytes); _ = self.map.remove(utils.typeId(T)); } diff --git a/zig-ecs/src/resources/assets.zig b/zig-ecs/src/resources/assets.zig index 3bf0a69..1c729eb 100644 --- a/zig-ecs/src/resources/assets.zig +++ b/zig-ecs/src/resources/assets.zig @@ -13,7 +13,7 @@ pub const Assets = struct { }; } - pub fn deinit(self: Assets) void { + pub fn deinit(self: *Assets) void { var it = self.caches.iterator(); while (it.next()) |ptr| { // HACK: we dont know the Type here but we need to call deinit @@ -24,7 +24,7 @@ pub const Assets = struct { } pub fn get(self: *Assets, comptime AssetT: type) *Cache(AssetT) { - if (self.caches.getValue(utils.typeId(AssetT))) |tid| { + if (self.caches.get(utils.typeId(AssetT))) |tid| { return @intToPtr(*Cache(AssetT), tid); } diff --git a/zig-ecs/src/resources/cache.zig b/zig-ecs/src/resources/cache.zig index f4127c3..6d8c325 100644 --- a/zig-ecs/src/resources/cache.zig +++ b/zig-ecs/src/resources/cache.zig @@ -43,7 +43,7 @@ pub fn Cache(comptime T: type) type { } pub fn load(self: *@This(), id: u32, comptime loader: anytype) @typeInfo(@TypeOf(@field(loader, "load"))).BoundFn.return_type.? { - if (self.resources.getValue(id)) |resource| { + if (self.resources.get(id)) |resource| { return resource; } @@ -72,11 +72,11 @@ pub fn Cache(comptime T: type) type { @call(.{ .modifier = .always_inline }, @field(kv.value, "deinit"), .{}); } } - self.resources.clear(); + self.resources.clearAndFree(); } pub fn size(self: @This()) usize { - return self.resources.size; + return self.resources.items().len; } }; } diff --git a/zig-ecs/src/signals/dispatcher.zig b/zig-ecs/src/signals/dispatcher.zig index bfd5526..1bcdb43 100644 --- a/zig-ecs/src/signals/dispatcher.zig +++ b/zig-ecs/src/signals/dispatcher.zig @@ -14,7 +14,7 @@ pub const Dispatcher = struct { }; } - pub fn deinit(self: Dispatcher) void { + pub fn deinit(self: *Dispatcher) void { var it = self.signals.iterator(); while (it.next()) |ptr| { // HACK: we dont know the Type here but we need to call deinit @@ -27,8 +27,8 @@ pub const Dispatcher = struct { fn assure(self: *Dispatcher, comptime T: type) *Signal(T) { var type_id = utils.typeId(T); - if (self.signals.get(type_id)) |kv| { - return @intToPtr(*Signal(T), kv.value); + if (self.signals.get(type_id)) |value| { + return @intToPtr(*Signal(T), value); } var signal = Signal(T).create(self.allocator);