diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index cf7878184..a8ed71008 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -46,10 +46,23 @@ enum DrawSpanType DS_RIPPLE = 0x0008, }; +template +static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col) +{ + if constexpr (Type & DrawSpanType::DS_COLORMAP) + { + return ds->translation[col]; + } + else + { + return col; + } +} + template static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col) { - col = colormap[col]; + col = colormap[R_GetSpanTranslated(ds, col)]; if constexpr (Type & DrawSpanType::DS_TRANSMAP) { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 336217cd0..40a58f165 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -629,13 +629,12 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw if (x-1 >= vid.width) x = vid.width; #ifdef HAVE_THREADS - drawspandata_t ds_copy = *ds; - // We want to draw N spans per subtask to ensure the work is // coarse enough to not be too slow due to task scheduling overhead. // To safely do this, we need to copy part of spanstart to a local. // This is essentially loop unrolling across threads. constexpr const int kSpanTaskGranularity = 8; + drawspandata_t ds_copy = *ds; while (t1 < t2 && t1 <= b1) { INT32 spanstartcopy[kSpanTaskGranularity] = {0}; @@ -1020,6 +1019,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle size_t size; INT32 spanfunctype = BASEDRAWFUNC; ffloor_t *rover; + levelflat_t *levelflat; void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane; if (pl->minx > pl->maxx) @@ -1177,8 +1177,15 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle ds->currentplane = pl; - ds->source = (UINT8 *)W_CacheLumpNum(levelflats[pl->picnum].lumpnum, PU_STATIC); // Stay here until Z_ChangeTag - size = W_LumpLength(levelflats[pl->picnum].lumpnum); + levelflat = &levelflats[pl->picnum]; + + // Get the texture + ds->source = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_STATIC); // Stay here until Z_ChangeTag + + if (ds->source == NULL) + return; + + size = W_LumpLength(levelflat->lumpnum); switch (size) {