From 31df64b2721bed2ac2c8d4a37ced76173bf4b603 Mon Sep 17 00:00:00 2001 From: <> Date: Thu, 6 Apr 2017 17:05:11 -0700 Subject: [PATCH] Placed hardcoded keywords into defines & cleaned up scraps --- ReflexToQ3/includes/v8mapparser.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ReflexToQ3/includes/v8mapparser.cpp b/ReflexToQ3/includes/v8mapparser.cpp index b550e10..34f04f0 100644 --- a/ReflexToQ3/includes/v8mapparser.cpp +++ b/ReflexToQ3/includes/v8mapparser.cpp @@ -3,9 +3,7 @@ // Email: chronokun@hotmail.com // -// Libraries Include #include "libraries.h" -// This Include #include "v8mapparser.h" using namespace std; @@ -24,6 +22,13 @@ inline char *strcpy_s(char *dest, const char *src) { } #endif +#define KEYWORD_GLOBAL "\tglobal" +#define KEYWORD_PREFAB "\tprefab" +#define KEYWORD_ENTITY "\tentity" +#define KEYWORD_BRUSH "\tbrush" +#define KEYWORD_VERTICES "\tvertices" +#define KEYWORD_FACES "\tfaces" + const bool CMapParser::LoadMap(const char* _kpcFileName) { std::ifstream InFile; @@ -47,11 +52,11 @@ const bool CMapParser::LoadMap(const char* _kpcFileName) bAdvance = true; if(eState == PARSERSTATE_UNKNOWN) { - if(Line.find("entity") != string::npos) + if(Line.find(KEYWORD_ENTITY) != string::npos) { eState = PARSERSTATE_ENTITY; continue; - } else if (Line.find("prefab") != string::npos || Line.find("global") != string::npos) { + } else if (Line.find(KEYWORD_PREFAB) != string::npos || Line.find(KEYWORD_GLOBAL) != string::npos) { // prefab and global share an indentation level // both encapsulate similar objects eState = PARSERSTATE_PREFAB; @@ -107,7 +112,7 @@ EParserState CMapParser::ParsePrefab(const std::string _Line) { // if prefabs are simply broken and de-indented. // typically entities are listed first, then brushes, but just in case. - if (_Line.find("entity") != string::npos) { + if (_Line.find(KEYWORD_ENTITY) != string::npos) { return PARSERSTATE_ENTITY; } else { return PARSERSTATE_BRUSH; @@ -125,7 +130,7 @@ EParserState CMapParser::ParseEntity(const std::string _Line) strcpy_s(pcLine, _Line.c_str()); pcToken = strtok_s(pcLine, kpcDelim, &pcContext); - if (_Line.find("\tbrush") != string::npos) { + if (_Line.find(KEYWORD_BRUSH) != string::npos) { m_WorldSpawn.m_Brushes.push_back(TBrush()); return PARSERSTATE_BRUSH; } @@ -153,7 +158,7 @@ EParserState CMapParser::ParseEntity(const std::string _Line) EParserState CMapParser::ParseWorldSpawn(const std::string _Line) { - if(_Line.find("brush") != string::npos) + if(_Line.find(KEYWORD_BRUSH) != string::npos) { m_WorldSpawn.m_Brushes.push_back(TBrush()); return(PARSERSTATE_BRUSH); @@ -163,16 +168,16 @@ EParserState CMapParser::ParseWorldSpawn(const std::string _Line) EParserState CMapParser::ParseBrush(const std::string _Line) { - if(_Line.find("brush") != string::npos) + if(_Line.find(KEYWORD_BRUSH) != string::npos) { m_WorldSpawn.m_Brushes.push_back(TBrush()); return(PARSERSTATE_BRUSH); } - if(_Line.find("\tvertices") != string::npos) + if(_Line.find(KEYWORD_VERTICES) != string::npos) { return(PARSERSTATE_VERTEX); } - else if(_Line.find("\tfaces") != string::npos) + else if(_Line.find(KEYWORD_FACES) != string::npos) { return(PARSERSTATE_FACE); } @@ -217,7 +222,6 @@ EParserState CMapParser::ParseVertex(const std::string _Line) pcToken = strtok_s(NULL, kpcDelim, &pcContext); } - //this->m_WorldSpawn.m_Brushes[this->m_WorldSpawn.m_Brushes.size()-1].m_Vertices.push_back(Vert); m_WorldSpawn.m_Brushes[m_WorldSpawn.m_Brushes.size()-1].m_Vertices.push_back(Vert); return(PARSERSTATE_VERTEX); } @@ -274,7 +278,6 @@ EParserState CMapParser::ParseFace(const std::string _Line) TFace Face; Face.m_Indices = Indices; Face.m_Material = material; - //this->m_WorldSpawn.m_Brushes[this->m_WorldSpawn.m_Brushes.size()-1].m_Faces.push_back(Face); m_WorldSpawn.m_Brushes[m_WorldSpawn.m_Brushes.size()-1].m_Faces.push_back(Face); return(PARSERSTATE_FACE); }