diff options
| author | 2026-07-27 21:38:26 +0100 | |
|---|---|---|
| committer | 2026-10-10 04:23:05 +0100 | |
| commit | b31df092583c1bfb9399b51fa04733955f73c230 (patch) | |
| tree | c37b1d645a22d42c62c068067492a16cbb3ef7af | |
| parent | e66dbc42d523ec6d1a4e1b4fec21fb211eb660bb (diff) | |
| download | sst-b31df092583c1bfb9399b51fa04733955f73c230.tar.gz sst-b31df092583c1bfb9399b51fa04733955f73c230.zip | |
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.
| -rw-r--r-- | src/con_.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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 |
