70 lines
1.3 KiB
C++
70 lines
1.3 KiB
C++
//
|
|
// 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
|
|
#include "brushdef.hpp"
|
|
|
|
using namespace std;
|
|
// .map files for GTKRadiant
|
|
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)
|
|
{
|
|
OutFile << GetBrushString(krBrush, f);
|
|
}
|
|
|
|
OutFile << "}" << std::endl;
|
|
return true;
|
|
}
|
|
|
|
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
|
|
{
|
|
if (writemap(Parser.m_WorldSpawn, _kppcArgv[2], &brushdef_net)) {
|
|
cout << "Successfully exported map." << endl;
|
|
} else {
|
|
cout << "Failed to write output file." << endl;
|
|
}
|
|
}
|
|
|
|
return(0);
|
|
} |