Skip to content

Commit

Permalink
Update to Zig 0.12.0-dev.1769+bf5ab5451
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Dec 1, 2023
1 parent c39dd1d commit 40479cd
Show file tree
Hide file tree
Showing 23 changed files with 242 additions and 231 deletions.
8 changes: 4 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ pub fn build(b: *std.Build) !void {
//SDL

{ //wgpu
var wgpu_from_source = b.option(bool, "wgpu_from_source", "Compile WGPU from source") orelse false;
const wgpu_from_source = b.option(bool, "wgpu_from_source", "Compile WGPU from source") orelse false;

if (wgpu_from_source) {
var wgpu_lib = try wgpu.create_wgpu(b, target, optimize);
const wgpu_lib = try wgpu.create_wgpu(b, target, optimize);

if (target.getOsTag() == .windows) {
@panic("TODO"); //we need to force dynamic linking here.
Expand All @@ -110,7 +110,7 @@ pub fn build(b: *std.Build) !void {
try wgpu_bin_path.append('-');
try wgpu_bin_path.appendSlice(@tagName(target.getCpuArch()));

var wgpu_bin_path_slice = try wgpu_bin_path.toOwnedSlice();
const wgpu_bin_path_slice = try wgpu_bin_path.toOwnedSlice();

exe.addLibraryPath(.{ .path = wgpu_bin_path_slice });
exe.linkSystemLibrary("wgpu_native");
Expand Down Expand Up @@ -154,7 +154,7 @@ pub fn build(b: *std.Build) !void {
//zigimg

{ //iconv
var iconv_lib = iconv.createIconv(b, target, optimize);
const iconv_lib = iconv.createIconv(b, target, optimize);

exe.linkLibrary(iconv_lib);

Expand Down
8 changes: 4 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
.version = "0.0.0",
.dependencies = .{
.SDL2 = .{
.url = "https://github.com/Beyley/SDL/archive/0a6995fbf53a00e181ddac434eaab3dd48ce1846.tar.gz",
.hash = "122076ecd1f0ff2720fa7011af7174b2b463989ecd0a3422e186c9b29b370e165da5",
.url = "https://github.com/Beyley/SDL/archive/f254788cd768adac006a25d7f1fe1e726596d9fd.tar.gz",
.hash = "1220f430383c1d7c198901c99dcd0b10cce8b3a34e77e60026f4c55ecf548e6d1ecc",
},
.zigimg = .{
.url = "https://github.com/zigimg/zigimg/archive/368658aa6b4d22cd532f2785d11f75b2ec2b490c.tar.gz",
.hash = "12201a74c6aa44832f8eac3e4a0e92e7bb7f3d6a12777f517fd470d7f6643cdc33fc",
.url = "https://github.com/zigimg/zigimg/archive/bb4dd9854c64cec6d810e1f9fa858ec308ac260c.tar.gz",
.hash = "12201813d83afa600cdbd68bbe5daf90c4b05edea8a99bded98217472760b425ec96",
},
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/f49b94700e0761b7514abdca0e4f0e7f3f938a93.tar.gz",
Expand Down
14 changes: 7 additions & 7 deletions game/convert.zig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn readUTypingConversions(allocator: std.mem.Allocator) !Self {
var file = try std.fs.cwd().openFile("convert.dat", .{});
defer file.close();

var raw_data = try allocator.alloc(u8, try file.getEndPos());
const raw_data = try allocator.alloc(u8, try file.getEndPos());
defer allocator.free(raw_data);

_ = try file.readAll(raw_data);
Expand All @@ -58,10 +58,10 @@ pub fn readUTypingConversions(allocator: std.mem.Allocator) !Self {
const yen_replaced = std.mem.replace(u8, raw_replaced_data[0..(raw_replaced_data.len - underlines_replaced * ("‾".len - "~".len))], "¥", "\\", converted_data);

//Calculate the length to cut off the end of the file, as the replacements will have shortened it
var length_to_cut = underlines_replaced * ("‾".len - "~".len) + yen_replaced * ("¥".len - "\\".len);
const length_to_cut = underlines_replaced * ("‾".len - "~".len) + yen_replaced * ("¥".len - "\\".len);

//Cut off the end of the file
var data = converted_data[0..(converted_data.len - length_to_cut)];
const data = converted_data[0..(converted_data.len - length_to_cut)];

var conversions = std.ArrayList(Conversion).init(allocator);
errdefer {
Expand All @@ -81,11 +81,11 @@ pub fn readUTypingConversions(allocator: std.mem.Allocator) !Self {

var line = if (raw_line[raw_line.len - 1] == '\r') raw_line[0..(raw_line.len - 1)] else raw_line;

var idx1 = std.mem.indexOf(u8, line, "\t") orelse return error.InvalidConvertFile;
var idx2 = std.mem.indexOfPos(u8, line, idx1 + 1, "\t");
const idx1 = std.mem.indexOf(u8, line, "\t") orelse return error.InvalidConvertFile;
const idx2 = std.mem.indexOfPos(u8, line, idx1 + 1, "\t");

var romaji = line[0..idx1];
var hiragana = line[(idx1 + 1)..(idx2 orelse line.len)];
const romaji = line[0..idx1];
const hiragana = line[(idx1 + 1)..(idx2 orelse line.len)];
var end_cut: ?[]const u8 = if (idx2 == null) null else line[(idx2.? + 1)..];

//The end cut must not be empty, so if it is, set it to null
Expand Down
18 changes: 9 additions & 9 deletions game/fontstash.zig
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub fn init(self: *Self, gfx: *Gfx, allocator: std.mem.Allocator) !void {
self.renderer = try Renderer.init(allocator, gfx, self.texture.?);
errdefer self.renderer.deinit();

var gothic_data = @embedFile("fonts/gothic.ttf");
var mincho_data = @embedFile("fonts/mincho.ttf");
const gothic_data = @embedFile("fonts/gothic.ttf");
const mincho_data = @embedFile("fonts/mincho.ttf");

self.gothic = try self.context.addFontMem("gothic", gothic_data);
self.mincho = try self.context.addFontMem("mincho", mincho_data);
Expand All @@ -61,7 +61,7 @@ pub fn verticalMetrics(self: *Self, state: Fontstash.State) struct { ascender: f
var internal_state = state;
internal_state.size *= self.gfx.scale;

var metrics = self.context.verticalMetrics(internal_state);
const metrics = self.context.verticalMetrics(internal_state);

return .{
.ascender = metrics.ascender / self.gfx.scale,
Expand Down Expand Up @@ -96,7 +96,7 @@ const Bounds = extern struct {
};

pub fn textBounds(self: *Self, text: []const u8, state: Fontstash.State) !Bounds {
var bounds = try self.context.textBounds(Gfx.Vector2Zero, text, state);
const bounds = try self.context.textBounds(Gfx.Vector2Zero, text, state);

return .{
.x1 = bounds.bounds.tl[0],
Expand Down Expand Up @@ -158,11 +158,11 @@ fn handleError(self_ptr: ?*anyopaque, err: anyerror) anyerror!void {
fn update(self_ptr: ?*anyopaque, rect: Fontstash.Rectangle, data: []const u8) anyerror!void {
var self = toSelf(self_ptr.?);

var rect_x = rect.tl[0];
var rect_y = rect.tl[1];
var rect_wh = rect.br - rect.tl;
var w = rect_wh[0];
var h = rect_wh[1];
const rect_x = rect.tl[0];
const rect_y = rect.tl[1];
const rect_wh = rect.br - rect.tl;
const w = rect_wh[0];
const h = rect_wh[1];

var full = try self.allocator.alloc(Gfx.ColorB, @intCast(w * h));
defer self.allocator.free(full);
Expand Down
Loading

0 comments on commit 40479cd

Please sign in to comment.