diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index a0fc6e716..c721af665 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -1076,7 +1076,7 @@ void OpenGLSWFrameBuffer::CalcFullscreenCoords(FBVERTEX verts[4], bool viewarea_ int OpenGLSWFrameBuffer::GetPageCount() { - return 1; + return 2; } //========================================================================== diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 76e06c640..19ea1db36 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -955,7 +955,7 @@ DEFINE_ACTION_FUNCTION(DBlockLinesIterator, CreateFromPos) ACTION_RETURN_OBJECT(new DBlockLinesIterator(x, y, z, h, radius, sec)); } -DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Next) +DEFINE_ACTION_FUNCTION(DBlockLinesIterator, Next) { PARAM_SELF_PROLOGUE(DBlockLinesIterator); ACTION_RETURN_BOOL(self->Next()); @@ -1294,9 +1294,9 @@ DEFINE_ACTION_FUNCTION(DBlockThingsIterator, CreateFromPos) ACTION_RETURN_OBJECT(new DBlockThingsIterator(x, y, z, h, radius, ignore, nullptr)); } -DEFINE_ACTION_FUNCTION(DBlockLinesIterator, Next) +DEFINE_ACTION_FUNCTION(DBlockThingsIterator, Next) { - PARAM_SELF_PROLOGUE(DBlockLinesIterator); + PARAM_SELF_PROLOGUE(DBlockThingsIterator); ACTION_RETURN_BOOL(self->Next()); } diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 68bf2ed3d..92cd52b95 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -735,7 +735,7 @@ bool SightCheck::P_SightPathTraverse () // step through map blocks // Count is present to prevent a round off error from skipping the break - int itres; + int itres = -1; for (count = 0 ; count < 1000 ; count++) { // end traversing when reaching the end of the blockmap diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index b3c695c78..c7cadfbab 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -69,7 +69,7 @@ namespace swrenderer { double cosine = cos(planeang), sine = sin(planeang); pviewx = pl->xform.xOffs + ViewPos.X * cosine - ViewPos.Y * sine; - pviewy = pl->xform.yOffs - ViewPos.X * sine - ViewPos.Y * cosine; + pviewy = pl->xform.yOffs + pl->xform.baseyOffs - ViewPos.X * sine - ViewPos.Y * cosine; } else { @@ -209,19 +209,27 @@ namespace swrenderer drawerargs.dc_viewpos.Z = (float)((viewport->CenterY - y - 0.5) / viewport->InvZtoScale * zspan); drawerargs.dc_viewpos_step.X = (float)(zspan / viewport->CenterX); - static DrawerLight lightbuffer[64 * 1024]; - static int nextlightindex = 0; - // Plane normal drawerargs.dc_normal.X = 0.0f; drawerargs.dc_normal.Y = 0.0f; drawerargs.dc_normal.Z = (y >= viewport->CenterY) ? 1.0f : -1.0f; - // Setup lights for row - drawerargs.dc_num_lights = 0; - drawerargs.dc_lights = lightbuffer + nextlightindex; + // Calculate max lights that can touch the row so we can allocate memory for the list + int max_lights = 0; VisiblePlaneLight *cur_node = light_list; - while (cur_node && nextlightindex < 64 * 1024) + while (cur_node) + { + if (!(cur_node->lightsource->flags2&MF2_DORMANT)) + max_lights++; + cur_node = cur_node->next; + } + + drawerargs.dc_num_lights = 0; + drawerargs.dc_lights = Thread->FrameMemory->AllocMemory(max_lights); + + // Setup lights for row + cur_node = light_list; + while (cur_node) { double lightX = cur_node->lightsource->X() - ViewPos.X; double lightY = cur_node->lightsource->Y() - ViewPos.Y; @@ -244,7 +252,6 @@ namespace swrenderer uint32_t green = cur_node->lightsource->GetGreen(); uint32_t blue = cur_node->lightsource->GetBlue(); - nextlightindex++; auto &light = drawerargs.dc_lights[drawerargs.dc_num_lights++]; light.x = lx; light.y = lconstant; @@ -255,9 +262,6 @@ namespace swrenderer cur_node = cur_node->next; } - - if (nextlightindex == 64 * 1024) - nextlightindex = 0; } else { diff --git a/src/swrenderer/r_swcanvas.cpp b/src/swrenderer/r_swcanvas.cpp index aa817e707..82f34313f 100644 --- a/src/swrenderer/r_swcanvas.cpp +++ b/src/swrenderer/r_swcanvas.cpp @@ -110,6 +110,13 @@ void SWCanvas::DrawTexture(DCanvas *canvas, FTexture *img, DrawParms &parms) double centeryback = viewport->CenterY; viewport->CenterY = 0; + int oldviewwindowx = 0; + int oldviewwindowy = 0; + oldviewwindowx = viewwindowx; + oldviewwindowy = viewwindowy; + viewwindowx = 0; + viewwindowy = 0; + // There is not enough precision in the drawing routines to keep the full // precision for y0. :( double sprtopscreen; @@ -187,6 +194,8 @@ void SWCanvas::DrawTexture(DCanvas *canvas, FTexture *img, DrawParms &parms) } viewport->CenterY = centeryback; + viewwindowx = oldviewwindowx; + viewwindowy = oldviewwindowy; } viewport->RenderTarget->Unlock();