From 97029c3c0c7950fe45b337e071930fd1d1c42598 Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 6 Nov 2011 19:43:34 +0000 Subject: [PATCH] change framegroups parsing so the final EOL is optional git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11532 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/model_shared.c b/model_shared.c index a1fc163f..1ebd90cd 100644 --- a/model_shared.c +++ b/model_shared.c @@ -247,21 +247,21 @@ static int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_pars bufptr = buf; i = 0; - for(;;) + while(bufptr) { // an anim scene! // REQUIRED: fetch start - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - break; + COM_ParseToken_Simple(&bufptr, true, false, true); + if (!bufptr) + break; // end of file if (!strcmp(com_token, "\n")) continue; // empty line start = atoi(com_token); // REQUIRED: fetch length - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - break; - if (!strcmp(com_token, "\n")) + COM_ParseToken_Simple(&bufptr, true, false, true); + if (!bufptr || !strcmp(com_token, "\n")) { Con_Printf("framegroups file: missing number of frames\n"); continue; @@ -269,47 +269,35 @@ static int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_pars len = atoi(com_token); // OPTIONAL args start - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - break; + COM_ParseToken_Simple(&bufptr, true, false, true); // OPTIONAL: fetch fps fps = 20; - if (strcmp(com_token, "\n")) + if (bufptr && strcmp(com_token, "\n")) { fps = atof(com_token); - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - break; + COM_ParseToken_Simple(&bufptr, true, false, true); } // OPTIONAL: fetch loopflag loop = true; - if (strcmp(com_token, "\n")) + if (bufptr && strcmp(com_token, "\n")) { loop = (atoi(com_token) != 0); - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - break; + COM_ParseToken_Simple(&bufptr, true, false, true); } // OPTIONAL: fetch name name[0] = 0; - if (strcmp(com_token, "\n")) + if (bufptr && strcmp(com_token, "\n")) { strlcpy(name, com_token, sizeof(name)); - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - break; + COM_ParseToken_Simple(&bufptr, true, false, true); } // OPTIONAL: remaining unsupported tokens (eat them) - while (strcmp(com_token, "\n")) - { - if (!COM_ParseToken_Simple(&bufptr, true, false, true)) - { - bufptr = NULL; - break; - } - } - if(!bufptr) - break; + while (bufptr && strcmp(com_token, "\n")) + COM_ParseToken_Simple(&bufptr, true, false, true); //Con_Printf("data: %d %d %d %f %d (%s)\n", i, start, len, fps, loop, name); -- 2.39.2