From 63f4e0c538ca8f14b1e4fd30d032104e99c930e3 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 5 Nov 2011 14:04:12 +0000 Subject: [PATCH] framegroups parsing: make 5th arg animation name, not comment git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11523 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 68 +++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/model_shared.c b/model_shared.c index 296d799e..05cb3427 100644 --- a/model_shared.c +++ b/model_shared.c @@ -239,23 +239,27 @@ typedef void (*mod_framegroupify_parsegroups_t) (unsigned int i, int start, int static 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 @@ static int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_pars 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; } -- 2.39.2