]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_particles.c
Fixes and cleanups related to the recent AGL patches
[xonotic/darkplaces.git] / cl_particles.c
index d4e1428a5f861d969b228fe02a17b6f720e5f50e..435981a06968559eb7575857cf049b1f9fc2cc4f 100644 (file)
@@ -218,9 +218,9 @@ void CL_Particles_ParseEffectInfo(const char *textstart, const char *textend)
                if (argc < 1)
                        continue;
 #define checkparms(n) if (argc != (n)) {Con_Printf("effectinfo.txt:%i: error while parsing: %s given %i parameters, should be %i parameters\n", linenumber, argv[0], argc, (n));break;}
-#define readints(array, n) checkparms(n+1);for (arrayindex = 0;arrayindex < argc - 1;arrayindex++) array[arrayindex] = (int)atof(argv[1+arrayindex])
+#define readints(array, n) checkparms(n+1);for (arrayindex = 0;arrayindex < argc - 1;arrayindex++) array[arrayindex] = strtol(argv[1+arrayindex], NULL, 0)
 #define readfloats(array, n) checkparms(n+1);for (arrayindex = 0;arrayindex < argc - 1;arrayindex++) array[arrayindex] = atof(argv[1+arrayindex])
-#define readint(var) checkparms(2);var = (int)atof(argv[1])
+#define readint(var) checkparms(2);var = strtol(argv[1], NULL, 0)
 #define readfloat(var) checkparms(2);var = atof(argv[1])
                if (!strcmp(argv[0], "effect"))
                {
@@ -293,15 +293,7 @@ void CL_Particles_ParseEffectInfo(const char *textstart, const char *textend)
                        else if (!strcmp(argv[1], "entityparticle")) info->particletype = pt_entityparticle;
                        else Con_Printf("effectinfo.txt:%i: unrecognized particle type %s\n", linenumber, argv[1]);
                }
-               else if (!strcmp(argv[0], "color")) 
-               {
-                       unsigned color[6] = {0};
-                       checkparms(3);
-                       sscanf( argv[1], "%i %i %i", &color[0], &color[1], &color[2] );
-                       sscanf( argv[2], "%i %i %i", &color[3], &color[4], &color[5] );
-                       info->color[0] = color[0] + (color[1] << 8) + (color[2] << 16);
-                       info->color[1] = color[3] + (color[4] << 8) + (color[5] << 16);
-               }
+               else if (!strcmp(argv[0], "color")) {readints(info->color, 2);}
                else if (!strcmp(argv[0], "tex")) {readints(info->tex, 2);}
                else if (!strcmp(argv[0], "size")) {readfloats(info->size, 2);}
                else if (!strcmp(argv[0], "alpha")) {readfloats(info->alpha, 3);}
@@ -546,7 +538,32 @@ void CL_ParticleEffect_Fallback(int effectnameindex, float count, const vec3_t o
        matrix4x4_t tempmatrix;
        VectorLerp(originmins, 0.5, originmaxs, center);
        Matrix4x4_CreateTranslate(&tempmatrix, center[0], center[1], center[2]);
-       if (effectnameindex == EFFECT_TE_WIZSPIKE)
+       if (effectnameindex == EFFECT_SVC_PARTICLE)
+       {
+               if (cl_particles.integer)
+               {
+                       // bloodhack checks if this effect's color matches regular or lightning blood and if so spawns a blood effect instead
+                       if (count == 1024)
+                               CL_ParticleExplosion(center);
+                       else if (cl_particles_blood_bloodhack.integer && !cl_particles_quake.integer && (palettecolor == 73 || palettecolor == 225))
+                               CL_ParticleEffect(EFFECT_TE_BLOOD, count / 6.0f, originmins, originmaxs, velocitymins, velocitymaxs, NULL, 0);
+                       else
+                       {
+                               count *= cl_particles_quality.value;
+                               for (;count > 0;count--)
+                               {
+                                       int k = particlepalette[palettecolor + (rand()&7)];
+                                       if (cl_particles_quake.integer)
+                                               particle(particletype + pt_alphastatic, k, k, tex_particle, 1, lhrandom(51, 255), 512, 0.05, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0, 8, 0);
+                                       else if (gamemode == GAME_GOODVSBAD2)
+                                               particle(particletype + pt_alphastatic, k, k, tex_particle, 5, 255, 300, 0, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0, 8, 10);
+                                       else
+                                               particle(particletype + pt_alphastatic, k, k, tex_particle, 1, 255, 512, 0, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0, 8, 15);
+                               }
+                       }
+               }
+       }
+       else if (effectnameindex == EFFECT_TE_WIZSPIKE)
                CL_ParticleEffect(EFFECT_SVC_PARTICLE, 30*count, originmins, originmaxs, velocitymins, velocitymaxs, NULL, 20);
        else if (effectnameindex == EFFECT_TE_KNIGHTSPIKE)
                CL_ParticleEffect(EFFECT_SVC_PARTICLE, 20*count, originmins, originmaxs, velocitymins, velocitymaxs, NULL, 226);
@@ -984,31 +1001,7 @@ void CL_ParticleEffect(int effectnameindex, float pcount, const vec3_t originmin
        if (!particleeffectname[effectnameindex][0])
                return; // no such effect
        VectorLerp(originmins, 0.5, originmaxs, center);
-       if (effectnameindex == EFFECT_SVC_PARTICLE)
-       {
-               if (!cl_particles.integer)
-                       return;
-               // bloodhack checks if this effect's color matches regular or lightning blood and if so spawns a blood effect instead
-               if (pcount == 1024)
-                       CL_ParticleExplosion(center);
-               else if (cl_particles_blood_bloodhack.integer && !cl_particles_quake.integer && (palettecolor == 73 || palettecolor == 225))
-                       CL_ParticleEffect(EFFECT_TE_BLOOD, pcount / 6.0f, originmins, originmaxs, velocitymins, velocitymaxs, NULL, 0);
-               else
-               {
-                       float count = pcount * cl_particles_quality.value;
-                       for (;count > 0;count--)
-                       {
-                               int k = particlepalette[palettecolor + (rand()&7)];
-                               if (cl_particles_quake.integer)
-                                       particle(particletype + pt_alphastatic, k, k, tex_particle, 1, lhrandom(51, 255), 512, 0.05, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0, 8, 0);
-                               else if (gamemode == GAME_GOODVSBAD2)
-                                       particle(particletype + pt_alphastatic, k, k, tex_particle, 5, 255, 300, 0, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0, 8, 10);
-                               else
-                                       particle(particletype + pt_alphastatic, k, k, tex_particle, 1, 255, 512, 0, 0, lhrandom(originmins[0], originmaxs[0]), lhrandom(originmins[1], originmaxs[1]), lhrandom(originmins[2], originmaxs[2]), lhrandom(velocitymins[0], velocitymaxs[0]), lhrandom(velocitymins[1], velocitymaxs[1]), lhrandom(velocitymins[2], velocitymaxs[2]), 0, 8, 15);
-                       }
-               }
-       }
-       else if (!cl_particles_quake.integer && particleeffectinfo[0].effectnameindex)
+       if (!cl_particles_quake.integer && particleeffectinfo[0].effectnameindex)
        {
                int effectinfoindex;
                int supercontents;