From 4d2a52418f653c1e4333a8173c42b9f511db3880 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 14:20:49 +0100 Subject: [PATCH] - added an errorlog option. This cuts down on as much message noise as possible, outputs everything to a file specified as a parameter and then quits immediately, allowing this to run from a batch that's supposed to check a larger list of files for errors. Multiple outputs get appended if the file already exists. --- .gitignore | 1 + src/c_cmds.cpp | 6 +-- src/c_dispatch.h | 2 +- src/d_dehacked.cpp | 4 +- src/d_main.cpp | 73 ++++++++++++++++++++-------------- src/d_net.cpp | 2 +- src/doomtype.h | 2 + src/g_shared/sbarinfo.cpp | 4 +- src/info.cpp | 2 +- src/m_specialpaths.cpp | 4 +- src/resourcefiles/file_7z.cpp | 2 +- src/resourcefiles/file_grp.cpp | 2 +- src/resourcefiles/file_pak.cpp | 2 +- src/resourcefiles/file_rff.cpp | 2 +- src/resourcefiles/file_wad.cpp | 2 +- src/resourcefiles/file_zip.cpp | 2 +- src/sound/i_sound.cpp | 2 +- src/thingdef/thingdef.cpp | 2 +- src/w_wad.cpp | 2 +- src/win32/i_main.cpp | 38 +++++++++++------- src/win32/i_system.cpp | 8 ++-- src/x86.cpp | 2 +- 22 files changed, 96 insertions(+), 70 deletions(-) diff --git a/.gitignore b/.gitignore index 596fe51824..f38b57ee93 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ /jpeg-6b/x64/ /lzma/x64/ /zlib/x64/ +/build_vc2015 diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 30fbd1e515..ed028ab934 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -456,9 +456,9 @@ CCMD (exec) } } -void execLogfile(const char *fn) +void execLogfile(const char *fn, bool append) { - if ((Logfile = fopen(fn, "w"))) + if ((Logfile = fopen(fn, append? "a" : "w"))) { const char *timestr = myasctime(); Printf("Log started: %s\n", timestr); @@ -482,7 +482,7 @@ CCMD (logfile) if (argv.argc() >= 2) { - execLogfile(argv[1]); + execLogfile(argv[1], argv.argc() >=3? !!argv[2]:false); } } diff --git a/src/c_dispatch.h b/src/c_dispatch.h index f9aeb0dc32..493655423c 100644 --- a/src/c_dispatch.h +++ b/src/c_dispatch.h @@ -182,6 +182,6 @@ extern unsigned int MakeKey (const char *s); extern unsigned int MakeKey (const char *s, size_t len); extern unsigned int SuperFastHash (const char *data, size_t len); -void execLogfile(const char *fn); +void execLogfile(const char *fn, bool append = false); #endif //__C_DISPATCH_H__ diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index a5a6526232..82d26d7ab7 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2495,7 +2495,7 @@ bool D_LoadDehFile(const char *patchfile) static bool DoDehPatch() { - Printf("Adding dehacked patch %s\n", PatchName); + if (!batchrun) Printf("Adding dehacked patch %s\n", PatchName); int cont; @@ -2586,7 +2586,7 @@ static bool DoDehPatch() UnloadDehSupp (); delete[] PatchName; delete[] PatchFile; - Printf ("Patch installed\n"); + if (!batchrun) Printf ("Patch installed\n"); return true; } diff --git a/src/d_main.cpp b/src/d_main.cpp index 054e597fa4..23c837dfab 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -228,6 +228,7 @@ bool nospriterename; FStartupInfo DoomStartupInfo; FString lastIWAD; int restart = 0; +bool batchrun; // just run the startup and collect all error messages in a logfile, then quit without any interaction cycle_t FrameCycles; @@ -1868,7 +1869,6 @@ static FString ParseGameInfo(TArray &pwads, const char *fn, const char static FString CheckGameInfo(TArray & pwads) { - DWORD t = I_FPSTime(); // scan the list of WADs backwards to find the last one that contains a GAMEINFO lump for(int i=pwads.Size()-1; i>=0; i--) { @@ -1920,8 +1920,6 @@ static FString CheckGameInfo(TArray & pwads) delete resfile; } } - t = I_FPSTime() - t; - Printf("Gameinfo scan took %d ms\n", t); return ""; } @@ -2002,7 +2000,7 @@ static void D_DoomInit() { rngseed = staticrngseed = atoi(v); use_staticrng = true; - Printf("D_DoomInit: Static RNGseed %d set.\n", rngseed); + if (!batchrun) Printf("D_DoomInit: Static RNGseed %d set.\n", rngseed); } else { @@ -2012,7 +2010,7 @@ static void D_DoomInit() FRandom::StaticClearRandom (); - Printf ("M_LoadDefaults: Load system defaults.\n"); + if (!batchrun) Printf ("M_LoadDefaults: Load system defaults.\n"); M_LoadDefaults (); // load before initing other systems } @@ -2080,7 +2078,7 @@ static void CheckCmdLine() int p; const char *v; - Printf ("Checking cmd-line parameters...\n"); + if (!batchrun) Printf ("Checking cmd-line parameters...\n"); if (Args->CheckParm ("-nomonsters")) flags |= DF_NO_MONSTERS; if (Args->CheckParm ("-respawn")) flags |= DF_MONSTERS_RESPAWN; if (Args->CheckParm ("-fast")) flags |= DF_FAST_MONSTERS; @@ -2222,6 +2220,7 @@ void D_DoomMain (void) FString *args; int argcount; FIWadManager *iwad_man; + const char *batchout = Args->CheckValue("-errorlog"); // +logfile gets checked too late to catch the full startup log in the logfile so do some extra check for it here. FString logfile = Args->TakeValue("+logfile"); @@ -2229,6 +2228,17 @@ void D_DoomMain (void) { execLogfile(logfile); } + else if (batchout != NULL && *batchout != 0) + { + batchrun = true; + execLogfile(batchout, true); + Printf("Command line: "); + for (int i = 0; i < Args->NumArgs(); i++) + { + Printf("%s ", Args->GetArg(i)); + } + Printf("\n"); + } if (Args->CheckParm("-hashfiles")) { @@ -2339,7 +2349,7 @@ void D_DoomMain (void) Printf("Notice: File hashing is incredibly verbose. Expect loading files to take much longer than usual.\n"); } - Printf ("W_Init: Init WADfiles.\n"); + if (!batchrun) Printf ("W_Init: Init WADfiles.\n"); Wads.InitMultipleFiles (allwads); allwads.Clear(); allwads.ShrinkToFit(); @@ -2370,21 +2380,21 @@ void D_DoomMain (void) if (!restart) { - Printf ("I_Init: Setting up machine state.\n"); + if (!batchrun) Printf ("I_Init: Setting up machine state.\n"); I_Init (); I_CreateRenderer(); } - Printf ("V_Init: allocate screen.\n"); + if (!batchrun) Printf ("V_Init: allocate screen.\n"); V_Init (!!restart); // Base systems have been inited; enable cvar callbacks FBaseCVar::EnableCallbacks (); - Printf ("S_Init: Setting up sound.\n"); + if (!batchrun) Printf ("S_Init: Setting up sound.\n"); S_Init (); - Printf ("ST_Init: Init startup screen.\n"); + if (!batchrun) Printf ("ST_Init: Init startup screen.\n"); if (!restart) { StartScreen = FStartupScreen::CreateInstance (TexMan.GuesstimateNumTextures() + 5); @@ -2402,23 +2412,23 @@ void D_DoomMain (void) S_ParseReverbDef (); // [RH] Parse any SNDINFO lumps - Printf ("S_InitData: Load sound definitions.\n"); + if (!batchrun) Printf ("S_InitData: Load sound definitions.\n"); S_InitData (); // [RH] Parse through all loaded mapinfo lumps - Printf ("G_ParseMapInfo: Load map definitions.\n"); + if (!batchrun) Printf ("G_ParseMapInfo: Load map definitions.\n"); G_ParseMapInfo (iwad_info->MapInfo); ReadStatistics(); // MUSINFO must be parsed after MAPINFO S_ParseMusInfo(); - Printf ("Texman.Init: Init texture manager.\n"); + if (!batchrun) Printf ("Texman.Init: Init texture manager.\n"); TexMan.Init(); C_InitConback(); // [CW] Parse any TEAMINFO lumps. - Printf ("ParseTeamInfo: Load team definitions.\n"); + if (!batchrun) Printf ("ParseTeamInfo: Load team definitions.\n"); TeamLibrary.ParseTeamInfo (); PClassActor::StaticInit (); @@ -2437,11 +2447,11 @@ void D_DoomMain (void) StartScreen->Progress (); - Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars()); + if (!batchrun) Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars()); StartScreen->LoadingStatus ("Loading graphics", 0x3f); R_Init (); - Printf ("DecalLibrary: Load decals.\n"); + if (!batchrun) Printf ("DecalLibrary: Load decals.\n"); DecalLibrary.ReadAllDecals (); // [RH] Add any .deh and .bex files on the command line. @@ -2458,7 +2468,7 @@ void D_DoomMain (void) { if (stricmp (key, "Path") == 0 && FileExists (value)) { - Printf ("Applying patch %s\n", value); + if (!batchrun) Printf ("Applying patch %s\n", value); D_LoadDehFile(value); } } @@ -2483,10 +2493,10 @@ void D_DoomMain (void) bglobal.spawn_tries = 0; bglobal.wanted_botnum = bglobal.getspawned.Size(); - Printf ("M_Init: Init menus.\n"); + if (!batchrun) Printf ("M_Init: Init menus.\n"); M_Init (); - Printf ("P_Init: Init Playloop state.\n"); + if (!batchrun) Printf ("P_Init: Init Playloop state.\n"); StartScreen->LoadingStatus ("Init game engine", 0x3f); AM_StaticInit(); P_Init (); @@ -2497,22 +2507,25 @@ void D_DoomMain (void) SBarInfo::Load(); HUD_InitHud(); - // [RH] User-configurable startup strings. Because BOOM does. - static const char *startupString[5] = { - "STARTUP1", "STARTUP2", "STARTUP3", "STARTUP4", "STARTUP5" - }; - for (p = 0; p < 5; ++p) + if (!batchrun) { - const char *str = GStrings[startupString[p]]; - if (str != NULL && str[0] != '\0') + // [RH] User-configurable startup strings. Because BOOM does. + static const char *startupString[5] = { + "STARTUP1", "STARTUP2", "STARTUP3", "STARTUP4", "STARTUP5" + }; + for (p = 0; p < 5; ++p) { - Printf ("%s\n", str); + const char *str = GStrings[startupString[p]]; + if (str != NULL && str[0] != '\0') + { + Printf("%s\n", str); + } } } if (!restart) { - Printf ("D_CheckNetGame: Checking network game status.\n"); + if (!batchrun) Printf ("D_CheckNetGame: Checking network game status.\n"); StartScreen->LoadingStatus ("Checking network game status.", 0x3f); D_CheckNetGame (); } @@ -2545,7 +2558,7 @@ void D_DoomMain (void) StartScreen = NULL; S_Sound (CHAN_BODY, "misc/startupdone", 1, ATTN_NONE); - if (Args->CheckParm("-norun")) + if (Args->CheckParm("-norun") || batchrun) { throw CNoRunExit(); } diff --git a/src/d_net.cpp b/src/d_net.cpp index a7be1cbaf1..00361053a7 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1739,7 +1739,7 @@ void D_CheckNetGame (void) Printf("Arbitrator selected " TEXTCOLOR_BLUE "%s" TEXTCOLOR_NORMAL " networking mode.\n", NetMode == NET_PeerToPeer ? "peer to peer" : "packet server"); } - Printf ("player %i of %i (%i nodes)\n", + if (!batchrun) Printf ("player %i of %i (%i nodes)\n", consoleplayer+1, doomcom.numplayers, doomcom.numnodes); } diff --git a/src/doomtype.h b/src/doomtype.h index 214c65f8b3..92717e4c86 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -125,6 +125,8 @@ typedef TMap FClassMap; #include "basictypes.h" +extern bool batchrun; + // Bounding box coordinate storage. enum { diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 791021ae8f..2c5b87cf0e 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -434,7 +434,7 @@ void SBarInfo::Load() int lump = Wads.CheckNumForFullName(gameinfo.statusbar, true); if(lump != -1) { - Printf ("ParseSBarInfo: Loading default status bar definition.\n"); + if (!batchrun) Printf ("ParseSBarInfo: Loading default status bar definition.\n"); if(SBarInfoScript[SCRIPT_DEFAULT] == NULL) SBarInfoScript[SCRIPT_DEFAULT] = new SBarInfo(lump); else @@ -444,7 +444,7 @@ void SBarInfo::Load() if(Wads.CheckNumForName("SBARINFO") != -1) { - Printf ("ParseSBarInfo: Loading custom status bar definition.\n"); + if (!batchrun) Printf ("ParseSBarInfo: Loading custom status bar definition.\n"); int lastlump, lump; lastlump = 0; while((lump = Wads.FindLump("SBARINFO", &lastlump)) != -1) diff --git a/src/info.cpp b/src/info.cpp index 2adfd14cc4..8c2ae06a63 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -152,7 +152,7 @@ void PClassActor::StaticInit() sprites.Push (temp); } - Printf ("LoadActors: Load actor definitions.\n"); + if (!batchrun) Printf ("LoadActors: Load actor definitions.\n"); ClearStrifeTypes(); LoadActors (); InitBotStuff(); diff --git a/src/m_specialpaths.cpp b/src/m_specialpaths.cpp index 7a48a2b9cb..60ccf08a8e 100644 --- a/src/m_specialpaths.cpp +++ b/src/m_specialpaths.cpp @@ -55,11 +55,11 @@ bool UseKnownFolders() if (file != INVALID_HANDLE_VALUE) { CloseHandle(file); - Printf("Using program directory for storage\n"); + if (!batchrun) Printf("Using program directory for storage\n"); iswritable = true; return false; } - Printf("Using known folders for storage\n"); + if (!batchrun) Printf("Using known folders for storage\n"); iswritable = false; return true; } diff --git a/src/resourcefiles/file_7z.cpp b/src/resourcefiles/file_7z.cpp index 65676fcf4f..0dd9e84a75 100644 --- a/src/resourcefiles/file_7z.cpp +++ b/src/resourcefiles/file_7z.cpp @@ -316,7 +316,7 @@ bool F7ZFile::Open(bool quiet) } } - if (!quiet) Printf(", %d lumps\n", NumLumps); + if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); PostProcessArchive(&Lumps[0], sizeof(F7ZLump)); return true; diff --git a/src/resourcefiles/file_grp.cpp b/src/resourcefiles/file_grp.cpp index 63738d7e60..74d50db67b 100644 --- a/src/resourcefiles/file_grp.cpp +++ b/src/resourcefiles/file_grp.cpp @@ -121,7 +121,7 @@ bool FGrpFile::Open(bool quiet) fileinfo[i].NameWithZero[12] = '\0'; // Be sure filename is null-terminated Lumps[i].LumpNameSetup(fileinfo[i].NameWithZero); } - if (!quiet) Printf(", %d lumps\n", NumLumps); + if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); delete[] fileinfo; return true; diff --git a/src/resourcefiles/file_pak.cpp b/src/resourcefiles/file_pak.cpp index 9ea01767b1..65752345d8 100644 --- a/src/resourcefiles/file_pak.cpp +++ b/src/resourcefiles/file_pak.cpp @@ -104,7 +104,7 @@ bool FPakFile::Open(bool quiet) Lumps = new FUncompressedLump[NumLumps]; - if (!quiet) Printf(", %d lumps\n", NumLumps); + if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); for(DWORD i = 0; i < NumLumps; i++) { diff --git a/src/resourcefiles/file_rff.cpp b/src/resourcefiles/file_rff.cpp index 682df985d0..c00f7c3b66 100644 --- a/src/resourcefiles/file_rff.cpp +++ b/src/resourcefiles/file_rff.cpp @@ -152,7 +152,7 @@ bool FRFFFile::Open(bool quiet) Lumps = new FRFFLump[NumLumps]; - if (!quiet) Printf(", %d lumps\n", NumLumps); + if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); for (DWORD i = 0; i < NumLumps; ++i) { Lumps[i].Position = LittleLong(lumps[i].FilePos); diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index 869e69ca09..a61128f3b8 100644 --- a/src/resourcefiles/file_wad.cpp +++ b/src/resourcefiles/file_wad.cpp @@ -370,7 +370,7 @@ bool FWadFile::Open(bool quiet) if (!quiet) { - Printf(", %d lumps\n", NumLumps); + if (!batchrun) Printf(", %d lumps\n", NumLumps); // don't bother with namespaces here. We won't need them. SetNamespace("S_START", "S_END", ns_sprites); diff --git a/src/resourcefiles/file_zip.cpp b/src/resourcefiles/file_zip.cpp index c7e787c70e..54e7725faa 100644 --- a/src/resourcefiles/file_zip.cpp +++ b/src/resourcefiles/file_zip.cpp @@ -268,7 +268,7 @@ bool FZipFile::Open(bool quiet) NumLumps -= skipped; free(directory); - if (!quiet) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps); + if (!quiet && !batchrun) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps); PostProcessArchive(&Lumps[0], sizeof(FZipLump)); return true; diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 8997c91572..0e5e3e7de8 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -259,7 +259,7 @@ void I_InitSound () nosfx = !!Args->CheckParm ("-nosfx"); GSnd = NULL; - if (nosound) + if (nosound || batchrun) { GSnd = new NullSoundRenderer; I_InitMusic (); diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 9f0a9a9512..b12f45abe3 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -444,7 +444,7 @@ void LoadActors () } FinishThingdef(); timer.Unclock(); - Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS()); + if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS()); // Base time: ~52 ms } diff --git a/src/w_wad.cpp b/src/w_wad.cpp index d4127ae7ba..1fcdc93ff8 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -256,7 +256,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) } } - Printf (" adding %s", filename); + if (!batchrun) Printf (" adding %s", filename); startlump = NumLumps; FResourceFile *resfile; diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 3836af3f8e..be3e0f6012 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1005,20 +1005,23 @@ void DoMain (HINSTANCE hInstance) catch (class CNoRunExit &) { I_ShutdownGraphics(); - if (FancyStdOut && !AttachedStdOut) - { // Outputting to a new console window: Wait for a keypress before quitting. - DWORD bytes; - HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE); - - ShowWindow (Window, SW_HIDE); - WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL); - FlushConsoleInputBuffer(stdinput); - SetConsoleMode(stdinput, 0); - ReadConsole(stdinput, &bytes, 1, &bytes, NULL); - } - else if (StdOut == NULL) + if (!batchrun) { - ShowErrorPane(NULL); + if (FancyStdOut && !AttachedStdOut) + { // Outputting to a new console window: Wait for a keypress before quitting. + DWORD bytes; + HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE); + + ShowWindow(Window, SW_HIDE); + WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL); + FlushConsoleInputBuffer(stdinput); + SetConsoleMode(stdinput, 0); + ReadConsole(stdinput, &bytes, 1, &bytes, NULL); + } + else if (StdOut == NULL) + { + ShowErrorPane(NULL); + } } exit(0); } @@ -1028,7 +1031,14 @@ void DoMain (HINSTANCE hInstance) RestoreConView (); if (error.GetMessage ()) { - ShowErrorPane (error.GetMessage()); + if (!batchrun) + { + ShowErrorPane(error.GetMessage()); + } + else + { + Printf("%s\n", error.GetMessage()); + } } exit (-1); } diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index a5c2eb84e0..7d349679e3 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -595,14 +595,14 @@ void I_DetectOS(void) if (OSPlatform == os_Win95) { - Printf ("OS: Windows %s %lu.%lu.%lu %s\n", + if (!batchrun) Printf ("OS: Windows %s %lu.%lu.%lu %s\n", osname, info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber & 0xffff, info.szCSDVersion); } else { - Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n", + if (!batchrun) Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n", osname, info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber, info.szCSDVersion); @@ -610,7 +610,7 @@ void I_DetectOS(void) if (OSPlatform == os_unknown) { - Printf ("(Assuming Windows 2000)\n"); + if (!batchrun) Printf ("(Assuming Windows 2000)\n"); OSPlatform = os_Win2k; } } @@ -727,7 +727,7 @@ void CalculateCPUSpeed() PerfToMillisec = PerfToSec * 1000.0; } - Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); + if (!batchrun) Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); } //========================================================================== diff --git a/src/x86.cpp b/src/x86.cpp index 89d88333d2..40c0b5435e 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -195,7 +195,7 @@ void DumpCPUInfo(const CPUInfo *cpu) } *t = '\0'; - if (cpu->VendorID[0]) + if (cpu->VendorID[0] && !batchrun) { Printf("CPU Vendor ID: %s\n", cpu->VendorID); if (cpustring[0])