Added function to identify jumppads and teleporters

This commit is contained in:
2017-06-15 07:09:38 -07:00
parent 98abd5c184
commit 0428d31ad7

View File

@ -1,5 +1,3 @@
#define KEYWORD_ENTITY "entity"
#define KEYWORD_BRUSH "brush"
#define KEYWORD_VERTICES "vertices"
@ -14,6 +12,18 @@
#include <iostream>
using namespace std;
bool is_ebrush(std::vector<std::string> 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<string> 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 {