summaryrefslogtreecommitdiff
path: root/tier2/util_init.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /tier2/util_init.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'tier2/util_init.cpp')
-rw-r--r--tier2/util_init.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tier2/util_init.cpp b/tier2/util_init.cpp
new file mode 100644
index 0000000..1fb1ddd
--- /dev/null
+++ b/tier2/util_init.cpp
@@ -0,0 +1,50 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: perform initialization needed in most command line programs
+//
+//===================================================================================-=//
+
+#include <tier0/platform.h>
+#include <tier2/tier2.h>
+#include <mathlib/mathlib.h>
+#include <tier0/icommandline.h>
+#include "tier0/memalloc.h"
+#include "tier0/progressbar.h"
+#include "tier1/strtools.h"
+
+
+static void PrintFReportHandler(char const *job_name, int total_units_to_do, int n_units_completed)
+{
+ static bool work_in_progress=false;
+ static char LastJobName[1024];
+ if ( Q_strncmp( LastJobName, job_name, sizeof( LastJobName ) ) )
+ {
+ if ( work_in_progress )
+ printf("..done\n");
+ Q_strncpy( LastJobName, job_name, sizeof( LastJobName ) );
+ }
+ if ( (total_units_to_do > 0 ) && (total_units_to_do >= n_units_completed) )
+ {
+ int percent_done=(100*n_units_completed)/total_units_to_do;
+ printf("\r%s : %d%%",LastJobName, percent_done );
+ work_in_progress = true;
+ }
+ else
+ {
+ printf("%s\n",LastJobName);
+ work_in_progress = false;
+ }
+}
+
+void InitCommandLineProgram( int argc, char **argv )
+{
+ MathLib_Init( 1,1,1,0,false,true,true,true);
+ CommandLine()->CreateCmdLine( argc, argv );
+ InitDefaultFileSystem();
+ InstallProgressReportHandler( PrintFReportHandler );
+
+ // By default, command line programs should not use the new assert dialog,
+ // and any asserts should be fatal, unless we are being debugged
+ if ( !Plat_IsInDebugSession() )
+ SpewOutputFunc( DefaultSpewFuncAbortOnAsserts );
+}