From a116c10574e2ed4972b647d28da3e00761c884d3 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 8 Feb 2016 20:38:59 -0600 Subject: [PATCH 1/9] Comment out re2c_test::range reference in re2c::Range --- tools/re2c/src/util/range.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/re2c/src/util/range.h b/tools/re2c/src/util/range.h index 9a9cf03b45..1ea7d9be47 100644 --- a/tools/re2c/src/util/range.h +++ b/tools/re2c/src/util/range.h @@ -55,7 +55,7 @@ private: static void append (Range ** & ptail, uint32_t l, uint32_t u); // test addition and subtraction - template friend Range * re2c_test::range (uint32_t n); + //template friend Range * re2c_test::range (uint32_t n); FORBID_COPY (Range); }; From 4c2bcede6157cf30fd829d5d3a26f7cee9270c8d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 8 Feb 2016 21:27:02 -0600 Subject: [PATCH 2/9] Update VS2005 projects for re2c and zdoom --- tools/re2c/config.msc.h | 62 +++ tools/re2c/re2c.vcproj | 845 +++++++++++++++++++++++++++++++ tools/re2c/src/conf/msg.cc | 4 + tools/re2c/src/util/c99_stdint.h | 4 + zdoom.vcproj | 8 + 5 files changed, 923 insertions(+) create mode 100644 tools/re2c/config.msc.h create mode 100644 tools/re2c/re2c.vcproj diff --git a/tools/re2c/config.msc.h b/tools/re2c/config.msc.h new file mode 100644 index 0000000000..d64e6d9e9e --- /dev/null +++ b/tools/re2c/config.msc.h @@ -0,0 +1,62 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Name of package */ +/* #undef PACKAGE */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "re2c-general@lists.sourceforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "re2c" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "re2c 0.16" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "re2c" + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.16" + +/* The size of `0i8', as computed by sizeof. */ +#define SIZEOF_0I8 1 + +/* The size of `0l', as computed by sizeof. */ +#define SIZEOF_0L 4 + +/* The size of `0ll', as computed by sizeof. */ +#define SIZEOF_0LL 8 + +/* The size of `char', as computed by sizeof. */ +#define SIZEOF_CHAR 1 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `void *', as computed by sizeof. */ +#ifdef _M_X64 +#define SIZEOF_VOID_P 8 +#else +#define SIZEOF_VOID_P 4 +#endif + +/* The size of `__int64', as computed by sizeof. */ +#define SIZEOF___INT64 8 + +/* Version number of package */ +/* #undef VERSION */ diff --git a/tools/re2c/re2c.vcproj b/tools/re2c/re2c.vcproj new file mode 100644 index 0000000000..81d8c4941f --- /dev/null +++ b/tools/re2c/re2c.vcproj @@ -0,0 +1,845 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/re2c/src/conf/msg.cc b/tools/re2c/src/conf/msg.cc index ec13c0ac7c..87962f0a9c 100644 --- a/tools/re2c/src/conf/msg.cc +++ b/tools/re2c/src/conf/msg.cc @@ -2,7 +2,11 @@ #include #include +#if defined(_MSC_VER) && _MSC_VER < 1500 +#include "config.msc.h" +#else #include "config.h" +#endif #include "src/conf/msg.h" namespace re2c { diff --git a/tools/re2c/src/util/c99_stdint.h b/tools/re2c/src/util/c99_stdint.h index ffe2e3ee00..5718604316 100644 --- a/tools/re2c/src/util/c99_stdint.h +++ b/tools/re2c/src/util/c99_stdint.h @@ -1,7 +1,11 @@ #ifndef _RE2C_UTIL_C99_STDINT_ #define _RE2C_UTIL_C99_STDINT_ +#if defined(_MSC_VER) && _MSC_VER < 1500 +#include "config.msc.h" +#else #include "config.h" +#endif #if HAVE_STDINT_H # include diff --git a/zdoom.vcproj b/zdoom.vcproj index b16c13fa82..3b98c29b1e 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -622,6 +622,10 @@ RelativePath=".\src\dthinker.cpp" > + + @@ -1271,6 +1275,10 @@ RelativePath=".\src\dthinker.h" > + + From 8d159b8506d5e0c271c8b9dc45b1b927f646ab23 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 8 Feb 2016 22:11:42 -0600 Subject: [PATCH 3/9] Add OF_StateChanged handling to NoDelay --- src/actor.h | 2 ++ src/g_shared/a_fastprojectile.cpp | 13 ++------- src/p_mobj.cpp | 45 +++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/actor.h b/src/actor.h index e6ae8d9f84..30e67fa306 100644 --- a/src/actor.h +++ b/src/actor.h @@ -647,6 +647,8 @@ public: // Returns true if this actor is within melee range of its target bool CheckMeleeRange(); + bool CheckNoDelay(); + virtual void BeginPlay(); // Called immediately after the actor is created virtual void PostBeginPlay(); // Called immediately before the actor's first tick virtual void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index da71358f98..4f103be57f 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -138,17 +138,8 @@ void AFastProjectile::Tick () } } } - if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT)) - { - flags7 &= ~MF7_HANDLENODELAY; - if (state->GetNoDelay()) - { - // For immediately spawned objects with the NoDelay flag set for their - // Spawn state, explicitly call the current state's function. - if (state->CallAction(this, this) && (ObjectFlags & OF_EuthanizeMe)) - return; // freed itself - } - } + if (!CheckNoDelay()) + return; // freed itself // Advance the state if (tics != -1) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a7573f4dca..eba7f86fdc 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3841,17 +3841,8 @@ void AActor::Tick () Destroy(); return; } - if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT)) - { - flags7 &= ~MF7_HANDLENODELAY; - if (state->GetNoDelay()) - { - // For immediately spawned objects with the NoDelay flag set for their - // Spawn state, explicitly call the current state's function. - if (state->CallAction(this, this) && (ObjectFlags & OF_EuthanizeMe)) - return; // freed itself - } - } + if (!CheckNoDelay()) + return; // freed itself // cycle through states, calling action functions at transitions if (tics != -1) { @@ -3892,6 +3883,38 @@ void AActor::Tick () } } +//========================================================================== +// +// AActor :: CheckNoDelay +// +//========================================================================== + +bool AActor::CheckNoDelay() +{ + if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT)) + { + flags7 &= ~MF7_HANDLENODELAY; + if (state->GetNoDelay()) + { + // For immediately spawned objects with the NoDelay flag set for their + // Spawn state, explicitly call the current state's function. + if (state->CallAction(this, this)) + { + if (ObjectFlags & OF_EuthanizeMe) + { + return false; // freed itself + } + if (ObjectFlags & OF_StateChanged) + { + ObjectFlags &= ~OF_StateChanged; + return SetState(state); + } + } + } + } + return true; +} + //========================================================================== // // AActor :: CheckSectorTransition From f0b496205272cde31a9dd406b0b8c3d1df86adc4 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 8 Feb 2016 22:21:42 -0600 Subject: [PATCH 4/9] Fix: CountInv must return a value if the caller's expecting one --- src/thingdef/thingdef_codeptr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index e6759e18a4..ebc5c0b979 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -238,14 +238,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, CountInv) self = COPY_AAPTR(self, pick_pointer); if (self == NULL || itemtype == NULL) { - ret->SetInt(false); + ret->SetInt(0); } else { AInventory *item = self->FindInventory(itemtype); ret->SetInt(item ? item->Amount : 0); - return 1; } + return 1; } return 0; } From 88f61579846e19a4681cfe0d5f7f3a6b63f86587 Mon Sep 17 00:00:00 2001 From: John Palomo Jr Date: Tue, 9 Feb 2016 02:49:28 -0500 Subject: [PATCH 5/9] Fixed: Player color slider size/position was wrong when using language strings. --- src/menu/playermenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu/playermenu.cpp b/src/menu/playermenu.cpp index 184b5a4655..691986548a 100644 --- a/src/menu/playermenu.cpp +++ b/src/menu/playermenu.cpp @@ -484,7 +484,7 @@ void FSliderItem::Drawer(bool selected) screen->DrawText(mFont, selected? OptionSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true, TAG_DONE); int x = SmallFont->StringWidth ("Green") + 8 + mXpos; - int x2 = SmallFont->StringWidth (mText) + 8 + mXpos; + int x2 = SmallFont->StringWidth (text) + 8 + mXpos; DrawSlider (MAX(x2, x), mYpos); } From 8823b60c0dbfb7e5d342d09728934fb7fdb0e83d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 11:51:19 +0100 Subject: [PATCH 6/9] - fixed: FxClassTypeCast must use FindClassTentative to get the class type. This function may well be invoked before a class is actually defined, so it needs to create a placeholder to be filled in later. --- src/thingdef/thingdef_exp.h | 4 ++-- src/thingdef/thingdef_expression.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index 691d4b8723..6dd11a681b 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -913,12 +913,12 @@ public: class FxClassTypeCast : public FxExpression { - const PClass *desttype; + PClass *desttype; FxExpression *basex; public: - FxClassTypeCast(const PClass *dtype, FxExpression *x); + FxClassTypeCast(PClass *dtype, FxExpression *x); ~FxClassTypeCast(); FxExpression *Resolve(FCompileContext&); ExpEmit Emit(VMFunctionBuilder *build); diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index f4c2b1f608..9124071e57 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -3503,7 +3503,7 @@ ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build, bool tailcall) // //========================================================================== -FxClassTypeCast::FxClassTypeCast(const PClass *dtype, FxExpression *x) +FxClassTypeCast::FxClassTypeCast(PClass *dtype, FxExpression *x) : FxExpression(x->ScriptPosition) { desttype = dtype; @@ -3542,11 +3542,11 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) if (basex->isConstant()) { FName clsname = static_cast(basex)->GetValue().GetName(); - const PClass *cls = NULL; + PClass *cls = NULL; if (clsname != NAME_None) { - cls = PClass::FindClass(clsname); + cls = desttype->FindClassTentative(clsname); if (cls == NULL) { /* lax */ From 6c92525fcd6613389e5adeefdbd2fae04ebfc51b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 12:26:00 +0100 Subject: [PATCH 7/9] - added an option to FindClassTentative to make eventual failure to declare the missing class non-fatal. Damn those old mods with broken actor references. Thanks to those FxClassTypeCast may not throw fatal errors. --- src/dobjtype.cpp | 15 +++++++++++---- src/dobjtype.h | 8 +++++++- src/thingdef/thingdef.cpp | 11 ++++++++--- src/thingdef/thingdef_expression.cpp | 22 ++++++---------------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index d9af4044a6..7e80eca0c1 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -2322,12 +2322,19 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size) const PClass *existclass = FindClass(name); // This is a placeholder so fill it in - if (existclass != NULL && existclass->Size == (unsigned)-1) + if (existclass != NULL && (existclass->Size == TClass_Fatal || existclass->Size == TClass_Nonfatal)) { type = const_cast(existclass); if (!IsDescendantOf(type->ParentClass)) { - I_Error("%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars()); + if (existclass->Size == TClass_Fatal) + { + I_Error("%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars()); + } + else + { + Printf(TEXTCOLOR_RED "%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars()); + } } DPrintf("Defining placeholder class %s\n", name.GetChars()); notnew = true; @@ -2380,7 +2387,7 @@ unsigned int PClass::Extend(unsigned int extension) // //========================================================================== -PClass *PClass::FindClassTentative(FName name) +PClass *PClass::FindClassTentative(FName name, bool fatal) { if (name == NAME_None) { @@ -2400,7 +2407,7 @@ PClass *PClass::FindClassTentative(FName name) type->TypeName = name; type->ParentClass = this; - type->Size = -1; + type->Size = fatal? TClass_Fatal : TClass_Nonfatal; type->bRuntimeClass = true; TypeTable.AddType(type, RUNTIME_CLASS(PClass), (intptr_t)type->Outer, name, bucket); return type; diff --git a/src/dobjtype.h b/src/dobjtype.h index 313130ddba..900059cab1 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -599,6 +599,12 @@ public: // Meta-info for every class derived from DObject --------------------------- +enum +{ + TClass_Fatal = UINT_MAX, + TClass_Nonfatal = UINT_MAX - 1 +}; + class PClassClass; class PClass : public PStruct { @@ -661,7 +667,7 @@ public: static PClassActor *FindActor(const FString &name) { return FindActor(FName(name, true)); } static PClassActor *FindActor(ENamedName name) { return FindActor(FName(name)); } static PClassActor *FindActor(FName name); - PClass *FindClassTentative(FName name); // not static! + PClass *FindClassTentative(FName name, bool fatal = true); // not static! static TArray AllClasses; diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 2d179e01d8..9f0a9a9512 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -340,10 +340,15 @@ static void FinishThingdef() { PClassActor *ti = PClassActor::AllActorClasses[i]; - if (ti->Size == (unsigned)-1) + if (ti->Size == TClass_Fatal || ti->Size == TClass_Nonfatal) { - Printf("Class %s referenced but not defined\n", ti->TypeName.GetChars()); - errorcount++; + Printf(TEXTCOLOR_RED "Class %s referenced but not defined\n", ti->TypeName.GetChars()); + if (ti->Size == TClass_Fatal) errorcount++; + else + { + // In order to prevent a crash, this class needs to be completed, even though it defines nothing. + ti->ParentClass->CreateDerivedClass(ti->TypeName, ti->ParentClass->Size); + } continue; } diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 9124071e57..b86c690f57 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -3546,23 +3546,13 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) if (clsname != NAME_None) { - cls = desttype->FindClassTentative(clsname); - if (cls == NULL) + // for backwards compatibility with old times it cannot be made a fatal error, if the class is not defined. :( + cls = desttype->FindClassTentative(clsname, false); + if (!cls->IsDescendantOf(desttype)) { - /* lax */ - // Since this happens in released WADs it must pass without a terminal error... :( - ScriptPosition.Message(MSG_WARNING, - "Unknown class name '%s'", - clsname.GetChars(), desttype->TypeName.GetChars()); - } - else - { - if (!cls->IsDescendantOf(desttype)) - { - ScriptPosition.Message(MSG_ERROR,"class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); - delete this; - return NULL; - } + ScriptPosition.Message(MSG_ERROR,"class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); + delete this; + return NULL; } ScriptPosition.Message(MSG_DEBUG,"resolving '%s' as class name", clsname.GetChars()); } From 4d2a52418f653c1e4333a8173c42b9f511db3880 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 14:20:49 +0100 Subject: [PATCH 8/9] - 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]) From 78ac944242192813a02169b5073ab959f7357825 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 14:38:42 +0100 Subject: [PATCH 9/9] - allow optional terrain definitions ... because any Doom terrain WAD would otherwise spam the logfile with messages when running an error log batch. --- src/p_terrain.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index af8de5cab2..d30354c1ed 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -627,13 +627,19 @@ static void ParseFloor (FScanner &sc) FTextureID picnum; int terrain; + bool opt = sc.CheckString("optional"); sc.MustGetString (); + picnum = TexMan.CheckForTexture (sc.String, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny); + if (!picnum.Exists()) { - Printf ("Unknown flat %s\n", sc.String); - sc.MustGetString (); + sc.MustGetString(); + if (!opt) + { + Printf("Unknown flat %s\n", sc.String); + } return; } sc.MustGetString ();