diff --git a/src/d_main.c b/src/d_main.c index 32528d285..9478fcec2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -46,6 +46,7 @@ #include "i_time.h" #include "i_threads.h" #include "i_video.h" +#include "hu_stuff.h" #include "m_argv.h" #include "m_menu.h" #include "m_misc.h" @@ -327,13 +328,12 @@ static void D_Renderview(void) if (splitscreen == 2) { // V_DrawPatchFill, but for the fourth screen only - patch_t *pat = W_CachePatchName("SRB2BACK", PU_PATCH); - INT32 x, y, pw = SHORT(pat->width) * vid.dup, ph = SHORT(pat->height) * vid.dup; + INT32 x, y, pw = SHORT(srb2back->width) * vid.dup, ph = SHORT(srb2back->height) * vid.dup; for (x = vid.width>>1; x < vid.width; x += pw) { for (y = vid.height>>1; y < vid.height; y += ph) - V_DrawScaledPatch(x, y, V_NOSCALESTART, pat); + V_DrawScaledPatch(x, y, V_NOSCALESTART, srb2back); } } diff --git a/src/f_finale.c b/src/f_finale.c index 6f221ff4d..0d3f6e64d 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -622,7 +622,6 @@ void F_StartCredits(void) timetonext = 2*TICRATE; } - void F_CreditDrawer(void) { UINT16 i; diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 611efdff4..9c715ca48 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -171,13 +171,14 @@ static int comparePolygons(const void *p1, const void *p2) // special case with signedness to prevent overflowing // FIXME: check for prediction slowdowns! - const bool sky1 = poly1->hash & 0x80000000; - const bool sky2 = poly2->hash & 0x80000000; + const int shader1 = poly1->hash & 0x80000000 ? -1 : poly1->shader; + const int shader2 = poly2->hash & 0x80000000 ? -1 : poly2->shader; - if (sky1 != sky2) - return sky1 < sky2 ? 1 : -1; + // skywalls and horizon lines must retain their order for horizon lines to work + if (shader1 == -1 && shader2 == -1) + return poly1 - poly2; - diff = poly1->shader - poly2->shader; + diff = shader1 - shader2; if (diff != 0) return diff; UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons @@ -212,16 +213,16 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; - // special case with signedness to prevent overflowing - // FIXME: check for prediction slowdowns! - const bool sky1 = poly1->hash & 0x80000000; - const bool sky2 = poly2->hash & 0x80000000; + const GLMipmap_t *texture1 = poly1->hash & 0x80000000 ? NULL : poly1->texture; + const GLMipmap_t *texture2 = poly1->hash & 0x80000000 ? NULL : poly2->texture; - if (sky1 != sky2) - return sky1 < sky2 ? 1 : -1; + // skywalls and horizon lines must retain their order for horizon lines to work + if (!texture1 && !texture2) + return poly1 - poly2; + + UINT32 downloaded1 = texture1 ? texture1->downloaded : 0; // there should be a opengl texture name here, usable for comparisons + UINT32 downloaded2 = texture2 ? texture2->downloaded : 0; - UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons - UINT32 downloaded2 = poly2->texture ? poly2->texture->downloaded : 0; diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 3b154f916..79069857c 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -538,7 +538,7 @@ static void loading_status(void) x = BASEVIDWIDTH/2; y = BASEVIDHEIGHT/2; V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect - //V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_PATCH)); // SRB2 background, ehhh too bright. + //V_DrawPatchFill(srb2back); // SRB2 background, ehhh too bright. M_DrawTextBox(x-58, y-8, 13, 1); V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 921223d0f..8dbe5e2aa 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1235,6 +1235,9 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) if (LIKELY(!gl_curline->polyseg)) { + // check if linedef alpha is within range + const boolean linealpha = (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT); + // set alpha for transparent walls switch (gl_linedef->special) { @@ -1249,7 +1252,7 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) case 221: case 253: case 256: - if (gl_linedef->blendmode) + if (gl_linedef->blendmode && linealpha) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); else blendmode = PF_Translucent; @@ -1257,12 +1260,12 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) default: if (gl_linedef->blendmode) { - if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + if (linealpha) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); else blendmode = HWR_GetBlendModeFlag(gl_linedef->blendmode); } - else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + else if (linealpha) blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf); else blendmode = PF_Masked; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 883de209d..814120b91 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -88,6 +88,8 @@ patch_t *ranknum[10] = {}; // rank numbers patch_t *framecounter = NULL; patch_t *frameslash = NULL; // framerate stuff. Used in screen.c +patch_t *srb2back = NULL; + static player_t *plr = NULL; boolean chat_on = false; // entering a chat message? static char w_chat_buf[HU_MAXMSGLEN + 1]; @@ -98,7 +100,7 @@ static char hu_tick; static tic_t hu_emoteanim = 0; emote_autocomplete_t emote_autocomplete = {0}; -static huddrawlist_h luahuddrawlist_scores; +static huddrawlist_h luahuddrawlist_scores = NULL; patch_t *rflagico = NULL; patch_t *bflagico = NULL; @@ -290,6 +292,7 @@ void HU_LoadGraphics(void) return; j = HU_FONTSTART; + for (i = 0; i < HU_FONTSIZE; i++, j++) { // cache the heads-up font for entire game execution @@ -360,21 +363,21 @@ void HU_LoadGraphics(void) cred_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - //cache numbers too! + // cache numbers too! for (i = 0; i < 10; i++) { sprintf(buffer, "STTNUM%d", i); tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "PINGN%d", i); - pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + pingnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "OPPRNK0%d", i); - ranknum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + ranknum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } // minus for negative tallnums tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX); - songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX); + songcreditbg = (patch_t *)W_CachePatchName("K_SONGCR", PU_HUDGFX); // cache ping gfx: for (i = 0; i < 5; i++) @@ -383,12 +386,15 @@ void HU_LoadGraphics(void) pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - pingmeasure[0] = W_CachePatchName("PINGD", PU_HUDGFX); - pingmeasure[1] = W_CachePatchName("PINGMS", PU_HUDGFX); + pingmeasure[0] = (patch_t *)W_CachePatchName("PINGD", PU_HUDGFX); + pingmeasure[1] = (patch_t *)W_CachePatchName("PINGMS", PU_HUDGFX); // fps stuff - framecounter = W_CachePatchName("FRAMER", PU_HUDGFX); - frameslash = W_CachePatchName("FRAMESL", PU_HUDGFX); + framecounter = (patch_t *)W_CachePatchName("FRAMER", PU_HUDGFX); + frameslash = (patch_t *)W_CachePatchName("FRAMESL", PU_HUDGFX); + + // idk where else to put this lul + srb2back = (patch_t *)W_CachePatchName("SRB2BACK", PU_HUDGFX); } // Initialise Heads up @@ -405,8 +411,10 @@ void HU_Init(void) // set shift translation table shiftxform = english_shiftxform; - luahuddrawlist_scores = LUA_HUD_CreateDrawList(); + if (dedicated || rendermode == render_none) + return; + luahuddrawlist_scores = LUA_HUD_CreateDrawList(); HU_LoadGraphics(); } diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 64d369a33..85ff630f5 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -90,6 +90,7 @@ extern patch_t *pinggfx[5]; extern patch_t *ranknum[10]; extern patch_t *framecounter; extern patch_t *frameslash; +extern patch_t *srb2back; extern patch_t *lt_font[LT_FONTSIZE]; extern patch_t *cred_font[CRED_FONTSIZE]; extern patch_t *rflagico; diff --git a/src/m_menu.c b/src/m_menu.c index 4e8ced814..a11effc3e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2349,7 +2349,7 @@ static void M_DrawGenericMenu(void) static void M_DrawGenericBackgroundMenu(void) { - V_DrawPatchFill((patch_t *)W_CachePatchName("SRB2BACK", PU_PATCH)); + V_DrawPatchFill(srb2back); M_DrawGenericMenu(); } @@ -2923,7 +2923,7 @@ static void M_DrawMessageMenu(void) // hack: draw RA background in RA menus if (gamestate == GS_TIMEATTACK) - V_DrawPatchFill((patch_t *)W_CachePatchName("SRB2BACK", PU_PATCH)); + V_DrawPatchFill(srb2back); M_DrawTextBox(currentMenu->x, y - 8, (max+7)>>3, mlines); @@ -4320,7 +4320,7 @@ static void M_DrawReplayHut(void) static UINT16 replayhutmenuy = 0; - V_DrawPatchFill((patch_t *)W_CachePatchName("SRB2BACK", PU_PATCH)); + V_DrawPatchFill(srb2back); if (cv_vhseffect.value) V_DrawVhsEffect(false); @@ -5959,7 +5959,7 @@ void M_DrawTimeAttackMenu(void) //S_ChangeMusicInternal("racent", true); // Eww, but needed for when user hits escape during demo playback - V_DrawPatchFill((patch_t *)W_CachePatchName("SRB2BACK", PU_PATCH)); + V_DrawPatchFill(srb2back); M_DrawMenuTitle(); if (currentMenu == &SP_TimeAttackDef) diff --git a/src/p_setup.c b/src/p_setup.c index cef1f3969..5568a5866 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2709,8 +2709,12 @@ void P_FreeLevelState(void) G_FreeGhosts(); // ghosts are allocated with PU_LEVEL - Patch_FreeTag(PU_PATCH_LOWPRIORITY); - //Patch_FreeTag(PU_PATCH_ROTATED); // we keep those ty! + if (rendermode != render_none) + { + Patch_FreeTag(PU_PATCH_LOWPRIORITY); + //Patch_FreeTag(PU_PATCH_ROTATED); // we keep those ty! + } + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); Y_VoteClear(); diff --git a/src/y_inter.c b/src/y_inter.c index c1bdafd32..8a105bfa3 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -61,8 +61,6 @@ typedef struct static y_data_t data; // graphics -static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK - static INT32 timer; static INT32 intertic; @@ -446,7 +444,7 @@ void Y_IntermissionDrawer(void) || (rendermode == render_opengl && cv_glscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif ) - V_DrawPatchFill(bgtile); // use the neato kart bg for intermission on disabled screen textures + V_DrawPatchFill(srb2back); // use the neato kart bg for intermission on disabled screen textures else { if (rendermode == render_soft) @@ -753,7 +751,7 @@ void Y_StartIntermission(void) } // This should always exist, but just in case... - if(!mapheaderinfo[prevmap]) + if (!mapheaderinfo[prevmap]) P_AllocMapHeader(prevmap); switch (intertype) @@ -782,16 +780,16 @@ void Y_StartIntermission(void) Y_CalculateMatchData(0, Y_CompareRace); break; } - case int_none: default: break; } - bgtile = W_CachePatchName("SRB2BACK", PU_PATCH_LOWPRIORITY); - - LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); - luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); + if (rendermode != render_none) + { + LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); + luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); + } } // ====== @@ -1537,7 +1535,7 @@ void Y_StartVote(void) levelinfo[i].gts = NULL; // set up the pic - if (!dedicated) + if (rendermode != render_none) { lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i][0]+1))); if (lumpnum != LUMPERROR)