various: upgrade Zig version

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia97044bd7d44c776f217f2223e35ae3b6a6a6964
This commit is contained in:
raf 2026-06-11 10:35:06 +03:00
commit bb10fb88f0
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
6 changed files with 45 additions and 35 deletions

View file

@ -29,11 +29,11 @@ pub fn build(b: *std.Build) void {
.link_libc = true, .link_libc = true,
}), }),
}); });
rng_lib.addCSourceFiles(.{ rng_lib.root_module.addCSourceFiles(.{
.files = &[_][]const u8{"libs/rng/rng.c"}, .files = &[_][]const u8{"libs/rng/rng.c"},
.flags = c_flags, .flags = c_flags,
}); });
rng_lib.addIncludePath(b.path("libs/rng")); rng_lib.root_module.addIncludePath(b.path("libs/rng"));
// Map library // Map library
const map_lib = b.addLibrary(.{ const map_lib = b.addLibrary(.{
@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void {
.link_libc = true, .link_libc = true,
}), }),
}); });
map_lib.addCSourceFiles(.{ map_lib.root_module.addCSourceFiles(.{
.files = &[_][]const u8{ .files = &[_][]const u8{
"libs/map/map.c", "libs/map/map.c",
"libs/map/utils.c", "libs/map/utils.c",
@ -52,11 +52,11 @@ pub fn build(b: *std.Build) void {
.flags = c_flags, .flags = c_flags,
}); });
// map.h includes common.h and settings.h which live in src/ // map.h includes common.h and settings.h which live in src/
map_lib.addIncludePath(b.path("src")); map_lib.root_module.addIncludePath(b.path("src"));
// map.c includes rng/rng.h via libs/ root // map.c includes rng/rng.h via libs/ root
map_lib.addIncludePath(b.path("libs")); map_lib.root_module.addIncludePath(b.path("libs"));
// utils.h is co-located with map.c // utils.h is co-located with map.c
map_lib.addIncludePath(b.path("libs/map")); map_lib.root_module.addIncludePath(b.path("libs/map"));
// Tileset library // Tileset library
const tileset_obj = b.addObject(.{ const tileset_obj = b.addObject(.{
@ -67,7 +67,7 @@ pub fn build(b: *std.Build) void {
.link_libc = true, .link_libc = true,
}), }),
}); });
tileset_obj.addCSourceFiles(.{ tileset_obj.root_module.addCSourceFiles(.{
.files = &[_][]const u8{ .files = &[_][]const u8{
"libs/tileset/tileset.c", "libs/tileset/tileset.c",
"libs/tileset/tileset_paint.c", "libs/tileset/tileset_paint.c",
@ -75,10 +75,10 @@ pub fn build(b: *std.Build) void {
.flags = c_flags, .flags = c_flags,
}); });
// tileset.h includes settings.h which lives in src/ // tileset.h includes settings.h which lives in src/
tileset_obj.addIncludePath(b.path("src")); tileset_obj.root_module.addIncludePath(b.path("src"));
// tileset.c includes tileset.h which is co-located // tileset.c includes tileset.h which is co-located
tileset_obj.addIncludePath(b.path("libs/tileset")); tileset_obj.root_module.addIncludePath(b.path("libs/tileset"));
tileset_obj.linkSystemLibrary("raylib"); tileset_obj.root_module.linkSystemLibrary("raylib", .{});
// Zig combat library. This must be compiled as an object and linked // Zig combat library. This must be compiled as an object and linked
// directly to bypassing the archive step, or it yields a corrupt // directly to bypassing the archive step, or it yields a corrupt
@ -93,8 +93,8 @@ pub fn build(b: *std.Build) void {
}), }),
}); });
// common.h and settings.h live in src/; rng.h exposed bare from libs/rng // common.h and settings.h live in src/; rng.h exposed bare from libs/rng
combat_obj.addIncludePath(b.path("src")); combat_obj.root_module.addIncludePath(b.path("src"));
combat_obj.addIncludePath(b.path("libs/rng")); combat_obj.root_module.addIncludePath(b.path("libs/rng"));
// C sources remaining in src/ // C sources remaining in src/
const c_sources = [_][]const u8{ const c_sources = [_][]const u8{
@ -118,24 +118,24 @@ pub fn build(b: *std.Build) void {
}), }),
}); });
exe.addCSourceFiles(.{ exe.root_module.addCSourceFiles(.{
.files = &c_sources, .files = &c_sources,
.flags = c_flags, .flags = c_flags,
}); });
// src/ for own headers; libs/ so "rng/rng.h" and "map/map.h" resolve // src/ for own headers; libs/ so "rng/rng.h" and "map/map.h" resolve
exe.addIncludePath(b.path("src")); exe.root_module.addIncludePath(b.path("src"));
exe.addIncludePath(b.path("libs")); exe.root_module.addIncludePath(b.path("libs"));
exe.linkLibrary(rng_lib); exe.root_module.linkLibrary(rng_lib);
exe.linkLibrary(map_lib); exe.root_module.linkLibrary(map_lib);
exe.addObject(tileset_obj); exe.root_module.addObject(tileset_obj);
exe.addObject(combat_obj); exe.root_module.addObject(combat_obj);
exe.linkSystemLibrary("raylib"); exe.root_module.linkSystemLibrary("raylib", .{});
exe.linkSystemLibrary("m"); exe.root_module.linkSystemLibrary("m", .{});
exe.linkSystemLibrary("pthread"); exe.root_module.linkSystemLibrary("pthread", .{});
exe.linkSystemLibrary("dl"); exe.root_module.linkSystemLibrary("dl", .{});
exe.linkSystemLibrary("rt"); exe.root_module.linkSystemLibrary("rt", .{});
b.installArtifact(exe); b.installArtifact(exe);

