From: havoc Date: Sat, 17 Mar 2018 07:35:38 +0000 (+0000) Subject: Fix a bug with PRVM_64 where CSQC float stats were sent by aliasing to int64 and... X-Git-Tag: xonotic-v0.8.5~65 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4513875d934ceed8f004bf62a1248a0afcb1da76;p=xonotic%2Fdarkplaces.git 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 ::stable-branch::merge=af6dae7f1b49b8269f6d8371d67ebc731ad0d0e1 --- 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: