]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix a few bugs detected by Cppcheck
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 18 May 2020 03:10:15 +0000 (03:10 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 18 May 2020 03:10:15 +0000 (03:10 +0000)
(warning) Logical conjunction always evaluates to false: matchrule < 0 && matchrule > 5.
(style) Condition 'k<16' is always true
(style) Variable 'settings->bounceminimumintensity2' is reassigned a value before the old one has been used.

From terencehill

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12532 d7cf8633-e32d-0410-b094-e92efae38249

cl_particles.c
prvm_cmds.c
r_shadow.c

index a93be5e772b62e4d865b4149c5a32cfd1ea13688..2093bcb5c1129f233802f5bf930c0aac571f487b 100644 (file)
@@ -1826,7 +1826,7 @@ void CL_ParticleExplosion (const vec3_t org)
                                                VectorMA(org, 128, v2, v);
                                                trace = CL_TraceLine(org, v, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, 0, 0, collision_extendmovelength.value, true, false, NULL, false, false);
                                        }
-                                       while (k < 16 && trace.fraction < 0.1f);
+                                       while (k++ < 16 && trace.fraction < 0.1f);
                                        VectorSubtract(trace.endpos, org, v2);
                                        VectorScale(v2, 2.0f, v2);
                                        CL_NewParticle(org, pt_spark, 0x903010, 0xFFD030, tex_particle, 1.0f, 0, lhrandom(0, 255), 512, 0, 0, org[0], org[1], org[2], v2[0], v2[1], v2[2], 0, 0, 0, 0, true, 0, 1, PBLEND_ADD, PARTICLE_SPARK, -1, -1, -1, 1, 1, 0, 0, NULL);
index 90ef213ea22376b2a741a509857a9222069eab58..e2bba64320f20711c5ffcf53aa7694ece3301e07 100644 (file)
@@ -5386,7 +5386,7 @@ void VM_bufstr_find(prvm_prog_t *prog)
        char string[VM_STRINGTEMP_LENGTH];
        int matchrule, matchlen, i, step;
        const char *match;
-       
+
        VM_SAFEPARMCOUNTRANGE(3, 5, VM_bufstr_find);
 
        PRVM_G_FLOAT(OFS_RETURN) = -1;
@@ -5401,7 +5401,7 @@ void VM_bufstr_find(prvm_prog_t *prog)
 
        // get pattern/rule
        matchrule = (int)PRVM_G_FLOAT(OFS_PARM2);
-       if (matchrule < 0 && matchrule > 5)
+       if (matchrule < 0 || matchrule > 5)
        {
                VM_Warning(prog, "VM_bufstr_find: invalid match rule %i in %s\n", matchrule, prog->name);
                return;
@@ -5447,9 +5447,9 @@ void VM_matchpattern(prvm_prog_t *prog)
 
        // get pattern/rule
        matchrule = (int)PRVM_G_FLOAT(OFS_PARM2);
-       if (matchrule < 0 && matchrule > 5)
+       if (matchrule < 0 || matchrule > 5)
        {
-               VM_Warning(prog, "VM_bufstr_find: invalid match rule %i in %s\n", matchrule, prog->name);
+               VM_Warning(prog, "VM_matchpattern: invalid match rule %i in %s\n", matchrule, prog->name);
                return;
        }
        if (matchrule)
index 3d14ab03dcc9ad09610f0e83a9421667d7e4ecf0..e6fda0f5d398178d1042c64f0105b56889740314 100644 (file)
@@ -1724,7 +1724,6 @@ static void R_Shadow_BounceGrid_GenerateSettings(r_shadow_bouncegrid_settings_t
        settings->rng_type                      = r_shadow_bouncegrid_rng_type.integer;
        settings->rng_seed                      = r_shadow_bouncegrid_rng_seed.integer;
        settings->bounceminimumintensity2       = bounceminimumintensity * bounceminimumintensity;
-       settings->bounceminimumintensity2       = bounceminimumintensity * bounceminimumintensity;
        settings->normalizevectors              = r_shadow_bouncegrid_normalizevectors.integer != 0;
        settings->subsamples                    = bound(1, r_shadow_bouncegrid_subsamples.integer, 4);