View file

@ -28,7 +28,7 @@
// Tracks the earliest Zig version that the package considers to be a // Tracks the earliest Zig version that the package considers to be a
// supported use case. // supported use case.
.minimum_zig_version = "0.15.2", .minimum_zig_version = "0.16.0",
// This field is optional. // This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`. // Each dependency must either provide a `url` and `hash`, or a `path`.

View file

@ -28,7 +28,7 @@ to be viable. For a semi-complete list of things that need to be done, see the
Rogged is built on a relatively simple stack. It uses C99 for the main game Rogged is built on a relatively simple stack. It uses C99 for the main game
logic, and Zig for the combat library. Besides `raylib` and `pkg-config`, you logic, and Zig for the combat library. Besides `raylib` and `pkg-config`, you
only need the core Zig tooling. For now the required Zig version is 0.15.2, but only need the core Zig tooling. For now the required Zig version is 0.16.0, but
this might change in the future. Additionally, you will need `clang-format` and this might change in the future. Additionally, you will need `clang-format` and
`just` for common development tasks in the case you plan to contribute. For `just` for common development tasks in the case you plan to contribute. For
building, Zig is enough. building, Zig is enough.
@ -53,7 +53,7 @@ $ just dev
### Manual Build ### Manual Build
If you are allergic to good tooling and would rather use your system Zig, you If you are allergic to good tooling and would rather use your system Zig, you
may simply invoke `zig build` after acquiring Zig 0.15.2. may simply invoke `zig build` after acquiring Zig 0.16.0.
```sh ```sh
# Full build # Full build

View file

@ -101,18 +101,18 @@ fn compact(effects: [*c]c.StatusEffect, count: [*c]c_int) void {
count[0] = @intCast(write); count[0] = @intCast(write);
} }
fn tickOne(eff: *c.StatusEffect, hp: *c_int) c_int { fn tickOne(eff: [*c]c.StatusEffect, hp: [*c]c_int) c_int {
if (eff.duration <= 0) return 0; if (eff[0].duration <= 0) return 0;
var dmg: c_int = 0; var dmg: c_int = 0;
switch (eff.type) { switch (eff[0].type) {
c.EFFECT_POISON, c.EFFECT_BLEED, c.EFFECT_BURN => { c.EFFECT_POISON, c.EFFECT_BLEED, c.EFFECT_BURN => {
dmg = eff.intensity; dmg = eff[0].intensity;
hp.* -= dmg; hp[0] -= dmg;
}, },
else => {}, else => {},
} }
eff.duration -= 1; eff[0].duration -= 1;
return dmg; return dmg;
} }

View file

@ -20,6 +20,7 @@ stdenv.mkDerivation {
(s + /libs) (s + /libs)
(s + /src) (s + /src)
(s + /build.zig) (s + /build.zig)
(s + /build.zig.zon)
]; ];
}; };

