fix bug when reading strings in quote in MD5 models
parent
6fa385549c
commit
96a64a353a
|
@ -228,6 +228,15 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
::memcpy(out.data,szStart,out.length); \
|
::memcpy(out.data,szStart,out.length); \
|
||||||
out.data[out.length] = '\0';
|
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
|
// .MD5MESH parsing function
|
||||||
MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
|
@ -249,7 +258,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
BoneDesc& desc = mJoints.back();
|
BoneDesc& desc = mJoints.back();
|
||||||
|
|
||||||
const char* sz = elem.szStart;
|
const char* sz = elem.szStart;
|
||||||
AI_MD5_PARSE_STRING(desc.mName);
|
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
// negative values, at least -1, is allowed here
|
// negative values, at least -1, is allowed here
|
||||||
|
@ -269,7 +278,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
// shader attribute
|
// shader attribute
|
||||||
if (TokenMatch(sz,"shader",6)) {
|
if (TokenMatch(sz,"shader",6)) {
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
AI_MD5_PARSE_STRING(desc.mShader);
|
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader);
|
||||||
}
|
}
|
||||||
// numverts attribute
|
// numverts attribute
|
||||||
else if (TokenMatch(sz,"numverts",8)) {
|
else if (TokenMatch(sz,"numverts",8)) {
|
||||||
|
@ -362,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
|
||||||
AnimBoneDesc& desc = mAnimatedBones.back();
|
AnimBoneDesc& desc = mAnimatedBones.back();
|
||||||
|
|
||||||
const char* sz = elem.szStart;
|
const char* sz = elem.szStart;
|
||||||
AI_MD5_PARSE_STRING(desc.mName);
|
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
// parent index - negative values are allowed (at least -1)
|
// parent index - negative values are allowed (at least -1)
|
||||||
|
|
Loading…
Reference in New Issue