From: divverent Date: Sat, 5 Nov 2011 14:04:12 +0000 (+0000) Subject: framegroups parsing: make 5th arg animation name, not comment X-Git-Tag: xonotic-v0.6.0~183 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ea88b71634284cf4f34c8e941d557e78c77c1e18;p=xonotic%2Fdarkplaces.git 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 ::stable-branch::merge=63f4e0c538ca8f14b1e4fd30d032104e99c930e3 --- diff --git a/model_shared.c b/model_shared.c index b7813728..b76459b1 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 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; }