shifted bit range from a stat
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7438
d7cf8633-e32d-0410-b094-
e92efae38249
static void VM_CL_getstati (void)
{
int i, index;
static void VM_CL_getstati (void)
{
int i, index;
- VM_SAFEPARMCOUNT(1, VM_CL_getstati);
+ int firstbit, bitcount;
+
+ VM_SAFEPARMCOUNTRANGE(1, 3, VM_CL_getstati);
+
index = (int)PRVM_G_FLOAT(OFS_PARM0);
index = (int)PRVM_G_FLOAT(OFS_PARM0);
+ if (prog->argc > 1)
+ {
+ firstbit = (int)PRVM_G_FLOAT(OFS_PARM1);
+ if (prog->argc > 2)
+ bitcount = (int)PRVM_G_FLOAT(OFS_PARM2);
+ else
+ bitcount = 1;
+ }
+ else
+ {
+ firstbit = 0;
+ bitcount = 32;
+ }
if(index < 0 || index >= MAX_CL_STATS)
{
if(index < 0 || index >= MAX_CL_STATS)
{
return;
}
i = cl.stats[index];
return;
}
i = cl.stats[index];
+ if (bitcount != 32) //32 causes the mask to overflow, so there's nothing to subtract from.
+ i = (((unsigned int)i)&(((1<<bitcount)-1)<<firstbit))>>firstbit;
PRVM_G_FLOAT(OFS_RETURN) = i;
}
PRVM_G_FLOAT(OFS_RETURN) = i;
}