Skip to content

Commit

Permalink
chore: investigate bug
Browse files Browse the repository at this point in the history
(And find/fix nothing)
  • Loading branch information
kiedtl committed Jun 27, 2024
1 parent c9d79a8 commit 9b69f9b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/items.zig
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ pub const RINGS = [_]ItemTemplate{
.{ .w = 9, .i = .{ .r = ObscurationRing } },
};
pub const NIGHT_RINGS = [_]ItemTemplate{
.{ .w = 9, .i = .{ .r = ExcisionRing } },
.{ .w = 9, .i = .{ .r = ConjurationRing } },
.{ .w = 9, .i = .{ .r = ExcisionRing } },
};
pub const ALL_ITEMS = [_]ItemTemplate{
.{ .w = 0, .i = .{ .List = &ITEM_DROPS } },
Expand Down
11 changes: 10 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,18 @@ fn viewerMain() void {
// std.log.info("Average% open space: {}", .{avg});
// std.log.info("Min open space: {}", .{open_space_min});
// std.log.info("Max open space: {}", .{open_space_max});
// std.log.info("Deviation: ±{}", .{math.max(open_space_max - avg, avg - open_space_min)});
// std.log.info("Deviation: ±{}", .{dev});

// if (true) return;
//
// if (true) {
// var i: usize = 100000;
// while (i > 0) : (i -= 1) {
// const ring = items.createItemFromTemplate(mapgen.chooseRing(true));
// std.log.info("Chose ring {s}", .{ring.Ring.name});
// }
// return;
// }

// Wrap whole thing in comptime if condition to ensure no linker errors
if (build_options.use_sdl) {
Expand Down
2 changes: 1 addition & 1 deletion src/mapgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fn choosePoster(level: usize) ?*const Poster {
return null;
}

fn chooseRing(night: bool) ItemTemplate {
pub fn chooseRing(night: bool) ItemTemplate {
const drop_list = if (night) &items.NIGHT_RINGS else &items.RINGS;
return _chooseLootItem(drop_list, minmax(usize, 1, 999), null);
}
Expand Down
4 changes: 2 additions & 2 deletions src/rng.zig
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub fn choose2(comptime T: type, arr: []const T, comptime weight_field: []const
var weight_total: usize = 0;
var selected = arr[0];

for (arr) |item, index| {
const weight = @field(arr[index], weight_field);
for (arr) |item| {
const weight = @field(item, weight_field);
if (weight == 0) continue;

const rnd = rng.random().int(usize) % (weight_total + weight);
Expand Down

0 comments on commit 9b69f9b

Please sign in to comment.