Fix a bug with PRVM_64 where CSQC float stats were sent by aliasing to int64 and...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 17 Mar 2018 07:35:38 +0000 (07:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 17 Mar 2018 07:35:38 +0000 (07:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12350 d7cf8633-e32d-0410-b094-e92efae38249

svvm_cmds.c

index b41de02..eeaf4e1 100644 (file)
@@ -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: