reflex2q3/ReflexToQ3/main.cpp

70 lines
1.3 KiB
C++
Raw Normal View History

2015-02-02 08:11:03 +05:30
//
// Author: Michael Cameron
// Email: chronokun@hotmail.com
//
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#ifdef V8
#include "v8mapparser.hpp"
typedef V8MapParser CMapParser;
#else
#include "v6mapparser.hpp"
typedef V6MapParser CMapParser;
#endif
2017-04-11 20:57:10 +05:30
#include "brushdef.hpp"
2015-02-02 08:11:03 +05:30
using namespace std;
// .map files for GTKRadiant
2017-04-11 20:57:10 +05:30
bool writemap(const TWorldSpawn &x,
const char *fn,
void (*f) (std::stringstream &, const vector<TPlanePoints> &)) {
ofstream OutFile;
OutFile.open(fn);
if(!OutFile.is_open())
{
return false;
}
OutFile << "{" << std::endl
<< "\"classname\" \"worldspawn\"" << std::endl;
for(const TBrush& krBrush : x.m_Brushes)
{
2017-04-11 20:57:10 +05:30
OutFile << GetBrushString(krBrush, f);
}
OutFile << "}" << std::endl;
return true;
}
2015-02-02 08:11:03 +05:30
int main(const int _kiArgC, const char** _kppcArgv)
{
// Check we have correct number of parameters
if(_kiArgC < 3)
{
return(3);
}
CMapParser Parser;
const bool kbSuccess = Parser.LoadMap(_kppcArgv[1]);
if(!kbSuccess)
{
return(1);
}
else
{
2017-04-11 20:57:10 +05:30
if (writemap(Parser.m_WorldSpawn, _kppcArgv[2], &brushdef_net)) {
cout << "Successfully exported map." << endl;
} else {
cout << "Failed to write output file." << endl;
}
2015-02-02 08:11:03 +05:30
}
return(0);
2017-04-02 19:34:09 +05:30
}