Changed output queue to vector

This commit is contained in:
2017-07-06 13:52:31 -07:00
parent 7595b42593
commit 984ff03c80
3 changed files with 12 additions and 15 deletions

View File

@ -103,20 +103,20 @@ vector<string> get_entity(ifstream &f) {
void parse_prefab(ifstream &f,
ofstream &out,
void (*b) (stringstream &, const vector<TPlanePoints> &),
queue<vector<string> > &entities) {
vector<vector<string> > &entities) {
string l;
getline(f, l);
if (l.find(KEYWORD_BRUSH) != string::npos) {
write(parse_brush<ifstream>(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<TPlanePoints> &),
queue<vector<string> > &entities) {
vector<vector<string> > &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<ifstream>(fin), fout, brushdef);
}

View File

@ -26,12 +26,12 @@ std::vector<std::string> get_entity(std::ifstream &);
void parse_prefab(std::ifstream &,
std::ofstream &,
void (*f) (std::stringstream &, const std::vector<TPlanePoints> &),
std::queue<std::vector<std::string> > &);
std::vector<std::vector<std::string> > &);
bool convertmap(const char * const,
const char * const,
void (*f) (std::stringstream &, const std::vector<TPlanePoints> &),
std::queue<std::vector<std::string> > &);
std::vector<std::vector<std::string> > &);
#define KEYWORD_ENTITY "entity"
#define KEYWORD_BRUSH "brush"

View File

@ -54,7 +54,7 @@ cxxopts::Options arguments(int ac, char ** av) {
}
bool convert_worldspawn(const cxxopts::Options &o,
queue<vector<string> > &q) {
vector<vector<string> > &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<vector<string> > &q) {
void print_entities(vector<vector<string> > &q) {
vector<string> entity;
do {
entity = q.front();
@ -92,12 +92,11 @@ void print_entities(queue<vector<string> > &q) {
cout << s << endl;
}
cout << "--------------------------" << endl;
q.pop();
} while (!q.empty());
}
void convert_entities(const cxxopts::Options &o, queue<vector<string> > &q) {
void convert_entities(const cxxopts::Options &o, vector<vector<string> > &q) {
string entfile = o["e"].as<string>();
if (entfile.empty()) {
cout << "No entity data file given"
@ -111,18 +110,16 @@ void convert_entities(const cxxopts::Options &o, queue<vector<string> > &q) {
if (o.count(ARG_BRUSHFORMAT)) {
fn = &brushdef_gtk;
}
do {
entity = q.front();
for (const vector<string> &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<vector<string> > entities;
vector<vector<string> > entities;
bool is_ok = convert_worldspawn(p, entities);
// print_entities(entities);
convert_entities(p, entities);