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 "oopless-parser.hpp"
|
||||||
#include "brushdef.hpp"
|
#include "brushdef.hpp"
|
||||||
|
|
||||||
#define ARG_INPUT_SHORTALIAS "i"
|
|
||||||
#define ARG_OUTPUT_SHORTALIAS "o"
|
|
||||||
using namespace std;
|
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) {
|
cxxopts::Options arguments(int ac, char ** av) {
|
||||||
vector<string> parg = {"input", "output"};
|
vector<string> parg = {"input", "output"};
|
||||||
cxxopts::Options o("reflex2q3",
|
cxxopts::Options o("reflex2q3",
|
||||||
@ -29,7 +34,7 @@ cxxopts::Options arguments(int ac, char ** av) {
|
|||||||
("o,output",
|
("o,output",
|
||||||
"required, output map file, for idTech 3 or similar map editors",
|
"required, output map file, for idTech 3 or similar map editors",
|
||||||
cxxopts::value<string>(), "FILE")
|
cxxopts::value<string>(), "FILE")
|
||||||
("gtk",
|
(ARG_BRUSHFORMAT,
|
||||||
"optional, output in GTK Radiant's brush definition format")
|
"optional, output in GTK Radiant's brush definition format")
|
||||||
("e,ent",
|
("e,ent",
|
||||||
"optional, convert game entities given a table of equivalents",
|
"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,
|
bool convert_worldspawn(const cxxopts::Options &o,
|
||||||
queue<vector<string> > &q) {
|
queue<vector<string> > &q) {
|
||||||
//ease of reading
|
|
||||||
typedef void (*brushdef) (std::stringstream &,
|
|
||||||
const std::vector<TPlanePoints> &);
|
|
||||||
bool is_ok = false;
|
bool is_ok = false;
|
||||||
brushdef fn = &brushdef_net;
|
brushdef fn = &brushdef_net;
|
||||||
if (o.count("gtk")) {
|
if (o.count(ARG_BRUSHFORMAT)) {
|
||||||
fn = &brushdef_gtk;
|
fn = &brushdef_gtk;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -81,26 +83,48 @@ typedef void (*brushdef) (std::stringstream &,
|
|||||||
return is_ok;
|
return is_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wip: current a print out of all entities
|
void print_entities(queue<vector<string> > &q) {
|
||||||
bool convert_entities(const cxxopts::Options &o, queue<vector<string> > &q) {
|
vector<string> entity;
|
||||||
vector<string> entity;
|
|
||||||
do {
|
do {
|
||||||
entity = q.front();
|
entity = q.front();
|
||||||
|
cout << "--------------------------" << endl;
|
||||||
for (const string &s : entity) {
|
for (const string &s : entity) {
|
||||||
cout << s << endl;
|
cout << s << endl;
|
||||||
}
|
}
|
||||||
|
cout << "--------------------------" << endl;
|
||||||
q.pop();
|
q.pop();
|
||||||
} while (!q.empty());
|
} 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)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
string entityfile;
|
|
||||||
cxxopts::Options p = arguments(argc, argv);
|
cxxopts::Options p = arguments(argc, argv);
|
||||||
|
|
||||||
queue<vector<string> > entities;
|
queue<vector<string> > entities;
|
||||||
bool is_ok = convert_worldspawn(p, entities);
|
bool is_ok = convert_worldspawn(p, entities);
|
||||||
|
// print_entities(entities);
|
||||||
convert_entities(p, entities);
|
convert_entities(p, entities);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user