From af6dae7f1b49b8269f6d8371d67ebc731ad0d0e1 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 17 Mar 2018 07:35:38 +0000 Subject: [PATCH] Fix a bug with PRVM_64 where CSQC float stats were sent by aliasing to int64 and returning as int32, now correctly converts to float and then uses a union to get the int32 representation. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12350 d7cf8633-e32d-0410-b094-e92efae38249 --- svvm_cmds.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/svvm_cmds.c b/svvm_cmds.c index b41de028..eeaf4e1d 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -1648,6 +1648,10 @@ void VM_SV_UpdateCustomStats (client_t *client, prvm_edict_t *ent, sizebuf_t *ms prvm_prog_t *prog = SVVM_prog; int i; char s[17]; + union { + int i; + float f; + } u; if(!vm_customstats) return; @@ -1669,7 +1673,9 @@ void VM_SV_UpdateCustomStats (client_t *client, prvm_edict_t *ent, sizebuf_t *ms break; //float field sent as-is case 8: - stats[i+32] = PRVM_E_INT(ent, vm_customstats[i].fieldoffset); + // can't directly use PRVM_E_INT on the field because it may be PRVM_64 and a double is not the representation we want to send + u.f = PRVM_E_FLOAT(ent, vm_customstats[i].fieldoffset); + stats[i+32] = u.i; break; //integer value of float field case 2: -- 2.39.2