From a47aea4c9f01b411372b95d28dfc57866ef6bb55 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Sep 2023 18:29:05 +0300 Subject: [PATCH 1/9] Fix 'error in error handling' for cases when error happens in cvar.func right when cvar is registered --- src/lua_consolelib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index dc965851f..584fc2ef8 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -293,6 +293,8 @@ static void Lua_OnChange(void) //lua_settop(gL, 0); // Just in case... lua_pushcfunction(gL, LUA_GetErrorMessage); + int error_handler_i = abs_index(gL, -1); + // From CV_OnChange registry field, get the function for this cvar by name. lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange"); I_Assert(lua_istable(gL, -1)); @@ -304,7 +306,7 @@ static void Lua_OnChange(void) lua_getfield(gL, -1, cvname); // get consvar_t* userdata. lua_remove(gL, -2); // pop the CV_Vars table. - LUA_Call(gL, 1, 0, 1); // call function(cvar) + LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar) lua_pop(gL, 2); // pop CV_OnChange table and error handler } -- 2.54.0 From 64b2e2ee37a2d2fb1e1b43d4084d8f01880091db Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Wed, 13 Sep 2023 01:40:52 +0200 Subject: [PATCH 2/9] Fix bugs with HWR_SplitWall and sloped midtextures but cleaner performance still pretty bad, atleast this is cleaner than last time --- src/hardware/hw_main.c | 148 ++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 90 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 66adf3522..07f74f6a5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -951,6 +951,9 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa pegb = wallVerts[0].t; pegmul = (pegb - pegt) / (top - bot); + if (fpclassify(pegmul) == FP_NAN) + pegmul = 0.0; + #ifdef ESLOPE endrealtop = endtop = wallVerts[2].y; endrealbot = endbot = wallVerts[1].y; @@ -959,6 +962,8 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa endpegmul = (endpegb - endpegt) / (endtop - endbot); #endif + if (fpclassify(endpegmul) == FP_NAN) + endpegmul = 0.0; for (i = 0; i < sector->numlights; i++) { @@ -1069,24 +1074,10 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa } #endif -#ifdef ESLOPE - if (endbheight >= endtop) -#endif - if (bheight >= top) - continue; + // Found a break + bot = min(max(bheight, realbot), top); + endbot = min(max(endbheight, endrealbot), endtop); - //Found a break; - bot = bheight; - - if (bot < realbot) - bot = realbot; - -#ifdef ESLOPE - endbot = endbheight; - - if (endbot < endrealbot) - endbot = endrealbot; -#endif Surf->PolyColor.s.alpha = alpha; #ifdef ESLOPE @@ -1680,10 +1671,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); if (gr_midtexture || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH || gl_drawing_stencil) { - FBITFIELD blendmode; sector_t *front, *back; - fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut; - fixed_t texturevpeg = 0; INT32 repeats; if (gr_linedef->frontsector->heightsec != -1) @@ -1719,6 +1707,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else repeats = 1; + fixed_t midtexheight = textureheight[gr_midtexture] * repeats; + fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut; + fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope; + // SoM: a little note: This code re-arranging will // fix the bug in Nimrod map02. popentop and popenbottom // record the limits the texture can be displayed in. @@ -1732,8 +1724,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // From CB if (gr_curline->polyseg) { - popentop = back->ceilingheight; - popenbottom = back->floorheight; + popentop = popentopslope = back->ceilingheight; + popenbottom = popenbottomslope = back->floorheight; } else #endif @@ -1741,10 +1733,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #ifdef ESLOPE popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); -#else - popentop = min(front->ceilingheight, back->ceilingheight); - popenbottom = max(front->floorheight, back->floorheight); -#endif + + popentopslope = min(worldtopslope, worldhighslope); + popenbottomslope = max(worldbottomslope, worldlowslope); } #ifdef ESLOPE @@ -1753,12 +1744,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) { polybottom = max(front->floorheight, back->floorheight) + gr_sidedef->rowoffset; - polytop = polybottom + textureheight[gr_midtexture]*repeats; + polybottomslope = polybottom; + polytop = polybottom + midtexheight; + polytopslope = polytop; } else { polytop = min(front->ceilingheight, back->ceilingheight) + gr_sidedef->rowoffset; - polybottom = polytop - textureheight[gr_midtexture]*repeats; + polytopslope = polytop; + polybottom = polytop - midtexheight; + polybottomslope = polybottom; } } else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) @@ -1767,12 +1762,17 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif { polybottom = popenbottom + gr_sidedef->rowoffset; - polytop = polybottom + textureheight[gr_midtexture]*repeats; + polytop = polybottom + midtexheight; + polybottomslope = popenbottomslope + gr_sidedef->rowoffset; + polytopslope = polybottomslope + midtexheight; } else { polytop = popentop + gr_sidedef->rowoffset; polybottom = polytop - textureheight[gr_midtexture]*repeats; + polybottom = polytop - midtexheight; + polytopslope = popentopslope + gr_sidedef->rowoffset; + polybottomslope = polytopslope - midtexheight; } // CB @@ -1783,6 +1783,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { lowcut = polybottom; highcut = polytop; + lowcutslope = polybottomslope; + highcutslope = polytopslope; } #endif else @@ -1790,83 +1792,49 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // The cut-off values of a linedef can always be constant, since every line has an absoulute front and or back sector lowcut = popenbottom; highcut = popentop; + lowcutslope = popenbottomslope; + highcutslope = popentopslope; } h = min(highcut, polytop); l = max(polybottom, lowcut); + hS = min(highcutslope, polytopslope); + lS = max(polybottomslope, lowcutslope); + // PEGGING + fixed_t texturevpeg, texturevpegslope; + + if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) { - // PEGGING -#ifdef ESLOPE - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) -#endif - texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; - else - texturevpeg = polytop - h; + texturevpeg = midtexheight - h + polybottom; + texturevpegslope = midtexheight - hS + polybottomslope; + } + else + { + texturevpeg = polytop - h; + texturevpegslope = polytopslope - hS; + } grTex = HWR_GetTexture(gr_midtexture); - wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - } + wallVerts[3].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; + wallVerts[2].t = texturevpegslope * grTex->scaleY; + wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; // set top/bottom coords // Take the texture peg into account, rather than changing the offsets past // where the polygon might not be. - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); - -#ifdef ESLOPE - // Correct to account for slopes - { - fixed_t midtextureslant; - - if (gr_linedef->flags & ML_EFFECT2) - midtextureslant = 0; - else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - midtextureslant = worldlow < worldbottom - ? worldbottomslope-worldbottom - : worldlowslope-worldlow; - else - midtextureslant = worldtop < worldhigh - ? worldtopslope-worldtop - : worldhighslope-worldhigh; - - polytop += midtextureslant; - polybottom += midtextureslant; - - highcut += worldtop < worldhigh - ? worldtopslope-worldtop - : worldhighslope-worldhigh; - lowcut += worldlow < worldbottom - ? worldbottomslope-worldbottom - : worldlowslope-worldlow; - - // Texture stuff - h = min(highcut, polytop); - l = max(polybottom, lowcut); - - { - // PEGGING - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; - else - texturevpeg = polytop - h; - wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY; - } - - wallVerts[2].y = FIXED_TO_FLOAT(h); - wallVerts[1].y = FIXED_TO_FLOAT(l); - } + wallVerts[3].y = FIXED_TO_FLOAT(h); + wallVerts[0].y = FIXED_TO_FLOAT(l); + wallVerts[2].y = FIXED_TO_FLOAT(hS); + wallVerts[1].y = FIXED_TO_FLOAT(lS); #endif // set alpha for transparent walls (new boom and legacy linedef types) - // ooops ! this do not work at all because render order we should render it in backtofront order + FBITFIELD blendmode; switch (gr_linedef->special) { -- 2.54.0 From 06a2508a9cbb2ccc1dd018d06507b1b710d346d9 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Wed, 13 Sep 2023 01:52:25 +0200 Subject: [PATCH 3/9] cleanup HWR_SplitWall e --- src/hardware/hw_main.c | 83 ++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 07f74f6a5..7fe8f9be8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -915,11 +915,10 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend // // HWR_SplitWall // +// SoM: split up and light walls according to the lightlist. +// This may also include leaving out parts of the wall that can't be seen void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) { - /* SoM: split up and light walls according to the - lightlist. This may also include leaving out parts - of the wall that can't be seen */ float realtop, realbot, top, bot; float pegt, pegb, pegmul; @@ -930,48 +929,55 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; - fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); - fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo - fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); - fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo - // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly - // use this as a temp var to store P_GetZAt's return value each time - fixed_t temp; + fixed_t v1x = FloatToFixed(wallVerts[0].x); + fixed_t v1y = FloatToFixed(wallVerts[0].z); + fixed_t v2x = FloatToFixed(wallVerts[1].x); + fixed_t v2y = FloatToFixed(wallVerts[1].z); + float diff; #endif - INT32 solid, i; - lightlist_t * list = sector->lightlist; const UINT8 alpha = Surf->PolyColor.s.alpha; FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; + diff = top - bot; pegt = wallVerts[3].t; pegb = wallVerts[0].t; - pegmul = (pegb - pegt) / (top - bot); - - if (fpclassify(pegmul) == FP_NAN) + + // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. + // To avoid division by zero, which would result in a NaN, we check if the vertical difference + // between the two vertices is not zero. + if (fpclassify(diff) == FP_ZERO) pegmul = 0.0; + else + pegmul = (pegb - pegt) / diff; #ifdef ESLOPE endrealtop = endtop = wallVerts[2].y; endrealbot = endbot = wallVerts[1].y; + diff = endtop - endbot; + endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; - endpegmul = (endpegb - endpegt) / (endtop - endbot); + + if (fpclassify(diff) == FP_ZERO) + endpegmul = 0.0; + else + endpegmul = (endpegb - endpegt) / diff; #endif - if (fpclassify(endpegmul) == FP_NAN) - endpegmul = 0.0; - for (i = 0; i < sector->numlights; i++) + for (INT32 i = 0; i < sector->numlights; i++) { #ifdef ESLOPE if (endtop < endrealbot) #endif if (top < realbot) return; + + lightlist_t *list = sector->lightlist; if (!(list[i].flags & FF_NOSHADE)) { @@ -987,7 +993,7 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa } } - solid = false; + boolean solid = false; if ((sector->lightlist[i].flags & FF_CUTSOLIDS) && !(cutflag & FF_EXTRA)) solid = true; @@ -1007,10 +1013,8 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa #ifdef ESLOPE if (list[i].slope) { - temp = P_GetZAt(list[i].slope, v1x, v1y); - height = FIXED_TO_FLOAT(temp); - temp = P_GetZAt(list[i].slope, v2x, v2y); - endheight = FIXED_TO_FLOAT(temp); + height = FixedToFloat(P_GetZAt(&list[i], v1x, v1y)); + endheight = FixedToFloat(P_GetZAt(&list[i], v2x, v2y)); } else height = endheight = FIXED_TO_FLOAT(list[i].height); @@ -1018,10 +1022,8 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa { if (*list[i].caster->b_slope) { - temp = P_GetZAt(*list[i].caster->b_slope, v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); - temp = P_GetZAt(*list[i].caster->b_slope, v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); + bheight = FixedToFloat(P_GetZAt(list[i].caster, v1x, v1y)); + endbheight = FixedToFloat(P_GetZAt(list[i].caster, v2x, v2y)); } else bheight = endbheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); @@ -1050,10 +1052,8 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa { if (list[i+1].slope) { - temp = P_GetZAt(list[i+1].slope, v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); - temp = P_GetZAt(list[i+1].slope, v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); + bheight = FixedToFloat(P_GetZAt(&list[i+1], v1x, v1y)); + endbheight = FixedToFloat(P_GetZAt(&list[i+1], v2x, v2y)); } else bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); @@ -1074,10 +1074,11 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa } #endif +#ifdef ESLOPE // Found a break bot = min(max(bheight, realbot), top); endbot = min(max(endbheight, endrealbot), endtop); - +#endif Surf->PolyColor.s.alpha = alpha; #ifdef ESLOPE @@ -1706,7 +1707,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else repeats = 1; - + fixed_t midtexheight = textureheight[gr_midtexture] * repeats; fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut; fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope; @@ -1733,9 +1734,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #ifdef ESLOPE popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); - popentopslope = min(worldtopslope, worldhighslope); popenbottomslope = max(worldbottomslope, worldlowslope); +#else + popentop = min(front->ceilingheight, back->ceilingheight); + popenbottom = max(front->floorheight, back->floorheight); +#endif } #ifdef ESLOPE @@ -1769,7 +1773,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { polytop = popentop + gr_sidedef->rowoffset; - polybottom = polytop - textureheight[gr_midtexture]*repeats; polybottom = polytop - midtexheight; polytopslope = popentopslope + gr_sidedef->rowoffset; polybottomslope = polytopslope - midtexheight; @@ -1800,11 +1803,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = max(polybottom, lowcut); hS = min(highcutslope, polytopslope); lS = max(polybottomslope, lowcutslope); - + // PEGGING fixed_t texturevpeg, texturevpegslope; - +#ifdef ESLOPE if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) +#else + if (gr_linedef->flags & ML_DONTPEGBOTTOM) +#endif { texturevpeg = midtexheight - h + polybottom; texturevpegslope = midtexheight - hS + polybottomslope; @@ -1831,7 +1837,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[1].y = FIXED_TO_FLOAT(lS); -#endif // set alpha for transparent walls (new boom and legacy linedef types) FBITFIELD blendmode; -- 2.54.0 From a929636a289f10b8fafdc2c53a5da47e3f04acdc Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Wed, 13 Sep 2023 01:52:25 +0200 Subject: [PATCH 4/9] Revert "cleanup HWR_SplitWall" This reverts commit 06a2508a9cbb2ccc1dd018d06507b1b710d346d9. --- src/hardware/hw_main.c | 83 ++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7fe8f9be8..07f74f6a5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -915,10 +915,11 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend // // HWR_SplitWall // -// SoM: split up and light walls according to the lightlist. -// This may also include leaving out parts of the wall that can't be seen void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) { + /* SoM: split up and light walls according to the + lightlist. This may also include leaving out parts + of the wall that can't be seen */ float realtop, realbot, top, bot; float pegt, pegb, pegmul; @@ -929,55 +930,48 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; - fixed_t v1x = FloatToFixed(wallVerts[0].x); - fixed_t v1y = FloatToFixed(wallVerts[0].z); - fixed_t v2x = FloatToFixed(wallVerts[1].x); - fixed_t v2y = FloatToFixed(wallVerts[1].z); - float diff; + fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); + fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo + fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); + fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo + // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly + // use this as a temp var to store P_GetZAt's return value each time + fixed_t temp; #endif + INT32 solid, i; + lightlist_t * list = sector->lightlist; const UINT8 alpha = Surf->PolyColor.s.alpha; FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; - diff = top - bot; pegt = wallVerts[3].t; pegb = wallVerts[0].t; - - // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. - // To avoid division by zero, which would result in a NaN, we check if the vertical difference - // between the two vertices is not zero. - if (fpclassify(diff) == FP_ZERO) + pegmul = (pegb - pegt) / (top - bot); + + if (fpclassify(pegmul) == FP_NAN) pegmul = 0.0; - else - pegmul = (pegb - pegt) / diff; #ifdef ESLOPE endrealtop = endtop = wallVerts[2].y; endrealbot = endbot = wallVerts[1].y; - diff = endtop - endbot; - endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; - - if (fpclassify(diff) == FP_ZERO) - endpegmul = 0.0; - else - endpegmul = (endpegb - endpegt) / diff; + endpegmul = (endpegb - endpegt) / (endtop - endbot); #endif + if (fpclassify(endpegmul) == FP_NAN) + endpegmul = 0.0; - for (INT32 i = 0; i < sector->numlights; i++) + for (i = 0; i < sector->numlights; i++) { #ifdef ESLOPE if (endtop < endrealbot) #endif if (top < realbot) return; - - lightlist_t *list = sector->lightlist; if (!(list[i].flags & FF_NOSHADE)) { @@ -993,7 +987,7 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa } } - boolean solid = false; + solid = false; if ((sector->lightlist[i].flags & FF_CUTSOLIDS) && !(cutflag & FF_EXTRA)) solid = true; @@ -1013,8 +1007,10 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa #ifdef ESLOPE if (list[i].slope) { - height = FixedToFloat(P_GetZAt(&list[i], v1x, v1y)); - endheight = FixedToFloat(P_GetZAt(&list[i], v2x, v2y)); + temp = P_GetZAt(list[i].slope, v1x, v1y); + height = FIXED_TO_FLOAT(temp); + temp = P_GetZAt(list[i].slope, v2x, v2y); + endheight = FIXED_TO_FLOAT(temp); } else height = endheight = FIXED_TO_FLOAT(list[i].height); @@ -1022,8 +1018,10 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa { if (*list[i].caster->b_slope) { - bheight = FixedToFloat(P_GetZAt(list[i].caster, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(list[i].caster, v2x, v2y)); + temp = P_GetZAt(*list[i].caster->b_slope, v1x, v1y); + bheight = FIXED_TO_FLOAT(temp); + temp = P_GetZAt(*list[i].caster->b_slope, v2x, v2y); + endbheight = FIXED_TO_FLOAT(temp); } else bheight = endbheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); @@ -1052,8 +1050,10 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa { if (list[i+1].slope) { - bheight = FixedToFloat(P_GetZAt(&list[i+1], v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(&list[i+1], v2x, v2y)); + temp = P_GetZAt(list[i+1].slope, v1x, v1y); + bheight = FIXED_TO_FLOAT(temp); + temp = P_GetZAt(list[i+1].slope, v2x, v2y); + endbheight = FIXED_TO_FLOAT(temp); } else bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); @@ -1074,11 +1074,10 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa } #endif -#ifdef ESLOPE // Found a break bot = min(max(bheight, realbot), top); endbot = min(max(endbheight, endrealbot), endtop); -#endif + Surf->PolyColor.s.alpha = alpha; #ifdef ESLOPE @@ -1707,7 +1706,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else repeats = 1; - + fixed_t midtexheight = textureheight[gr_midtexture] * repeats; fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut; fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope; @@ -1734,12 +1733,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #ifdef ESLOPE popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); + popentopslope = min(worldtopslope, worldhighslope); popenbottomslope = max(worldbottomslope, worldlowslope); -#else - popentop = min(front->ceilingheight, back->ceilingheight); - popenbottom = max(front->floorheight, back->floorheight); -#endif } #ifdef ESLOPE @@ -1773,6 +1769,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { polytop = popentop + gr_sidedef->rowoffset; + polybottom = polytop - textureheight[gr_midtexture]*repeats; polybottom = polytop - midtexheight; polytopslope = popentopslope + gr_sidedef->rowoffset; polybottomslope = polytopslope - midtexheight; @@ -1803,14 +1800,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = max(polybottom, lowcut); hS = min(highcutslope, polytopslope); lS = max(polybottomslope, lowcutslope); - + // PEGGING fixed_t texturevpeg, texturevpegslope; -#ifdef ESLOPE + if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) -#endif { texturevpeg = midtexheight - h + polybottom; texturevpegslope = midtexheight - hS + polybottomslope; @@ -1837,6 +1831,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[1].y = FIXED_TO_FLOAT(lS); +#endif // set alpha for transparent walls (new boom and legacy linedef types) FBITFIELD blendmode; -- 2.54.0 From ad4d587a526eb62114931a3eca2b760148c4e456 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Wed, 13 Sep 2023 02:58:20 +0200 Subject: [PATCH 5/9] screw you bleh, pegging midtextures to slopes now works correctly, but cutting them is broken again atleast this fixes the performance issues no idea tho why it screws up things so much --- src/hardware/hw_main.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 07f74f6a5..40ec21cbe 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1074,9 +1074,24 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa } #endif - // Found a break - bot = min(max(bheight, realbot), top); - endbot = min(max(endbheight, endrealbot), endtop); +#ifdef ESLOPE + if (endbheight >= endtop) +#endif + if (bheight >= top) + continue; + + //Found a break; + bot = bheight; + + if (bot < realbot) + bot = realbot; + +#ifdef ESLOPE + endbot = endbheight; + + if (endbot < endrealbot) + endbot = endrealbot; +#endif Surf->PolyColor.s.alpha = alpha; -- 2.54.0 From 2cba586d9c3bd244e6aa52507895491eb32a3316 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Wed, 13 Sep 2023 03:54:12 +0200 Subject: [PATCH 6/9] im good at coding absolute bruh thing, but it somehow works, fixes the midtextures, and doesent kill performance lmao --- src/hardware/hw_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 40ec21cbe..6a254a285 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1075,7 +1075,8 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa #endif #ifdef ESLOPE - if (endbheight >= endtop) + if (endbheight > endtop) + endbot = endtop; #endif if (bheight >= top) continue; @@ -1085,12 +1086,9 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa if (bot < realbot) bot = realbot; - + #ifdef ESLOPE - endbot = endbheight; - - if (endbot < endrealbot) - endbot = endrealbot; + endbot = min(max(endbheight, endrealbot), endtop); #endif Surf->PolyColor.s.alpha = alpha; -- 2.54.0 From 538de7d2d2b439331949320a31a99bc8ca37b041 Mon Sep 17 00:00:00 2001 From: lug420 Date: Wed, 13 Sep 2023 04:42:35 +0200 Subject: [PATCH 7/9] fix memfree command on 64bit --- src/android/i_system.c | 2 +- src/dummy/i_system.c | 2 +- src/i_system.h | 2 +- src/sdl/i_system.c | 13 ++++++------- src/z_zone.c | 10 +++++----- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/android/i_system.c b/src/android/i_system.c index 51a96d93a..c0b49a886 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -24,7 +24,7 @@ static INT64 start_time; // as microseconds since the epoch // I should probably return how much memory is remaining // for this process, considering Android's process memory limit. -UINT32 I_GetFreeMem(UINT32 *total) +size_t I_GetFreeMem(size_t *total) { // what the heck? sysinfo() is partially missing in bionic? /* struct sysinfo si; */ diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index 1696672b8..cf8144b90 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -5,7 +5,7 @@ UINT8 graphics_started = 0; UINT8 keyboard_started = 0; -UINT32 I_GetFreeMem(UINT32 *total) +size_t I_GetFreeMem(size_t *total) { *total = 0; return 0; diff --git a/src/i_system.h b/src/i_system.h index 89ea1ae2d..05826c79e 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -40,7 +40,7 @@ extern UINT8 keyboard_started; \return free memory in the system */ -UINT32 I_GetFreeMem(UINT32 *total); +size_t I_GetFreeMem(size_t *total); /** \brief Returns precise time value for performance measurement. The precise time should be a monotonically increasing counter, and will wrap. diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 5b76edddf..d1add12b4 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3806,8 +3806,7 @@ static long get_entry(const char* name, const char* buf) } #endif -// quick fix for compil -UINT32 I_GetFreeMem(UINT32 *total) +size_t I_GetFreeMem(size_t *total) { #ifdef FREEBSD struct vmmeter sum; @@ -3855,8 +3854,8 @@ UINT32 I_GetFreeMem(UINT32 *total) info.dwLength = sizeof (MEMORYSTATUS); GlobalMemoryStatus( &info ); if (total) - *total = (UINT32)info.dwTotalPhys; - return (UINT32)info.dwAvailPhys; + *total = (size_t)info.dwTotalPhys; + return (size_t)info.dwAvailPhys; #elif defined (__OS2__) UINT32 pr_arena; @@ -3871,8 +3870,8 @@ UINT32 I_GetFreeMem(UINT32 *total) /* Linux */ char buf[1024]; char *memTag; - UINT32 freeKBytes; - UINT32 totalKBytes; + size_t freeKBytes; + size_t totalKBytes; INT32 n; INT32 meminfo_fd = -1; long Cached; @@ -3903,7 +3902,7 @@ UINT32 I_GetFreeMem(UINT32 *total) } memTag += sizeof (MEMTOTAL); - totalKBytes = atoi(memTag); + totalKBytes = (size_t)atoi(memTag); if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL) { diff --git a/src/z_zone.c b/src/z_zone.c index 199eefd08..1eb9ba42e 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -140,14 +140,14 @@ static void Command_Memdump_f(void); void Z_Init(void) { - UINT32 total, memfree; + size_t total, memfree; memset(&head, 0x00, sizeof(head)); head.next = head.prev = &head; memfree = I_GetFreeMem(&total)>>20; - CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree); + CONS_Printf("System memory: %sMB - Free: %sMB\n", sizeu1(total>>20), sizeu2(memfree)); // Note: This allocates memory. Watch out. COM_AddCommand("memfree", Command_Memfree_f); @@ -616,7 +616,7 @@ size_t Z_TagUsage(INT32 tagnum) void Command_Memfree_f(void) { - UINT32 freebytes, totalbytes; + size_t freebytes, totalbytes; Z_CheckHeap(-1); CONS_Printf("\x82%s", M_GetText("Memory Info\n")); @@ -644,8 +644,8 @@ void Command_Memfree_f(void) CONS_Printf("\x82%s", M_GetText("System Memory Info\n")); freebytes = I_GetFreeMem(&totalbytes); - CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10); - CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10); + CONS_Printf(M_GetText(" Total physical memory: %s KB\n"), sizeu1(totalbytes>>10)); + CONS_Printf(M_GetText("Available physical memory: %s KB\n"), sizeu1(freebytes>>10)); } #ifdef ZDEBUG -- 2.54.0 From 679a8387c90c060875eef96440697652cf0e0ecf Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 14 Sep 2023 00:09:33 +0300 Subject: [PATCH 8/9] Add logo (WIP) --- logo.png | Bin 0 -> 4303 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 logo.png diff --git a/logo.png b/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..2f84c3321152c32a77735b482f6c72c57d2c0d64 GIT binary patch literal 4303 zcmeHKeNfVO9R8uL*TcN6tSrN}U1nyi7he*?UM%Z2C6}nZh}9w(saTod3refYrB~jq z)H4-q^x`5V<3JOEiom6*y&Ezhtt=8mFcC#!U%0m2?sm67pudVcK6h~3eO{jD_dE|L zw!}oir+QC?APByBQ{?v$go;(qJb3Gxd5`sKSH%G3GqgLvk){_)JddYh3@A>9d zsCSUNyAgidH?HPBzH!sJv}uPs0?)Sw-mWUt>^wh+Z;V|qp#z@ixrz0=Y;r<(CS~_* zA#+B4>2SEUr*d|S4WTBBVW7pQ*T;5&^w-|J>2w=qRZ|UZo%ZdEMyko6$r4Jo(%sXu z5AGbd=H+IqUi!}!c&p>&)5N#LBm_8-C31~Bv}TPHr8?FE;W%ygHC0vFthsz<-6Vq)bektmR1HI7O=kT8#%EtupYLX_mD2U7mW+W}Fl zYCAZnAw}?b$pBY+5ZgRL%H0~CLu__}NB?jTFp6H5xvFUqBemhIlw0(YloY1WXBLhO zuvDYlN`%k*6}@sKGeSG~IX(H+^Gh5lm({bYpe!XVo05zt2LjGf`AU*kgL2RH#j2bj zkv~Hjg{y`^zP`?udo{E*Cji$St22_8B=kR!=QV6?rXYqpIxlM-$eucW)CYI%y2>IM zQ$qX@YcS^;1!0rL=m*%^TKw_=o016DN@`53D;&X{Bo`9)8(j1N)Jp#cPapUsRP&3} zeqqEFHNiadqPmZVc{))UX;7DLxo}SK@(966=fJx`lQubj@ zidf;V5)@~@B4ACYIApdKf9N53sM`-p*;_$wC5A3yDEsDy2?a<-ExuwScnYMcPttNqFHT^n=<%noz{3JfkVlQ$Lq~we5z@L(!Non?JO{=;gE`vD)P6p%`uaY z@{MBk`}NAWN} zM~mC{Ga+p`ZG1;U8#=FzYIV)y{jA0WYsT3Zq?$lKADodttfG*Z(BQt&QbPds$V7-v zr#o40!~!?qZIrAvXw74pNnsX?U>_^P^h$C$V+K9sH9)ynu8){sD8?&t*JmkQxf!dc znwptQ6R3Lpp?O!C)7gMN!RqB^lxrj?J%*Qp?7j1{Zu|Bk1zQaCk7wzz@wMto8Cj#J?Lq^#2 zU1O*$B7ZbVXxO5aLIH>7M!vT<80qlN z4`DJocUBfpCd64SeMq_aZ(*)AKruNdgGZ{ v2ZBUk8qOJ)7{bT)_vzEV_6yK&+{F#pEqxaiL6_<>!&{fCV^aF literal 0 HcmV?d00001 -- 2.54.0 From 8ee4fc2fa118d5fa19762185d82b0ca29def8af5 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 14 Sep 2023 00:18:22 +0300 Subject: [PATCH 9/9] Oops used upscaled image >< --- logo.png | Bin 4303 -> 480 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/logo.png b/logo.png index 2f84c3321152c32a77735b482f6c72c57d2c0d64..a950aa51fd9dd2e47e679af9f3b68b5d8242d3c3 100644 GIT binary patch literal 480 zcmV<60U!Q}P)TmbIjG+B=<>t`j) zW-{5YGAmj8o+TtLAP9mW2!il`nGJclEb=CWh(mRZ))D-oDtf(KwDHfcTQ6q9)Q@5@ zM%XWqa9to*xQ@#Rz&GRVWD~x6enjoG;f-AMUI; z8_ObZOu_;5#1DZ?05BSHnXooYC7y^iVGR1jQ=-*V*t)lI{=W6b=9=gQxZ*qQkw!?k zN~np>51)7dMgu9)^Y~26>A@#{$YB%8p*qgU2x%bJ%SGobn#01q#1k$PDi5IptLxpg zhGQ7A83Y?hl{gjFB}5e4EZLZYXt0000go;(qJb3Gxd5`sKSH%G3GqgLvk){_)JddYh3@A>9d zsCSUNyAgidH?HPBzH!sJv}uPs0?)Sw-mWUt>^wh+Z;V|qp#z@ixrz0=Y;r<(CS~_* zA#+B4>2SEUr*d|S4WTBBVW7pQ*T;5&^w-|J>2w=qRZ|UZo%ZdEMyko6$r4Jo(%sXu z5AGbd=H+IqUi!}!c&p>&)5N#LBm_8-C31~Bv}TPHr8?FE;W%ygHC0vFthsz<-6Vq)bektmR1HI7O=kT8#%EtupYLX_mD2U7mW+W}Fl zYCAZnAw}?b$pBY+5ZgRL%H0~CLu__}NB?jTFp6H5xvFUqBemhIlw0(YloY1WXBLhO zuvDYlN`%k*6}@sKGeSG~IX(H+^Gh5lm({bYpe!XVo05zt2LjGf`AU*kgL2RH#j2bj zkv~Hjg{y`^zP`?udo{E*Cji$St22_8B=kR!=QV6?rXYqpIxlM-$eucW)CYI%y2>IM zQ$qX@YcS^;1!0rL=m*%^TKw_=o016DN@`53D;&X{Bo`9)8(j1N)Jp#cPapUsRP&3} zeqqEFHNiadqPmZVc{))UX;7DLxo}SK@(966=fJx`lQubj@ zidf;V5)@~@B4ACYIApdKf9N53sM`-p*;_$wC5A3yDEsDy2?a<-ExuwScnYMcPttNqFHT^n=<%noz{3JfkVlQ$Lq~we5z@L(!Non?JO{=;gE`vD)P6p%`uaY z@{MBk`}NAWN} zM~mC{Ga+p`ZG1;U8#=FzYIV)y{jA0WYsT3Zq?$lKADodttfG*Z(BQt&QbPds$V7-v zr#o40!~!?qZIrAvXw74pNnsX?U>_^P^h$C$V+K9sH9)ynu8){sD8?&t*JmkQxf!dc znwptQ6R3Lpp?O!C)7gMN!RqB^lxrj?J%*Qp?7j1{Zu|Bk1zQaCk7wzz@wMto8Cj#J?Lq^#2 zU1O*$B7ZbVXxO5aLIH>7M!vT<80qlN z4`DJocUBfpCd64SeMq_aZ(*)AKruNdgGZ{ v2ZBUk8qOJ)7{bT)_vzEV_6yK&+{F#pEqxaiL6_<>!&{fCV^aF -- 2.54.0