From 4c529c4f8242466ba10100fb26353b986b7eb4e8 Mon Sep 17 00:00:00 2001 From: <> Date: Mon, 10 Apr 2017 14:29:47 -0700 Subject: [PATCH] Moved file output segment to its own function. --- ReflexToQ3/main.cpp | 50 ++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/ReflexToQ3/main.cpp b/ReflexToQ3/main.cpp index cf9f653..39f3af1 100644 --- a/ReflexToQ3/main.cpp +++ b/ReflexToQ3/main.cpp @@ -9,6 +9,34 @@ #include "mapparser.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) { // Check we have correct number of parameters @@ -26,23 +54,11 @@ int main(const int _kiArgC, const char** _kppcArgv) } else { - // Open output file - std::ofstream OutFile; - OutFile.open(_kppcArgv[2]); - if(!OutFile.is_open()) - { - return(2); - } - - OutFile << "{" << std::endl - << "\"classname\" \"worldspawn\"" << std::endl; - - for(const TBrush& krBrush : Parser.m_WorldSpawn.m_Brushes) - { - OutFile << GetBrushString(krBrush); - } - - OutFile << "}" << std::endl; + if (brushdef_legacy(Parser.m_WorldSpawn,_kppcArgv[2])) { + cout << "Successfully exported map." << endl; + } else { + cout << "Failed to write output file." << endl; + } } return(0);