diff --git a/src/chunk.zig b/src/chunk.zig index 5c435cd68..586d16917 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -98,9 +98,9 @@ pub const ChunkPosition = struct { var dx = @fabs(@intToFloat(f64, self.wx) + halfWidth - playerPosition[0]); var dy = @fabs(@intToFloat(f64, self.wy) + halfWidth - playerPosition[1]); var dz = @fabs(@intToFloat(f64, self.wz) + halfWidth - playerPosition[2]); - dx = @max(0.0, dx - halfWidth); // TODO: #15644 - dy = @max(0.0, dy - halfWidth); // TODO: #15644 - dz = @max(0.0, dz - halfWidth); // TODO: #15644 + dx = @max(0, dx - halfWidth); + dy = @max(0, dy - halfWidth); + dz = @max(0, dz - halfWidth); return dx*dx + dy*dy + dz*dz; } diff --git a/src/graphics.zig b/src/graphics.zig index 738f80478..9471a55c8 100644 --- a/src/graphics.zig +++ b/src/graphics.zig @@ -631,7 +631,7 @@ pub const TextBuffer = struct { } pub fn mousePosToIndex(self: TextBuffer, mousePos: Vec2f, bufferLen: usize) u32 { - var line: usize = @floatToInt(usize, @max(0.0, mousePos[1]/16.0)); // TODO: #15644 + var line: usize = @floatToInt(usize, @max(0, mousePos[1]/16.0)); line = @min(line, self.lineBreaks.items.len - 2); var x: f32 = self.getLineOffset(line); const start = self.lineBreaks.items[line].index; @@ -781,7 +781,7 @@ pub const TextBuffer = struct { else y += 8; draw.setColor(line.color | (@as(u32, 0xff000000) & draw.color)); for(lineWraps, 0..) |lineWrap, j| { - const lineStart = @max(0.0, line.start); // TODO: #15644 + const lineStart = @max(0, line.start); const lineEnd = @min(lineWrap, line.end); if(lineStart < lineEnd) { var start = Vec2f{lineStart + self.getLineOffset(j), y}; @@ -848,7 +848,7 @@ pub const TextBuffer = struct { else y += 8; draw.setColor(shadowColor(line.color) | (@as(u32, 0xff000000) & draw.color)); for(lineWraps, 0..) |lineWrap, j| { - const lineStart = @max(0.0, line.start); // TODO: #15644 + const lineStart = @max(0, line.start); const lineEnd = @min(lineWrap, line.end); if(lineStart < lineEnd) { var start = Vec2f{lineStart + self.getLineOffset(j), y}; @@ -1089,7 +1089,7 @@ pub const Shader = struct { const self = try Shader.init(vertex, fragment); inline for(@typeInfo(@TypeOf(ptrToUniformStruct.*)).Struct.fields) |field| { if(field.type == c_int) { - @field(ptrToUniformStruct, field.name) = c.glGetUniformLocation(self.id, field.name[0..]); + @field(ptrToUniformStruct, field.name) = c.glGetUniformLocation(self.id, field.name[0..] ++ "\x00"); // TODO: #16072 } } return self; diff --git a/src/gui/GuiWindow.zig b/src/gui/GuiWindow.zig index 07681dc3d..4e7f9a45d 100644 --- a/src/gui/GuiWindow.zig +++ b/src/gui/GuiWindow.zig @@ -364,7 +364,7 @@ pub fn updateWindowPosition(self: *GuiWindow) void { switch(relPos) { .ratio => |ratio| { self.pos[i] = windowSize[i]*ratio - self.size[i]/2; - self.pos[i] = @max(self.pos[i], 0.0); // TODO: #15644 + self.pos[i] = @max(self.pos[i], 0); self.pos[i] = @min(self.pos[i], windowSize[i] - self.size[i]); }, .attachedToFrame => |attachedToFrame| { diff --git a/src/gui/components/ScrollBar.zig b/src/gui/components/ScrollBar.zig index f1042176a..e496df39c 100644 --- a/src/gui/components/ScrollBar.zig +++ b/src/gui/components/ScrollBar.zig @@ -76,7 +76,7 @@ fn updateValueFromButtonPos(self: *ScrollBar) void { pub fn scroll(self: *ScrollBar, offset: f32) void { self.currentState += offset; - self.currentState = @min(1.0, @max(0.0, self.currentState)); // TODO: #15644 + self.currentState = @min(1, @max(0, self.currentState)); } pub fn updateHovered(self: *ScrollBar, mousePosition: Vec2f) void { @@ -106,7 +106,7 @@ pub fn render(self: *ScrollBar, mousePosition: Vec2f) !void { self.setButtonPosFromValue(); if(self.button.pressed) { self.button.pos[1] = mousePosition[1] - self.mouseAnchor; - self.button.pos[1] = @min(@max(self.button.pos[1], 0.0), range - 0.001); // TODO: #15644 + self.button.pos[1] = @min(@max(self.button.pos[1], 0), range - 0.001); self.updateValueFromButtonPos(); } const oldTranslation = draw.setTranslation(self.pos); diff --git a/src/itemdrop.zig b/src/itemdrop.zig index 6257ba7a5..39a734c2b 100644 --- a/src/itemdrop.zig +++ b/src/itemdrop.zig @@ -352,7 +352,7 @@ pub const ItemDropManager = struct { } // Apply drag: vel.* += acceleration; - vel.* *= @splat(3, @max(0.0, 1 - drag*deltaTime)); // TODO: #15644 + vel.* *= @splat(3, @max(0, 1 - drag*deltaTime)); } fn fixStuckInBlock(self: *ItemDropManager, chunk: *Chunk, pos: *Vec3d, vel: *Vec3d, deltaTime: f64) void { diff --git a/src/items.zig b/src/items.zig index 9d1a6ffa2..4a5be7f83 100644 --- a/src/items.zig +++ b/src/items.zig @@ -34,7 +34,7 @@ const Material = struct { self.density = json.get(f32, "density", 1.0); self.resistance = json.get(f32, "resistance", 1.0); self.power = json.get(f32, "power", 1.0); - self.roughness = @max(0.0, json.get(f32, "roughness", 1.0)); // TODO: #15644 + self.roughness = @max(0, json.get(f32, "roughness", 1.0)); const colors = json.getChild("colors"); self.colorPalette = try allocator.alloc(Color, colors.JsonArray.items.len); for(colors.JsonArray.items, self.colorPalette) |item, *color| { @@ -758,7 +758,7 @@ const ToolPhysics = struct { } } // Smaller tools are faster to swing. To balance that smaller tools get a lower durability. - tool.maxDurability = @floatToInt(u32, @max(1.0, std.math.pow(f32, durability/4, 1.5))); // TODO: #15644 + tool.maxDurability = @floatToInt(u32, @max(1, std.math.pow(f32, durability/4, 1.5))); tool.durability = tool.maxDurability; } diff --git a/src/renderer.zig b/src/renderer.zig index e466131e4..f0f939e55 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -670,9 +670,9 @@ pub const Frustum = struct { inline for(self.planes) |plane| { var dist: f32 = vec.dot(pos - plane.pos, plane.norm); // Find the most positive corner: - dist += @max(0.0, dim[0]*plane.norm[0]); // TODO: #15644 - dist += @max(0.0, dim[1]*plane.norm[1]); // TODO: #15644 - dist += @max(0.0, dim[2]*plane.norm[2]); // TODO: #15644 + dist += @max(0, dim[0]*plane.norm[0]); + dist += @max(0, dim[1]*plane.norm[1]); + dist += @max(0, dim[2]*plane.norm[2]); if(dist < 128) return false; } return true; diff --git a/src/server/terrain/cavegen/FractalCaveGenerator.zig b/src/server/terrain/cavegen/FractalCaveGenerator.zig index c317a7398..755b04ea7 100644 --- a/src/server/terrain/cavegen/FractalCaveGenerator.zig +++ b/src/server/terrain/cavegen/FractalCaveGenerator.zig @@ -253,7 +253,7 @@ fn considerCoordinates(x: i32, y: i32, z: i32, map: *CaveMapFragment, seed: *u64 }; // At y = caveHeightWithMaxDensity blocks the chance is saturated, while at maxCaveHeight the chance gets 0: - if(random.nextFloat(seed) >= maxCaveDensity*@min(1.0, @floatCast(f32, (maxCaveHeight - startWorldPos[1])/(maxCaveHeight - caveHeightWithMaxDensity)))) return; // TODO: #15644 + if(random.nextFloat(seed) >= maxCaveDensity*@min(1, @floatCast(f32, (maxCaveHeight - startWorldPos[1])/(maxCaveHeight - caveHeightWithMaxDensity)))) return; var starters = 1 + random.nextIntBounded(u8, seed, 4); while(starters != 0) : (starters -= 1) { diff --git a/src/server/terrain/climategen/PolarCircles.zig b/src/server/terrain/climategen/PolarCircles.zig index 5b27fb968..69542169c 100644 --- a/src/server/terrain/climategen/PolarCircles.zig +++ b/src/server/terrain/climategen/PolarCircles.zig @@ -188,7 +188,7 @@ fn heightDependantTemperature(temperature: f32, height: f32) f32 { // Therefor the total equation gets: `65K*2/80K/(1 - oceanThreshold)*(height - oceanThreshold)` = `1.625/(1 - oceanThreshold)*(height - oceanThreshold)` // Furthermore I assume that the average temperature is at 1km of height. - return temperature - 1.625*(@max(0.0, height - oceanThreshold)/(1 - oceanThreshold) - 0.1); // TODO: #15644 + return temperature - 1.625*(@max(0, height - oceanThreshold)/(1 - oceanThreshold) - 0.1); } fn findClimate(height: f32, humid: f32, temp: f32) Biome.Type {