Merge pull request #673 from Online5277/fix/render-distance-settings-cap

Allow render distances up to 64 chunks in settings
This commit is contained in:
Ludovic Marie
2026-10-17 14:13:30 +02:00
committed by GitHub
4 changed files with 37 additions and 7 deletions
@@ -1,7 +1,10 @@
#![forbid(unsafe_code)]
//! Loads and saves option files like `Options.load`/`save`, for the
//! differential harness (tools/test_options_parity.py).
use horizon_client::{Result, keybinds, options_file::OptionsFile};
use horizon_client::{
Result, keybinds,
options_file::{OptionsFile, V},
};
use std::{fs, io::Write};
fn main() -> Result<()> {
@@ -14,11 +17,16 @@ fn main() -> Result<()> {
let mut first = true;
for path in names {
let name = path.file_name().unwrap().to_string_lossy().into_owned();
let file = if name == "absent.txt" {
let mut file = if name == "absent.txt" {
OptionsFile::default()
} else {
OptionsFile::parse(&String::from_utf8_lossy(&fs::read(&path)?))
};
// Horizon extends the slider to 64; vanilla rejects 33..64 to its default.
// Compare that deliberate extension as vanilla would serialize it.
if file.int("renderDistance") > 32 {
file.set("renderDistance", V::Int(12));
}
write!(out, "== {name}\n{}", file.serialize())?;
if first {
first = false;
+1 -1
View File
@@ -159,7 +159,7 @@ static TABLE: LazyLock<Vec<Def>> = LazyLock::new(|| {
b("reducedDebugInfo", false),
def("renderClouds", O(Clouds), V::Int(2)),
i("cloudRange", 2, 128, 128),
i("renderDistance", 2, 32, 12),
i("renderDistance", 2, 64, 12),
i("simulationDistance", 5, 32, 12),
u("screenEffectScale", 1.0),
def("soundDevice", O(AnyStr), V::Str(String::new())),
+21 -2
View File
@@ -190,7 +190,7 @@ impl Opt {
let unit = |v: f32, lo: f32, hi: f32| Kind::Slider(((v - lo) / (hi - lo)).clamp(0.0, 1.0));
match self {
Opt::Fov => unit(s.fov, 30.0, 110.0),
Opt::RenderDistance => unit(s.render_distance as f32, 2.0, 32.0),
Opt::RenderDistance => unit(s.render_distance as f32, 2.0, 64.0),
Opt::SimulationDistance => unit(s.simulation_distance as f32, 5.0, 32.0),
Opt::Sensitivity => Kind::Slider(s.sensitivity),
Opt::WheelSensitivity => unit(s.mouse_wheel_sensitivity, 0.01, 10.0),
@@ -484,7 +484,7 @@ impl Opt {
let step = |lo: f32, hi: f32| (lo + v * (hi - lo)).round();
match self {
Opt::Fov => s.fov = step(30.0, 110.0),
Opt::RenderDistance => s.render_distance = step(2.0, 32.0) as i32,
Opt::RenderDistance => s.render_distance = step(2.0, 64.0) as i32,
Opt::SimulationDistance => s.simulation_distance = step(5.0, 32.0) as i32,
Opt::Sensitivity => s.sensitivity = v,
Opt::WheelSensitivity => s.mouse_wheel_sensitivity = 0.01 + v * 9.99,
@@ -2356,6 +2356,25 @@ mod tests {
use super::*;
use crate::ui_theme::{MenuStyle, set_style, style};
#[test]
fn render_distance_slider_round_trips_through_extended_options_range() {
let mut s = Settings::default();
for (position, distance) in [(0.0, 2), (0.5, 33), (1.0, 64)] {
set_slider(Opt::RenderDistance, &mut s, position);
assert_eq!(s.render_distance, distance);
let reloaded = Settings::parse(&s.serialize());
assert_eq!(reloaded.render_distance, distance);
assert_eq!(
Opt::RenderDistance.slider_position(&reloaded),
Some(position)
);
}
let mut file = crate::options_file::OptionsFile::default();
file.set_text("renderDistance", "64").unwrap();
assert!(file.set_text("renderDistance", "65").is_err());
assert!(file.set_text("renderDistance", "1").is_err());
assert_eq!(file.int("renderDistance"), 64);
}
fn atlas() -> HudAtlas {
HudAtlas::build(std::path::Path::new("/nonexistent/horizon-test-assets")).unwrap()
}
+5 -2
View File
@@ -1,7 +1,9 @@
#!/usr/bin/env python3
"""Compare options.txt loading and saving, and the key mapping table, with the
pinned client: every file is loaded through the real Options.load and written
back with Options.save, and the Rust port must produce identical text."""
back with Options.save. The Rust probe normalizes Horizon's intentional 33..64
render-distance extension to vanilla's default; a Rust slider/persistence
regression covers the extended range."""
from pathlib import Path
import random
import shutil
@@ -182,7 +184,8 @@ def main():
'fields, lenient Gson parsing and syntax-error aborts, key mappings (names, scancode-number forms, unbinding), '
'sound volumes, model parts, line endings, the OPTIONS data fixers across version boundaries, and the '
'KeyMapping table (order, defaults, categories, toggle mappings). Does not cover option screens or '
'runtime side effects of setting an option.')
'runtime side effects of setting an option. Horizon render distances 33..64 are normalized to vanilla\'s '
'default by options_probe; the slider/persistence unit regression checks that intentional extension.')
harness.differential(
'rust-options-parity', 'VanillaOptionsOracle', 'options_probe', make_cases, scope,
sources=[lab.ROOT / 'crates/horizon-client/src/options_file.rs', lab.ROOT / 'crates/horizon-client/src/options_fixes.rs',