From 1e7df5505e553f3a0f4596813423d96fbb67baac Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Wed, 27 Dec 2017 14:38:17 -0600 Subject: [PATCH 1/6] Added GetPixelStretch to LevelLocals struct. --- src/g_level.cpp | 17 +++++++++++++++++ src/g_levellocals.h | 1 + wadsrc/static/zscript/base.txt | 1 + 3 files changed, 19 insertions(+) diff --git a/src/g_level.cpp b/src/g_level.cpp index 0ee56d6c3..c333ba074 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1952,6 +1952,23 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, SetInterMusic) return 0; } +//========================================================================== +// +// +// +//========================================================================== + +float FLevelLocals::PixelStretch() +{ + return level.info->pixelstretch; +} + +DEFINE_ACTION_FUNCTION(FLevelLocals, GetPixelStretch) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + ACTION_RETURN_FLOAT(self->PixelStretch()); +} + //========================================================================== // // diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 505d797b6..024e6302d 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -46,6 +46,7 @@ struct FLevelLocals void Tick (); void AddScroller (int secnum); void SetInterMusic(const char *nextmap); + float PixelStretch(); uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. int time; // time in the hub diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index c0373fab0..237f8a084 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -547,6 +547,7 @@ struct LevelLocals native native static void WorldDone(); native static void RemoveAllBots(bool fromlist); native void SetInterMusic(String nextmap); + native double GetPixelStretch(); native String FormatMapName(int mapnamecolor); native bool IsJumpingAllowed() const; native bool IsCrouchingAllowed() const; From a3399c1af2904e52230aa9c40565070f7fa9ff03 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Wed, 27 Dec 2017 13:05:13 -0800 Subject: [PATCH 2/6] Fix: Bind the default framebuffer before testing whether hardware stereo 3D is supported. This allows Nvidia 3D vision glasses to function correctly when gl_light_shadowmap is ON. Doc: Add "requires restart" to "enable quad stereo" option menu label, to help folks trying to setup 3D. --- src/gl/stereo3d/gl_quadstereo.cpp | 16 ++++++++-------- wadsrc/static/language.enu | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gl/stereo3d/gl_quadstereo.cpp b/src/gl/stereo3d/gl_quadstereo.cpp index b65c109c8..769f28906 100644 --- a/src/gl/stereo3d/gl_quadstereo.cpp +++ b/src/gl/stereo3d/gl_quadstereo.cpp @@ -50,19 +50,19 @@ void QuadStereo::checkInitialRenderContextState() { // Keep trying until we see at least one good OpenGL context to render to static bool bDecentContextWasFound = false; - if (!bDecentContextWasFound) { - // I'm using a "random" OpenGL call (glGetFramebufferAttachmentParameteriv) - // that appears to correlate with whether the context is ready - GLint attachmentType = GL_NONE; - glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType); - if (attachmentType != GL_NONE) // Finally, a useful OpenGL context + static int contextCheckCount = 0; + if ( (! bDecentContextWasFound) && (contextCheckCount < 200) ) + { + contextCheckCount += 1; + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // This question is about the main screen display context + GLboolean supportsStereo, supportsBuffered; + glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); + if (supportsBuffered) // Finally, a useful OpenGL context { // This block will be executed exactly ONCE during a game run bDecentContextWasFound = true; // now we can stop checking every frame... // Now check whether this context supports hardware stereo - GLboolean supportsStereo, supportsBuffered; glGetBooleanv(GL_STEREO, &supportsStereo); - glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); bQuadStereoSupported = supportsStereo && supportsBuffered; leftEye.bQuadStereoSupported = bQuadStereoSupported; rightEye.bQuadStereoSupported = bQuadStereoSupported; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 06af66307..b05981a5a 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2725,7 +2725,7 @@ GLPREFMNU_AMBLIGHT = "Ambient light level"; GLPREFMNU_RENDERQUALITY = "Rendering quality"; GLPREFMNU_MENUBLUR = "Menu Blur"; GLPREFMNU_VRMODE = "Stereo 3D VR"; -GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; +GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo (Requires Restart)"; GLPREFMNU_MULTISAMPLE = "Multisample"; GLPREFMNU_TONEMAP = "Tonemap Mode"; GLPREFMNU_BLOOM = "Bloom effect"; From fa0082aef6fcb4aa84bb8bb2b8028ed47b1030e2 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Wed, 27 Dec 2017 19:21:11 -0600 Subject: [PATCH 3/6] Added ability to perform reverse fades with A_SetBlend --- src/g_shared/a_flashfader.cpp | 1 + src/p_actionfunctions.cpp | 7 ++++--- wadsrc/static/zscript/actor.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/g_shared/a_flashfader.cpp b/src/g_shared/a_flashfader.cpp index 64c4ff218..359c732a6 100644 --- a/src/g_shared/a_flashfader.cpp +++ b/src/g_shared/a_flashfader.cpp @@ -59,6 +59,7 @@ DFlashFader::DFlashFader (float r1, float g1, float b1, float a1, void DFlashFader::OnDestroy () { + Blends[1][3] = 0.f; // Needed in order to cancel out the secondary fade. SetBlend (1.f); Super::OnDestroy(); } diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index ea64c36d3..b7a817cd3 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -3575,16 +3575,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetBlend) PARAM_FLOAT (alpha); PARAM_INT (tics); PARAM_COLOR_DEF (color2); + PARAM_FLOAT_DEF (alpha2); if (color == MAKEARGB(255,255,255,255)) color = 0; if (color2 == MAKEARGB(255,255,255,255)) color2 = 0; - if (color2.a == 0) - color2 = color; +// if (color2.a == 0) +// color2 = color; Create(color.r/255.f, color.g/255.f, color.b/255.f, float(alpha), - color2.r/255.f, color2.g/255.f, color2.b/255.f, 0.f, + color2.r/255.f, color2.g/255.f, color2.b/255.f, float(alpha2), float(tics)/TICRATE, self); return 0; } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 13f5140c9..ee464a35b 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -1030,7 +1030,7 @@ class Actor : Thinker native native void A_SpawnParticle(color color1, int flags = 0, int lifetime = 35, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0); native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); native void A_DropInventory(class itemtype, int amount = -1); - native void A_SetBlend(color color1, double alpha, int tics, color color2 = 0); + native void A_SetBlend(color color1, double alpha, int tics, color color2 = 0, double alpha2 = 0.); deprecated("2.3") native void A_ChangeFlag(string flagname, bool value); native void A_ChangeCountFlags(int kill = FLAG_NO_CHANGE, int item = FLAG_NO_CHANGE, int secret = FLAG_NO_CHANGE); native void A_RaiseMaster(int flags = 0); From 10465c1d27c6fe78c4ac232d627753ac104abd06 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Wed, 27 Dec 2017 22:24:23 -0600 Subject: [PATCH 4/6] - Fade cancelling should only always be active for A_SetBlend fades, not always for everything else (such as ACS fades). --- src/g_shared/a_flashfader.cpp | 5 +++-- src/g_shared/a_sharedglobal.h | 5 +++-- src/p_actionfunctions.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/g_shared/a_flashfader.cpp b/src/g_shared/a_flashfader.cpp index 359c732a6..ed0e02202 100644 --- a/src/g_shared/a_flashfader.cpp +++ b/src/g_shared/a_flashfader.cpp @@ -50,16 +50,17 @@ DFlashFader::DFlashFader () DFlashFader::DFlashFader (float r1, float g1, float b1, float a1, float r2, float g2, float b2, float a2, - float time, AActor *who) + float time, AActor *who, bool terminate) : TotalTics ((int)(time*TICRATE)), StartTic (level.time), ForWho (who) { Blends[0][0]=r1; Blends[0][1]=g1; Blends[0][2]=b1; Blends[0][3]=a1; Blends[1][0]=r2; Blends[1][1]=g2; Blends[1][2]=b2; Blends[1][3]=a2; + Terminate = terminate; } void DFlashFader::OnDestroy () { - Blends[1][3] = 0.f; // Needed in order to cancel out the secondary fade. + if (Terminate) Blends[1][3] = 0.f; // Needed in order to cancel out the secondary fade. SetBlend (1.f); Super::OnDestroy(); } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 626985f93..ce2376cec 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -84,19 +84,20 @@ class DFlashFader : public DThinker public: DFlashFader (float r1, float g1, float b1, float a1, float r2, float g2, float b2, float a2, - float time, AActor *who); + float time, AActor *who, bool terminate = false); void OnDestroy() override; void Serialize(FSerializer &arc); void Tick (); AActor *WhoFor() { return ForWho; } void Cancel (); + protected: float Blends[2][4]; int TotalTics; int StartTic; TObjPtr ForWho; - + bool Terminate; void SetBlend (float time); DFlashFader (); }; diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index b7a817cd3..1abe2c939 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -3586,7 +3586,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetBlend) Create(color.r/255.f, color.g/255.f, color.b/255.f, float(alpha), color2.r/255.f, color2.g/255.f, color2.b/255.f, float(alpha2), - float(tics)/TICRATE, self); + float(tics)/TICRATE, self, true); return 0; } From 45531090a7f2754acfc0ba46e5624c261621d2dd Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 28 Dec 2017 00:53:30 -0500 Subject: [PATCH 5/6] - add 'playerrespawn' skill flag to allow gameplay mods to retroactively enable player respawns in single player on all maps --- src/g_game.cpp | 3 ++- src/g_level.h | 2 ++ src/g_skill.cpp | 8 ++++++++ src/p_mobj.cpp | 3 ++- wadsrc/static/zscript/constants.txt | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 404484672..82bff3f73 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1743,7 +1743,8 @@ static void G_QueueBody (AActor *body) EXTERN_CVAR(Bool, sv_singleplayerrespawn) void G_DoReborn (int playernum, bool freshbot) { - if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn) + if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn && + !G_SkillProperty(SKILLP_PlayerRespawn)) { if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName.GetChars())) { // Load game from the last point it was saved diff --git a/src/g_level.h b/src/g_level.h index 7fb38a046..78dcd55b1 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -538,6 +538,7 @@ enum ESkillProperty SKILLP_EasyKey, SKILLP_SlowMonsters, SKILLP_Infight, + SKILLP_PlayerRespawn, }; enum EFSkillProperty // floating point properties { @@ -595,6 +596,7 @@ struct FSkillInfo double FriendlyHealth; bool NoPain; int Infighting; + bool PlayerRespawn; FSkillInfo() {} FSkillInfo(const FSkillInfo &other) diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 6e23c9523..5c252274f 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -89,6 +89,7 @@ void FMapInfoParser::ParseSkill () skill.FriendlyHealth = 1.; skill.NoPain = false; skill.Infighting = 0; + skill.PlayerRespawn = false; sc.MustGetString(); skill.Name = sc.String; @@ -155,6 +156,10 @@ void FMapInfoParser::ParseSkill () { skill.NoMenu = true; } + else if (sc.Compare ("playerrespawn")) + { + skill.PlayerRespawn = true; + } else if (sc.Compare("respawntime")) { ParseAssign(); @@ -397,6 +402,9 @@ int G_SkillProperty(ESkillProperty prop) if (AllSkills[gameskill].Infighting == LEVEL2_TOTALINFIGHTING) return 1; if (AllSkills[gameskill].Infighting == LEVEL2_NOINFIGHTING) return -1; return infighting; + + case SKILLP_PlayerRespawn: + return AllSkills[gameskill].PlayerRespawn; } } return 0; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 561334a52..dc0e76ad1 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5648,7 +5648,8 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { // Give all cards in death match mode. p->mo->GiveDeathmatchInventory (); } - else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn) && state == PST_REBORN && oldactor != NULL) + else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn || + !!G_SkillProperty(SKILLP_PlayerRespawn)) && state == PST_REBORN && oldactor != NULL) { // Special inventory handling for respawning in coop p->mo->FilterCoopRespawnInventory (oldactor); } diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index dc4483253..e35af3a80 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -962,6 +962,7 @@ enum ESkillProperty SKILLP_EasyKey, SKILLP_SlowMonsters, SKILLP_Infight, + SKILLP_PlayerRespawn, }; enum EFSkillProperty // floating point properties { From 5c602b1ec098a0a61b3bdd187b13cfa23fed8c8d Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 28 Dec 2017 01:41:56 -0500 Subject: [PATCH 6/6] - fixed: FSkillInfo operator "=" did not set PlayerRespawn value --- src/g_skill.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 5c252274f..90ed9f723 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -558,6 +558,7 @@ FSkillInfo &FSkillInfo::operator=(const FSkillInfo &other) Infighting = other.Infighting; ArmorFactor = other.ArmorFactor; HealthFactor = other.HealthFactor; + PlayerRespawn = other.PlayerRespawn; return *this; }