View file

@ -240,6 +240,11 @@ void render_map(const Map *map, const Tileset *tileset) {
Color stairs_color = color_lerp((Color){85, 80, 70, 255}, (Color){180, 160, 100, 255}, light_factor); Color stairs_color = color_lerp((Color){85, 80, 70, 255}, (Color){180, 160, 100, 255}, light_factor);
Color door_color = color_lerp((Color){38, 34, 30, 255}, (Color){120, 92, 58, 255}, light_factor); Color door_color = color_lerp((Color){38, 34, 30, 255}, (Color){120, 92, 58, 255}, light_factor);
Color door_handle_color = color_lerp((Color){42, 38, 32, 255}, (Color){145, 122, 82, 255}, light_factor); Color door_handle_color = color_lerp((Color){42, 38, 32, 255}, (Color){145, 122, 82, 255}, light_factor);
int is_currently_lit = brightness > 0;
if (is_door && !is_currently_lit) {
door_color = (Color){30, 27, 24, 255};
door_handle_color = (Color){34, 31, 27, 255};
}
switch (map->tiles[y][x]) { switch (map->tiles[y][x]) {
case TILE_WALL: case TILE_WALL:
@ -299,11 +304,13 @@ void render_map(const Map *map, const Tileset *tileset) {
int open_x = swing_to_left ? x * TILE_SIZE + 1 : x * TILE_SIZE + 13; int open_x = swing_to_left ? x * TILE_SIZE + 1 : x * TILE_SIZE + 13;
int px = (int)(closed_x + (open_x - closed_x) * t); int px = (int)(closed_x + (open_x - closed_x) * t);
int alpha = (int)(255 * (1.0f - t * 0.45f)); int alpha = (int)(255 * (1.0f - t * 0.45f));
if (!is_currently_lit)
alpha = (int)(alpha * 0.55f);
int width = (int)(2 + (1 - t)); // 2px closed, 1px open int width = (int)(2 + (1 - t)); // 2px closed, 1px open
Color panel_color = door_color; Color panel_color = door_color;
panel_color.a = alpha; panel_color.a = alpha;
DrawRectangle(px, y * TILE_SIZE + 1, width, TILE_SIZE - 2, panel_color); DrawRectangle(px, y * TILE_SIZE + 1, width, TILE_SIZE - 2, panel_color);
if (t < 0.5f && light_factor > 0.05f) { if (t < 0.5f && is_currently_lit) {
int hx = px + (swing_to_left ? -1 : width + 1); int hx = px + (swing_to_left ? -1 : width + 1);
Color handle_color = door_handle_color; Color handle_color = door_handle_color;
handle_color.a = alpha; handle_color.a = alpha;
@ -324,11 +331,13 @@ void render_map(const Map *map, const Tileset *tileset) {
int open_y = swing_up ? y * TILE_SIZE + 1 : y * TILE_SIZE + 13; int open_y = swing_up ? y * TILE_SIZE + 1 : y * TILE_SIZE + 13;
int py = (int)(closed_y + (open_y - closed_y) * t); int py = (int)(closed_y + (open_y - closed_y) * t);
int alpha = (int)(255 * (1.0f - t * 0.45f)); int alpha = (int)(255 * (1.0f - t * 0.45f));
if (!is_currently_lit)
alpha = (int)(alpha * 0.55f);
int height = (int)(2 + (1 - t)); // 2px closed, 1px open int height = (int)(2 + (1 - t)); // 2px closed, 1px open
Color panel_color = door_color; Color panel_color = door_color;
panel_color.a = alpha; panel_color.a = alpha;
DrawRectangle(x * TILE_SIZE + 1, py, TILE_SIZE - 2, height, panel_color); DrawRectangle(x * TILE_SIZE + 1, py, TILE_SIZE - 2, height, panel_color);
if (t < 0.5f && light_factor > 0.05f) { if (t < 0.5f && is_currently_lit) {
int hy = py + (swing_up ? -1 : height + 1); int hy = py + (swing_up ? -1 : height + 1);
Color handle_color = door_handle_color; Color handle_color = door_handle_color;
handle_color.a = alpha; handle_color.a = alpha;