From 0428d31ad7a7724cca5023eb3f5a63e4d5edacdc Mon Sep 17 00:00:00 2001 From: <> Date: Thu, 15 Jun 2017 07:09:38 -0700 Subject: [PATCH] Added function to identify jumppads and teleporters --- ReflexToQ3/includes/oopless-parser.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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 {