From b6ff468aaf1ee16ea045addebd0b31a647dcb966 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 12 Aug 2018 10:55:24 +0300 Subject: [PATCH 01/21] - creation of dither texture no longer affects active unit Red checkerboard was rendered upon startup instead of * the first saved game's thumbnail * the first game frame --- src/gl/renderer/gl_renderbuffers.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 094e6e30e..48cbd0e75 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -576,6 +576,7 @@ void FGLRenderBuffers::BindDitherTexture(int texunit) .8515625, .6015625, .9765625, .7265625, .8671875, .6171875, .9921875, .7421875, }; + glActiveTexture(GL_TEXTURE0 + texunit); mDitherTexture = Create2DTexture("DitherTexture", GL_R32F, 8, 8, data); } mDitherTexture.Bind(1, GL_NEAREST, GL_REPEAT); From a10f9526bc0570a0e2272add56053bfb5c9a4f66 Mon Sep 17 00:00:00 2001 From: argv-minus-one Date: Sat, 11 Aug 2018 23:49:41 -0700 Subject: [PATCH 02/21] Bump ZScript version to 3.5.0. When GZDoom 3.5.0 was released, the ZScript version in the release commit was set to 3.5.0, but on master it was left at 3.4.0. In the future, I suggest setting the ZScript version *before* making a release commit. Then master will remain up to date. --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 679ae1113..9e36f91fe 100644 --- a/src/version.h +++ b/src/version.h @@ -55,9 +55,9 @@ const char *GetVersionString(); #define RC_FILEVERSION 3,5,9999,0 #define RC_PRODUCTVERSION 3,5,9999,0 #define RC_PRODUCTVERSION2 VERSIONSTR -// These are for content versioning. The current state is '3.3'. +// These are for content versioning. The current state is '3.5'. #define VER_MAJOR 3 -#define VER_MINOR 4 +#define VER_MINOR 5 #define VER_REVISION 0 // Version identifier for network games. From c33f3588946a44f27564b0699467ded86c77512b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Aug 2018 20:46:26 +0200 Subject: [PATCH 03/21] - clear GLWF_TRANSLUCENT at the end of PutWall. --- src/hwrenderer/scene/hw_walls.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hwrenderer/scene/hw_walls.cpp b/src/hwrenderer/scene/hw_walls.cpp index 7be61d9b6..d164aaf31 100644 --- a/src/hwrenderer/scene/hw_walls.cpp +++ b/src/hwrenderer/scene/hw_walls.cpp @@ -204,6 +204,7 @@ void GLWall::PutWall(HWDrawInfo *di, bool translucent) // make sure that following parts of the same linedef do not get this one's vertex and lighting info. vertcount = 0; dynlightindex = -1; + flags &= ~GLWF_TRANSLUCENT; } void GLWall::PutPortal(HWDrawInfo *di, int ptype) From 57ed4df85eeddad8483d9f099abb2478caee7034 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 13 Aug 2018 20:47:56 +0200 Subject: [PATCH 04/21] - fixed FraggleScript's moving camera. The logic here was a bit more complicated than I assumed but it was all buried in a heap of code that tried to deal with angular wraparounds in the BAM format. --- src/fragglescript/t_func.cpp | 58 +++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 85b6e726d..6e37b7a16 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2885,44 +2885,62 @@ void FParser::SF_MoveCamera(void) } double targetheight = floatvalue(t_argv[2]); + double movespeed = floatvalue(t_argv[3]); DVector3 campos = cam->Pos(); DVector3 targpos = DVector3(target->Pos(), targetheight); + DVector3 movement = targpos - campos; + double movelen = movement.Length(); + + bool finishedmove = false; + bool finishedangle = false; + + cam->radius = 1 / 8192.; + cam->Height = 1 / 8192.; + if (campos != targpos) { - DVector3 movement = targpos - campos; - double movelen = movement.Length(); - double movespeed = floatvalue(t_argv[3]); DVector3 movepos; - bool finished = (movespeed >= movelen); - if (finished) movepos = targpos; + finishedmove = (movespeed >= movelen); + if (finishedmove) movepos = targpos; else movepos = campos + movement.Resized(movespeed); + cam->SetOrigin(movepos, true); + } - DAngle targetangle = floatvalue(t_argv[4]); + DAngle targetangle = DAngle(floatvalue(t_argv[4])).Normalized360(); + if (cam->Angles.Yaw != targetangle) + { DAngle anglespeed = floatvalue(t_argv[5]); + DAngle anglenow = targetangle; + const DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle); if (movespeed > 0 && anglespeed == 0.) { - if (!finished) + if (!finishedmove) { - const DAngle diffangle = targetangle - cam->Angles.Yaw; - targetangle = cam->Angles.Yaw + diffangle * movespeed / movelen; + anglenow = cam->Angles.Yaw + diffangle * movespeed / movelen; } + else finishedangle = true; } else { - targetangle = cam->Angles.Yaw + anglespeed; + if (diffangle > 0) + { + anglenow = (cam->Angles.Yaw + anglespeed).Normalized360(); + } + else + { + anglenow = (cam->Angles.Yaw - anglespeed).Normalized360(); + } + const DAngle diffangle2 = deltaangle(anglenow, targetangle); + if (diffangle.Degrees * diffangle2.Degrees <= 0) + { + anglenow = targetangle; + finishedangle = true; + } } - - cam->radius = 1 / 8192.; - cam->Height = 1 / 8192.; - cam->SetOrigin(movepos, true); - cam->SetAngle(targetangle, false); - t_return.value.i = 1; - } - else - { - t_return.value.i = 0; + cam->SetAngle(anglenow, false); } + t_return.value.i = !(finishedmove & finishedangle); t_return.type = svt_int; } } From 0717f5aedea8596aab81f47d6eaaa505e27c9ec9 Mon Sep 17 00:00:00 2001 From: argv-minus-one Date: Tue, 14 Aug 2018 01:14:35 -0700 Subject: [PATCH 05/21] Make various getter and pure-math Actor methods clearscope. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These methods do not examine or change playsim state. They only perform math or look at class metadata. Methods changed are: • deltaangle • absangle • AngleToVector • RotateVector • Normalize180 • BobSin • GetDefaultSpeed • FindState • GetDropItems (which changes the scope of the returned struct, but the returned struct is all-readonly anyway) --- wadsrc/static/zscript/actor.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 58620d33c..174722d00 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -407,11 +407,11 @@ class Actor : Thinker native // Functions // 'parked' global functions. - native static double deltaangle(double ang1, double ang2); - native static double absangle(double ang1, double ang2); - native static Vector2 AngleToVector(double angle, double length = 1); - native static Vector2 RotateVector(Vector2 vec, double angle); - native static double Normalize180(double ang); + native clearscope static double deltaangle(double ang1, double ang2); + native clearscope static double absangle(double ang1, double ang2); + native clearscope static Vector2 AngleToVector(double angle, double length = 1); + native clearscope static Vector2 RotateVector(Vector2 vec, double angle); + native clearscope static double Normalize180(double ang); bool IsPointerEqual(int ptr_select1, int ptr_select2) @@ -419,7 +419,7 @@ class Actor : Thinker native return GetPointer(ptr_select1) == GetPointer(ptr_select2); } - static double BobSin(double fb) + clearscope static double BobSin(double fb) { return sin(fb * (180./32)) * 8; } @@ -547,7 +547,7 @@ class Actor : Thinker native native static class GetReplacement(class cls); native static class GetReplacee(class cls); native static int GetSpriteIndex(name sprt); - native static double GetDefaultSpeed(class type); + native clearscope static double GetDefaultSpeed(class type); native static class GetSpawnableType(int spawnnum); native static int ApplyDamageFactors(class itemcls, Name damagetype, int damage, int defdamage); native void RemoveFromHash(); @@ -667,7 +667,7 @@ class Actor : Thinker native native void RandomChaseDir(); native bool CheckMissileRange(); native bool SetState(state st, bool nofunction = false); - native state FindState(statelabel st, bool exact = false); + clearscope native state FindState(statelabel st, bool exact = false) const; bool SetStateLabel(statelabel st, bool nofunction = false) { return SetState(FindState(st), nofunction); } native action state ResolveState(statelabel st); // this one, unlike FindState, is context aware. native void LinkToWorld(LinkContext ctx = null); @@ -689,7 +689,7 @@ class Actor : Thinker native native clearscope bool isFriend(Actor other) const; native clearscope bool isHostile(Actor other) const; native void AdjustFloorClip(); - native DropItem GetDropItems(); + native clearscope DropItem GetDropItems() const; native void CopyFriendliness (Actor other, bool changeTarget, bool resetHealth = true); native bool LookForMonsters(); native bool LookForTid(bool allaround, LookExParams params = null); From 96ec6b1dc665d7bb3d5ba005d0e238ac6309db17 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Aug 2018 21:12:16 +0200 Subject: [PATCH 06/21] - fixed FS camera for real. --- src/fragglescript/t_func.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 6e37b7a16..c034b5116 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2905,6 +2905,7 @@ void FParser::SF_MoveCamera(void) else movepos = campos + movement.Resized(movespeed); cam->SetOrigin(movepos, true); } + else finishedmove = true; DAngle targetangle = DAngle(floatvalue(t_argv[4])).Normalized360(); if (cam->Angles.Yaw != targetangle) @@ -2940,6 +2941,7 @@ void FParser::SF_MoveCamera(void) } cam->SetAngle(anglenow, false); } + else finishedangle = true; t_return.value.i = !(finishedmove & finishedangle); t_return.type = svt_int; } From 7d40edd6ac6cec0ca4e41f84acb97f72e4ecd7b8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Aug 2018 21:29:14 +0200 Subject: [PATCH 07/21] - disable runtime buffer security check in release build. This has a minor but measurable effect on performance because it gets inserted into every function which uses a local stack space structure. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1328491d3..032dbb12c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,9 +203,9 @@ if( MSVC ) # Avoid CRT DLL dependancies in release builds, optionally generate assembly output for checking crash locations. option( ZDOOM_GENERATE_ASM "Generate assembly output." OFF ) if( ZDOOM_GENERATE_ASM ) - set( REL_C_FLAGS "/MT /Oy /Oi /FAcs" ) + set( REL_C_FLAGS "/MT /Oy /Oi /FAcs /GS-" ) else() - set( REL_C_FLAGS "/MT /Oy /Oi" ) + set( REL_C_FLAGS "/MT /Oy /Oi /GS-" ) endif() From e18b17217fbcb35e9670b3fae2f39bfcb0715ecf Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Wed, 15 Aug 2018 17:46:03 +0200 Subject: [PATCH 08/21] Added CheckReplacement to event handlers, a function inspired by its namesake in Unreal's Mutator class. Performs runtime replacement of actor classes. Takes priority over the "replaces" keyword in both DECORATE and ZScript. --- src/events.cpp | 27 +++++++++++++++++++++++++++ src/events.h | 12 ++++++++++++ src/info.cpp | 4 +++- wadsrc/static/zscript/events.txt | 9 +++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/events.cpp b/src/events.cpp index eabf1b931..11766f6c9 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -38,6 +38,7 @@ #include "actor.h" #include "c_dispatch.h" #include "d_net.h" +#include "info.h" DStaticEventHandler* E_FirstEventHandler = nullptr; DStaticEventHandler* E_LastEventHandler = nullptr; @@ -506,6 +507,12 @@ bool E_CheckRequireMouse() return false; } +void E_CheckReplacement( PClassActor *replacee, PClassActor **replacement ) +{ + for (DStaticEventHandler *handler = E_FirstEventHandler; handler; handler = handler->next) + handler->CheckReplacement(replacee,replacement); +} + // normal event loopers (non-special, argument-less) DEFINE_EVENT_LOOPER(RenderFrame) DEFINE_EVENT_LOOPER(WorldLightning) @@ -571,6 +578,9 @@ DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, Name) DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, Args) DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, IsManual) +DEFINE_FIELD_X(ReplaceEvent, FReplaceEvent, Replacee) +DEFINE_FIELD_X(ReplaceEvent, FReplaceEvent, Replacement) + DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder) { PARAM_SELF_PROLOGUE(DStaticEventHandler); @@ -653,6 +663,8 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, PostUiTick); DEFINE_EMPTY_HANDLER(DStaticEventHandler, ConsoleProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, NetworkProcess); +DEFINE_EMPTY_HANDLER(DStaticEventHandler, CheckReplacement); + // =========================================== // // Event handlers @@ -1123,6 +1135,21 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int } } +void DStaticEventHandler::CheckReplacement( PClassActor *replacee, PClassActor **replacement ) +{ + IFVIRTUAL(DStaticEventHandler, CheckReplacement) + { + // don't create excessive DObjects if not going to be processed anyway + if (func == DStaticEventHandler_CheckReplacement_VMPtr) + return; + FReplaceEvent e = { replacee, *replacement }; + VMValue params[2] = { (DStaticEventHandler*)this, &e }; + VMCall(func, params, 2, nullptr, 0); + if ( e.Replacement != replacee ) // prevent infinite recursion + *replacement = e.Replacement; + } +} + // void DStaticEventHandler::OnDestroy() { diff --git a/src/events.h b/src/events.h index 072502501..4359178ce 100755 --- a/src/events.h +++ b/src/events.h @@ -69,6 +69,9 @@ bool E_Responder(const event_t* ev); // splits events into InputProcess and UiPr // this executes on console/net events. void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual); +// called when looking up the replacement for an actor class +void E_CheckReplacement(PClassActor* replacee, PClassActor** replacement); + // send networked event. unified function. bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual); @@ -166,6 +169,9 @@ public: // void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual); + + // + void CheckReplacement(PClassActor* replacee, PClassActor** replacement); }; class DEventHandler : public DStaticEventHandler { @@ -262,4 +268,10 @@ struct FConsoleEvent bool IsManual; }; +struct FReplaceEvent +{ + PClassActor* Replacee; + PClassActor* Replacement; +}; + #endif diff --git a/src/info.cpp b/src/info.cpp index 4022e8b2a..480c35814 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -425,7 +425,9 @@ PClassActor *PClassActor::GetReplacement(bool lookskill) lookskill = false; skillrepname = NAME_None; } } - auto Replacement = ActorInfo()->Replacement; + // [MK] ZScript replacement through Event Handlers, has priority over others + PClassActor *Replacement = ActorInfo()->Replacement; + E_CheckReplacement(this,&Replacement); if (Replacement == nullptr && (!lookskill || skillrepname == NAME_None)) { return this; diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index fc8b82721..038e84515 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -285,6 +285,12 @@ struct ConsoleEvent native version("2.4") native readonly bool IsManual; } +struct ReplaceEvent native version("2.4") +{ + native readonly Class Replacee; + native Class Replacement; +} + class StaticEventHandler : Object native play version("2.4") { // static event handlers CAN register other static event handlers. @@ -329,6 +335,9 @@ class StaticEventHandler : Object native play version("2.4") virtual native ui void ConsoleProcess(ConsoleEvent e); virtual native void NetworkProcess(ConsoleEvent e); + // + virtual native void CheckReplacement(ReplaceEvent e); + // this value will be queried on Register() to decide the relative order of this handler to every other. // this is most useful in UI systems. // default is 0. From 4e690b1f60d9f9d9154bbf342e79f5a5769ac60d Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Wed, 15 Aug 2018 19:41:52 +0200 Subject: [PATCH 09/21] Fix SDL window "sticking" to the center of the screen after using vid_setsize. --- src/posix/sdl/gl_sysfb.h | 2 ++ src/posix/sdl/sdlglvideo.cpp | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/posix/sdl/gl_sysfb.h b/src/posix/sdl/gl_sysfb.h index c9c1e8192..ee2713bc5 100644 --- a/src/posix/sdl/gl_sysfb.h +++ b/src/posix/sdl/gl_sysfb.h @@ -31,6 +31,8 @@ public: SDL_Window *GetSDLWindow() { return Screen; } void GetWindowBordersSize(int &top, int &left); + bool m_fsswitch; + protected: void SetGammaTable(uint16_t *tbl); void ResetGammaTable(); diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 651842083..15c0e4944 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -175,6 +175,8 @@ IVideo *gl_CreateVideo() SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen) : DFrameBuffer (vid_defwidth, vid_defheight) { + m_fsswitch = false; + // SDL_GetWindowBorderSize() is only available since 2.0.5, but because // GZDoom supports platforms with older SDL2 versions, this function // has to be dynamically loaded @@ -334,8 +336,16 @@ void SystemGLFrameBuffer::ToggleFullscreen(bool yes) SDL_SetWindowFullscreen(Screen, yes ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); if ( !yes ) { - fullscreen = false; - SetWindowSize(win_w, win_h); + if ( !m_fsswitch ) + { + m_fsswitch = true; + fullscreen = false; + } + else + { + m_fsswitch = false; + SetWindowSize(win_w, win_h); + } } } @@ -414,7 +424,7 @@ void ProcessSDLWindowEvent(const SDL_WindowEvent &event) break; case SDL_WINDOWEVENT_RESIZED: - if (!fullscreen) + if (!fullscreen && !(static_cast(screen)->m_fsswitch)) { win_w = event.data1; win_h = event.data2; From 02926a55673f00b47c7005603cb7cf291d2d03d9 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Thu, 16 Aug 2018 20:46:40 +0200 Subject: [PATCH 10/21] Add "IsFinal" parameter for CheckReplacement. If set to true it guarantees that the replacement is final and will not go through the rest of the replacement chain. --- src/events.cpp | 12 ++++++++---- src/events.h | 5 +++-- src/info.cpp | 6 +++++- wadsrc/static/zscript/events.txt | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 11766f6c9..91e66b82b 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -507,10 +507,12 @@ bool E_CheckRequireMouse() return false; } -void E_CheckReplacement( PClassActor *replacee, PClassActor **replacement ) +bool E_CheckReplacement( PClassActor *replacee, PClassActor **replacement ) { + bool final = false; for (DStaticEventHandler *handler = E_FirstEventHandler; handler; handler = handler->next) - handler->CheckReplacement(replacee,replacement); + handler->CheckReplacement(replacee,replacement,&final); + return final; } // normal event loopers (non-special, argument-less) @@ -580,6 +582,7 @@ DEFINE_FIELD_X(ConsoleEvent, FConsoleEvent, IsManual) DEFINE_FIELD_X(ReplaceEvent, FReplaceEvent, Replacee) DEFINE_FIELD_X(ReplaceEvent, FReplaceEvent, Replacement) +DEFINE_FIELD_X(ReplaceEvent, FReplaceEvent, IsFinal) DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder) { @@ -1135,18 +1138,19 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int } } -void DStaticEventHandler::CheckReplacement( PClassActor *replacee, PClassActor **replacement ) +void DStaticEventHandler::CheckReplacement( PClassActor *replacee, PClassActor **replacement, bool *final ) { IFVIRTUAL(DStaticEventHandler, CheckReplacement) { // don't create excessive DObjects if not going to be processed anyway if (func == DStaticEventHandler_CheckReplacement_VMPtr) return; - FReplaceEvent e = { replacee, *replacement }; + FReplaceEvent e = { replacee, *replacement, *final }; VMValue params[2] = { (DStaticEventHandler*)this, &e }; VMCall(func, params, 2, nullptr, 0); if ( e.Replacement != replacee ) // prevent infinite recursion *replacement = e.Replacement; + *final = e.IsFinal; } } diff --git a/src/events.h b/src/events.h index 4359178ce..1fbf271dc 100755 --- a/src/events.h +++ b/src/events.h @@ -70,7 +70,7 @@ bool E_Responder(const event_t* ev); // splits events into InputProcess and UiPr void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual); // called when looking up the replacement for an actor class -void E_CheckReplacement(PClassActor* replacee, PClassActor** replacement); +bool E_CheckReplacement(PClassActor* replacee, PClassActor** replacement); // send networked event. unified function. bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual); @@ -171,7 +171,7 @@ public: void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual); // - void CheckReplacement(PClassActor* replacee, PClassActor** replacement); + void CheckReplacement(PClassActor* replacee, PClassActor** replacement, bool* final); }; class DEventHandler : public DStaticEventHandler { @@ -272,6 +272,7 @@ struct FReplaceEvent { PClassActor* Replacee; PClassActor* Replacement; + bool IsFinal; }; #endif diff --git a/src/info.cpp b/src/info.cpp index 480c35814..f31abf953 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -427,7 +427,11 @@ PClassActor *PClassActor::GetReplacement(bool lookskill) } // [MK] ZScript replacement through Event Handlers, has priority over others PClassActor *Replacement = ActorInfo()->Replacement; - E_CheckReplacement(this,&Replacement); + if ( E_CheckReplacement(this,&Replacement) ) + { + // [MK] the replacement is final, so don't continue with the chain + return Replacement ? Replacement : this; + } if (Replacement == nullptr && (!lookskill || skillrepname == NAME_None)) { return this; diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index 038e84515..9a908f060 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -289,6 +289,7 @@ struct ReplaceEvent native version("2.4") { native readonly Class Replacee; native Class Replacement; + native bool IsFinal; } class StaticEventHandler : Object native play version("2.4") From 155afebb65c7982c989becd16dafd8e75413469a Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 17 Aug 2018 19:03:50 +0200 Subject: [PATCH 11/21] Add HITOWNER flag, when set, allows a projectile to collide with its shooter. --- src/actor.h | 1 + src/p_map.cpp | 4 ++-- src/scripting/thingdef_data.cpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/actor.h b/src/actor.h index 9c326fdc6..71295794a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -403,6 +403,7 @@ enum ActorFlag8 MF8_INSCROLLSEC = 0x00000002, // actor is partially inside a scrolling sector MF8_BLOCKASPLAYER = 0x00000004, // actor is blocked by player-blocking lines even if not a player MF8_DONTFACETALKER = 0x00000008, // don't alter the angle to face the player in conversations + MF8_HITOWNER = 0x00000010, // projectile can hit the actor that fired it }; // --- mobj.renderflags --- diff --git a/src/p_map.cpp b/src/p_map.cpp index 2e3e24651..c43a739d4 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1554,8 +1554,8 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (tm.thing->target != NULL) { - if (thing == tm.thing->target) - { // Don't missile self + if (thing == tm.thing->target && !(tm.thing->flags8 & MF8_HITOWNER)) + { // Don't missile self -- [MK] unless explicitly allowed return true; } diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index c0ef05e23..ca6bee2a4 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -318,6 +318,7 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF8, FRIGHTENING, AActor, flags8), DEFINE_FLAG(MF8, BLOCKASPLAYER, AActor, flags8), DEFINE_FLAG(MF8, DONTFACETALKER, AActor, flags8), + DEFINE_FLAG(MF8, HITOWNER, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), From 20b6db30d78b801aa04f273a3df3e32b7c5590a2 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 17 Aug 2018 21:27:02 +0200 Subject: [PATCH 12/21] Added missing check for HITOWNER on bouncers with 0 damage. --- src/p_map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index c43a739d4..9ca345d9b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1539,7 +1539,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch // MBF bouncer might have a non-0 damage value, but they must not deal damage on impact either. if ((tm.thing->BounceFlags & BOUNCE_Actors) && (tm.thing->IsZeroDamage() || !(tm.thing->flags & MF_MISSILE))) { - return (tm.thing->target == thing || !(thing->flags & MF_SOLID)); + return ((tm.thing->target == thing && !(tm.thing->flags8 & MF8_HITOWNER)) || !(thing->flags & MF_SOLID)); } switch (tm.thing->SpecialMissileHit(thing)) From d965c9aa769b1b88173bb50a24f75ce046bebe08 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Aug 2018 13:00:33 +0300 Subject: [PATCH 13/21] - support static const arrays inside structs https://forum.zdoom.org/viewtopic.php?t=61677 --- src/scripting/zscript/zcc-parse.lemon | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripting/zscript/zcc-parse.lemon b/src/scripting/zscript/zcc-parse.lemon index 11847217f..97b63198a 100644 --- a/src/scripting/zscript/zcc-parse.lemon +++ b/src/scripting/zscript/zcc-parse.lemon @@ -390,6 +390,7 @@ struct_body(X) ::= struct_body(A) struct_member(B). { X = A; /*X-overwrites-A*/ struct_member(X) ::= declarator(A). { X = A; /*X-overwrites-A*/ } struct_member(X) ::= enum_def(A). { X = A; /*X-overwrites-A*/ } struct_member(X) ::= const_def(A). { X = A; /*X-overwrites-A*/ } +struct_member(X) ::= staticarray_statement(A). { X = A; /*X-overwrites-A*/ } /*----- Constant Definition ------*/ /* Like UnrealScript, a constant's type is implied by its value's type. */ From 31bd7cfc0441bff1c6899d2b6c8e2ed180cca067 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Aug 2018 15:20:38 +0300 Subject: [PATCH 14/21] - prohibit assignment of dynamic arrays https://forum.zdoom.org/viewtopic.php?t=61682 --- src/scripting/backend/codegen.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 75f04d421..b98b2ae24 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -2480,6 +2480,12 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) delete this; return nullptr; } + else if (Base->IsDynamicArray()) + { + ScriptPosition.Message(MSG_ERROR, "Cannot assign dymanic arrays, use Copy() or Move() function instead"); + delete this; + return nullptr; + } if (!Base->IsVector() && Base->ValueType->isStruct()) { ScriptPosition.Message(MSG_ERROR, "Struct assignment not implemented yet"); From 12b851057430fee7f13bfd676cd2c9c6cf6af485 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Aug 2018 16:05:33 +0300 Subject: [PATCH 15/21] - cleaned up inconsistent leading whitespaces Bump copyright year as well --- src/posix/cocoa/i_main.mm | 20 ++++++------- src/posix/cocoa/i_system.mm | 60 ++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/posix/cocoa/i_main.mm b/src/posix/cocoa/i_main.mm index 7db0d40ee..9fe38947b 100644 --- a/src/posix/cocoa/i_main.mm +++ b/src/posix/cocoa/i_main.mm @@ -2,7 +2,7 @@ ** i_main.mm ** **--------------------------------------------------------------------------- - ** Copyright 2012-2015 Alexey Lysiuk + ** Copyright 2012-2018 Alexey Lysiuk ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -405,23 +405,23 @@ extern bool AppActive; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - while (true) - { - NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask + while (true) + { + NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0] inMode:NSDefaultRunLoopMode dequeue:YES]; - if (nil == event) - { - break; - } + if (nil == event) + { + break; + } I_ProcessEvent(event); [NSApp sendEvent:event]; } - - [NSApp updateWindows]; + + [NSApp updateWindows]; [pool release]; } diff --git a/src/posix/cocoa/i_system.mm b/src/posix/cocoa/i_system.mm index 94a911bfa..1b1d79dbb 100644 --- a/src/posix/cocoa/i_system.mm +++ b/src/posix/cocoa/i_system.mm @@ -2,7 +2,7 @@ ** i_system.mm ** **--------------------------------------------------------------------------- - ** Copyright 2012-2015 Alexey Lysiuk + ** Copyright 2012-2018 Alexey Lysiuk ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ void I_Tactile(int /*on*/, int /*off*/, int /*total*/) ticcmd_t* I_BaseTiccmd() { static ticcmd_t emptycmd; - return &emptycmd; + return &emptycmd; } @@ -109,16 +109,16 @@ void I_Init(void) DumpCPUInfo(&CPU); atterm(I_ShutdownSound); - I_InitSound(); + I_InitSound(); } static int has_exited; void I_Quit() { - has_exited = 1; // Prevent infinitely recursive exits -- killough + has_exited = 1; // Prevent infinitely recursive exits -- killough - if (demorecording) + if (demorecording) { G_CheckDemoStatus(); } @@ -132,11 +132,11 @@ bool gameisdead; void I_FatalError(const char* const error, ...) { - static bool alreadyThrown = false; - gameisdead = true; + static bool alreadyThrown = false; + gameisdead = true; - if (!alreadyThrown) // ignore all but the first message -- killough - { + if (!alreadyThrown) // ignore all but the first message -- killough + { alreadyThrown = true; char errortext[MAX_ERRORTEXT]; @@ -158,25 +158,25 @@ void I_FatalError(const char* const error, ...) fprintf(stderr, "%s\n", errortext); exit(-1); - } + } - if (!has_exited) // If it hasn't exited yet, exit now -- killough - { + if (!has_exited) // If it hasn't exited yet, exit now -- killough + { has_exited = 1; // Prevent infinitely recursive exits -- killough exit(-1); - } + } } void I_Error(const char* const error, ...) { - va_list argptr; - char errortext[MAX_ERRORTEXT]; + va_list argptr; + char errortext[MAX_ERRORTEXT]; - va_start(argptr, error); - vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); + va_start(argptr, error); + vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); - throw CRecoverableError(errortext); + throw CRecoverableError(errortext); } @@ -270,7 +270,7 @@ static int matchfile(struct dirent *ent) static int matchfile(const struct dirent *ent) #endif { - return fnmatch(pattern, ent->d_name, FNM_NOESCAPE) == 0; + return fnmatch(pattern, ent->d_name, FNM_NOESCAPE) == 0; } void* I_FindFirst(const char* const filespec, findstate_t* const fileinfo) @@ -290,24 +290,24 @@ void* I_FindFirst(const char* const filespec, findstate_t* const fileinfo) dir = "."; } - fileinfo->current = 0; - fileinfo->count = scandir(dir.GetChars(), &fileinfo->namelist, matchfile, alphasort); + fileinfo->current = 0; + fileinfo->count = scandir(dir.GetChars(), &fileinfo->namelist, matchfile, alphasort); - if (fileinfo->count > 0) - { + if (fileinfo->count > 0) + { return fileinfo; - } + } - return (void*)-1; + return (void*)-1; } int I_FindNext(void* const handle, findstate_t* const fileinfo) { - findstate_t* const state = static_cast(handle); + findstate_t* const state = static_cast(handle); - if (state->current < fileinfo->count) - { - return ++state->current < fileinfo->count ? 0 : -1; + if (state->current < fileinfo->count) + { + return ++state->current < fileinfo->count ? 0 : -1; } return -1; From 34f2d8f31048591484c35051d54bed023d4fa2f3 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 18 Aug 2018 17:45:26 +0300 Subject: [PATCH 16/21] - fixed typo in error message --- src/scripting/backend/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index b98b2ae24..0e8bd619f 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -2482,7 +2482,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) } else if (Base->IsDynamicArray()) { - ScriptPosition.Message(MSG_ERROR, "Cannot assign dymanic arrays, use Copy() or Move() function instead"); + ScriptPosition.Message(MSG_ERROR, "Cannot assign dynamic arrays, use Copy() or Move() function instead"); delete this; return nullptr; } From fad406c4c92074492a4be7500ec4e0da828d47b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Aug 2018 01:14:15 +0200 Subject: [PATCH 17/21] - got rid of FNameNoInit and made the default constructor of FName non-initializing. This setup has been a constant source of problems so now I reviewed all uses of FName to make sure that everything that needs to be initialized is done manually. This also merges the player_t constructor into the class definition as default values. --- src/actor.h | 14 +- src/c_console.cpp | 2 +- src/d_netinfo.cpp | 8 +- src/d_player.h | 164 +++++++++++----------- src/decallib.cpp | 4 +- src/dobjtype.h | 4 +- src/doomdata.h | 2 +- src/edata.cpp | 2 +- src/events.h | 2 +- src/g_level.h | 7 +- src/g_mapinfo.cpp | 5 +- src/g_statusbar/sbar.h | 2 +- src/g_statusbar/sbarinfo_commands.cpp | 2 +- src/g_statusbar/shared_sbar.cpp | 2 +- src/info.cpp | 4 +- src/intermission/intermission.h | 4 +- src/menu/menu.h | 4 +- src/menu/menudef.cpp | 8 +- src/name.h | 16 +-- src/p_conversation.h | 2 +- src/p_interaction.cpp | 13 +- src/p_map.cpp | 5 +- src/p_mobj.cpp | 10 +- src/p_states.cpp | 20 ++- src/p_terrain.cpp | 6 +- src/p_udmf.cpp | 7 +- src/p_udmf.h | 2 +- src/p_usdf.cpp | 4 +- src/p_user.cpp | 76 ---------- src/r_defs.h | 6 +- src/s_sndseq.cpp | 6 +- src/sc_man.cpp | 7 +- src/sc_man.h | 1 - src/scripting/backend/codegen.cpp | 10 +- src/scripting/backend/codegen.h | 2 +- src/scripting/decorate/olddecorations.cpp | 3 +- src/scripting/decorate/thingdef_exp.cpp | 2 +- src/scripting/decorate/thingdef_parse.cpp | 8 +- src/scripting/thingdef_properties.cpp | 12 +- src/scripting/types.cpp | 4 +- src/scripting/types.h | 6 +- src/scripting/zscript/zcc_parser.cpp | 2 +- src/serializer.cpp | 2 +- src/textures/animations.cpp | 1 + src/umapinfo.cpp | 2 +- src/v_font.h | 2 +- src/zstring.h | 1 - 47 files changed, 177 insertions(+), 301 deletions(-) diff --git a/src/actor.h b/src/actor.h index 71295794a..7fb4e4cc8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1141,7 +1141,7 @@ public: uint8_t WeaveIndexZ; int skillrespawncount; int TIDtoHate; // TID of things to hate (0 if none) - FNameNoInit Species; // For monster families + FName Species; // For monster families TObjPtr alternative; // (Un)Morphed actors stored here. Those with the MF_UNMORPHED flag are the originals. TObjPtr tracer; // Thing being chased/attacked for tracers TObjPtr master; // Thing which spawned this one (prevents mutual attacks) @@ -1184,12 +1184,12 @@ public: line_t *BlockingLine; // Line that blocked the last move int PoisonDamage; // Damage received per tic from poison. - FNameNoInit PoisonDamageType; // Damage type dealt by poison. + FName PoisonDamageType; // Damage type dealt by poison. int PoisonDuration; // Duration left for receiving poison damage. int PoisonPeriod; // How often poison damage is applied. (Every X tics.) int PoisonDamageReceived; // Damage received per tic from poison. - FNameNoInit PoisonDamageTypeReceived; // Damage type received by poison. + FName PoisonDamageTypeReceived; // Damage type received by poison. int PoisonDurationReceived; // Duration left for receiving poison damage. int PoisonPeriodReceived; // How often poison damage is applied. (Every X tics.) TObjPtr Poisoner; // Last source of received poison damage. @@ -1229,13 +1229,13 @@ public: int32_t Mass; int16_t PainChance; int PainThreshold; - FNameNoInit DamageType; - FNameNoInit DamageTypeReceived; + FName DamageType; + FName DamageTypeReceived; double DamageFactor; double DamageMultiply; - FNameNoInit PainType; - FNameNoInit DeathType; + FName PainType; + FName DeathType; PClassActor *TeleFogSourceType; PClassActor *TeleFogDestType; int RipperLevel; diff --git a/src/c_console.cpp b/src/c_console.cpp index da38a25e9..bc552c3b8 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1807,7 +1807,7 @@ struct TabData FName TabName; TabData() - : UseCount(0) + : UseCount(0), TabName(NAME_None) { } diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index 2bc59fe71..ef68ebf4e 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -756,7 +756,7 @@ void D_ReadUserInfoStrings (int pnum, uint8_t **stream, bool update) const char *breakpt; FString value; bool compact; - FName keyname; + FName keyname = NAME_None; unsigned int infotype = 0; if (*ptr++ != '\\') @@ -925,8 +925,6 @@ void WriteUserInfo(FSerializer &arc, userinfo_t &info) void ReadUserInfo(FSerializer &arc, userinfo_t &info, FString &skin) { - FName name; - FBaseCVar **cvar; UCVarValue val; const char *key; const char *str; @@ -938,8 +936,8 @@ void ReadUserInfo(FSerializer &arc, userinfo_t &info, FString &skin) while ((key = arc.GetKey())) { arc.StringPtr(nullptr, str); - name = key; - cvar = info.CheckKey(name); + FName name = key; + FBaseCVar **cvar = info.CheckKey(name); if (cvar != NULL && *cvar != NULL) { switch (name) diff --git a/src/d_player.h b/src/d_player.h index 189b0973b..1ae74de32 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -141,7 +141,7 @@ public: double SideMove1, SideMove2; FTextureID ScoreIcon; int SpawnMask; - FNameNoInit MorphWeapon; + FName MorphWeapon; double AttackZOffset; // attack height, relative to player center double UseRange; // [NS] Distance at which player can +use double AirCapacity; // Multiplier for air supply underwater. @@ -155,10 +155,10 @@ public: double ViewBob; // Former class properties that were moved into the object to get rid of the meta class. - FNameNoInit SoundClass; // Sound class - FNameNoInit Face; // Doom status bar face (when used) - FNameNoInit Portrait; - FNameNoInit Slot[10]; + FName SoundClass; // Sound class + FName Face; // Doom status bar face (when used) + FName Portrait; + FName Slot[10]; double HexenArmor[5]; uint8_t ColorRangeStart; // Skin color range uint8_t ColorRangeEnd; @@ -372,7 +372,7 @@ void WriteUserInfo(FSerializer &arc, userinfo_t &info); class player_t { public: - player_t(); + player_t() = default; ~player_t(); player_t &operator= (const player_t &p); @@ -384,117 +384,117 @@ public: void SetLogText (const char *text); void SendPitchLimits() const; - APlayerPawn *mo; - uint8_t playerstate; - ticcmd_t cmd; + APlayerPawn *mo = nullptr; + uint8_t playerstate = 0; + ticcmd_t cmd = {}; usercmd_t original_cmd; uint32_t original_oldbuttons; userinfo_t userinfo; // [RH] who is this? - PClassActor *cls; // class of associated PlayerPawn + PClassActor *cls = nullptr; // class of associated PlayerPawn - float DesiredFOV; // desired field of vision - float FOV; // current field of vision - double viewz; // focal origin above r.z - double viewheight; // base height above floor for viewz - double deltaviewheight; // squat speed. - double bob; // bounded/scaled total velocity + float DesiredFOV = 0; // desired field of vision + float FOV = 0; // current field of vision + double viewz = 0; // focal origin above r.z + double viewheight = 0; // base height above floor for viewz + double deltaviewheight = 0; // squat speed. + double bob = 0; // bounded/scaled total velocity // killough 10/98: used for realistic bobbing (i.e. not simply overall speed) // mo->velx and mo->vely represent true velocity experienced by player. // This only represents the thrust that the player applies himself. // This avoids anomalies with such things as Boom ice and conveyors. - DVector2 Vel; + DVector2 Vel = { 0,0 }; - bool centering; - uint8_t turnticks; + bool centering = false; + uint8_t turnticks = 0; - bool attackdown; - bool usedown; - uint32_t oldbuttons; - int health; // only used between levels, mo->health + bool attackdown = false; + bool usedown = false; + uint32_t oldbuttons = false; + int health = 0; // only used between levels, mo->health // is used during levels - int inventorytics; - uint8_t CurrentPlayerClass; // class # for this player instance + int inventorytics = 0; + uint8_t CurrentPlayerClass = 0; // class # for this player instance - int frags[MAXPLAYERS]; // kills of other players - int fragcount; // [RH] Cumulative frags for this player - int lastkilltime; // [RH] For multikills - uint8_t multicount; - uint8_t spreecount; // [RH] Keep track of killing sprees - uint16_t WeaponState; + int frags[MAXPLAYERS] = {}; // kills of other players + int fragcount = 0; // [RH] Cumulative frags for this player + int lastkilltime = 0; // [RH] For multikills + uint8_t multicount = 0; + uint8_t spreecount = 0; // [RH] Keep track of killing sprees + uint16_t WeaponState = 0; - AWeapon *ReadyWeapon; - AWeapon *PendingWeapon; // WP_NOCHANGE if not changing - TObjPtr psprites; // view sprites (gun, etc) + AWeapon *ReadyWeapon = nullptr; + AWeapon *PendingWeapon = nullptr; // WP_NOCHANGE if not changing + TObjPtr psprites = nullptr; // view sprites (gun, etc) - int cheats; // bit flags - int timefreezer; // Player has an active time freezer - short refire; // refired shots are less accurate - short inconsistant; - bool waiting; - int killcount, itemcount, secretcount; // for intermission - int damagecount, bonuscount;// for screen flashing - int hazardcount; // for delayed Strife damage - int hazardinterval; // Frequency of damage infliction - FName hazardtype; // Damage type of last hazardous damage encounter. - int poisoncount; // screen flash for poison damage - FName poisontype; // type of poison damage to apply - FName poisonpaintype; // type of Pain state to enter for poison damage - TObjPtr poisoner; // NULL for non-player actors - TObjPtr attacker; // who did damage (NULL for floors) - int extralight; // so gun flashes light up areas - short fixedcolormap; // can be set to REDCOLORMAP, etc. - short fixedlightlevel; - int morphTics; // player is a chicken/pig if > 0 - PClassActor *MorphedPlayerClass; // [MH] (for SBARINFO) class # for this player instance when morphed - int MorphStyle; // which effects to apply for this player instance when morphed - PClassActor *MorphExitFlash; // flash to apply when demorphing (cache of value given to P_MorphPlayer) - TObjPtr PremorphWeapon; // ready weapon before morphing - int chickenPeck; // chicken peck countdown - int jumpTics; // delay the next jump for a moment - bool onground; // Identifies if this player is on the ground or other object + int cheats = 0; // bit flags + int timefreezer = 0; // Player has an active time freezer + short refire = 0; // refired shots are less accurate + short inconsistant = 0; + bool waiting = 0; + int killcount = 0, itemcount = 0, secretcount = 0; // for intermission + int damagecount = 0, bonuscount = 0;// for screen flashing + int hazardcount = 0; // for delayed Strife damage + int hazardinterval = 0; // Frequency of damage infliction + FName hazardtype = NAME_None; // Damage type of last hazardous damage encounter. + int poisoncount = 0; // screen flash for poison damage + FName poisontype = NAME_None; // type of poison damage to apply + FName poisonpaintype = NAME_None; // type of Pain state to enter for poison damage + TObjPtr poisoner = nullptr; // NULL for non-player actors + TObjPtr attacker = nullptr; // who did damage (NULL for floors) + int extralight = 0; // so gun flashes light up areas + short fixedcolormap = 0; // can be set to REDCOLORMAP, etc. + short fixedlightlevel = 0; + int morphTics = 0; // player is a chicken/pig if > 0 + PClassActor *MorphedPlayerClass = nullptr; // [MH] (for SBARINFO) class # for this player instance when morphed + int MorphStyle = 0; // which effects to apply for this player instance when morphed + PClassActor *MorphExitFlash = nullptr; // flash to apply when demorphing (cache of value given to P_MorphPlayer) + TObjPtr PremorphWeapon = nullptr; // ready weapon before morphing + int chickenPeck = 0; // chicken peck countdown + int jumpTics = 0; // delay the next jump for a moment + bool onground = 0; // Identifies if this player is on the ground or other object - int respawn_time; // [RH] delay respawning until this tic - TObjPtr camera; // [RH] Whose eyes this player sees through + int respawn_time = 0; // [RH] delay respawning until this tic + TObjPtr camera = nullptr; // [RH] Whose eyes this player sees through - int air_finished; // [RH] Time when you start drowning + int air_finished = 0; // [RH] Time when you start drowning - FName LastDamageType; // [RH] For damage-specific pain and death sounds + FName LastDamageType = NAME_None; // [RH] For damage-specific pain and death sounds - TObjPtr MUSINFOactor; // For MUSINFO purposes - int8_t MUSINFOtics; + TObjPtr MUSINFOactor = nullptr; // For MUSINFO purposes + int8_t MUSINFOtics = 0; - bool settings_controller; // Player can control game settings. - int8_t crouching; - int8_t crouchdir; + bool settings_controller = false; // Player can control game settings. + int8_t crouching = 0; + int8_t crouchdir = 0; //Added by MC: - TObjPtr Bot; + TObjPtr Bot = nullptr; - float BlendR; // [RH] Final blending values - float BlendG; - float BlendB; - float BlendA; + float BlendR = 0; // [RH] Final blending values + float BlendG = 0; + float BlendB = 0; + float BlendA = 0; FString LogText; // [RH] Log for Strife - DAngle MinPitch; // Viewpitch limits (negative is up, positive is down) - DAngle MaxPitch; + DAngle MinPitch = 0.; // Viewpitch limits (negative is up, positive is down) + DAngle MaxPitch = 0.; - double crouchfactor; - double crouchoffset; - double crouchviewdelta; + double crouchfactor = 0; + double crouchoffset = 0; + double crouchviewdelta = 0; FWeaponSlots weapons; // [CW] I moved these here for multiplayer conversation support. - TObjPtr ConversationNPC, ConversationPC; - DAngle ConversationNPCAngle; - bool ConversationFaceTalker; + TObjPtr ConversationNPC = nullptr, ConversationPC = nullptr; + DAngle ConversationNPCAngle = 0.; + bool ConversationFaceTalker = false; double GetDeltaViewHeight() const { diff --git a/src/decallib.cpp b/src/decallib.cpp index 3b5daef5a..71ac662d3 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -1037,8 +1037,8 @@ FDecalLib::FTranslation *FDecalLib::GenerateTranslation (uint32_t start, uint32_ } FDecalBase::FDecalBase () + : Name(NAME_None) { - Name = NAME_None; } FDecalBase::~FDecalBase () @@ -1152,8 +1152,8 @@ const FDecalTemplate *FDecalGroup::GetDecal () const } FDecalAnimator::FDecalAnimator (const char *name) + : Name(name) { - Name = name; } FDecalAnimator::~FDecalAnimator () diff --git a/src/dobjtype.h b/src/dobjtype.h index 212174005..3445e02ba 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -58,8 +58,8 @@ public: uint8_t *Meta = nullptr; // Per-class static script data unsigned Size = sizeof(DObject); unsigned MetaSize = 0; - FName TypeName; - FName SourceLumpName; + FName TypeName = NAME_None; + FName SourceLumpName = NAME_None; bool bRuntimeClass = false; // class was defined at run-time, not compile-time bool bDecorateClass = false; // may be subject to some idiosyncracies due to DECORATE backwards compatibility bool bAbstract = false; diff --git a/src/doomdata.h b/src/doomdata.h index 38a65ca50..eb54f5f32 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -373,7 +373,7 @@ struct FMapThing uint32_t RenderStyle; int FloatbobPhase; int friendlyseeblocks; - FNameNoInit arg0str; + FName arg0str; }; diff --git a/src/edata.cpp b/src/edata.cpp index 15f3241cf..ee60356a7 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -120,7 +120,7 @@ struct EDSector int damageamount; int damageinterval; - FNameNoInit damagetype; + FName damagetype; uint8_t leaky; uint8_t leakyadd; uint8_t leakyremove; diff --git a/src/events.h b/src/events.h index 1fbf271dc..54d975566 100755 --- a/src/events.h +++ b/src/events.h @@ -204,7 +204,7 @@ struct FWorldEvent AActor* Inflictor = nullptr; // can be null - for damagemobj AActor* DamageSource = nullptr; // can be null int Damage = 0; - FName DamageType; + FName DamageType = NAME_None; int DamageFlags = 0; DAngle DamageAngle; // for line(pre)activated diff --git a/src/g_level.h b/src/g_level.h index b717bdbcf..98bdb4229 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -264,9 +264,8 @@ struct level_info_t; struct FOptionalMapinfoData { - FOptionalMapinfoData *Next; - FName identifier; - FOptionalMapinfoData() { Next = NULL; identifier = NAME_None; } + FOptionalMapinfoData *Next = nullptr; + FName identifier = NAME_None; virtual ~FOptionalMapinfoData() {} virtual FOptionalMapinfoData *Clone() const = 0; }; @@ -572,7 +571,7 @@ typedef TMap SkillActorReplacement; struct FSkillInfo { - FName Name; + FName Name = NAME_None; double AmmoFactor, DoubleAmmoFactor, DropAmmoFactor; double DamageFactor; double ArmorFactor; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 9eb80ae09..d621b231c 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -259,10 +259,13 @@ void level_info_t::Reset() compatflags = compatflags2 = 0; compatmask = compatmask2 = 0; Translator = ""; - RedirectType = 0; + RedirectType = NAME_None; RedirectMapName = ""; EnterPic = ""; ExitPic = ""; + Intermission = NAME_None; + deathsequence = NAME_None; + slideshow = NAME_None; InterMusic = ""; intermusicorder = 0; SoundInfo = ""; diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index a98111a29..968c91760 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -252,7 +252,7 @@ struct FMugShotState unsigned int Position; int Time; int Random; - FName State; + FName State = NAME_None; TArray Frames; FMugShotState(FName name); diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index 199a0fe9d..15b0663af 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -667,7 +667,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage Operator conditionalOperator[2]; FString inventoryItem[2]; int armorType[2]; - FName keySpecies[2]; + FName keySpecies[2] = { NAME_None, NAME_None }; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 7236bc39b..6be4abf9f 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -319,7 +319,7 @@ void ST_CreateStatusBar(bool bTitleLevel) } if (StatusBar == nullptr) { - FName defname; + FName defname = NAME_None; if (gameinfo.gametype & GAME_DoomChex) defname = "DoomStatusBar"; else if (gameinfo.gametype == GAME_Heretic) defname = "HereticStatusBar"; diff --git a/src/info.cpp b/src/info.cpp index f31abf953..0ff3928cd 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -408,7 +408,7 @@ void PClassActor::RegisterIDs() PClassActor *PClassActor::GetReplacement(bool lookskill) { - FName skillrepname; + FName skillrepname = NAME_None; if (lookskill && AllSkills.Size() > (unsigned)gameskill) { @@ -470,7 +470,7 @@ DEFINE_ACTION_FUNCTION(AActor, GetReplacement) PClassActor *PClassActor::GetReplacee(bool lookskill) { - FName skillrepname; + FName skillrepname = NAME_None; if (lookskill && AllSkills.Size() > (unsigned)gameskill) { diff --git a/src/intermission/intermission.h b/src/intermission/intermission.h index a73d18a12..f159ebb7a 100644 --- a/src/intermission/intermission.h +++ b/src/intermission/intermission.h @@ -122,7 +122,7 @@ struct FIntermissionActionCast : public FIntermissionAction typedef FIntermissionAction Super; FString mName; - FName mCastClass; + FName mCastClass = NAME_None; TArray mCastSounds; FIntermissionActionCast(); @@ -144,7 +144,7 @@ struct FIntermissionActionScroller : public FIntermissionAction struct FIntermissionDescriptor { - FName mLink; + FName mLink = NAME_None; TDeletingArray mActions; }; diff --git a/src/menu/menu.h b/src/menu/menu.h index 2091bd823..904ea0080 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -121,7 +121,7 @@ class DMenuDescriptor : public DObject { DECLARE_CLASS(DMenuDescriptor, DObject) public: - FName mMenuName; + FName mMenuName = NAME_None; FString mNetgameMessage; PClass *mClass = nullptr; bool mProtected = false; @@ -287,7 +287,7 @@ class DMenuItemBase : public DObject DECLARE_CLASS(DMenuItemBase, DObject) public: double mXpos, mYpos; - FNameNoInit mAction; + FName mAction; bool mEnabled; bool Activate(); diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 5cbc88549..19217e527 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -657,11 +657,9 @@ static void ParseListMenu(FScanner &sc) static void ParseOptionValue(FScanner &sc) { - FName optname; - FOptionValues *val = new FOptionValues; sc.MustGetString(); - optname = sc.String; + FName optname = sc.String; sc.MustGetStringName("{"); while (!sc.CheckString("}")) { @@ -689,11 +687,9 @@ static void ParseOptionValue(FScanner &sc) static void ParseOptionString(FScanner &sc) { - FName optname; - FOptionValues *val = new FOptionValues; sc.MustGetString(); - optname = sc.String; + FName optname = sc.String; sc.MustGetStringName("{"); while (!sc.CheckString("}")) { diff --git a/src/name.h b/src/name.h index 521a8e697..575e42d06 100644 --- a/src/name.h +++ b/src/name.h @@ -46,7 +46,7 @@ class FString; class FName { public: - FName () : Index(0) {} + FName() = default;// : Index(0) {} FName (const char *text) { Index = NameData.FindName (text, false); } FName (const char *text, bool noCreate) { Index = NameData.FindName (text, noCreate); } FName (const char *text, size_t textlen, bool noCreate) { Index = NameData.FindName (text, textlen, noCreate); } @@ -120,20 +120,6 @@ protected: }; static NameManager NameData; - - enum EDummy { NoInit }; - FName (EDummy) {} -}; - -class FNameNoInit : public FName -{ -public: - FNameNoInit() : FName(NoInit) {} - - FName &operator = (const char *text) { Index = NameData.FindName (text, false); return *this; } - FName &operator = (const FString &text); - FName &operator = (const FName &other) { Index = int(other); return *this; } - FName &operator = (ENamedName index) { Index = index; return *this; } }; #endif diff --git a/src/p_conversation.h b/src/p_conversation.h index bc2e56be1..2a516e06e 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -33,7 +33,7 @@ struct FStrifeDialogueNode FString Goodbye; // must init to null for binary scripts to work as intended FStrifeDialogueReply *Children = nullptr; - FName MenuClassName; + FName MenuClassName = NAME_None; FString UserData; }; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 159ec53dd..ab7dce496 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -182,25 +182,22 @@ void SexMessage (const char *from, char *to, int gender, const char *victim, con // void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgflags, FName MeansOfDeath) { - FName mod; FString ret; - const char *message; - const char *messagename; char gendermessage[1024]; // No obituaries for non-players, voodoo dolls or when not wanted - if (self->player == NULL || self->player->mo != self || !show_obituaries) + if (self->player == nullptr || self->player->mo != self || !show_obituaries) return; // Treat voodoo dolls as unknown deaths if (inflictor && inflictor->player && inflictor->player->mo != inflictor) MeansOfDeath = NAME_None; - mod = MeansOfDeath; - message = NULL; - messagename = NULL; + FName mod = MeansOfDeath; + const char *message = nullptr; + const char *messagename = nullptr; - if (attacker == NULL || attacker->player != NULL) + if (attacker == nullptr || attacker->player != nullptr) { if (mod == NAME_Telefrag) { diff --git a/src/p_map.cpp b/src/p_map.cpp index 9ca345d9b..dacc7ae8b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4484,7 +4484,7 @@ DEFINE_ACTION_FUNCTION(AActor, AimLineAttack) struct Origin { AActor *Caller; - FNameNoInit PuffSpecies; + FName PuffSpecies; bool hitGhosts; bool MThruSpecies; bool ThruSpecies; @@ -5092,6 +5092,7 @@ AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, TData.MThruSpecies = false; TData.ThruActors = false; TData.ThruSpecies = false; + TData.PuffSpecies = NAME_None; if (Trace(t1->PosAtZ(shootz), t1->Sector, direction, distance, actorMask, wallMask, t1, trace, TRACE_NoSky | TRACE_PortalRestrict, CheckForActor, &TData)) @@ -5309,7 +5310,7 @@ struct RailData AActor *Caller; TArray RailHits; TArray PortalHits; - FNameNoInit PuffSpecies; + FName PuffSpecies; bool StopAtOne; bool StopAtInvul; bool ThruGhosts; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2f8b89a84..16396f29c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2171,13 +2171,9 @@ bool AActor::FloorBounceMissile (secplane_t &plane) // Set bounce state if (BounceFlags & BOUNCE_UseBounceState) { - FName names[2]; - FState *bouncestate; - - names[0] = NAME_Bounce; - names[1] = plane.fC() < 0 ? NAME_Ceiling : NAME_Floor; - bouncestate = FindState(2, names); - if (bouncestate != NULL) + FName names[2] = { NAME_Bounce, plane.fC() < 0 ? NAME_Ceiling : NAME_Floor }; + FState *bouncestate = FindState(2, names); + if (bouncestate != nullptr) { SetState(bouncestate); } diff --git a/src/p_states.cpp b/src/p_states.cpp index 8b5922470..addf8ad1d 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -196,7 +196,7 @@ bool AActor::HasSpecialDeathStates () const TArray &MakeStateNameList(const char * fname) { static TArray namelist(3); - FName firstpart, secondpart; + FName firstpart = NAME_None, secondpart = NAME_None; char *c; // Handle the old names for the existing death states @@ -256,21 +256,19 @@ TArray &MakeStateNameList(const char * fname) FState *PClassActor::FindState(int numnames, FName *names, bool exact) const { FStateLabels *labels = GetStateLabels(); - FState *best = NULL; + FState *best = nullptr; - if (labels != NULL) + if (labels != nullptr) { int count = 0; - FStateLabel *slabel = NULL; - FName label; // Find the best-matching label for this class. - while (labels != NULL && count < numnames) + while (labels != nullptr && count < numnames) { - label = *names++; - slabel = labels->FindLabel(label); + FName label = *names++; + FStateLabel *slabel = labels->FindLabel(label); - if (slabel != NULL) + if (slabel != nullptr) { count++; labels = slabel->Children; @@ -283,7 +281,7 @@ FState *PClassActor::FindState(int numnames, FName *names, bool exact) const } if (count < numnames && exact) { - return NULL; + return nullptr; } } return best; @@ -411,7 +409,7 @@ FStateDefine *FStateDefinitions::FindStateLabelInList(TArray & lis { FStateDefine def; def.Label = name; - def.State = NULL; + def.State = nullptr; def.DefineFlags = SDF_NEXT; return &list[list.Push(def)]; } diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index 8459ed27a..73756ec57 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -375,10 +375,9 @@ void ParseSplash (FScanner &sc) int splashnum; FSplashDef *splashdef; bool isnew = false; - FName name; sc.MustGetString (); - name = sc.String; + FName name = sc.String; splashnum = (int)FindSplash (name); if (splashnum < 0) { @@ -422,10 +421,9 @@ void ParseSplash (FScanner &sc) void ParseTerrain (FScanner &sc) { int terrainnum; - FName name; sc.MustGetString (); - name = sc.String; + FName name = sc.String; terrainnum = (int)P_FindTerrain (name); if (terrainnum < 0) { diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 6acf9e37c..a2b45fe7f 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -462,7 +462,7 @@ class UDMFParser : public UDMFParserBase TArray ParsedVertices; TArray UDMFScrollers; - FDynamicColormap *fogMap, *normMap; + FDynamicColormap *fogMap = nullptr, *normMap = nullptr; FMissingTextureTracker &missingTex; public: @@ -470,7 +470,6 @@ public: : missingTex(missing) { linemap.Clear(); - fogMap = normMap = NULL; } void ReadUserKey(FUDMFKey &ukey) { @@ -1357,11 +1356,11 @@ public: // Brand new UDMF scroller properties double scroll_ceil_x = 0; double scroll_ceil_y = 0; - FName scroll_ceil_type; + FName scroll_ceil_type = NAME_None; double scroll_floor_x = 0; double scroll_floor_y = 0; - FName scroll_floor_type; + FName scroll_floor_type = NAME_None; memset(sec, 0, sizeof(*sec)); diff --git a/src/p_udmf.h b/src/p_udmf.h index dbc7eed54..8e0901755 100644 --- a/src/p_udmf.h +++ b/src/p_udmf.h @@ -8,7 +8,7 @@ class UDMFParserBase { protected: FScanner sc; - FName namespc; + FName namespc = NAME_None; int namespace_bits; FString parsedString; bool BadCoordinates = false; diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index cb375816f..4838d4b8d 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -400,9 +400,9 @@ class USDFParser : public UDMFParserBase bool ParseConversation() { - PClassActor *type = NULL; + PClassActor *type = nullptr; int dlgid = -1; - FName clsid; + FName clsid = NAME_None; unsigned int startpos = StrifeDialogues.Size(); while (!sc.CheckToken('}')) diff --git a/src/p_user.cpp b/src/p_user.cpp index a4f5ec439..29efe9001 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -301,82 +301,6 @@ CCMD (playerclasses) // 16 pixels of bob #define MAXBOB 16. -// The player_t constructor. Since LogText is not a POD, we cannot just -// memset it all to 0. -player_t::player_t() -: mo(0), - playerstate(0), - cls(0), - DesiredFOV(0), - FOV(0), - viewz(0), - viewheight(0), - deltaviewheight(0), - bob(0), - Vel(0, 0), - centering(0), - turnticks(0), - attackdown(0), - usedown(0), - oldbuttons(0), - health(0), - inventorytics(0), - CurrentPlayerClass(0), - fragcount(0), - lastkilltime(0), - multicount(0), - spreecount(0), - WeaponState(0), - ReadyWeapon(0), - PendingWeapon(0), - psprites(0), - cheats(0), - timefreezer(0), - refire(0), - inconsistant(0), - killcount(0), - itemcount(0), - secretcount(0), - damagecount(0), - bonuscount(0), - hazardcount(0), - poisoncount(0), - poisoner(0), - attacker(0), - extralight(0), - morphTics(0), - MorphedPlayerClass(0), - MorphStyle(0), - MorphExitFlash(0), - PremorphWeapon(0), - chickenPeck(0), - jumpTics(0), - onground(0), - respawn_time(0), - camera(0), - air_finished(0), - MUSINFOactor(0), - MUSINFOtics(-1), - crouching(0), - crouchdir(0), - Bot(0), - BlendR(0), - BlendG(0), - BlendB(0), - BlendA(0), - LogText(), - crouchfactor(0), - crouchoffset(0), - crouchviewdelta(0), - ConversationNPC(0), - ConversationPC(0), - ConversationNPCAngle(0.), - ConversationFaceTalker(0) -{ - memset (&cmd, 0, sizeof(cmd)); - memset (frags, 0, sizeof(frags)); -} - player_t::~player_t() { DestroyPSprites(); diff --git a/src/r_defs.h b/src/r_defs.h index 4422fbf8d..ffe526969 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -582,7 +582,7 @@ struct FTransform struct secspecial_t { - FNameNoInit damagetype; // [RH] Means-of-death for applied damage + FName damagetype; // [RH] Means-of-death for applied damage int damageamount; // [RH] Damage to do while standing on floor short special; short damageinterval; // Interval for damage application @@ -997,7 +997,7 @@ public: short seqType; // this sector's sound sequence int sky; - FNameNoInit SeqName; // Sound sequence name. Setting seqType non-negative will override this. + FName SeqName; // Sound sequence name. Setting seqType non-negative will override this. DVector2 centerspot; // origin for any sounds played by the sector int validcount; // if == validcount, already checked @@ -1047,7 +1047,7 @@ public: struct msecnode_t *touching_renderthings; // this is used to allow wide things to be rendered not only from their main sector. double gravity; // [RH] Sector gravity (1.0 is normal) - FNameNoInit damagetype; // [RH] Means-of-death for applied damage + FName damagetype; // [RH] Means-of-death for applied damage int damageamount; // [RH] Damage to do while standing on floor short damageinterval; // Interval for damage application short leakydamage; // chance of leaking through radiation suit diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index 6f99fad6e..a3937a01e 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -314,7 +314,7 @@ void DSeqNode::Serialize(FSerializer &arc) { int seqOffset; unsigned int i; - FName seqName; + FName seqName = NAME_None; int delayTics = 0; FSoundID id; float volume; @@ -571,8 +571,8 @@ void S_ParseSndSeq (int levellump) TArray ScriptTemp; int lastlump, lump; char seqtype = ':'; - FName seqname; - FName slot; + FName seqname = NAME_None; + FName slot = NAME_None; int stopsound; int delaybase; float volumebase; diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 3399947cf..44fbdb42c 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -211,7 +211,6 @@ FScanner &FScanner::operator=(const FScanner &other) TokenType = other.TokenType; Number = other.Number; Float = other.Float; - Name = other.Name; Line = other.Line; End = other.End; Crossed = other.Crossed; @@ -619,11 +618,7 @@ bool FScanner::GetToken () { if (ScanString (true)) { - if (TokenType == TK_NameConst) - { - Name = FName(String); - } - else if (TokenType == TK_IntConst) + if (TokenType == TK_IntConst) { char *stopper; // Check for unsigned diff --git a/src/sc_man.h b/src/sc_man.h index 9962cbde0..9c4f34a22 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -82,7 +82,6 @@ public: int TokenType; int Number; double Float; - FName Name; int Line; bool End; bool Crossed; diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 0e8bd619f..c8fcb1f09 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -9336,10 +9336,8 @@ ExpEmit FxFlopFunctionCall::Emit(VMFunctionBuilder *build) //========================================================================== FxVectorBuiltin::FxVectorBuiltin(FxExpression *self, FName name) - :FxExpression(EFX_VectorBuiltin, self->ScriptPosition) + :FxExpression(EFX_VectorBuiltin, self->ScriptPosition), Function(name), Self(self) { - Self = self; - Function = name; } FxVectorBuiltin::~FxVectorBuiltin() @@ -11136,7 +11134,7 @@ ExpEmit FxRuntimeStateIndex::Emit(VMFunctionBuilder *build) FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPosition &pos, PClassActor *checkclass) :FxExpression(EFX_MultiNameState, pos) { - FName scopename; + FName scopename = NAME_None; FString statestring = _statestring; int scopeindex = statestring.IndexOf("::"); @@ -11145,10 +11143,6 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi scopename = FName(statestring, scopeindex, false); statestring = statestring.Right(statestring.Len() - scopeindex - 2); } - else - { - scopename = NAME_None; - } names = MakeStateNameList(statestring); names.Insert(0, scopename); scope = checkclass; diff --git a/src/scripting/backend/codegen.h b/src/scripting/backend/codegen.h index 88ea7bcdd..092503282 100644 --- a/src/scripting/backend/codegen.h +++ b/src/scripting/backend/codegen.h @@ -369,7 +369,7 @@ public: class FxIdentifier : public FxExpression { public: - FName Identifier; + FName Identifier = NAME_None; bool noglobal = false; FxIdentifier(FName i, const FScriptPosition &p); diff --git a/src/scripting/decorate/olddecorations.cpp b/src/scripting/decorate/olddecorations.cpp index 62a00fe57..209bf393d 100644 --- a/src/scripting/decorate/olddecorations.cpp +++ b/src/scripting/decorate/olddecorations.cpp @@ -101,12 +101,11 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns) FExtraInfo extra; PClassActor *type; PClassActor *parent; - FName typeName; parent = (def == DEF_Pickup) ? PClass::FindActor("FakeInventory") : RUNTIME_CLASS(AActor); sc.MustGetString(); - typeName = FName(sc.String); + FName typeName = FName(sc.String); type = DecoDerivedClass(FScriptPosition(sc), parent, typeName); ResetBaggage(&bag, parent); bag.Namespace = ns; diff --git a/src/scripting/decorate/thingdef_exp.cpp b/src/scripting/decorate/thingdef_exp.cpp index c94b98093..4a1a82922 100644 --- a/src/scripting/decorate/thingdef_exp.cpp +++ b/src/scripting/decorate/thingdef_exp.cpp @@ -421,7 +421,7 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls) } else if (sc.CheckToken(TK_NameConst)) { - return new FxConstant(sc.Name, scpos); + return new FxConstant(FName(sc.String), scpos); } else if (sc.CheckToken(TK_StringConst)) { diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 43330d58f..eb553028d 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -1029,9 +1029,7 @@ PClassActor *CreateNewActor(const FScriptPosition &sc, FName typeName, FName par //========================================================================== static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag) { - FName typeName; - FName parentName; - FName replaceName; + FName replaceName = NAME_None; bool native = false; int DoomEdNum = -1; @@ -1044,7 +1042,7 @@ static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag) *colon++ = 0; } - typeName = sc.String; + FName typeName = sc.String; // Do some tweaking so that a definition like 'Actor:Parent' which is read as a single token is recognized as well // without having resort to C-mode (which disallows periods in actor names.) @@ -1071,7 +1069,7 @@ static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag) sc.UnGet(); } - parentName = colon; + FName parentName = colon; // Check for "replaces" if (sc.CheckString ("replaces")) diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index e5338e37e..522a569ee 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -569,9 +569,8 @@ DEFINE_PROPERTY(painchance, ZI, Actor) } else { - FName painType; - if (!stricmp(str, "Normal")) painType = NAME_None; - else painType=str; + FName painType = NAME_None; + if (stricmp(str, "Normal")) painType = str; info->SetPainChance(painType, id); } @@ -897,15 +896,14 @@ DEFINE_PROPERTY(damagefactor, ZF, Actor) PROP_STRING_PARM(str, 0); PROP_DOUBLE_PARM(id, 1); - if (str == NULL) + if (str == nullptr) { defaults->DamageFactor = id; } else { - FName dmgType; - if (!stricmp(str, "Normal")) dmgType = NAME_None; - else dmgType=str; + FName dmgType = NAME_None; + if (stricmp(str, "Normal")) dmgType = str; info->SetDamageFactor(dmgType, id); } diff --git a/src/scripting/types.cpp b/src/scripting/types.cpp index 7aed2850c..269de5cc9 100644 --- a/src/scripting/types.cpp +++ b/src/scripting/types.cpp @@ -1593,10 +1593,8 @@ PClassPointer *NewClassPointer(PClass *restrict) //========================================================================== PEnum::PEnum(FName name, PTypeBase *outer) -: PInt(4, false) +: PInt(4, false), Outer(outer), EnumName(name) { - EnumName = name; - Outer = outer; Flags |= TYPE_IntNotInt; mDescriptiveName.Format("Enum<%s>", name.GetChars()); } diff --git a/src/scripting/types.h b/src/scripting/types.h index 0817aa99d..52f1fc464 100644 --- a/src/scripting/types.h +++ b/src/scripting/types.h @@ -238,10 +238,10 @@ protected: class PContainerType : public PCompoundType { public: - PTypeBase *Outer; // object this type is contained within - FName TypeName; // this type's name + PTypeBase *Outer = nullptr; // object this type is contained within + FName TypeName = NAME_None; // this type's name - PContainerType() : Outer(NULL) + PContainerType() { mDescriptiveName = "ContainerType"; Flags |= TYPE_Container; diff --git a/src/scripting/zscript/zcc_parser.cpp b/src/scripting/zscript/zcc_parser.cpp index 693ffcffa..5ddc9207d 100644 --- a/src/scripting/zscript/zcc_parser.cpp +++ b/src/scripting/zscript/zcc_parser.cpp @@ -274,7 +274,7 @@ static void ParseSingleFile(FScanner *pSC, const char *filename, int lump, void break; case TK_NameConst: - value.Int = sc.Name; + value.Int = FName(sc.String).GetIndex(); tokentype = ZCC_NAMECONST; break; diff --git a/src/serializer.cpp b/src/serializer.cpp index 58d5658d4..fe8864a33 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -2147,7 +2147,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, FFont *&fon } else { - FName n; + FName n = NAME_None; arc(key, n); font = V_GetFont(n); if (font == nullptr) diff --git a/src/textures/animations.cpp b/src/textures/animations.cpp index b2c0e3e56..c1b8f5c48 100644 --- a/src/textures/animations.cpp +++ b/src/textures/animations.cpp @@ -789,6 +789,7 @@ void FTextureManager::ParseAnimatedDoor(FScanner &sc) sc.MustGetString(); anim.BaseTexture = CheckForTexture (sc.String, ETextureType::Wall, texflags); + anim.OpenSound = anim.CloseSound = NAME_None; if (!anim.BaseTexture.Exists()) { diff --git a/src/umapinfo.cpp b/src/umapinfo.cpp index d7997a083..3c1517632 100644 --- a/src/umapinfo.cpp +++ b/src/umapinfo.cpp @@ -403,7 +403,7 @@ void CommitUMapinfo(level_info_t *defaultinfo) if (map.nextmap[0]) levelinfo->NextMap = map.nextmap; else if (map.endpic[0]) { - FName name; + FName name = NAME_None; if (!stricmp(map.endpic, "$CAST")) { diff --git a/src/v_font.h b/src/v_font.h index 83ea5de19..383363ce8 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -130,7 +130,7 @@ protected: uint8_t *PatchRemap; int Lump; - FName FontName; + FName FontName = NAME_None; FFont *Next; static FFont *FirstFont; diff --git a/src/zstring.h b/src/zstring.h index c6cd44fc9..5ab267414 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -454,7 +454,6 @@ namespace StringFormat inline FName::FName(const FString &text) { Index = NameData.FindName (text.GetChars(), text.Len(), false); } inline FName::FName(const FString &text, bool noCreate) { Index = NameData.FindName (text.GetChars(), text.Len(), noCreate); } inline FName &FName::operator = (const FString &text) { Index = NameData.FindName (text.GetChars(), text.Len(), false); return *this; } -inline FName &FNameNoInit::operator = (const FString &text) { Index = NameData.FindName (text.GetChars(), text.Len(), false); return *this; } // Hash FStrings on their contents. (used by TMap) extern unsigned int SuperFastHash (const char *data, size_t len); From 03fa1a12cbcfc741060001beb7b363cf4a0e5b5d Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 19 Aug 2018 15:23:03 -0700 Subject: [PATCH 18/21] Avoid overriding vr eye-specific buffer binding during 2D rendering. --- src/gl/renderer/gl_renderer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index a2dfaebaa..47d82c965 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -50,6 +50,7 @@ #include "gl/renderer/gl_renderbuffers.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" +#include "hwrenderer/utility/hw_vrmodes.h" #include "hwrenderer/postprocessing/hw_presentshader.h" #include "hwrenderer/postprocessing/hw_present3dRowshader.h" #include "hwrenderer/postprocessing/hw_shadowmapshader.h" @@ -422,7 +423,8 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) { twoD.Clock(); FGLDebug::PushGroup("Draw2D"); - mBuffers->BindCurrentFB(); + if (VRMode::GetVRMode(true)->mEyeCount == 1) + mBuffers->BindCurrentFB(); const auto &mScreenViewport = screen->mScreenViewport; glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); From 1d930b45cf595bcff2d3c8115df803e4977c19bc Mon Sep 17 00:00:00 2001 From: argv-minus-one Date: Mon, 20 Aug 2018 16:31:52 -0700 Subject: [PATCH 19/21] Add ZScript method `LevelLocals.SphericalCoords`. It computes spherical coordinates from one point in the world to another. Useful for checking whether one actor is inside another actor's view cone. --- src/g_level.cpp | 24 ++++++++++++++++++++++++ wadsrc/static/zscript/base.txt | 1 + 2 files changed, 25 insertions(+) diff --git a/src/g_level.cpp b/src/g_level.cpp index 207a3682a..86567ea84 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2043,6 +2043,30 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, Vec3Diff) ACTION_RETURN_VEC3(VecDiff(DVector3(x1, y1, z1), DVector3(x2, y2, z2))); } +DEFINE_ACTION_FUNCTION(FLevelLocals, SphericalCoords) +{ + PARAM_PROLOGUE; + PARAM_FLOAT(viewpointX); + PARAM_FLOAT(viewpointY); + PARAM_FLOAT(viewpointZ); + PARAM_FLOAT(targetX); + PARAM_FLOAT(targetY); + PARAM_FLOAT(targetZ); + PARAM_ANGLE_DEF(viewYaw); + PARAM_ANGLE_DEF(viewPitch); + PARAM_BOOL_DEF(absolute); + + DVector3 viewpoint(viewpointX, viewpointY, viewpointZ); + DVector3 target(targetX, targetY, targetZ); + auto vecTo = absolute ? target - viewpoint : VecDiff(viewpoint, target); + + ACTION_RETURN_VEC3(DVector3( + deltaangle(vecTo.Angle(), viewYaw).Degrees, + deltaangle(-vecTo.Pitch(), viewPitch).Degrees, + vecTo.Length() + )); +} + DEFINE_ACTION_FUNCTION(FLevelLocals, Vec2Offset) { PARAM_PROLOGUE; diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index dbf71a942..498f6ae71 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -668,6 +668,7 @@ struct LevelLocals native native static clearscope vector2 Vec2Diff(vector2 v1, vector2 v2); native static clearscope vector3 Vec3Diff(vector3 v1, vector3 v2); + native static clearscope vector3 SphericalCoords(vector3 viewpoint, vector3 targetPos, vector2 viewAngles = (0, 0), bool absolute = false); native static clearscope vector2 Vec2Offset(vector2 pos, vector2 dir, bool absolute = false); native static clearscope vector3 Vec2OffsetZ(vector2 pos, vector2 dir, double atz, bool absolute = false); From cbbf4fb662f54fffa5e4f3f4b50bfe1e7af25d9d Mon Sep 17 00:00:00 2001 From: Kevin Caccamo Date: Tue, 21 Aug 2018 05:08:57 -0400 Subject: [PATCH 20/21] Add 1280x1024 to the resolution preset menu --- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index c3bff9b29..c843f5fcd 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2275,6 +2275,7 @@ VIDMNU_RESPRESET = "Choose Resolution Preset"; VIDMNU_RESPRESETTTL = "Custom Resolution Presets"; VIDMNU_RESPRESETHEAD = "Preset Resolution Modes"; VIDMNU_ASPECT43 = "4:3 Aspect"; +VIDMNU_ASPECT54 = "5:4 Aspect"; VIDMNU_ASPECT169 = "16:9 Aspect"; VIDMNU_ASPECT1610 = "16:10 Aspect"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index f83a65fd9..218182c07 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1954,6 +1954,9 @@ OptionMenu CustomResolutionMenu protected Command "1280x960", "menu_resolution_set_custom 1280 960" Command "1600x1200", "menu_resolution_set_custom 1600 1200" StaticText "" + StaticText "$VIDMNU_ASPECT54" + Command "1280x1024", "menu_resolution_set_custom 1280 1024" + StaticText "" StaticText "$VIDMNU_ASPECT169" Command "960x540", "menu_resolution_set_custom 960 540" Command "(720p HD) 1280x720", "menu_resolution_set_custom 1280 720" From 01ea329cd4ba6e726a60e39a38d710fdd41cde6f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 23 Aug 2018 18:19:53 +0200 Subject: [PATCH 21/21] - only render visual portals if they are front facing --- src/polyrenderer/scene/poly_wall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index 7aae2c32c..b7872724b 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -60,7 +60,7 @@ bool RenderPolyWall::RenderLine(PolyRenderThread *thread, seg_t *line, sector_t linePortals.push_back(std::unique_ptr(new PolyDrawLinePortal(line->linedef))); polyportal = linePortals.back().get(); } - else if (line->linedef && line->linedef->isVisualPortal()) + else if (line->linedef && line->linedef->isVisualPortal() && line->sidedef == line->linedef->sidedef[0]) { if (portalEnterLine == line->linedef) {