diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 0806d05c8..87192e2bd 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -388,11 +388,11 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 extralight = FixedMul(extralight, std::min(std::max(0, *lightlevel), 255) * FRACUNIT / 255); // simple OGL approximation - fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y); - fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + const fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y); + const fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); // Less change in contrast at further distances, to counteract DOOM diminished light - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + const fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); extralight = FixedMul(extralight, std::min(n, FRACUNIT)); // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance @@ -515,7 +515,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) { - INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); + const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); finallight += offset; finallight = CLAMP(finallight, 0 , 255); @@ -533,7 +533,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t if (slope != NULL && sector != NULL && P_ApplyLightOffsetFine(lightnum, sector)) { - INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); + const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); finallight += (fof ? -offset : offset); finallight = CLAMP(finallight, 0 , 255); @@ -1420,6 +1420,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { draw_sky_walls(0, 1, worldhigh, worldhighslope); } + + // hack to allow height changes in outdoor areas + // This is what gets rid of the upper textures if there should be sky + worldtop = worldhigh; + worldtopslope = worldhighslope; } else { @@ -1464,15 +1469,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - // hack to allow height changes in outdoor areas - // This is what gets rid of the upper textures if there should be sky - if (gl_frontsector->ceilingpic == skyflatnum - && gl_backsector->ceilingpic == skyflatnum) - { - worldtop = worldhigh; - worldtopslope = worldhighslope; - } - gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); // check TOP TEXTURE @@ -2263,7 +2259,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom static inline boolean HWR_UsePortals(void) { - return supportstencil && cv_glportals.value && gl_maphasportals; + return supportstencil && gl_maphasportals && cv_glportals.value; } // From PrBoom: @@ -2407,7 +2403,8 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) // SoM: Backsector needs to be run through R_FakeFlat static sector_t tempsec; - auto do_addline = [&](bool dontdraw) { + auto do_addline = [&](bool dontdraw) + { // Single sided line? if (!line->backsector) { @@ -2688,14 +2685,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, if (nrPlaneVerts < 3) // not even a triangle ? return; - if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size - { - CONS_Debug(DBG_RENDER, "polygon size of %s exceeds max value of %d vertices\n", sizeu1(nrPlaneVerts), UINT16_MAX); - return; - } - - const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; - // Allocate plane-vertex buffer if we need to if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) { @@ -2704,6 +2693,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, Z_Malloc(numAllocedPlaneVerts * sizeof(FOutVector), PU_LEVEL, &planeVerts); } + const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; + height = FixedToFloat(fixedheight); len = W_LumpLength(lumpnum); diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 90d019b2b..31723eab1 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -365,13 +365,17 @@ static void HWR_CompileShader(int index) if (vertex_source) { char *preprocessed = HWR_PreprocessShader(vertex_source); - if (!preprocessed) return; + if (!preprocessed) + return; + GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX); } if (fragment_source) { char *preprocessed = HWR_PreprocessShader(fragment_source); - if (!preprocessed) return; + if (!preprocessed) + return; + GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT); } @@ -387,8 +391,10 @@ void HWR_CompileShaders(void) { int custom_index = gl_shadertargets[i].custom_shader; HWR_CompileShader(i); + if (!gl_shaders[i].compiled) CONS_Alert(CONS_ERROR, "HWR_CompileShaders: Compilation failed for base %s shader!\n", shaderxlat[i].type); + if (custom_index != -1) { HWR_CompileShader(custom_index); diff --git a/src/r_main.cpp b/src/r_main.cpp index 2b318858a..cf7df9088 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -342,14 +342,14 @@ angle_t R_PointToAngle64(INT64 x, INT64 y) return (y -= viewy, (x -= viewx) || y) ? x >= 0 ? y >= 0 ? - (x > y) ? tantoangle[SlopeDivEx(y,x)] : // octant 0 - ANGLE_90-tantoangle[SlopeDivEx(x,y)] : // octant 1 - x > (y = -y) ? 0-tantoangle[SlopeDivEx(y,x)] : // octant 8 - ANGLE_270+tantoangle[SlopeDivEx(x,y)] : // octant 7 + (x > y) ? tantoangle[SlopeDivEx(y,x)] : // octant 0 + ANGLE_90-tantoangle[SlopeDivEx(x,y)] : // octant 1 + x > (y = -y) ? 0-tantoangle[SlopeDivEx(y,x)] : // octant 8 + ANGLE_270+tantoangle[SlopeDivEx(x,y)] : // octant 7 y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDivEx(y,x)] : // octant 3 - ANGLE_90 + tantoangle[SlopeDivEx(x,y)] : // octant 2 + ANGLE_90 + tantoangle[SlopeDivEx(x,y)] : // octant 2 (x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDivEx(y,x)] : // octant 4 - ANGLE_270-tantoangle[SlopeDivEx(x,y)] : // octant 5 + ANGLE_270-tantoangle[SlopeDivEx(x,y)] : // octant 5 0; } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 8ddea4249..2f2253fe8 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -304,7 +304,7 @@ static void I_StartupConsole(void) if (!consolevent) return; - if (isatty(STDIN_FILENO)!=1) + if (isatty(STDIN_FILENO) != 1) { I_OutputMsg("stdin is not a tty, tty console mode failed\n"); consolevent = false; @@ -1993,12 +1993,14 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) I_ShutdownInput(); I_ShutdownSystem(); SDL_Quit(); + /* if option -noendtxt is set, don't print the text */ if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) { printf("\r"); ShowEndTxt(); } + if (myargmalloc) free(myargv); // Deallocate allocated memory