]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
support "declaring" particle effects at the top of the effectinfo file
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 Sep 2013 19:52:54 +0000 (19:52 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 Sep 2013 19:52:54 +0000 (19:52 +0000)
Now "effect EFFECTNAME" without any fields set is harmless; the slot it creates
will be used by a later "effect EFFECTNAME" definition.

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

cl_particles.c

index f901e18724e23d9db69b5c48a965e0058bdd1f5f..83639adedf9c760405f56d974c666768cbba48d1 100644 (file)
@@ -44,6 +44,7 @@ particletype_t particletype[pt_total] =
 
 #define PARTICLEEFFECT_UNDERWATER 1
 #define PARTICLEEFFECT_NOTUNDERWATER 2
+#define PARTICLEEFFECT_DEFINED 2147483648U
 
 typedef struct particleeffectinfo_s
 {
@@ -314,6 +315,7 @@ static void CL_Particles_ParseEffectInfo(const char *textstart, const char *text
 {
        int arrayindex;
        int argc;
+       int i;
        int linenumber;
        particleeffectinfo_t *info = NULL;
        const char *text = textstart;
@@ -371,17 +373,29 @@ static void CL_Particles_ParseEffectInfo(const char *textstart, const char *text
                                Con_Printf("%s:%i: too many effects!\n", filename, linenumber);
                                break;
                        }
+                       for(i = 0; i < numparticleeffectinfo; ++i)
+                       {
+                               info = particleeffectinfo + i;
+                               if(!(info->flags & PARTICLEEFFECT_DEFINED))
+                                       if(info->effectnameindex == effectnameindex)
+                                               break;
+                       }
+                       if(i < numparticleeffectinfo)
+                               continue;
                        info = particleeffectinfo + numparticleeffectinfo++;
                        // copy entire info from baseline, then fix up the nameindex
                        *info = baselineparticleeffectinfo;
                        info->effectnameindex = effectnameindex;
+                       continue;
                }
                else if (info == NULL)
                {
                        Con_Printf("%s:%i: command %s encountered before effect\n", filename, linenumber, argv[0]);
                        break;
                }
-               else if (!strcmp(argv[0], "countabsolute")) {readfloat(info->countabsolute);}
+
+               info->flags |= PARTICLEEFFECT_DEFINED;
+               if (!strcmp(argv[0], "countabsolute")) {readfloat(info->countabsolute);}
                else if (!strcmp(argv[0], "count")) {readfloat(info->countmultiplier);}
                else if (!strcmp(argv[0], "type"))
                {
@@ -1490,7 +1504,7 @@ static void CL_NewParticlesFromEffectinfo(int effectnameindex, float pcount, con
                }
                for (effectinfoindex = 0, info = particleeffectinfo;effectinfoindex < MAX_PARTICLEEFFECTINFO && info->effectnameindex;effectinfoindex++, info++)
                {
-                       if (info->effectnameindex == effectnameindex)
+                       if ((info->effectnameindex == effectnameindex) && (info->flags & PARTICLEEFFECT_DEFINED))
                        {
                                qboolean definedastrail = info->trailspacing > 0;