Moved file output segment to its own function.

This commit is contained in:
2017-04-10 14:29:47 -07:00
parent 19f97c27c1
commit 4c529c4f82

View File

@ -9,6 +9,34 @@
#include "mapparser.h" #include "mapparser.h"
#include "planes.h" #include "planes.h"
using namespace std;
// .map files for GTKRadiant
bool brushdef_legacy(const TWorldSpawn &x, const char *fn) {
cout << fn << endl;
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);
}
OutFile << "}" << std::endl;
return true;
}
// .map files for NetRadiant
void brushdef(const TWorldSpawn &x, const char *fn) {
}
int main(const int _kiArgC, const char** _kppcArgv) int main(const int _kiArgC, const char** _kppcArgv)
{ {
// Check we have correct number of parameters // Check we have correct number of parameters
@ -26,23 +54,11 @@ int main(const int _kiArgC, const char** _kppcArgv)
} }
else else
{ {
// Open output file if (brushdef_legacy(Parser.m_WorldSpawn,_kppcArgv[2])) {
std::ofstream OutFile; cout << "Successfully exported map." << endl;
OutFile.open(_kppcArgv[2]); } else {
if(!OutFile.is_open()) cout << "Failed to write output file." << endl;
{
return(2);
} }
OutFile << "{" << std::endl
<< "\"classname\" \"worldspawn\"" << std::endl;
for(const TBrush& krBrush : Parser.m_WorldSpawn.m_Brushes)
{
OutFile << GetBrushString(krBrush);
}
OutFile << "}" << std::endl;
} }
return(0); return(0);