diff --git a/ReflexToQ3/includes/oopless-parser.cpp b/ReflexToQ3/includes/oopless-parser.cpp index 072092c..023b02b 100644 --- a/ReflexToQ3/includes/oopless-parser.cpp +++ b/ReflexToQ3/includes/oopless-parser.cpp @@ -1,5 +1,3 @@ - - #define KEYWORD_ENTITY "entity" #define KEYWORD_BRUSH "brush" #define KEYWORD_VERTICES "vertices" @@ -14,6 +12,18 @@ #include using namespace std; +bool is_ebrush(std::vector input) { +// defines are only used in this function. +#define KEYWORD_ENTBRUSH1 "type Teleporter" +#define KEYWORD_ENTBRUSH2 "type JumpPad" + for (const string &str : input) { + if (str.compare(KEYWORD_ENTBRUSH1) == 0 || + str.compare(KEYWORD_ENTBRUSH2) == 0) { + return true; + } + } + return false; +} // place holding functions to test proper control flow. bool write(const struct TBrush &geometry, @@ -45,9 +55,12 @@ vector get_entity(ifstream &f) { string line; unsigned int pos = f.tellg(); while (getline(f, line)) { - if (line.find(KEYWORD_ENTITY) != string::npos || - line.find(KEYWORD_BRUSH) != string::npos || - line.find(KEYWORD_PREFAB) != string::npos) { + // stop when + // entity or a prefab keyword + // brush keyword and the entity is not of the type teleporter or jumppad. + if ((line.find(KEYWORD_ENTITY) != string::npos || + line.find(KEYWORD_PREFAB) != string::npos) || ( + line.find(KEYWORD_BRUSH) != string::npos && !is_ebrush(output))) { f.seekg(pos); return output; } else {