fix bug when reading strings in quote in MD5 models

pull/1029/head
amit512 2016-10-11 13:04:41 +03:00
parent 6fa385549c
commit 96a64a353a
1 changed files with 15 additions and 6 deletions

View File

@ -228,6 +228,15 @@ bool MD5Parser::ParseSection(Section& out)
::memcpy(out.data,szStart,out.length); \
out.data[out.length] = '\0';
// parse a string, enclosed in quotation marks
#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \
while('\"'!=*sz)++sz; \
const char* szStart = ++sz; \
while('\"'!=*sz)++sz; \
const char* szEnd = (sz++); \
out.length = (size_t)(szEnd - szStart); \
::memcpy(out.data,szStart,out.length); \
out.data[out.length] = '\0';
// ------------------------------------------------------------------------------------------------
// .MD5MESH parsing function
MD5MeshParser::MD5MeshParser(SectionList& mSections)
@ -249,7 +258,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
BoneDesc& desc = mJoints.back();
const char* sz = elem.szStart;
AI_MD5_PARSE_STRING(desc.mName);
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
AI_MD5_SKIP_SPACES();
// negative values, at least -1, is allowed here
@ -269,7 +278,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
// shader attribute
if (TokenMatch(sz,"shader",6)) {
AI_MD5_SKIP_SPACES();
AI_MD5_PARSE_STRING(desc.mShader);
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader);
}
// numverts attribute
else if (TokenMatch(sz,"numverts",8)) {
@ -362,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
AnimBoneDesc& desc = mAnimatedBones.back();
const char* sz = elem.szStart;
AI_MD5_PARSE_STRING(desc.mName);
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
AI_MD5_SKIP_SPACES();
// parent index - negative values are allowed (at least -1)