summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2026-07-27 21:38:26 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2026-10-10 04:23:05 +0100
commitb31df092583c1bfb9399b51fa04733955f73c230 (patch)
treec37b1d645a22d42c62c068067492a16cbb3ef7af
parente66dbc42d523ec6d1a4e1b4fec21fb211eb660bb (diff)
downloadsst-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_.c14
1 files changed, 8 insertions, 6 deletions
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