From 481bddf6288de9c2c646fe6ee164d36511788264 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Feb 2017 11:26:17 +0200 Subject: [PATCH 1/6] Fixed incorrect offscreen rendering of player's blend --- src/gl/scene/gl_scene.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b67cf810e..e9d6b7e1e 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -866,6 +866,14 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo // This should be done after postprocessing, not before. mBuffers->BindCurrentFB(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + if (!toscreen) + { + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(mScreenViewport.left, mScreenViewport.width, mScreenViewport.height, mScreenViewport.top, -1.0f, 1.0f); + gl_RenderState.ApplyMatrices(); + } + DrawBlend(lviewsector); } mDrawingScene2D = false; From e55406bc234f610386b0b4a4135188454ef188ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Feb 2017 18:48:49 +0100 Subject: [PATCH 2/6] - changed clean scaling factor calculation so that it doesn't prefer larger scales on high resolution displays. This was a tweak that only makes sense when the scaling factors are low, i.e. 2 vs. 3, but for modern high resolutions it will enlarge things a bit too much. --- src/v_video.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index 6077f878e..6d5913ce1 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1396,7 +1396,7 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real cy1 = MAX(cheight / designheight, 1); cx2 = MAX(realwidth / designwidth, 1); cy2 = MAX(realheight / designheight, 1); - if (abs(cx1 - cy1) <= abs(cx2 - cy2)) + if (abs(cx1 - cy1) <= abs(cx2 - cy2) || cx1 >= 4) { // e.g. 640x360 looks better with this. *cleanx = cx1; *cleany = cy1; From 810efe517df4f9228023032bc9a9b341b4dc222b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Feb 2017 21:38:06 +0100 Subject: [PATCH 3/6] - fixed: AActor::SetOrigin lost its 'virtual' qualifier in the ZScript merge, but ADynamicLight needs this to work properly. --- src/actor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actor.h b/src/actor.h index 652d40aa1..05b1aa076 100644 --- a/src/actor.h +++ b/src/actor.h @@ -972,7 +972,7 @@ public: { SetOrigin(Pos() + vel, true); } - void SetOrigin(double x, double y, double z, bool moving); + virtual void SetOrigin(double x, double y, double z, bool moving); void SetOrigin(const DVector3 & npos, bool moving) { SetOrigin(npos.X, npos.Y, npos.Z, moving); From a4dbbf696987747a85534fc6d194ac1829e6e0ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Feb 2017 21:43:16 +0100 Subject: [PATCH 4/6] - fixed P_NightmareRespawn did not respawn a map defined spawn health and neither made skill-related adjustments. --- src/p_mobj.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index df6223242..758b4ac18 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3196,6 +3196,7 @@ void P_NightmareRespawn (AActor *mobj) // spawn it mo = AActor::StaticSpawn(mobj->GetClass(), DVector3(mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z), NO_REPLACE, true); + mo->health = mobj->SpawnHealth(); if (z == ONFLOORZ) { From d90f2ba1faa0a68f3d3d0c9f1b34e447f8e41287 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Feb 2017 21:54:09 +0100 Subject: [PATCH 5/6] - wrap the va_list that gets passed around by the Draw functions into a struct so that the templates can use reliable, identical semantics for both this and the VM's arg list. --- src/v_draw.cpp | 28 ++++++++++++++-------------- src/v_text.cpp | 12 ++++++------ src/v_video.h | 5 +++++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 52f8cde7a..6f0e8330a 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -129,12 +129,12 @@ static int PalFromRGB(uint32 rgb) void DCanvas::DrawTexture (FTexture *img, double x, double y, int tags_first, ...) { - va_list tags; - va_start(tags, tags_first); + Va_List tags; + va_start(tags.list, tags_first); DrawParms parms; bool res = ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, false); - va_end(tags); + va_end(tags.list); if (!res) { return; @@ -457,30 +457,30 @@ bool DCanvas::SetTextureParms(DrawParms *parms, FTexture *img, double xx, double return false; } -static void ListEnd(va_list &tags) +static void ListEnd(Va_List &tags) { - va_end(tags); + va_end(tags.list); } -static int ListGetInt(va_list &tags) +static int ListGetInt(Va_List &tags) { - return va_arg(tags, int); + return va_arg(tags.list, int); } -static inline double ListGetDouble(va_list &tags) +static inline double ListGetDouble(Va_List &tags) { - return va_arg(tags, double); + return va_arg(tags.list, double); } // These two options are only being used by the D3D version of the HUD weapon drawer, they serve no purpose anywhere else. -static inline FSpecialColormap * ListGetSpecialColormap(va_list &tags) +static inline FSpecialColormap * ListGetSpecialColormap(Va_List &tags) { - return va_arg(tags, FSpecialColormap *); + return va_arg(tags.list, FSpecialColormap *); } -static inline FColormapStyle * ListGetColormapStyle(va_list &tags) +static inline FColormapStyle * ListGetColormapStyle(Va_List &tags) { - return va_arg(tags, FColormapStyle *); + return va_arg(tags.list, FColormapStyle *); } static void ListEnd(VMVa_List &tags) @@ -946,7 +946,7 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, DWORD tag, } // explicitly instantiate both versions for v_text.cpp. -template bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, DWORD tag, va_list& tags, DrawParms *parms, bool fortext) const; +template bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, DWORD tag, Va_List& tags, DrawParms *parms, bool fortext) const; template bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, DWORD tag, VMVa_List& tags, DrawParms *parms, bool fortext) const; void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h, diff --git a/src/v_text.cpp b/src/v_text.cpp index 3394e448a..8b612e83c 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -71,10 +71,10 @@ void DCanvas::DrawChar (FFont *font, int normalcolor, double x, double y, int ch if (NULL != (pic = font->GetChar (character, &dummy))) { DrawParms parms; - va_list tags; - va_start(tags, tag_first); + Va_List tags; + va_start(tags.list, tag_first); bool res = ParseDrawTextureTags(pic, x, y, tag_first, tags, &parms, false); - va_end(tags); + va_end(tags.list); if (!res) { return; @@ -197,15 +197,15 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c void DCanvas::DrawText(FFont *font, int normalcolor, double x, double y, const char *string, int tag_first, ...) { - va_list tags; + Va_List tags; DrawParms parms; if (font == NULL || string == NULL) return; - va_start(tags, tag_first); + va_start(tags.list, tag_first); bool res = ParseDrawTextureTags(nullptr, 0, 0, tag_first, tags, &parms, true); - va_end(tags); + va_end(tags.list); if (!res) { return; diff --git a/src/v_video.h b/src/v_video.h index a594fa8fe..a2586d5a7 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -177,6 +177,11 @@ struct DrawParms bool virtBottom; }; +struct Va_List +{ + va_list list; +}; + struct VMVa_List { VMValue *args; From 124d0251316e919b145ce959a5a37ff65ac9a5e0 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Mon, 6 Feb 2017 13:18:10 +0200 Subject: [PATCH 6/6] More string methods --- src/scripting/thingdef_data.cpp | 46 ++++++++++++++++++++++++++++++++- wadsrc/static/zscript/base.txt | 7 ++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 9c36f0e49..9b1b9aaba 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -1136,4 +1136,48 @@ DEFINE_ACTION_FUNCTION(FStringStruct, AppendFormat) FString s = FStringFormat(param+1, defaultparam, numparam-1, ret, numret); (*self) += s; return 0; -} \ No newline at end of file +} + +DEFINE_ACTION_FUNCTION(FStringStruct, Mid) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_INT(pos); + PARAM_INT(len); + // validate. we don't want to crash if someone passes negative values. + // with size_t it's handled naturally I think, as it's unsigned, but not in ZScript. + if (pos < 0) pos = 0; + if (len < 0) len = 0; + int slen = self->Len(); + if (pos > slen) pos = slen - 1; + if (pos + len > slen) + len = slen - pos; + FString s = self->Mid(pos, len); + ACTION_RETURN_STRING(s); +} + +DEFINE_ACTION_FUNCTION(FStringStruct, Len) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + ACTION_RETURN_INT(self->Len()); +} + +// CharAt and CharCodeAt is how JS does it, and JS is similar here in that it doesn't have char type as int. +DEFINE_ACTION_FUNCTION(FStringStruct, CharAt) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_INT(pos); + int slen = self->Len(); + if (pos < 0 || pos >= slen) + ACTION_RETURN_STRING(""); + ACTION_RETURN_STRING(FString((*self)[pos])); +} + +DEFINE_ACTION_FUNCTION(FStringStruct, CharCodeAt) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_INT(pos); + int slen = self->Len(); + if (pos < 0 || pos >= slen) + ACTION_RETURN_INT(0); + ACTION_RETURN_INT((*self)[pos]); +} diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 175f8341d..83d714684 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -417,9 +417,14 @@ enum EPickStart // Although String is a builtin type, this is a convenient way to attach methods to it. struct StringStruct native { - native void Replace(String pattern, String replacement); native static vararg String Format(String fmt, ...); native vararg void AppendFormat(String fmt, ...); + + native void Replace(String pattern, String replacement); + native String Mid(int pos = 0, int len = 2147483647); + native int Len(); + native String CharAt(int pos); + native int CharCodeAt(int pos); } class Floor : Thinker native