diff --git a/src/swrenderer/scene/r_draw_segment.cpp b/src/swrenderer/scene/r_draw_segment.cpp index d4122f728..b6e29b396 100644 --- a/src/swrenderer/scene/r_draw_segment.cpp +++ b/src/swrenderer/scene/r_draw_segment.cpp @@ -46,4 +46,33 @@ namespace swrenderer ds_p = drawsegs; } + ptrdiff_t R_NewOpening(ptrdiff_t len) + { + ptrdiff_t res = lastopening; + len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings... + lastopening += len; + if ((size_t)lastopening > maxopenings) + { + do + maxopenings = maxopenings ? maxopenings * 2 : 16384; + while ((size_t)lastopening > maxopenings); + openings = (short *)M_Realloc(openings, maxopenings * sizeof(*openings)); + DPrintf(DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings); + } + return res; + } + + void R_CheckDrawSegs() + { + if (ds_p == &drawsegs[MaxDrawSegs]) + { // [RH] Grab some more drawsegs + size_t newdrawsegs = MaxDrawSegs ? MaxDrawSegs * 2 : 32; + ptrdiff_t firstofs = firstdrawseg - drawsegs; + drawsegs = (drawseg_t *)M_Realloc(drawsegs, newdrawsegs * sizeof(drawseg_t)); + firstdrawseg = drawsegs + firstofs; + ds_p = drawsegs + MaxDrawSegs; + MaxDrawSegs = newdrawsegs; + DPrintf(DMSG_NOTIFY, "MaxDrawSegs increased to %zu\n", MaxDrawSegs); + } + } } diff --git a/src/swrenderer/scene/r_draw_segment.h b/src/swrenderer/scene/r_draw_segment.h index 07aa6198f..d22e754e0 100644 --- a/src/swrenderer/scene/r_draw_segment.h +++ b/src/swrenderer/scene/r_draw_segment.h @@ -40,4 +40,6 @@ namespace swrenderer extern size_t FirstInterestingDrawseg; void R_ClearDrawSegs(); + void R_CheckDrawSegs(); + ptrdiff_t R_NewOpening(ptrdiff_t len); } diff --git a/src/swrenderer/scene/r_segs.cpp b/src/swrenderer/scene/r_segs.cpp index f23a9326b..833755fe1 100644 --- a/src/swrenderer/scene/r_segs.cpp +++ b/src/swrenderer/scene/r_segs.cpp @@ -1542,46 +1542,6 @@ void R_NewWall (bool needlights) } } - -// -// R_CheckDrawSegs -// - -void R_CheckDrawSegs () -{ - if (ds_p == &drawsegs[MaxDrawSegs]) - { // [RH] Grab some more drawsegs - size_t newdrawsegs = MaxDrawSegs ? MaxDrawSegs*2 : 32; - ptrdiff_t firstofs = firstdrawseg - drawsegs; - drawsegs = (drawseg_t *)M_Realloc (drawsegs, newdrawsegs * sizeof(drawseg_t)); - firstdrawseg = drawsegs + firstofs; - ds_p = drawsegs + MaxDrawSegs; - MaxDrawSegs = newdrawsegs; - DPrintf (DMSG_NOTIFY, "MaxDrawSegs increased to %zu\n", MaxDrawSegs); - } -} - -// -// R_CheckOpenings -// - -ptrdiff_t R_NewOpening (ptrdiff_t len) -{ - ptrdiff_t res = lastopening; - len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings... - lastopening += len; - if ((size_t)lastopening > maxopenings) - { - do - maxopenings = maxopenings ? maxopenings*2 : 16384; - while ((size_t)lastopening > maxopenings); - openings = (short *)M_Realloc (openings, maxopenings * sizeof(*openings)); - DPrintf (DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings); - } - return res; -} - - // // R_StoreWallRange // A wall segment will be drawn between start and stop pixels (inclusive). diff --git a/src/swrenderer/scene/r_segs.h b/src/swrenderer/scene/r_segs.h index f9b235872..a4aa36b65 100644 --- a/src/swrenderer/scene/r_segs.h +++ b/src/swrenderer/scene/r_segs.h @@ -45,10 +45,6 @@ inline int R_CreateWallSegmentY(short *outbuf, double z, const FWallCoords *wall void PrepWall (float *swall, fixed_t *lwall, double walxrepeat, int x1, int x2); void PrepLWall (fixed_t *lwall, double walxrepeat, int x1, int x2); -ptrdiff_t R_NewOpening (ptrdiff_t len); - -void R_CheckDrawSegs (); - void R_RenderSegLoop (); extern float swall[MAXWIDTH];