Skip to content

Commit 1981f65

Browse files
Do not spam Mikk message with cmd tools
1 parent 1bf33b1 commit 1981f65

File tree

10 files changed

+167
-8
lines changed

10 files changed

+167
-8
lines changed

neo/framework/Common.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ int com_frameNumber; // variable frame number
111111
volatile int com_ticNumber; // 60 hz tics
112112
int com_editors; // currently opened editor(s)
113113
bool com_editorActive; // true if an editor has focus
114+
bool com_editorCMDActive = false; // same as com_editors but for cmd tools
114115

115116
#ifdef _WIN32
116117
HWND com_hwndMsg = NULL;
@@ -506,7 +507,7 @@ void idCommonLocal::DWarning( const char *fmt, ... ) {
506507
va_end( argptr );
507508
msg[sizeof(msg)-1] = '\0';
508509

509-
Printf( S_COLOR_YELLOW"WARNING: %s\n", msg );
510+
Printf( S_COLOR_YELLOW"WARNING: " S_COLOR_GRAY "%s\n", msg );
510511
}
511512

512513
/*
@@ -715,6 +716,9 @@ void idCommonLocal::Error( const char *fmt, ... ) {
715716
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "vid_restart partial windowed\n" );
716717
}
717718

719+
// make sure no cmd tools are active
720+
com_editorCMDActive = false;
721+
718722
Shutdown();
719723

720724
Sys_Error( "%s", errorMessage );

neo/framework/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern int com_frameTime; // time for the current frame in milliseconds
8484
extern volatile int com_ticNumber; // 60 hz tics, incremented by async function
8585
extern int com_editors; // current active editor(s)
8686
extern bool com_editorActive; // true if an editor has focus
87+
extern bool com_editorCMDActive; // same as com_editors but for cmd tools
8788

8889
#ifdef _WIN32
8990
const char DMAP_MSGID[] = "DMAPOutput";

neo/idlib/Lib.cpp

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ If you have questions concerning this license or the applicable additional terms
5555

5656
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
5757
#if D3_IS_BIG_ENDIAN != 1
58-
#error "CMake (which sets D3_IS_BIG_ENDIAN) and SDL disagree about the endianess! CMake says little, SDL says big"
58+
#error "CMake (which sets D3_IS_BIG_ENDIAN) and SDL disagree about the endianess! CMake says little, SDL says big"
5959
#endif
6060
#elif SDL_BYTEORDER == SDL_LIL_ENDIAN
6161
#if D3_IS_BIG_ENDIAN != 0
62-
#error "CMake (which sets D3_IS_BIG_ENDIAN) and SDL disagree about the endianess! CMake says big, SDL says little"
62+
#error "CMake (which sets D3_IS_BIG_ENDIAN) and SDL disagree about the endianess! CMake says big, SDL says little"
6363
#endif
6464
#else
6565
#error "According to SDL, endianess is neither Big nor Little - dhewm3 doesn't support other byteorders!"
@@ -245,6 +245,28 @@ void UnpackColor( const dword color, idVec3 &unpackedColor ) {
245245
#endif
246246
}
247247

248+
/*
249+
===============
250+
idLib::FatalError
251+
===============
252+
*/
253+
void idLib::FatalError( const char* fmt, ... )
254+
{
255+
va_list argptr;
256+
char text[MAX_STRING_CHARS];
257+
258+
va_start( argptr, fmt );
259+
idStr::vsnPrintf( text, sizeof( text ), fmt, argptr );
260+
va_end( argptr );
261+
262+
common->FatalError( "%s", text );
263+
264+
#if !defined( _WIN32 )
265+
// SRS - Added exit to silence build warning since FatalError has attribute noreturn
266+
exit( EXIT_FAILURE );
267+
#endif
268+
}
269+
248270
/*
249271
===============
250272
idLib::Error
@@ -282,6 +304,93 @@ void idLib::Warning( const char *fmt, ... ) {
282304
common->Warning( "%s", text );
283305
}
284306

307+
/*
308+
===============
309+
idLib::WarningIf
310+
===============
311+
*/
312+
void idLib::WarningIf( const bool test, const char *fmt, ... ) {
313+
if ( !test ) {
314+
return;
315+
}
316+
317+
va_list argptr;
318+
char text[MAX_STRING_CHARS];
319+
320+
va_start( argptr, fmt );
321+
idStr::vsnPrintf( text, sizeof( text ), fmt, argptr );
322+
va_end( argptr );
323+
324+
common->Warning( "%s", text );
325+
}
326+
327+
/*
328+
===============
329+
idLib::DWarning
330+
===============
331+
*/
332+
void idLib::DWarning( const char *fmt, ... ) {
333+
va_list argptr;
334+
char text[MAX_STRING_CHARS];
335+
336+
va_start( argptr, fmt );
337+
idStr::vsnPrintf( text, sizeof( text ), fmt, argptr );
338+
va_end( argptr );
339+
340+
common->DWarning( "%s", text );
341+
}
342+
343+
/*
344+
===============
345+
idLib::DWarningIf
346+
===============
347+
*/
348+
void idLib::DWarningIf( const bool test, const char *fmt, ... ) {
349+
if ( !test ) {
350+
return;
351+
}
352+
353+
va_list argptr;
354+
char text[MAX_STRING_CHARS];
355+
356+
va_start( argptr, fmt );
357+
idStr::vsnPrintf( text, sizeof( text ), fmt, argptr );
358+
va_end( argptr );
359+
360+
common->DWarning( "%s", text );
361+
}
362+
363+
364+
/*
365+
===============
366+
idLib::Printf
367+
===============
368+
*/
369+
void idLib::Printf( const char *fmt, ... ) {
370+
va_list argptr;
371+
va_start( argptr, fmt );
372+
if ( common ) {
373+
common->VPrintf( fmt, argptr );
374+
}
375+
va_end( argptr );
376+
}
377+
378+
/*
379+
===============
380+
idLib::PrintfIf
381+
===============
382+
*/
383+
void idLib::PrintfIf( const bool test, const char *fmt, ... ) {
384+
if ( !test ) {
385+
return;
386+
}
387+
388+
va_list argptr;
389+
va_start( argptr, fmt );
390+
common->VPrintf( fmt, argptr );
391+
va_end( argptr );
392+
}
393+
285394
/*
286395
===============================================================================
287396

neo/idlib/Lib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ class idLib {
5858
static void ShutDown( void );
5959

6060
// wrapper to idCommon functions
61+
static void Printf( VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 1, 2 );
62+
static void PrintfIf( const bool test, VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 2, 3 );
6163
NO_RETURN static void Error( VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 1, 2 );
64+
NO_RETURN static void FatalError( VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 1, 2 );
6265
static void Warning( VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 1, 2 );
66+
static void WarningIf( const bool test, VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 2, 3 );
67+
static void DWarning( VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 1, 2 );
68+
static void DWarningIf( const bool test, VERIFY_FORMAT_STRING const char *fmt, ... ) ID_STATIC_ATTRIBUTE_PRINTF( 2, 3 );
6369
};
6470

6571

neo/renderer/tr_trisurf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,9 @@ this version only handles bilateral symetry
14151415
void R_DeriveTangentsWithoutNormals( srfTriangles_t *tri ) {
14161416
#if 1 // New Normal Calculation - Mikktspace
14171417
if ( !R_DeriveMikktspaceTangents( tri ) ) {
1418-
idLib::Warning( "Mikkelsen tangent space calculation failed" );
1418+
idLib::DWarningIf( !com_editorCMDActive, "Mikkelsen tangent space calculation failed" );
14191419
} else {
1420-
idLib::Warning( "Mikkelsen tangent space calculation success" );
1420+
idLib::DWarningIf( !com_editorCMDActive, "Mikkelsen tangent space calculation success" );
14211421
tri->tangentsCalculated = true;
14221422
return;
14231423
}

neo/tools/compilers/aas/AASBuild.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,12 +882,16 @@ void RunAAS_f( const idCmdArgs &args ) {
882882
idAASSettings settings;
883883
idStr mapName;
884884

885+
com_editorCMDActive = true;
886+
885887
if ( args.Argc() <= 1 ) {
886888
common->Printf( "runAAS [options] <mapfile>\n"
887889
"options:\n"
888890
" -usePatches = use bezier patches for collision detection.\n"
889891
" -writeBrushMap = write a brush map with the AAS geometry.\n"
890892
" -playerFlood = use player spawn points as valid AAS positions.\n" );
893+
894+
com_editorCMDActive = false;
891895
return;
892896
}
893897

@@ -924,6 +928,8 @@ void RunAAS_f( const idCmdArgs &args ) {
924928
}
925929
common->SetRefreshOnPrint( false );
926930
common->PrintWarnings();
931+
932+
com_editorCMDActive = false;
927933
}
928934

929935
/*
@@ -937,8 +943,11 @@ void RunAASDir_f( const idCmdArgs &args ) {
937943
idAASSettings settings;
938944
idFileList *mapFiles;
939945

946+
com_editorCMDActive = true;
947+
940948
if ( args.Argc() <= 1 ) {
941949
common->Printf( "runAASDir <folder>\n" );
950+
com_editorCMDActive = false;
942951
return;
943952
}
944953

@@ -950,6 +959,7 @@ void RunAASDir_f( const idCmdArgs &args ) {
950959
const idDict *dict = gameEdit->FindEntityDefDict( "aas_types", false );
951960
if ( !dict ) {
952961
common->Error( "Unable to find entityDef for 'aas_types'" );
962+
com_editorCMDActive = false;
953963
}
954964

955965
// scan for .map files
@@ -982,6 +992,8 @@ void RunAASDir_f( const idCmdArgs &args ) {
982992

983993
common->SetRefreshOnPrint( false );
984994
common->PrintWarnings();
995+
996+
com_editorCMDActive = false;
985997
}
986998

987999
/*
@@ -994,8 +1006,11 @@ void RunReach_f( const idCmdArgs &args ) {
9941006
idAASBuild aas;
9951007
idAASSettings settings;
9961008

1009+
com_editorCMDActive = true;
1010+
9971011
if ( args.Argc() <= 1 ) {
9981012
common->Printf( "runReach [options] <mapfile>\n" );
1013+
com_editorCMDActive = false;
9991014
return;
10001015
}
10011016

@@ -1007,6 +1022,7 @@ void RunReach_f( const idCmdArgs &args ) {
10071022
const idDict *dict = gameEdit->FindEntityDefDict( "aas_types", false );
10081023
if ( !dict ) {
10091024
common->Error( "Unable to find entityDef for 'aas_types'" );
1025+
com_editorCMDActive = false;
10101026
}
10111027

10121028
const idKeyValue *kv = dict->MatchPrefix( "type" );
@@ -1028,4 +1044,6 @@ void RunReach_f( const idCmdArgs &args ) {
10281044

10291045
common->SetRefreshOnPrint( false );
10301046
common->PrintWarnings();
1047+
1048+
com_editorCMDActive = false;
10311049
}

neo/tools/compilers/dmap/dmap.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ Dmap_f
418418
============
419419
*/
420420
void Dmap_f( const idCmdArgs &args ) {
421+
com_editorCMDActive = true;
421422

422423
if ( !dmapGlobals.noStats ) {
423424
// Reset the timers
@@ -456,4 +457,6 @@ void Dmap_f( const idCmdArgs &args ) {
456457
printTimingsStats( dmapGlobals.timingOptimize, "Optimize " );
457458
printTimingsStats( dmapGlobals.timingFixTJunctions, "Fix T Junctions " );
458459
}
460+
461+
com_editorCMDActive = false;
459462
}

neo/tools/compilers/matbuild/matbuild.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ MatBuildDir_f
3939
================
4040
*/
4141
void MatBuildDir_f( const idCmdArgs &args ) {
42+
com_editorCMDActive = true;
43+
4244
if ( args.Argc() < 2 ) {
43-
common->Warning( "Usage: matbuilddir <folder>\n" );
45+
common->Printf( "Usage: matbuilddir <folder>\n" );
46+
com_editorCMDActive = false;
4447
return;
4548
}
4649

@@ -87,4 +90,6 @@ void MatBuildDir_f( const idCmdArgs &args ) {
8790

8891
idStr mtrName = args.Argv( 1 );
8992
fileSystem->WriteFile( va( "materials/%s.mtr", mtrName.c_str() ), mtrBuffer.c_str(), mtrBuffer.Length(), "fs_basepath" );
93+
94+
com_editorCMDActive = false;
9095
}

neo/tools/compilers/renderbump/renderbump.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ void RenderBump_f( const idCmdArgs &args ) {
11721172
renderBump_t opt;
11731173
int startTime, endTime;
11741174

1175+
com_editorCMDActive = true;
1176+
11751177
// update the screen as we print
11761178
common->SetRefreshOnPrint( true );
11771179

@@ -1322,6 +1324,8 @@ void RenderBump_f( const idCmdArgs &args ) {
13221324

13231325
// stop updating the screen as we print
13241326
common->SetRefreshOnPrint( false );
1327+
1328+
com_editorCMDActive = false;
13251329
}
13261330

13271331

@@ -1350,6 +1354,8 @@ void RenderBumpFlat_f( const idCmdArgs &args ) {
13501354
idBounds bounds;
13511355
srfTriangles_t *mesh;
13521356

1357+
com_editorCMDActive = true;
1358+
13531359
// update the screen as we print
13541360
common->SetRefreshOnPrint( true );
13551361

@@ -1380,7 +1386,8 @@ void RenderBumpFlat_f( const idCmdArgs &args ) {
13801386
}
13811387

13821388
if ( i != ( args.Argc() - 1 ) ) {
1383-
common->Error( "usage: renderBumpFlat [-size width height] asefile" );
1389+
common->Warning( "usage: renderBumpFlat [-size width height] asefile" );
1390+
com_editorCMDActive = false;
13841391
return;
13851392
}
13861393

@@ -1636,5 +1643,7 @@ void RenderBumpFlat_f( const idCmdArgs &args ) {
16361643
// stop updating the screen as we print
16371644
common->SetRefreshOnPrint( false );
16381645

1639-
common->Error( "Completed." );
1646+
common->Printf( "Completed." );
1647+
1648+
com_editorCMDActive = false;
16401649
}

neo/tools/compilers/roqvq/roq.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,11 @@ int roq::NumberOfFrames( void ) {
844844
}
845845

846846
void RoQFileEncode_f( const idCmdArgs &args ) {
847+
com_editorCMDActive = true;
848+
847849
if ( args.Argc() != 2 ) {
848850
common->Printf( "Usage: roq <paramfile>\n" );
851+
com_editorCMDActive = false;
849852
return;
850853
}
851854
theRoQ = new roq;
@@ -854,4 +857,5 @@ void RoQFileEncode_f( const idCmdArgs &args ) {
854857
int stopMsec = Sys_Milliseconds();
855858
common->Printf( "total encoding time: %i second\n", ( stopMsec - startMsec ) / 1000 );
856859

860+
com_editorCMDActive = false;
857861
}

0 commit comments

Comments
 (0)