Added robust program options & prepared for entity conversion
This commit is contained in:
@@ -103,32 +103,26 @@ vector<string> get_entity(ifstream &f) {
|
||||
void parse_prefab(ifstream &f,
|
||||
ofstream &out,
|
||||
void (*b) (stringstream &, const vector<TPlanePoints> &),
|
||||
EntityConverter &e) {
|
||||
queue<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) {
|
||||
write(get_entity(f), out, b, e);
|
||||
entities.push(get_entity(f));
|
||||
}
|
||||
}
|
||||
|
||||
bool convertmap(const char * const infile,
|
||||
const char * const outfile,
|
||||
void (*brushdef) (stringstream &, const vector<TPlanePoints> &),
|
||||
const char * const entfile) {
|
||||
queue<vector<string> > &entities) {
|
||||
ifstream fin;
|
||||
fin.open(infile);
|
||||
if (!fin.good()){
|
||||
cerr << "error: failed to open input file" << endl;
|
||||
return false;
|
||||
}
|
||||
EntityConverter ec;
|
||||
if (entfile != NULL) {
|
||||
string ef(entfile);
|
||||
string in(infile);
|
||||
ec = EntityConverter(ef, in);
|
||||
}
|
||||
ofstream fout;
|
||||
fout.open(outfile);
|
||||
if (!fout.good()) {
|
||||
@@ -141,9 +135,9 @@ bool convertmap(const char * const infile,
|
||||
while (getline(fin, line)) {
|
||||
if (line.find(KEYWORD_PREFAB) != string::npos ||
|
||||
line.find(KEYWORD_GLOBAL) != string::npos) {
|
||||
parse_prefab(fin, fout, brushdef, ec);
|
||||
parse_prefab(fin, fout, brushdef, entities);
|
||||
} else if (line.find(KEYWORD_ENTITY) != string::npos) {
|
||||
write(get_entity(fin), fout, brushdef, ec);
|
||||
entities.push(get_entity(fin));
|
||||
} else if (line.find(KEYWORD_BRUSH) != string::npos) {
|
||||
write(parse_brush<ifstream>(fin), fout, brushdef);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user