]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
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 b41de028d7d00279a77fa3aa84d19715ae944e87..eeaf4e1db1deac4aae2e6dc12aeaae96371455bb 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: