]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - svvm_cmds.c
Fix dumb mistake allowing cheats to be used despite sv_cheats being 0...
[xonotic/darkplaces.git] / svvm_cmds.c
index 8e8b00ad5e166a257b3aefa4fd75993452f3bb73..40523c7853bc414bca5a3c7d68e646d5c12c2f0a 100644 (file)
@@ -244,7 +244,7 @@ static void VM_SV_setorigin(prvm_prog_t *prog)
 {
        prvm_edict_t    *e;
 
-       VM_SAFEPARMCOUNT(2, VM_setorigin);
+       VM_SAFEPARMCOUNT(2, VM_SV_setorigin);
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
@@ -295,7 +295,7 @@ static void VM_SV_setsize(prvm_prog_t *prog)
        prvm_edict_t    *e;
        vec3_t mins, maxs;
 
-       VM_SAFEPARMCOUNT(3, VM_setsize);
+       VM_SAFEPARMCOUNT(3, VM_SV_setsize);
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
@@ -328,7 +328,7 @@ static void VM_SV_setmodel(prvm_prog_t *prog)
        dp_model_t      *mod;
        int             i;
 
-       VM_SAFEPARMCOUNT(2, VM_setmodel);
+       VM_SAFEPARMCOUNT(2, VM_SV_setmodel);
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
@@ -1636,11 +1636,8 @@ static int vm_customstats_last;
 
 void VM_CustomStats_Clear (void)
 {
-       if(vm_customstats)
-       {
-               memset(vm_customstats, 0, sizeof(vm_customstats));
-               vm_customstats_last = -1;
-       }
+       memset(vm_customstats, 0, sizeof(vm_customstats));
+       vm_customstats_last = -1;
 }
 
 void VM_SV_UpdateCustomStats (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats)
@@ -1684,6 +1681,8 @@ void VM_SV_UpdateCustomStats (client_t *client, prvm_edict_t *ent, sizebuf_t *ms
        }
 }
 
+extern cvar_t sv_gameplayfix_customstats;
+
 // void(float index, float type, .void field) SV_AddStat = #232;
 // Set up an auto-sent player stat.
 // Client's get thier own fields sent to them. Index may not be less than 32.
@@ -1720,22 +1719,22 @@ static void VM_SV_AddStat(prvm_prog_t *prog)
 
        if (i >= MAX_CL_STATS)
        {
-               VM_Warning(prog, "PF_SV_AddStat: index (%i) >= MAX_CL_STATS (%i), not supported by protocol, and AddStat beyond MAX_VM_STAT conflicts with engine MOVEVARS\n", i, MAX_CL_STATS, MAX_VM_STAT);
+               VM_Warning(prog, "PF_SV_AddStat: index (%i) >= MAX_CL_STATS (%i), not supported by protocol, and AddStat beyond MAX_VM_STAT (%i) conflicts with engine MOVEVARS\n", i, MAX_CL_STATS, MAX_VM_STAT);
                return;
        }
 
        if (i > (MAX_CL_STATS - 4) && type == 1)
        {
-               VM_Warning(prog, "PF_SV_AddStat: index (%i) > (MAX_CL_STATS-4) with string type won't fit in the protocol, and AddStat beyond MAX_VM_STAT conflicts with engine MOVEVARS\n", i, MAX_CL_STATS);
+               VM_Warning(prog, "PF_SV_AddStat: index (%i) > (MAX_CL_STATS (%i) - 4) with string type won't fit in the protocol, and AddStat beyond MAX_VM_STAT conflicts with engine MOVEVARS\n", i, MAX_CL_STATS);
                return;
        }
 
        // these are hazardous to override but sort of allowed if one wants to be adventurous...  and enjoys warnings.
        if (i < MIN_VM_STAT)
                VM_Warning(prog, "PF_SV_AddStat: index (%i) < MIN_VM_STAT (%i) may conflict with engine stats - allowed, but this may break things\n", i, MIN_VM_STAT);
-       else if (i >= MAX_VM_STAT)
+       else if (i >= MAX_VM_STAT && !sv_gameplayfix_customstats.integer)
                VM_Warning(prog, "PF_SV_AddStat: index (%i) >= MAX_VM_STAT (%i) conflicts with engine stats - allowed, but this may break slowmo and stuff\n", i, MAX_VM_STAT);
-       else if (i > (MAX_VM_STAT - 4) && type == 1)
+       else if (i > (MAX_VM_STAT - 4) && type == 1 && !sv_gameplayfix_customstats.integer)
                VM_Warning(prog, "PF_SV_AddStat: index (%i) >= MAX_VM_STAT (%i) - 4 with string type won't fit within MAX_VM_STAT, thus conflicting with engine stats - allowed, but this may break slowmo and stuff\n", i, MAX_VM_STAT);
 
        vm_customstats[i].type          = type;