E. conversion set up - some output causes parsing error in editors
This commit is contained in:
parent
ff1f57fdaa
commit
e2ee4e1325
@ -13,10 +13,15 @@
|
||||
#include "oopless-parser.hpp"
|
||||
#include "brushdef.hpp"
|
||||
|
||||
#define ARG_INPUT_SHORTALIAS "i"
|
||||
#define ARG_OUTPUT_SHORTALIAS "o"
|
||||
using namespace std;
|
||||
|
||||
//ease of reading function pointer
|
||||
typedef void (*brushdef) (std::stringstream &,
|
||||
const std::vector<TPlanePoints> &);
|
||||
|
||||
#define ARG_INPUT_SHORTALIAS "i"
|
||||
#define ARG_OUTPUT_SHORTALIAS "o"
|
||||
#define ARG_BRUSHFORMAT "gtk"
|
||||
cxxopts::Options arguments(int ac, char ** av) {
|
||||
vector<string> parg = {"input", "output"};
|
||||
cxxopts::Options o("reflex2q3",
|
||||
@ -29,7 +34,7 @@ cxxopts::Options arguments(int ac, char ** av) {
|
||||
("o,output",
|
||||
"required, output map file, for idTech 3 or similar map editors",
|
||||
cxxopts::value<string>(), "FILE")
|
||||
("gtk",
|
||||
(ARG_BRUSHFORMAT,
|
||||
"optional, output in GTK Radiant's brush definition format")
|
||||
("e,ent",
|
||||
"optional, convert game entities given a table of equivalents",
|
||||
@ -50,12 +55,9 @@ cxxopts::Options arguments(int ac, char ** av) {
|
||||
|
||||
bool convert_worldspawn(const cxxopts::Options &o,
|
||||
queue<vector<string> > &q) {
|
||||
//ease of reading
|
||||
typedef void (*brushdef) (std::stringstream &,
|
||||
const std::vector<TPlanePoints> &);
|
||||
bool is_ok = false;
|
||||
brushdef fn = &brushdef_net;
|
||||
if (o.count("gtk")) {
|
||||
if (o.count(ARG_BRUSHFORMAT)) {
|
||||
fn = &brushdef_gtk;
|
||||
}
|
||||
try {
|
||||
@ -81,26 +83,48 @@ typedef void (*brushdef) (std::stringstream &,
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
// wip: current a print out of all entities
|
||||
bool convert_entities(const cxxopts::Options &o, queue<vector<string> > &q) {
|
||||
vector<string> entity;
|
||||
void print_entities(queue<vector<string> > &q) {
|
||||
vector<string> entity;
|
||||
do {
|
||||
entity = q.front();
|
||||
cout << "--------------------------" << endl;
|
||||
for (const string &s : entity) {
|
||||
cout << s << endl;
|
||||
}
|
||||
cout << "--------------------------" << endl;
|
||||
q.pop();
|
||||
} while (!q.empty());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void convert_entities(const cxxopts::Options &o, queue<vector<string> > &q) {
|
||||
string entfile = o["e"].as<string>();
|
||||
if (entfile.empty()) {
|
||||
cout << "No entity data file given"
|
||||
"- skipping entity conversion" << endl;
|
||||
return;
|
||||
}
|
||||
EntityConverter e(entfile, o[ARG_INPUT_SHORTALIAS].as<string>());
|
||||
ofstream fout(o[ARG_OUTPUT_SHORTALIAS].as<string>(), ios::app);
|
||||
brushdef fn = &brushdef_net;
|
||||
vector<string> entity;
|
||||
if (o.count(ARG_BRUSHFORMAT)) {
|
||||
fn = &brushdef_gtk;
|
||||
}
|
||||
do {
|
||||
entity = q.front();
|
||||
write(entity, fout, fn, e);
|
||||
q.pop();
|
||||
} while(!q.empty());
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
string entityfile;
|
||||
cxxopts::Options p = arguments(argc, argv);
|
||||
|
||||
queue<vector<string> > entities;
|
||||
bool is_ok = convert_worldspawn(p, entities);
|
||||
// print_entities(entities);
|
||||
convert_entities(p, entities);
|
||||
return(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user