From 697cce13efdc75fd0f51b6bf53a4acbd9c155d4d Mon Sep 17 00:00:00 2001 From: <> Date: Tue, 11 Apr 2017 04:30:36 -0700 Subject: [PATCH] TFace attributes offset, scale, and rotation are assigned. --- ReflexToQ3/includes/v8mapparser.cpp | 75 +++++++++++------------------ 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/ReflexToQ3/includes/v8mapparser.cpp b/ReflexToQ3/includes/v8mapparser.cpp index 34f04f0..b622ae9 100644 --- a/ReflexToQ3/includes/v8mapparser.cpp +++ b/ReflexToQ3/includes/v8mapparser.cpp @@ -226,56 +226,35 @@ EParserState CMapParser::ParseVertex(const std::string _Line) return(PARSERSTATE_VERTEX); } -EParserState CMapParser::ParseFace(const std::string _Line) -{ - const size_t kszLineSize = 2048; - char pcLine[kszLineSize]; - const char* kpcDelim = " \t"; - char* pcToken; - char* pcContext; - - strcpy_s(pcLine, _Line.c_str()); - pcToken = strtok_s(pcLine, kpcDelim, &pcContext); - - int iTokenNum = 0; - - std::string material; - - std::vector Indices; - while(pcToken != nullptr) - { - if(iTokenNum < 5) - { - if(std::isdigit(pcToken[0], std::locale()) || pcToken[0] == '-') - { - double dValue = std::stod(pcToken); - } - else - { - return(PARSERSTATE_BRUSH); - } - } else if (iTokenNum == 9) { - // this should be '0x' something, which wasn't in V6. +EParserState CMapParser::ParseFace(const std::string _Line) { + stringstream ss(_Line); + string material; + vector Indices; + TFace Face; + float *f = &Face.m_fXOffset; + string data; + unsigned int i = 0; + // For a primitive in Reflex, there is at least 9 and at most 10 fields. + while (ss >> data) { + if (i < 5) { + if (isdigit(data[0], std::locale()) || data[0] == '-') { + double dvalue = stod(data); + *f = (float)dvalue; + f++; + } else { + return PARSERSTATE_BRUSH; + } + } else if (i == 9) { ; + } else { + if (isdigit(data[0], std::locale()) || data[0] == '-') { + Indices.push_back(stoi(data)); + } else { + material = data; + } } - else - { - if(std::isdigit(pcToken[0], std::locale()) || pcToken[0] == '-') - { - int iValue = std::stoi(pcToken); - Indices.push_back(iValue); - } - else - { - material = pcToken; - } - } - - iTokenNum++; - pcToken = strtok_s(nullptr, kpcDelim, &pcContext); - } - - TFace Face; + i++; + } Face.m_Indices = Indices; Face.m_Material = material; m_WorldSpawn.m_Brushes[m_WorldSpawn.m_Brushes.size()-1].m_Faces.push_back(Face);