From b31df092583c1bfb9399b51fa04733955f73c230 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 27 Jul 2026 21:38:26 +0100 Subject: Fix cvar value clamping not changing the string I believe this was a regression in the OE support added in 0.15, so it's been here a while. We don't have a lot of clamped cvars so I guess maybe nobody noticed for a while. I just happened to find it while testing other stuff. Quite a silly mistake but an easy fix. --- src/con_.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/con_.c b/src/con_.c index 1d7d06e..8dcf638 100644 --- a/src/con_.c +++ b/src/con_.c @@ -237,25 +237,27 @@ static void VCALLCONV ChangeStringValue_OE(struct con_var *this, const char *s) // vtable just in case (see below), though arguably nothing in the engine // *should* be calling these internal things anyway. -static void InternalSetValue_common(struct con_var *this, - struct con_var_common *common, const char *v) { +static const char *InternalSetValue_common(struct con_var *this, + struct con_var_common *common, const char *v, char tmp[static 32]) { float newf = atof(v); - char tmp[32]; if (ClampValue_common(common, &newf)) { - snprintf(tmp, sizeof(tmp), "%f", newf); + snprintf(tmp, 32, "%f", newf); v = tmp; } common->fval = newf; common->ival = (int)newf; + return v; } static void VCALLCONV InternalSetValue(struct con_var *this, const char *v) { float oldf = this->v2.fval; - InternalSetValue_common(this, &this->v2, v); + char tmp[32]; + v = InternalSetValue_common(this, &this->v2, v, tmp); if (!(this->base.flags & CON_NOPRINT)) ChangeStringValue(this, v, oldf); } #ifdef _WIN32 static void VCALLCONV InternalSetValue_OE(struct con_var *this, const char *v) { - InternalSetValue_common(this, &this->v1, v); + char tmp[32]; + v = InternalSetValue_common(this, &this->v1, v, tmp); if (!(this->base.flags & CON_NOPRINT)) ChangeStringValue_OE(this, v); } #endif -- cgit v1.2.3-54-g00ecf