From 5cfe9a4c4ee5c3bf5892f0c07c12695733d7aab5 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 11 Nov 2023 18:27:24 +0300 Subject: [PATCH 01/15] Optimize gif recording in opengl a bit --- src/hardware/hw_draw.c | 5 ++++- src/m_anigif.c | 26 +++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8f94abbba..cfb9fae2c 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -1138,10 +1138,13 @@ static inline boolean saveTGA(const char *file_name, void *buffer, UINT8 *HWR_GetScreenshot(void) { - UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf)); + static UINT8 *buf = NULL; + + buf = realloc(buf, vid.width * vid.height * 3); if (!buf) return NULL; + // returns 24bit 888 RGB HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf); return buf; diff --git a/src/m_anigif.c b/src/m_anigif.c index 8071f030d..744651319 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -465,19 +465,23 @@ static size_t gifframe_size = 8192; static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) { UINT8 r, g, b; - size_t src = 0, dest = 0; - size_t size = (vid.width * vid.height * 3); + size_t src, dest; + int x, y; InitColorLUT(); - while (src < size) + for (x = 0; x < vid.width; x += scrbuf_downscaleamt) { - r = (UINT8)linear[src]; - g = (UINT8)linear[src + 1]; - b = (UINT8)linear[src + 2]; - scr[dest] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS]; - src += (3 * scrbuf_downscaleamt); - dest += scrbuf_downscaleamt; + for (y = 0; y < vid.height; y += scrbuf_downscaleamt) + { + dest = y*vid.width + x; + src = dest*3; + + r = (UINT8)linear[src]; + g = (UINT8)linear[src + 1]; + b = (UINT8)linear[src + 2]; + scr[dest] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS]; + } } } #endif @@ -514,7 +518,7 @@ static void GIF_framewrite(void) { UINT8 *linear = HWR_GetScreenshot(); GIF_rgbconvert(linear, movie_screen); - free(linear); + //free(linear); // Allocated 'statically', no need to free now } #endif } @@ -530,7 +534,7 @@ static void GIF_framewrite(void) { UINT8 *linear = HWR_GetScreenshot(); GIF_rgbconvert(linear, screens[0]); - free(linear); + //free(linear); // Allocated 'statically', no need to free now } #endif From 4377a6d7fe0755e5c59c345aa61eca86f360cd1a Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 11 Nov 2023 18:43:37 +0300 Subject: [PATCH 02/15] Remove unnecessary Z_Calloc from HWR_AddPolyObjectSegs Effect is most likely unnoticable but still having less calls to Z_Calloc and Z_Free would be better --- src/hardware/hw_main.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6874539fd..21be5ac04 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3071,9 +3071,9 @@ boolean HWR_CheckBBox(fixed_t *bspcoord) void HWR_AddPolyObjectSegs(void) { size_t i, j; - seg_t *gr_fakeline = Z_Calloc(sizeof(seg_t), PU_STATIC, NULL); - polyvertex_t *pv1 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL); - polyvertex_t *pv2 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL); + seg_t gr_fakeline; + polyvertex_t pv1; + polyvertex_t pv2; // Sort through all the polyobjects for (i = 0; i < numpolys; ++i) @@ -3082,25 +3082,20 @@ void HWR_AddPolyObjectSegs(void) for (j = 0; j < po_ptrs[i]->segCount; ++j) { // Copy the info of a polyobject's seg, then convert it to OpenGL floating point - M_Memcpy(gr_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t)); + M_Memcpy(&gr_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t)); // Now convert the line to float and add it to be rendered - pv1->x = FIXED_TO_FLOAT(gr_fakeline->v1->x); - pv1->y = FIXED_TO_FLOAT(gr_fakeline->v1->y); - pv2->x = FIXED_TO_FLOAT(gr_fakeline->v2->x); - pv2->y = FIXED_TO_FLOAT(gr_fakeline->v2->y); + pv1.x = FIXED_TO_FLOAT(gr_fakeline.v1->x); + pv1.y = FIXED_TO_FLOAT(gr_fakeline.v1->y); + pv2.x = FIXED_TO_FLOAT(gr_fakeline.v2->x); + pv2.y = FIXED_TO_FLOAT(gr_fakeline.v2->y); - gr_fakeline->pv1 = pv1; - gr_fakeline->pv2 = pv2; + gr_fakeline.pv1 = &pv1; + gr_fakeline.pv2 = &pv2; - HWR_AddLine(gr_fakeline); + HWR_AddLine(&gr_fakeline); } } - - // Free temporary data no longer needed - Z_Free(pv2); - Z_Free(pv1); - Z_Free(gr_fakeline); } #ifdef POLYOBJECTS_PLANES From 2b75d0b26bc4213e2eab86b3d085ed656c6a30dd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Nov 2023 18:35:38 +0100 Subject: [PATCH 03/15] replace those with gl error messages instead --- src/hardware/r_opengl/r_opengl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index d558a0834..02e7382c1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1222,7 +1222,7 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boo return; if (number < 1 || number > MAXSHADERS) - I_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS); + GL_MSG_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS); if (fragment) { @@ -1375,7 +1375,7 @@ void InitPalette(int flashnum, boolean skiplut) pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if (!pglTexImage3D) - I_Error("pglTexImage3D is NULL!"); + GL_MSG_Error("pglTexImage3D is NULL!"); pglTexImage3D(GL_TEXTURE_3D, 0, internalFormat, LUT_SIZE, LUT_SIZE, LUT_SIZE, 0, GL_RED, GL_UNSIGNED_BYTE, pal_lookup_tex); free(pal_lookup_tex); } @@ -1597,7 +1597,7 @@ EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) ltcachetail->next = NULL; pglGenTextures(1, <cachetail->id); if (!ltcachetail->id) - I_Error("hwr lighttable cache entry id is zero"); + GL_MSG_Error("hwr lighttable cache entry id is zero"); pglBindTexture(GL_TEXTURE_2D, ltcachetail->id); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); From 3610096c35ff3730d955bd0da20d38d64fa61d54 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Nov 2023 19:05:17 +0100 Subject: [PATCH 04/15] this always annoyed me why was it always offcenter like that? --- src/m_menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index d22d29494..73f7348c3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11608,7 +11608,7 @@ static void M_DrawSetupMultiPlayerMenu(void) patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_CACHE); // draw box around guy - V_DrawFill(mx + 43 - (charw/2), my+65, charw, 84, 239); + V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); // draw player sprite if (setupm_fakecolor) // inverse should never happen @@ -11617,13 +11617,13 @@ static void M_DrawSetupMultiPlayerMenu(void) if (skins[skintodisplay].flags & SF_HIRES) { - V_DrawFixedPatch((mx+43)< Date: Mon, 27 Nov 2023 21:46:18 +0100 Subject: [PATCH 05/15] hopefully fix older hardware crashing even if they dont use palshader also guard the last InitPalette, we do not need to call it if we dont use palshader also if either pglTexImage3D or ltcachetail->id is null, the game wont crash now, instead returns, and turns off the palshader so all should work hopefully --- src/hardware/r_opengl/r_opengl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 02e7382c1..ef306fcf5 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1222,7 +1222,7 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boo return; if (number < 1 || number > MAXSHADERS) - GL_MSG_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS); + I_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS); if (fragment) { @@ -1307,6 +1307,12 @@ void InitPalette(int flashnum, boolean skiplut) { int i, r, g, b; + if (!pglTexImage3D){ + GL_MSG_Error("pglTexImage3D is NULL!"); + CV_Set(&cv_grpaletteshader, "Off"); // turn that thing off if you cant use it + return; + } + //Hudler: 16/10/99: added for OpenGL gamma correction RGBA_t gamma_correction = {0x7F7F7F7F}; @@ -1374,8 +1380,6 @@ void InitPalette(int flashnum, boolean skiplut) pglBindTexture(GL_TEXTURE_3D, palette_tex_num); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - if (!pglTexImage3D) - GL_MSG_Error("pglTexImage3D is NULL!"); pglTexImage3D(GL_TEXTURE_3D, 0, internalFormat, LUT_SIZE, LUT_SIZE, LUT_SIZE, 0, GL_RED, GL_UNSIGNED_BYTE, pal_lookup_tex); free(pal_lookup_tex); } @@ -1584,6 +1588,12 @@ EXPORT void HWRAPI(ClearMipMapCache) (void) EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) { + if (!ltcachetail->id){ + GL_MSG_Error("HWR Lighttable cache entry id is zero"); + CV_Set(&cv_grpaletteshader, "Off"); // turn that thing off if you cant use it + return; + } + LightTableCacheEntry_t *cache_entry = malloc(sizeof(LightTableCacheEntry_t)); if (!ltcachetail) { @@ -1596,8 +1606,6 @@ EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) } ltcachetail->next = NULL; pglGenTextures(1, <cachetail->id); - if (!ltcachetail->id) - GL_MSG_Error("hwr lighttable cache entry id is zero"); pglBindTexture(GL_TEXTURE_2D, ltcachetail->id); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -1734,7 +1742,7 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, pglEnableClientState(GL_VERTEX_ARRAY); // We always use this one pglEnableClientState(GL_TEXTURE_COORD_ARRAY); // And mostly this one, too - if (!gl_palette_initialized) + if ((!gl_palette_initialized) && (HWR_ShouldUsePaletteRendering())) InitPalette(0, false); // just gonna put this here for now } From dc190be6b3771f22992bc68d6c345b048be6d8ce Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 21:58:28 +0100 Subject: [PATCH 06/15] Zzz... AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA --- src/hardware/r_opengl/r_opengl.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ef306fcf5..ba0c5bef0 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1307,12 +1307,6 @@ void InitPalette(int flashnum, boolean skiplut) { int i, r, g, b; - if (!pglTexImage3D){ - GL_MSG_Error("pglTexImage3D is NULL!"); - CV_Set(&cv_grpaletteshader, "Off"); // turn that thing off if you cant use it - return; - } - //Hudler: 16/10/99: added for OpenGL gamma correction RGBA_t gamma_correction = {0x7F7F7F7F}; @@ -1380,6 +1374,13 @@ void InitPalette(int flashnum, boolean skiplut) pglBindTexture(GL_TEXTURE_3D, palette_tex_num); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + if (!pglTexImage3D){ + GL_MSG_Error("pglTexImage3D is NULL!"); + CV_Set(&cv_grpaletteshader, "Off"); // turn that thing off if you cant use it + return; + } + pglTexImage3D(GL_TEXTURE_3D, 0, internalFormat, LUT_SIZE, LUT_SIZE, LUT_SIZE, 0, GL_RED, GL_UNSIGNED_BYTE, pal_lookup_tex); free(pal_lookup_tex); } @@ -1588,12 +1589,6 @@ EXPORT void HWRAPI(ClearMipMapCache) (void) EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) { - if (!ltcachetail->id){ - GL_MSG_Error("HWR Lighttable cache entry id is zero"); - CV_Set(&cv_grpaletteshader, "Off"); // turn that thing off if you cant use it - return; - } - LightTableCacheEntry_t *cache_entry = malloc(sizeof(LightTableCacheEntry_t)); if (!ltcachetail) { @@ -1606,6 +1601,11 @@ EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) } ltcachetail->next = NULL; pglGenTextures(1, <cachetail->id); + if (!ltcachetail->id){ + GL_MSG_Error("HWR Lighttable cache entry id is zero"); + CV_Set(&cv_grpaletteshader, "Off"); // turn that thing off if you cant use it + return; + } pglBindTexture(GL_TEXTURE_2D, ltcachetail->id); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); From 4cb3b5bc0d2c8595416c9cc9d61b39aec49d688a Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 22:28:28 +0100 Subject: [PATCH 07/15] fix hudcolor when returning from time attacking --- src/k_kart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e199fd01c..f3932fbac 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -599,8 +599,8 @@ UINT8 K_GetHudColor(void) if (cv_colorizedhud.value){ if (cv_colorizedhudcolor.value) return cv_colorizedhudcolor.value; } - if (stplyr && P_IsLocalPlayer(stplyr)) return stplyr->skincolor; - return (stplyr ? stplyr->skincolor : cv_playercolor.value); + if (stplyr && P_IsLocalPlayer(stplyr) && gamestate == GS_LEVEL) return stplyr->skincolor; + return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value); } //} @@ -8083,7 +8083,6 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI } } - if (!cv_colorizedhud.value || !clr_hud) V_DrawScaledPatch(TX, TY, splitflags, ((mode == 2) ? kp_lapstickerwide : kp_timestickerwide)); else From 9de9b72940bc2cb63801a91c090ef75531c188cc Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 22:34:02 +0100 Subject: [PATCH 08/15] do the same for lighttable tex --- src/hardware/r_opengl/r_opengl.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ba0c5bef0..b69a3c951 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1600,6 +1600,21 @@ EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) ltcachetail = cache_entry; } ltcachetail->next = NULL; + + GLenum internalFormat; + if (gl_version[0] == '1' || gl_version[0] == '2') + { + // if the OpenGL version is below 3.0, then the GL_R8 format may not be available. + // so use GL_LUMINANCE8 instead to get a single component 8-bit format + // (it is possible to have access to shaders even in some OpenGL 1.x systems, + // so palette rendering can still possibly be achieved there) + internalFormat = GL_LUMINANCE8; + } + else + { + internalFormat = GL_R8; + } + pglGenTextures(1, <cachetail->id); if (!ltcachetail->id){ GL_MSG_Error("HWR Lighttable cache entry id is zero"); @@ -1609,7 +1624,7 @@ EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable) pglBindTexture(GL_TEXTURE_2D, ltcachetail->id); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - pglTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 256, 32, 0, GL_RED, GL_UNSIGNED_BYTE, lighttable); + pglTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 256, 32, 0, GL_RED, GL_UNSIGNED_BYTE, lighttable); // restore previously bound texture if (!gl_batching) From c2ddac2c1eb1365aadd21a160543c6fa1a7947df Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 28 Nov 2023 01:46:28 +0300 Subject: [PATCH 09/15] Allow using localskins for any kind of mobj from lua --- src/hardware/hw_main.c | 2 +- src/lua_mobjlib.c | 41 ++++++++++++++++++++++++++++++++++------- src/r_things.c | 2 +- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2ce496ae1..de4ddc765 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5558,7 +5558,7 @@ void HWR_ProjectSprite(mobj_t *thing) rot = thing->frame&FF_FRAMEMASK; //Fab : 02-08-98: 'skin' override spritedef currently used for skin - if (thing->skin && thing->sprite == SPR_PLAY) + if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY) { sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef; #ifdef ROTSPRITE diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index cfc5c8e5f..06c56645f 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -217,7 +217,7 @@ UNIMPLEMENTED(mobjnum) // For some dumb reason it is valid to set sloperoll, even though it is read // only -int mobj_sloperoll_noop(lua_State *L) { return 0; } +int mobj_sloperoll_noop(lua_State *L) { (void)L; return 0; } // Now other getters/setters with arbitary logic @@ -415,13 +415,40 @@ int mobj_localskin_setter(lua_State *L) { mobj_t *mo = GETMO(); - // TODO - add ability to set localskin to non-player mobjs - // Will probably just need to reimplement SetLocalPlayerSkin as something - // like SetLocalObjectSkin - if (!mo->player) - return luaL_error(L, "mobj.localskin can't be set for non-player mobjs!"); + if (mo->player) + { + SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL); + } + else + { + INT32 i; + char skin[SKINNAMESIZE+1]; // all skin names are limited to this length + strlcpy(skin, luaL_checkstring(L, 2), sizeof skin); + strlwr(skin); // all skin names are lowercase + + // Try localskins + for (i = 0; i < numlocalskins; i++) + { + if (stricmp(localskins[i].name, skin) == 0) + { + mo->localskin = &localskins[i]; + mo->skinlocal = true; + return 0; + } + } + + // Try other skins + for (i = 0; i < numskins; i++) + { + if (fastcmp(skins[i].name, skin)) + { + mo->localskin = &skins[i]; + mo->skinlocal = false; + return 0; + } + } + } - SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL); return 0; } diff --git a/src/r_things.c b/src/r_things.c index d08b57501..6334716ce 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1399,7 +1399,7 @@ static void R_ProjectSprite(mobj_t *thing) rot = thing->frame&FF_FRAMEMASK; //Fab : 02-08-98: 'skin' override spritedef currently used for skin - if (thing->skin && thing->sprite == SPR_PLAY) + if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY) { sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef; #ifdef ROTSPRITE From ea5ac63e0fe10061ff72a766a445bd18af9101e4 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Fri, 1 Dec 2023 09:36:40 +0100 Subject: [PATCH 10/15] a --- src/r_data.c | 2 +- src/st_stuff.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 4010aae0b..4a8ab0a45 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1325,7 +1325,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) extra_colormaps[mapnum].fadeend = (UINT16)fadeend; extra_colormaps[mapnum].fog = fog; - if (rendermode == render_soft || rendermode == render_opengl) + if (rendermode != render_none) { double r, g, b, cbrightness; int p; diff --git a/src/st_stuff.c b/src/st_stuff.c index ac7eb9c41..e444d2184 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -245,7 +245,7 @@ void ST_doPaletteStuff(void) palette = 0; #ifdef HWRENDER - if ((rendermode == render_opengl && !cv_grpaletteshader.value) || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering() && !cv_grflashpal.value)) + if ((rendermode == render_opengl && !HWR_ShouldUsePaletteRendering()) || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering() && !cv_grflashpal.value)) palette = 0; // No flashpals here in OpenGL #endif From ccb2c4ef18fd87f257d05e84b64ccd6e84a0a2d6 Mon Sep 17 00:00:00 2001 From: hayaunderscore Date: Fri, 1 Dec 2023 16:34:40 +0800 Subject: [PATCH 11/15] Fix horizon lines not rendering on levels with portals --- src/hardware/hw_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 842a765b7..9846c2b1f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6251,8 +6251,15 @@ void RecursivePortalRendering(portal_t *rootportal, const float fpov, player_t * if (!rootportal && portallist.base && !skybox)// if portals have been drawn in the main view, then render skywalls differently gr_collect_skywalls = true; + // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. + // This fixes specific effects not working, such as horizon lines. + int oldportal_state = gr_portal; + + gr_portal = GRPORTAL_OFF; // TURN IT OFF // Recursively "render" the BSP tree. HWR_RenderBSPNode((INT32)numnodes-1); + // woo we back + gr_portal = oldportal_state; PS_STOP_TIMING(ps_bsptime); From 34933fdf82fd1237d0ede679ab56b7670abb311a Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Fri, 1 Dec 2023 15:25:47 +0100 Subject: [PATCH 12/15] optimise span drawers a little --- src/r_draw8.c | 73 ++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 7f1c0763c..c80ff2cbc 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -542,16 +542,19 @@ void R_DrawTranslatedColumn_8(void) */ void R_DrawSpan_8 (void) { - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; UINT8 *source; UINT8 *colormap; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - size_t count; + size_t count = (ds_x2 - ds_x1 + 1); + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the @@ -560,13 +563,12 @@ void R_DrawSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; if (dest+8 > deststop) return; @@ -576,35 +578,35 @@ void R_DrawSpan_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[0] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[1] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[1] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[2] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[2] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[3] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[3] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[4] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[4] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[5] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[5] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[6] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[6] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[7] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[7] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; @@ -613,7 +615,7 @@ void R_DrawSpan_8 (void) } while (count-- && dest <= deststop) { - *dest++ = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + *dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; } @@ -1281,15 +1283,20 @@ void R_DrawTranslucentSplat_8 (void) */ void R_DrawTranslucentSpan_8 (void) { - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; UINT8 *source; UINT8 *colormap; UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - size_t count; + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the @@ -1298,57 +1305,57 @@ void R_DrawTranslucentSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; while (count >= 8) { // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[0]); + dest[0] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[0]); xposition += xstep; yposition += ystep; - dest[1] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[1]); + dest[1] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[1]); xposition += xstep; yposition += ystep; - dest[2] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[2]); + dest[2] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[2]); xposition += xstep; yposition += ystep; - dest[3] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[3]); + dest[3] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[3]); xposition += xstep; yposition += ystep; - dest[4] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[4]); + dest[4] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[4]); xposition += xstep; yposition += ystep; - dest[5] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[5]); + dest[5] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[5]); xposition += xstep; yposition += ystep; - dest[6] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[6]); + dest[6] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[6]); xposition += xstep; yposition += ystep; - dest[7] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[7]); + dest[7] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[7]); xposition += xstep; yposition += ystep; dest += 8; count -= 8; } - while (count--) + while (count-- && dest <= deststop) { - *dest = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + *dest); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest); dest++; xposition += xstep; yposition += ystep; From 39b70b36861d85f02314dc0701e223e751eb1daa Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Fri, 1 Dec 2023 16:13:45 +0100 Subject: [PATCH 13/15] add drawstretchypatch lua support --- src/lua_hudlib.c | 37 +++++++++++++++++++++++++++++++++++++ src/lua_hudlib_drawlist.c | 27 +++++++++++++++++++++++++++ src/lua_hudlib_drawlist.h | 10 ++++++++++ 3 files changed, 74 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 340bc1352..04bbaa928 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -596,6 +596,42 @@ static int libd_drawOnMinimap(lua_State *L) return 0; } +static int libd_drawStretched(lua_State *L) +{ + fixed_t x, y, hscale, vscale; + INT32 flags; + patch_t *patch; + UINT8 *colormap = NULL; + huddrawlist_h list; + + HUDONLY + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + hscale = luaL_checkinteger(L, 3); + if (hscale < 0) + return luaL_error(L, "negative horizontal scale"); + vscale = luaL_checkinteger(L, 4); + if (vscale < 0) + return luaL_error(L, "negative vertical scale"); + patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH)); + flags = luaL_optinteger(L, 6, 0); + if (!lua_isnoneornil(L, 7)) + colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP)); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); + list = (huddrawlist_h) lua_touserdata(L, -1); + lua_pop(L, 1); + + if (LUA_HUD_IsDrawListValid(list)) + LUA_HUD_AddDrawStretched(list, x, y, hscale, vscale, patch, flags, colormap); + else + V_DrawStretchyFixedPatch(x, y, hscale, vscale, flags, patch, colormap); + return 0; +} + + static int libd_drawNum(lua_State *L) { INT32 x, y, flags, num; @@ -913,6 +949,7 @@ static luaL_Reg lib_draw[] = { {"cachePatch", libd_cachePatch}, {"draw", libd_draw}, {"drawScaled", libd_drawScaled}, + {"drawStretched", libd_drawStretched}, {"drawNum", libd_drawNum}, {"drawPaddedNum", libd_drawPaddedNum}, {"drawPingNum", libd_drawPingNum}, diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index eedbff910..c543c15d8 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -20,6 +20,7 @@ enum drawitem_e { DI_Draw = 0, DI_DrawScaled, + DI_DrawStretched, DI_DrawNum, DI_DrawPaddedNum, DI_DrawPingNum, @@ -216,6 +217,29 @@ void LUA_HUD_AddDrawScaled( item->colormap = colormap; } +void LUA_HUD_AddDrawStretched( + huddrawlist_h list, + fixed_t x, + fixed_t y, + fixed_t hscale, + fixed_t vscale, + patch_t *patch, + INT32 flags, + UINT8 *colormap +) +{ + size_t i = AllocateDrawItem(list); + drawitem_t *item = &list->items[i]; + item->type = DI_DrawStretched; + item->x = x; + item->y = y; + item->hscale = hscale; + item->vscale = vscale; + item->patch = patch; + item->flags = flags; + item->colormap = colormap; +} + void LUA_HUD_AddDrawNum( huddrawlist_h list, INT32 x, @@ -377,6 +401,9 @@ void LUA_HUD_DrawList(huddrawlist_h list) case DI_DrawScaled: V_DrawFixedPatch(item->x, item->y, item->scale, item->flags, item->patch, item->colormap); break; + case DI_DrawStretched: + V_DrawStretchyFixedPatch(item->x, item->y, item->hscale, item->vscale, item->flags, item->patch, item->colormap); + break; case DI_DrawNum: V_DrawTallNum(item->x, item->y, item->flags, item->num); break; diff --git a/src/lua_hudlib_drawlist.h b/src/lua_hudlib_drawlist.h index 992578778..4354b6f95 100644 --- a/src/lua_hudlib_drawlist.h +++ b/src/lua_hudlib_drawlist.h @@ -42,6 +42,16 @@ void LUA_HUD_AddDraw( INT32 flags, UINT8 *colormap ); +void LUA_HUD_AddDrawStretched( + huddrawlist_h list, + fixed_t x, + fixed_t y, + fixed_t hscale, + fixed_t vscale, + patch_t *patch, + INT32 flags, + UINT8 *colormap +); void LUA_HUD_AddDrawScaled( huddrawlist_h list, fixed_t x, From 7d5c63d8eee8d8adafba4b89b6c6f1e2e22ce343 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Fri, 1 Dec 2023 16:39:47 +0100 Subject: [PATCH 14/15] assign bool instead of if else thing --- src/p_setup.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 3167d8462..ee87f8657 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3490,11 +3490,8 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) if (wadfiles[wadnum]->important) partadd_important = true; - - if (local) - wadfiles[wadnum]->localfile = true; - else - wadfiles[wadnum]->localfile = false; + + wadfiles[wadnum]->localfile = local; // // search for sound replacements From 2797fa9a055a9a2330c03b1113f26ec8d29e0ecb Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Fri, 1 Dec 2023 19:14:15 +0100 Subject: [PATCH 15/15] add global toggle for bird music things + move stuff to s_sound well reason a global toggle is, cause stuff always does stuff even when "disabled" and i cant be assed trying to unmangle this mess like this we can just turn off everything and game behaves like vanilla default is off so everythings disabled if someone wants to do a better approach go ahead --- src/d_netcmd.c | 11 ----------- src/g_game.c | 10 +--------- src/g_game.h | 11 ----------- src/k_kart.c | 4 ++-- src/m_menu.c | 35 ++++++++++++++++++++++++++++++++--- src/p_inter.c | 2 +- src/p_user.c | 28 +++++++++++++++++++--------- src/s_sound.c | 32 ++++++++++++++++++++++++++++++-- src/s_sound.h | 14 ++++++++++++++ src/sdl/mixer_sound.c | 2 +- 10 files changed, 100 insertions(+), 49 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 67b875617..234009041 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1106,17 +1106,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_ps_thinkframe_page); CV_RegisterVar(&cv_ps_samplesize); CV_RegisterVar(&cv_ps_descriptor); - - CV_RegisterVar(&cv_invincmusicfade); - CV_RegisterVar(&cv_growmusicfade); - - CV_RegisterVar(&cv_respawnfademusicout); - CV_RegisterVar(&cv_respawnfademusicback); - - CV_RegisterVar(&cv_resetspecialmusic); - - CV_RegisterVar(&cv_resume); - CV_RegisterVar(&cv_fading); //Value used to store last server player has joined CV_RegisterVar(&cv_lastserver); diff --git a/src/g_game.c b/src/g_game.c index 6f7bce1cd..55438cc83 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -519,14 +519,6 @@ consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldis consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_resetspecialmusic = {"resetspecialmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_resume = {"resume", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fading = {"fading", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; - #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" #endif @@ -2832,7 +2824,7 @@ void G_PlayerReborn(INT32 player) /* I'm putting this here because lol */ - fade = ( cv_fading.value && P_IsLocalPlayer(p) ); + fade = (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(p)); if (fade) { diff --git a/src/g_game.h b/src/g_game.h index 8cebc088a..2f69070af 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -160,19 +160,8 @@ extern consvar_t cv_sliptideroll; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; -extern consvar_t cv_invincmusicfade; -extern consvar_t cv_growmusicfade; - -extern consvar_t cv_respawnfademusicout; -extern consvar_t cv_respawnfademusicback; - -extern consvar_t cv_resetspecialmusic; - extern consvar_t cv_cechotoggle; -extern consvar_t cv_resume; -extern consvar_t cv_fading; - #ifndef NONET extern consvar_t cv_chatlogsize; #endif diff --git a/src/k_kart.c b/src/k_kart.c index f3932fbac..3c843f88d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6028,7 +6028,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetScale(overlay, player->mo->scale); } player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds - if (P_IsLocalPlayer(player) && cv_supermusic.value) + if (P_IsLocalPlayer(player) && cv_supermusic.value && cv_birdmusic.value) S_ChangeMusicSpecial("kinvnc"); else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc)); @@ -6233,7 +6233,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (cv_kartdebugshrink.value && !modeattacking && !player->bot) player->mo->destscale = (6*player->mo->destscale)/8; player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds - if (P_IsLocalPlayer(player) && cv_growmusic.value) + if (P_IsLocalPlayer(player) && cv_growmusic.value && cv_birdmusic.value ) S_ChangeMusicSpecial("kgrow"); else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); diff --git a/src/m_menu.c b/src/m_menu.c index 73f7348c3..9c29d5328 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2181,10 +2181,11 @@ static menuitem_t OP_BirdMenu[] = //{IT_STRING | IT_CVAR, NULL, "Encore Choices", &cv_encorevotes, 90}, {IT_HEADER, NULL, "Music", NULL, 70}, - {IT_STRING | IT_CVAR, NULL, "Resume Level Music", &cv_resume, 80}, - {IT_STRING | IT_CVAR, NULL, "Restart Special Music", &cv_resetspecialmusic, 90}, + {IT_STRING | IT_CVAR, NULL, "Music Features", &cv_birdmusic, 80}, + {IT_STRING | IT_CVAR, NULL, "Resume Level Music", &cv_resume, 95}, + {IT_STRING | IT_CVAR, NULL, "Restart Special Music", &cv_resetspecialmusic, 105}, - {IT_STRING | IT_SUBMENU, NULL, "Advanced Music Options...", &OP_AdvancedBirdDef, 120}, + {IT_STRING | IT_SUBMENU, NULL, "Advanced Music Options...", &OP_AdvancedBirdDef, 130}, }; static const char* OP_BirdTooltips[] = @@ -2198,12 +2199,27 @@ static const char* OP_BirdTooltips[] = //"Only show one battle choice in map vote", //"Amount of encore choices in map vote.", NULL, + "Global toggle for all bird music features.", "Resume level music from last position after music change.", "Restart Special music if item is used again.", "Options for advanced music settings.", }; +enum +{ + headercrzy, + tiltmenu, + headerhud, + viewpointext, + freeplaytext, + headermusic, + birdmusic, + lvlresum, + spclresum, + advmusic, +}; + static menuitem_t OP_ForkedBirdMenu[] = { {IT_HEADER, NULL, "Local Skins", NULL, 0}, @@ -3137,6 +3153,19 @@ void Bird_menu_Onchange(void) OP_AdvancedBirdMenu[fadegrow].status = status; OP_AdvancedBirdMenu[respawnfadeout].status = status; OP_AdvancedBirdMenu[respawnfadein].status = status; + + if (cv_birdmusic.value) + { + OP_BirdMenu[lvlresum].status = IT_STRING | IT_CVAR; + OP_BirdMenu[spclresum].status = IT_STRING | IT_CVAR; + OP_BirdMenu[advmusic].status = IT_STRING | IT_SUBMENU; + } + else + { + OP_BirdMenu[lvlresum].status = IT_GRAYEDOUT; + OP_BirdMenu[spclresum].status = IT_GRAYEDOUT; + OP_BirdMenu[advmusic].status = IT_GRAYEDOUT; + } } //menu code is nice diff --git a/src/p_inter.c b/src/p_inter.c index 07f4860e9..9e333ebe2 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2348,7 +2348,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (cv_fading.value && P_IsLocalPlayer(target->player)) + if (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(target->player)) { if (netgame || multiplayer) ms = cv_respawntime.value * 1000; diff --git a/src/p_user.c b/src/p_user.c index 517e6a07f..fab59d28b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1281,13 +1281,17 @@ void P_RestoreMusic(player_t *player) if (wantedmus == 2 && cv_growmusic.value) { S_ChangeMusicInternal("kgrow", true); - S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); + + if (cv_birdmusic.value) + S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1 && cv_supermusic.value) { S_ChangeMusicInternal("kinvnc", true); - S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); + + if (cv_birdmusic.value) + S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else { @@ -1297,14 +1301,20 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - if (mapmusresume && cv_resume.value) - position = mapmusresume; - else - position = mapmusposition; + if (cv_birdmusic.value) + { + if (mapmusresume && cv_resume.value) + position = mapmusresume; + else + position = mapmusposition; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, - S_GetRestoreMusicFadeIn()); - S_ClearRestoreMusicFadeInCvar(); + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, + S_GetRestoreMusicFadeIn()); + S_ClearRestoreMusicFadeInCvar(); + } + else + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + mapmusresume = 0; } } diff --git a/src/s_sound.c b/src/s_sound.c index bbbd7a6d3..6ecd1dfd5 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -27,6 +27,7 @@ #include "r_sky.h" // skyflatnum #include "p_local.h" // camera info #include "m_misc.h" // for tunes command +#include "m_menu.h" // bird music stuff #ifdef HAVE_BLUA #include "lua_hook.h" // MusicChange hook @@ -98,6 +99,7 @@ consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_ consvar_t cv_pausemusic = {"playmusicifpaused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +//bird music stuff static CV_PossibleValue_t music_resync_threshold_cons_t[] = { {0, "MIN"}, {1000, "MAX"}, @@ -108,6 +110,16 @@ consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetspecialmusic = {"resetspecialmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resume = {"resume", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fading = {"fading", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_birdmusic = {"birdmusicstuff", "No", CV_SAVE|CV_CALL, CV_YesNo, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; + + #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -272,12 +284,25 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_gamemidimusic); #endif + //bird music stuff CV_RegisterVar(&cv_playmusicifunfocused); CV_RegisterVar(&cv_playsoundifunfocused); CV_RegisterVar(&cv_pausemusic); CV_RegisterVar(&cv_music_resync_threshold); CV_RegisterVar(&cv_music_resync_powerups_only); + + CV_RegisterVar(&cv_invincmusicfade); + CV_RegisterVar(&cv_growmusicfade); + + CV_RegisterVar(&cv_respawnfademusicout); + CV_RegisterVar(&cv_respawnfademusicback); + + CV_RegisterVar(&cv_resetspecialmusic); + + CV_RegisterVar(&cv_resume); + CV_RegisterVar(&cv_fading); + CV_RegisterVar(&cv_birdmusic); COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -1702,7 +1727,8 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) if (S_MusicDisabled()) return false; - I_UpdateSongLagConditions(); + if (cv_birdmusic.value) + I_UpdateSongLagConditions(); if ((!fadeinms && !I_PlaySong(looping)) || (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) @@ -1826,8 +1852,10 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - if (strcasecmp(music_name, mapmusname) == 0) + if ((cv_birdmusic.value) && (strcasecmp(music_name, mapmusname) == 0)) mapmusresume = I_GetSongPosition(); + else + mapmusresume = 0; if (I_SongPaused()) I_ResumeSong(); diff --git a/src/s_sound.h b/src/s_sound.h index 19ce89037..29bac405c 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -53,9 +53,23 @@ extern consvar_t cv_amigatype; #endif #endif +//bird music stuff extern consvar_t cv_music_resync_threshold; extern consvar_t cv_music_resync_powerups_only; +extern consvar_t cv_invincmusicfade; +extern consvar_t cv_growmusicfade; + +extern consvar_t cv_respawnfademusicout; +extern consvar_t cv_respawnfademusicback; + +extern consvar_t cv_resetspecialmusic; + +extern consvar_t cv_resume; +extern consvar_t cv_fading; +extern consvar_t cv_birdmusic; + + extern CV_PossibleValue_t soundvolume_cons_t[]; typedef enum diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ce9a8b12f..b34ccb18a 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -624,7 +624,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) return; music_bytes += len; - if (gamestate == GS_LEVEL) + if ((gamestate == GS_LEVEL) && (cv_birdmusic.value)) Countstutter(len); }