]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
framegroups parsing: make 5th arg animation name, not comment
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Nov 2011 14:04:12 +0000 (14:04 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 5 Nov 2011 14:10:44 +0000 (15:10 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11523 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=63f4e0c538ca8f14b1e4fd30d032104e99c930e3

model_shared.c

index b7813728cd195f889a2504c741400c2ff12b4edf..b76459b1923bb42f05fa6ffcb3a4db07d1abc958 100644 (file)
@@ -239,23 +239,27 @@ typedef void (*mod_framegroupify_parsegroups_t) (unsigned int i, int start, int
 int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_parsegroups_t cb, void *pass)
 {
        const char *bufptr;
-       const char *name;
        int start, len;
        float fps;
        unsigned int i;
        qboolean loop;
+       char name[64];
 
        bufptr = buf;
        i = 0;
        for(;;)
        {
                // an anim scene!
-               if (!COM_ParseToken_Simple(&bufptr, true, false, false))
+
+               // REQUIRED: fetch start
+               if (!COM_ParseToken_Simple(&bufptr, true, false, true))
                        break;
                if (!strcmp(com_token, "\n"))
                        continue; // empty line
                start = atoi(com_token);
-               if (!COM_ParseToken_Simple(&bufptr, true, false, false))
+
+               // REQUIRED: fetch length
+               if (!COM_ParseToken_Simple(&bufptr, true, false, true))
                        break;
                if (!strcmp(com_token, "\n"))
                {
@@ -263,56 +267,42 @@ int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_parsegroups
                        continue;
                }
                len = atoi(com_token);
-               if (!COM_ParseToken_Simple(&bufptr, true, false, false))
+
+               // OPTIONAL args start
+               if (!COM_ParseToken_Simple(&bufptr, true, false, true))
                        break;
-               // we default to looping as it's usually wanted, so to NOT loop you append a 0
-               if (strcmp(com_token, "\n") && strcmp(com_token, "//"))
+
+               // OPTIONAL: fetch fps
+               fps = 20;
+               if (strcmp(com_token, "\n"))
                {
                        fps = atof(com_token);
-                       if (!COM_ParseToken_Simple(&bufptr, true, false, false))
+                       if (!COM_ParseToken_Simple(&bufptr, true, false, true))
                                break;
-                       if (strcmp(com_token, "\n") && strcmp(com_token, "//"))
-                               loop = atoi(com_token) != 0;
-                       else
-                               loop = true;
-               }
-               else
-               {
-                       fps = 20;
-                       loop = true;
                }
 
-               if (strcmp(com_token, "\n") && strcmp(com_token, "//"))
+               // OPTIONAL: fetch loopflag
+               loop = true;
+               if (strcmp(com_token, "\n"))
                {
-                       while (COM_ParseToken_Simple(&bufptr, true, false, false)) // fetch newline
-                       {
-                               if (strcmp(com_token, "\n") && strcmp(com_token, "//"))
-                                       Con_Printf("framegroups file: extra data (%s) found, skipped\n", com_token);
-                               else
-                                       break;
-                       }
+                       loop = (atoi(com_token) != 0);
+                       if (!COM_ParseToken_Simple(&bufptr, true, false, true))
+                               break;
                }
 
-               name = NULL;
-               if(!strcmp(com_token, "//"))
+               // OPTIONAL: fetch name
+               name[0] = 0;
+               if (strcmp(com_token, "\n"))
                {
-                       if (COM_ParseToken_Simple(&bufptr, true, false, false))
-                       {
-                               if(strcmp(com_token, "\n"))
-                               {
-                                       name = com_token;
-                                       // skip to EOL
-                                       while (*bufptr && !(*bufptr == '\n' || *bufptr == '\r'))
-                                               bufptr++;
-                                       while (*bufptr && (*bufptr == '\n' || *bufptr == '\r'))
-                                               bufptr++;
-                               }
-                       }
+                       strlcpy(name, com_token, sizeof(name));
+                       if (!COM_ParseToken_Simple(&bufptr, true, false, true))
+                               break;
                }
+
                //Con_Printf("data: %d %d %d %f %d (%s)\n", i, start, len, fps, loop, name);
 
                if(cb)
-                       cb(i, start, len, fps, loop, name, pass);
+                       cb(i, start, len, fps, loop, (name[0] ? name : NULL), pass);
                ++i;
        }