cameraYawSmoothSpeed follows at the stored rate, not the slider's 90-270 (#1712)
`cameraYawSmoothSpeed` was clamped to 90-270 when applied, the Auto-Follow Speed slider's range, so `/console cameraYawSmoothSpeed 360` followed at 270. In 1.12.1 its validator `0x50c000` refuses only outside [0.1, 360] (`0x50b330`, `Value out of range` at `0x50b36c`) and the follow reader takes the stored rate as is (`[0xbe1070]` at `0x512d75`). The camera now uses the stored value; the registry's existing check, which already matched `0x50b330` and also runs on the config load, does the refusing. `FOLLOW_SPEED_RANGE` is gone. Test: 270, 360, 0.2 and 30 are stored and applied as given; 360.5, 400, 9000, 0, 0.05 and -30 are vetoed and keep 30. It fails with the clamp put back. Fixes #323 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1009,7 +1009,7 @@ mod tests {
|
||||
use crate::chat_bubble::BubbleConfig;
|
||||
use crate::minimap::MinimapZoom;
|
||||
use crate::nameplates::NameConfig;
|
||||
use crate::player::camera::{FollowConfig, FollowStyle, LookConfig, FOLLOW_SPEED_RANGE};
|
||||
use crate::player::camera::{FollowConfig, FollowStyle, LookConfig};
|
||||
use crate::player::camera_zoom::ZoomLimit;
|
||||
use crate::portrait::PaneRate;
|
||||
use crate::sound::SoundConfig;
|
||||
@@ -1525,17 +1525,25 @@ mod tests {
|
||||
FollowStyle::Smart,
|
||||
"and only that one"
|
||||
);
|
||||
apply(&mut app, "cameraYawSmoothSpeed", "270");
|
||||
assert_eq!(res::<FollowConfig>(&app).yaw_speed, 270.0);
|
||||
// Past the validator's 360 (`0x50c000`): refused, 270 stands.
|
||||
assert_eq!(
|
||||
apply(&mut app, "cameraYawSmoothSpeed", "9000"),
|
||||
SetOutcome::Vetoed
|
||||
);
|
||||
assert_eq!(
|
||||
res::<FollowConfig>(&app).yaw_speed,
|
||||
*FOLLOW_SPEED_RANGE.end()
|
||||
);
|
||||
// The validator's [0.1, 360] (`0x50c000`) is the range, not the stock slider's 90 to 270:
|
||||
// a value inside it is stored and used as is (`0x512d75`).
|
||||
for (text, want) in [("270", 270.0), ("360", 360.0), ("0.2", 0.2), ("30", 30.0)] {
|
||||
assert_eq!(
|
||||
apply(&mut app, "cameraYawSmoothSpeed", text),
|
||||
SetOutcome::Changed,
|
||||
"{text}"
|
||||
);
|
||||
assert_eq!(res::<FollowConfig>(&app).yaw_speed, want, "{text}");
|
||||
}
|
||||
// Outside it: refused, and the last stored value stands.
|
||||
for text in ["360.5", "400", "9000", "0", "0.05", "-30"] {
|
||||
assert_eq!(
|
||||
apply(&mut app, "cameraYawSmoothSpeed", text),
|
||||
SetOutcome::Vetoed,
|
||||
"{text}"
|
||||
);
|
||||
assert_eq!(res::<FollowConfig>(&app).yaw_speed, 30.0, "{text}");
|
||||
}
|
||||
// The max orbit lands as yards on the knob: `cameraDistanceMax` x the factor, held to
|
||||
// [0, 50]; the factor is not held to its slider's 1 to 2.
|
||||
apply(&mut app, "cameraDistanceMaxFactor", "1");
|
||||
|
||||
@@ -481,8 +481,8 @@ pub(crate) const REGISTERED: &[Registered] = &[
|
||||
same("cameraSmoothTrackingStyle", "1").checked(benilla_ui::script::check_camera_smooth_style),
|
||||
// AUTO_FOLLOW_SPEED (`UIOptionsFrame.lua:88`), deg/s, registered "180.0" (`[0xbe1070]`): it
|
||||
// sets the transition's duration (`|dyaw| / rate * factor`), an average rate, not a slew. The
|
||||
// validator `0x50c000` refuses outside [0.1, 360]; the knob then clamps to `FOLLOW_SPEED_RANGE`,
|
||||
// the slider's.
|
||||
// validator `0x50c000` refuses outside [0.1, 360] and the follow reader (`0x512d75`) uses the
|
||||
// stored value as is; 90 to 270 is only the stock slider's range.
|
||||
same("cameraYawSmoothSpeed", "180").checked(benilla_ui::script::check_camera_rate),
|
||||
// `UIOptionsFrame.lua:353` names `cameraPitchSmoothSpeed`, registered "45.0" (`0x50b90b`) with
|
||||
// the same validator, and `SetCVar` raises on a name no CVar has (`0x488c53`). `FollowRig` has
|
||||
|
||||
@@ -98,9 +98,9 @@ pub(crate) fn on_cvar(
|
||||
// The stock dropdown writes 1 Smart, 2 Always, 0 Never (`UIOptionsFrame.lua:518`).
|
||||
"camerasmoothstyle" => follow.style = FollowStyle::from_cvar(v),
|
||||
"camerasmoothtrackingstyle" => follow.tracking_style = FollowStyle::from_cvar(v),
|
||||
"camerayawsmoothspeed" => {
|
||||
follow.yaw_speed = v.clamp(*FOLLOW_SPEED_RANGE.start(), *FOLLOW_SPEED_RANGE.end());
|
||||
}
|
||||
// The registry has refused a rate outside the validator's [0.1, 360] (`0x50c000`); the
|
||||
// follow reader takes the stored value as is (`0x512d75`).
|
||||
"camerayawsmoothspeed" => follow.yaw_speed = v,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,6 @@ impl LookConfig {
|
||||
/// `cameraYawSmoothSpeed`, default 180°/s (`[0xbe1070]`, read at `0x512d75`): a duration divisor,
|
||||
/// as a return lasts `|Δyaw| / rate × factor`. The AUTO_FOLLOW_SPEED slider, greyed under Never.
|
||||
pub(crate) const FOLLOW_SPEED_DEFAULT: f32 = 180.0;
|
||||
/// The 1.12 slider's own range for [`FollowConfig::yaw_speed`].
|
||||
pub(crate) const FOLLOW_SPEED_RANGE: std::ops::RangeInclusive<f32> = 90.0..=270.0;
|
||||
/// `cameraSmoothTimeMin`/`Max`: 0.1 s and 2.0 s (`[0xbe105c]`/`[0xbe1038]`, clamped at `0x510f4d`).
|
||||
const FOLLOW_TIME_MIN: f32 = 0.1;
|
||||
const FOLLOW_TIME_MAX: f32 = 2.0;
|
||||
|
||||
Reference in New Issue
Block a user