From 984ff03c80fe718ebe953da0b7ed5e26933ac5f5 Mon Sep 17 00:00:00 2001 From: <> Date: Thu, 6 Jul 2017 13:52:31 -0700 Subject: [PATCH] Changed output queue to vector --- ReflexToQ3/includes/oopless-parser.cpp | 8 ++++---- ReflexToQ3/includes/oopless-parser.hpp | 4 ++-- ReflexToQ3/main.cpp | 15 ++++++--------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ReflexToQ3/includes/oopless-parser.cpp b/ReflexToQ3/includes/oopless-parser.cpp index bf9700f..94dc062 100644 --- a/ReflexToQ3/includes/oopless-parser.cpp +++ b/ReflexToQ3/includes/oopless-parser.cpp @@ -103,20 +103,20 @@ vector get_entity(ifstream &f) { void parse_prefab(ifstream &f, ofstream &out, void (*b) (stringstream &, const vector &), - queue > &entities) { + vector > &entities) { string l; getline(f, l); if (l.find(KEYWORD_BRUSH) != string::npos) { write(parse_brush(f), out, b); } else if (l.find(KEYWORD_ENTITY) != string::npos) { - entities.push(get_entity(f)); + entities.push_back(get_entity(f)); } } bool convertmap(const char * const infile, const char * const outfile, void (*brushdef) (stringstream &, const vector &), - queue > &entities) { + vector > &entities) { ifstream fin; fin.open(infile); if (!fin.good()){ @@ -137,7 +137,7 @@ bool convertmap(const char * const infile, line.find(KEYWORD_GLOBAL) != string::npos) { parse_prefab(fin, fout, brushdef, entities); } else if (line.find(KEYWORD_ENTITY) != string::npos) { - entities.push(get_entity(fin)); + entities.push_back(get_entity(fin)); } else if (line.find(KEYWORD_BRUSH) != string::npos) { write(parse_brush(fin), fout, brushdef); } diff --git a/ReflexToQ3/includes/oopless-parser.hpp b/ReflexToQ3/includes/oopless-parser.hpp index dede6f9..096e9cb 100644 --- a/ReflexToQ3/includes/oopless-parser.hpp +++ b/ReflexToQ3/includes/oopless-parser.hpp @@ -26,12 +26,12 @@ std::vector get_entity(std::ifstream &); void parse_prefab(std::ifstream &, std::ofstream &, void (*f) (std::stringstream &, const std::vector &), - std::queue > &); + std::vector > &); bool convertmap(const char * const, const char * const, void (*f) (std::stringstream &, const std::vector &), - std::queue > &); + std::vector > &); #define KEYWORD_ENTITY "entity" #define KEYWORD_BRUSH "brush" diff --git a/ReflexToQ3/main.cpp b/ReflexToQ3/main.cpp index a0ae841..fe0bbcc 100644 --- a/ReflexToQ3/main.cpp +++ b/ReflexToQ3/main.cpp @@ -54,7 +54,7 @@ cxxopts::Options arguments(int ac, char ** av) { } bool convert_worldspawn(const cxxopts::Options &o, - queue > &q) { + vector > &q) { bool is_ok = false; brushdef fn = &brushdef_net; if (o.count(ARG_BRUSHFORMAT)) { @@ -83,7 +83,7 @@ bool convert_worldspawn(const cxxopts::Options &o, return is_ok; } -void print_entities(queue > &q) { +void print_entities(vector > &q) { vector entity; do { entity = q.front(); @@ -92,12 +92,11 @@ void print_entities(queue > &q) { cout << s << endl; } cout << "--------------------------" << endl; - q.pop(); } while (!q.empty()); } -void convert_entities(const cxxopts::Options &o, queue > &q) { +void convert_entities(const cxxopts::Options &o, vector > &q) { string entfile = o["e"].as(); if (entfile.empty()) { cout << "No entity data file given" @@ -111,18 +110,16 @@ void convert_entities(const cxxopts::Options &o, queue > &q) { if (o.count(ARG_BRUSHFORMAT)) { fn = &brushdef_gtk; } - do { - entity = q.front(); + for (const vector &entity : q) { write(entity, fout, fn, e); - q.pop(); - } while(!q.empty()); + } } int main(int argc, char** argv) { cxxopts::Options p = arguments(argc, argv); - queue > entities; + vector > entities; bool is_ok = convert_worldspawn(p, entities); // print_entities(entities); convert_entities(p, entities);