From 6a80bf2629490ca7c17477687678ac4caa29894a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 14 Jan 2020 23:29:56 -0600 Subject: [PATCH 01/40] wip viewroll stuff --- src/d_main.c | 6 ++ src/d_player.h | 2 + src/lua_playerlib.c | 4 ++ src/p_user.c | 2 + src/r_main.c | 141 +++++++++++++++++++++++++++++++++++++++++++- src/r_main.h | 3 + 6 files changed, 157 insertions(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 8a7c446bb..763814a5a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -266,6 +266,9 @@ static void D_Display(void) #endif } + if (rendermode == render_soft && !splitscreen) + R_CheckViewMorph(); + // change the view size if needed if (setsizeneeded || setrenderstillneeded) { @@ -446,6 +449,9 @@ static void D_Display(void) // Image postprocessing effect if (rendermode == render_soft) { + if (!splitscreen) + R_ApplyViewMorph(); + if (postimgtype) V_DoPostProcessor(0, postimgtype, postimgparam); if (postimgtype2) diff --git a/src/d_player.h b/src/d_player.h index 62f38193f..6a1750113 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -324,6 +324,8 @@ typedef struct player_s // bounded/scaled total momentum. fixed_t bob; + angle_t viewrollangle; + // Mouse aiming, where the guy is looking at! // It is updated with cmd->aiming. angle_t aiming; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index c501fbbb2..8b9397663 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -120,6 +120,8 @@ static int player_get(lua_State *L) lua_pushfixed(L, plr->deltaviewheight); else if (fastcmp(field,"bob")) lua_pushfixed(L, plr->bob); + else if (fastcmp(field,"viewrollangle")) + lua_pushangle(L, plr->viewrollangle); else if (fastcmp(field,"aiming")) lua_pushangle(L, plr->aiming); else if (fastcmp(field,"drawangle")) @@ -415,6 +417,8 @@ static int player_set(lua_State *L) plr->deltaviewheight = luaL_checkfixed(L, 3); else if (fastcmp(field,"bob")) plr->bob = luaL_checkfixed(L, 3); + else if (fastcmp(field,"viewrollangle")) + plr->viewrollangle = luaL_checkangle(L, 3); else if (fastcmp(field,"aiming")) { plr->aiming = luaL_checkangle(L, 3); if (plr == &players[consoleplayer]) diff --git a/src/p_user.c b/src/p_user.c index 0c4d25554..5d7383c4b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7432,6 +7432,8 @@ static void P_NiGHTSMovement(player_t *player) else // AngleFixed(R_PointToAngle2()) results in slight inaccuracy! Don't use it unless movement is on both axises. newangle = (INT16)FixedInt(AngleFixed(R_PointToAngle2(0,0, cmd->sidemove*FRACUNIT, cmd->forwardmove*FRACUNIT))); + newangle -= player->viewrollangle / ANG1; + if (newangle < 0 && moved) newangle = (INT16)(360+newangle); } diff --git a/src/r_main.c b/src/r_main.c index 3c6aaf6a6..fbb3c7047 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -551,6 +551,145 @@ static inline void R_InitLightTables(void) } } +static struct { + angle_t rollangle; // pre-shifted by fineshift + fixed_t fisheye; + + fixed_t zoomneeded; + INT32 *scrmap; + size_t scrmapsize; + boolean use; +} viewmorph = {0, 0, FRACUNIT, NULL, 0, false}; + +void R_CheckViewMorph(void) +{ + float zoomfactor, rollcos, rollsin; + float x1, y1, x2, y2; + fixed_t temp; + size_t end, vx, vy, pos, usedpos; + INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; + + angle_t rollangle = players[displayplayer].viewrollangle; + //fixed_t fisheye = players[displayplayer].viewfisheye; + + // temp values + //angle_t rollangle = leveltime << (ANGLETOFINESHIFT); + fixed_t fisheye = 0; + + rollangle >>= ANGLETOFINESHIFT; + rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. + + fisheye &= ~0xFF; // Same limiter logic for fisheye + + if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye) + return; // No change + + viewmorph.rollangle = rollangle; + viewmorph.fisheye = fisheye; + + if (viewmorph.rollangle == 0 && viewmorph.fisheye == 0) + { + viewmorph.use = false; + if (viewmorph.zoomneeded != FRACUNIT) + R_SetViewSize(); + viewmorph.zoomneeded = FRACUNIT; + + return; + } + + if (viewmorph.scrmapsize != vid.width*vid.height) + { + if (viewmorph.scrmap) + free(viewmorph.scrmap); + viewmorph.scrmap = malloc(vid.width*vid.height * sizeof(INT32)); + viewmorph.scrmapsize = vid.width*vid.height; + } + + temp = FINECOSINE(rollangle); + rollcos = FIXED_TO_FLOAT(temp); + temp = FINESINE(rollangle); + rollsin = FIXED_TO_FLOAT(temp); + + // Calculate maximum zoom needed + x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; + y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; + + temp = max(x1, y1)*FRACUNIT; + if (temp < FRACUNIT) + temp = FRACUNIT; + else + temp |= 0xFFF; // Limit how many times the viewport needs to be recalculated + + //CONS_Printf("Setting zoom to %f\n", FIXED_TO_FLOAT(temp)); + + if (temp != viewmorph.zoomneeded) + { + viewmorph.zoomneeded = temp; + R_SetViewSize(); + } + + zoomfactor = FIXED_TO_FLOAT(viewmorph.zoomneeded); + + end = vid.width * vid.height - 1; + + pos = 0; + + // Pre-multiply rollcos and rollsin to use for positional stuff + rollcos /= zoomfactor; + rollsin /= zoomfactor; + + x1 = -(halfwidth * rollcos - halfheight * rollsin); + y1 = -(halfheight * rollcos + halfwidth * rollsin); + + //CONS_Printf("Top left corner is %f %f\n", x1, y1); + + for (vy = 0; vy < halfheight; vy++) + { + x2 = x1; + y2 = y1; + x1 -= rollsin; + y1 += rollcos; + + for (vx = 0; vx < vid.width; vx++) + { + usedx = halfwidth+x2; + usedy = halfheight+y2; + + if (usedx < 0) usedx = 0; + else if (usedx >= vid.width) usedx = vid.width-1; + if (usedy < 0) usedy = 0; + else if (usedy >= vid.height) usedy = vid.height-1; + + usedpos = usedx + usedy*vid.width; + + viewmorph.scrmap[pos] = usedpos; + viewmorph.scrmap[end-pos] = end-usedpos; + + x2 += rollcos; + y2 += rollsin; + pos++; + } + } + + viewmorph.use = true; +} + +void R_ApplyViewMorph(void) +{ + UINT8 *tmpscr = screens[4]; + UINT8 *srcscr = screens[0]; + INT32 p, end = vid.width * vid.height; + + if (!viewmorph.use) + return; + + for (p = 0; p < end; p++) + tmpscr[p] = srcscr[viewmorph.scrmap[p]]; + + VID_BlitLinearScreen(tmpscr, screens[0], + vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); +} + // // R_SetViewSize @@ -599,7 +738,7 @@ void R_ExecuteSetViewSize(void) centeryfrac = centery<> ANGLETOFINESHIFT); + fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded); if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view fovtan = 17*fovtan/10; diff --git a/src/r_main.h b/src/r_main.h index 998bb50ef..92876ce25 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -95,6 +95,9 @@ void R_InitHardwareMode(void); #endif void R_ReloadHUDGraphics(void); +void R_CheckViewMorph(void); +void R_ApplyViewMorph(void); + // just sets setsizeneeded true extern boolean setsizeneeded; void R_SetViewSize(void); From a9bceb40c2950e4ea4581cb1b47bebcaf086dba5 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 14 Jan 2020 23:30:19 -0600 Subject: [PATCH 02/40] LMAO fisheye --- src/r_main.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index fbb3c7047..6efc7d99b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -564,7 +564,7 @@ static struct { void R_CheckViewMorph(void) { float zoomfactor, rollcos, rollsin; - float x1, y1, x2, y2; + float x1, y1, x2, y2, fisheyef; fixed_t temp; size_t end, vx, vy, pos, usedpos; INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; @@ -574,14 +574,14 @@ void R_CheckViewMorph(void) // temp values //angle_t rollangle = leveltime << (ANGLETOFINESHIFT); - fixed_t fisheye = 0; + fixed_t fisheye = FRACUNIT; rollangle >>= ANGLETOFINESHIFT; rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. fisheye &= ~0xFF; // Same limiter logic for fisheye - if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye) + if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye && viewmorph.scrmapsize == vid.width*vid.height) return; // No change viewmorph.rollangle = rollangle; @@ -614,6 +614,13 @@ void R_CheckViewMorph(void) x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; + if (fisheye) + { + float dist = powf(2, (fisheyef = FIXED_TO_FLOAT(fisheye))/2); + x1 *= dist; + y1 *= dist; + } + temp = max(x1, y1)*FRACUNIT; if (temp < FRACUNIT) temp = FRACUNIT; @@ -652,8 +659,20 @@ void R_CheckViewMorph(void) for (vx = 0; vx < vid.width; vx++) { - usedx = halfwidth+x2; - usedy = halfheight+y2; + if (fisheye) + { + float dist = sqrtf(x2*x2 + y2*y2) * zoomfactor / sqrtf(halfwidth*halfwidth + halfheight*halfheight); + dist += (1 - sqrtf(1 - dist*dist)) / dist; + dist = powf(dist, fisheyef); + usedx = halfwidth+x2*dist; + usedy = halfheight+y2*dist; + + } + else + { + usedx = halfwidth+x2; + usedy = halfheight+y2; + } if (usedx < 0) usedx = 0; else if (usedx >= vid.width) usedx = vid.width-1; From a3844ae26ab1ae97a90b562ae8a0d181d2b78a62 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 14 Jan 2020 23:30:39 -0600 Subject: [PATCH 03/40] Revert "LMAO fisheye" This reverts commit a9bceb40c2950e4ea4581cb1b47bebcaf086dba5. --- src/r_main.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 6efc7d99b..fbb3c7047 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -564,7 +564,7 @@ static struct { void R_CheckViewMorph(void) { float zoomfactor, rollcos, rollsin; - float x1, y1, x2, y2, fisheyef; + float x1, y1, x2, y2; fixed_t temp; size_t end, vx, vy, pos, usedpos; INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; @@ -574,14 +574,14 @@ void R_CheckViewMorph(void) // temp values //angle_t rollangle = leveltime << (ANGLETOFINESHIFT); - fixed_t fisheye = FRACUNIT; + fixed_t fisheye = 0; rollangle >>= ANGLETOFINESHIFT; rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. fisheye &= ~0xFF; // Same limiter logic for fisheye - if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye && viewmorph.scrmapsize == vid.width*vid.height) + if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye) return; // No change viewmorph.rollangle = rollangle; @@ -614,13 +614,6 @@ void R_CheckViewMorph(void) x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; - if (fisheye) - { - float dist = powf(2, (fisheyef = FIXED_TO_FLOAT(fisheye))/2); - x1 *= dist; - y1 *= dist; - } - temp = max(x1, y1)*FRACUNIT; if (temp < FRACUNIT) temp = FRACUNIT; @@ -659,20 +652,8 @@ void R_CheckViewMorph(void) for (vx = 0; vx < vid.width; vx++) { - if (fisheye) - { - float dist = sqrtf(x2*x2 + y2*y2) * zoomfactor / sqrtf(halfwidth*halfwidth + halfheight*halfheight); - dist += (1 - sqrtf(1 - dist*dist)) / dist; - dist = powf(dist, fisheyef); - usedx = halfwidth+x2*dist; - usedy = halfheight+y2*dist; - - } - else - { - usedx = halfwidth+x2; - usedy = halfheight+y2; - } + usedx = halfwidth+x2; + usedy = halfheight+y2; if (usedx < 0) usedx = 0; else if (usedx >= vid.width) usedx = vid.width-1; From 88b89fc46ef3462504a2ee3c9d6607064bc050fc Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 14 Jan 2020 23:44:21 -0600 Subject: [PATCH 04/40] Clean up fisheye and fix crashes --- src/r_main.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index fbb3c7047..628ba078f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -553,13 +553,12 @@ static inline void R_InitLightTables(void) static struct { angle_t rollangle; // pre-shifted by fineshift - fixed_t fisheye; fixed_t zoomneeded; INT32 *scrmap; size_t scrmapsize; boolean use; -} viewmorph = {0, 0, FRACUNIT, NULL, 0, false}; +} viewmorph = {0, FRACUNIT, NULL, 0, false}; void R_CheckViewMorph(void) { @@ -570,24 +569,16 @@ void R_CheckViewMorph(void) INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; angle_t rollangle = players[displayplayer].viewrollangle; - //fixed_t fisheye = players[displayplayer].viewfisheye; - - // temp values - //angle_t rollangle = leveltime << (ANGLETOFINESHIFT); - fixed_t fisheye = 0; rollangle >>= ANGLETOFINESHIFT; rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. - fisheye &= ~0xFF; // Same limiter logic for fisheye - - if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye) + if (rollangle == viewmorph.rollangle && viewmorph.scrmapsize == vid.width*vid.height) return; // No change viewmorph.rollangle = rollangle; - viewmorph.fisheye = fisheye; - if (viewmorph.rollangle == 0 && viewmorph.fisheye == 0) + if (viewmorph.rollangle == 0) { viewmorph.use = false; if (viewmorph.zoomneeded != FRACUNIT) @@ -655,11 +646,6 @@ void R_CheckViewMorph(void) usedx = halfwidth+x2; usedy = halfheight+y2; - if (usedx < 0) usedx = 0; - else if (usedx >= vid.width) usedx = vid.width-1; - if (usedy < 0) usedy = 0; - else if (usedy >= vid.height) usedy = vid.height-1; - usedpos = usedx + usedy*vid.width; viewmorph.scrmap[pos] = usedpos; From 459602f4b2a702b196d8ff54474c9d7fe71fc42d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 18:32:13 -0600 Subject: [PATCH 05/40] Un/archive viewrollangle in netsaves --- src/p_saveg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 2b6a474bf..e0b6d9579 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -116,6 +116,7 @@ static void P_NetArchivePlayers(void) WRITEANGLE(save_p, players[i].aiming); WRITEANGLE(save_p, players[i].drawangle); + WRITEANGLE(save_p, players[i].viewrollangle); WRITEANGLE(save_p, players[i].awayviewaiming); WRITEINT32(save_p, players[i].awayviewtics); WRITEINT16(save_p, players[i].rings); @@ -325,6 +326,7 @@ static void P_NetUnArchivePlayers(void) players[i].aiming = READANGLE(save_p); players[i].drawangle = READANGLE(save_p); + players[i].viewrollangle = READANGLE(save_p); players[i].awayviewaiming = READANGLE(save_p); players[i].awayviewtics = READINT32(save_p); players[i].rings = READINT16(save_p); From a48b36f387f41aee76867e480295329f0ae73c3f Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 19:01:45 -0600 Subject: [PATCH 06/40] OGL can have little a viewroll --- src/hardware/hw_main.c | 6 ++++++ src/hardware/r_opengl/r_opengl.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 74be53db5..e1b5d23ff 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5969,6 +5969,8 @@ static void HWR_DrawSkyBackground(player_t *player) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails + dometransform.roll = (player->viewrollangle != 0); + dometransform.rollangle = FIXED_TO_FLOAT(AngleFixed(player->viewrollangle)); dometransform.splitscreen = splitscreen; HWR_GetTexture(texturetranslation[skytexture]); @@ -6192,6 +6194,8 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails + atransform.roll = (player->viewrollangle != 0); + atransform.rollangle = FIXED_TO_FLOAT(AngleFixed(player->viewrollangle)); atransform.splitscreen = splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -6412,6 +6416,8 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails + atransform.roll = (player->viewrollangle != 0); + atransform.rollangle = FIXED_TO_FLOAT(AngleFixed(player->viewrollangle)); atransform.splitscreen = splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index becce9fa3..a3ed3c8d2 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2238,6 +2238,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) else pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez); + if (stransform->roll) + pglRotatef(stransform->rollangle, 0.0f, 0.0f, 1.0f); pglRotatef(stransform->anglex , 1.0f, 0.0f, 0.0f); pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); From b74ff9eb73086095de9a66657c40e58e8b7a38ce Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 20:39:15 -0600 Subject: [PATCH 07/40] Add DBG_VIEWMORPH to view pre-transformed view --- src/doomdef.h | 1 + src/r_main.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 3d02871e4..565d1aadf 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -490,6 +490,7 @@ extern INT32 cv_debug; #define DBG_SETUP 0x0400 #define DBG_LUA 0x0800 #define DBG_RANDOMIZER 0x1000 +#define DBG_VIEWMORPH 0x2000 // ======================= // Misc stuff for later... diff --git a/src/r_main.c b/src/r_main.c index d4d05ad44..91e1b3fe7 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -667,8 +667,34 @@ void R_ApplyViewMorph(void) if (!viewmorph.use) return; - for (p = 0; p < end; p++) - tmpscr[p] = srcscr[viewmorph.scrmap[p]]; + if (cv_debug & DBG_VIEWMORPH) + { + UINT8 border = 32; + UINT8 grid = 160; + INT32 ws = vid.width / 4; + INT32 hs = vid.width * (vid.height / 4); + + memcpy(tmpscr, srcscr, vid.width*vid.height); + for (p = 0; p < vid.width; p++) + { + tmpscr[viewmorph.scrmap[p]] = border; + tmpscr[viewmorph.scrmap[p + hs]] = grid; + tmpscr[viewmorph.scrmap[p + hs*2]] = grid; + tmpscr[viewmorph.scrmap[p + hs*3]] = grid; + tmpscr[viewmorph.scrmap[end - 1 - p]] = border; + } + for (p = vid.width; p < end; p += vid.width) + { + tmpscr[viewmorph.scrmap[p]] = border; + tmpscr[viewmorph.scrmap[p + ws]] = grid; + tmpscr[viewmorph.scrmap[p + ws*2]] = grid; + tmpscr[viewmorph.scrmap[p + ws*3]] = grid; + tmpscr[viewmorph.scrmap[end - 1 - p]] = border; + } + } + else + for (p = 0; p < end; p++) + tmpscr[p] = srcscr[viewmorph.scrmap[p]]; VID_BlitLinearScreen(tmpscr, screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); From 4ab0301202d939d939be7105bf89bdc9204c77f3 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 20:39:38 -0600 Subject: [PATCH 08/40] Fisheye lens experiments --- src/r_main.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 91e1b3fe7..689f18f2b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -549,14 +549,29 @@ static inline void R_InitLightTables(void) } } +//#define WOUGHMP_WOUGHMP // I got a fish-eye lens - I'll make a rap video with a couple of friends +// it's kinda laggy sometimes + static struct { angle_t rollangle; // pre-shifted by fineshift +#ifdef WOUGHMP_WOUGHMP + fixed_t fisheye; +#endif fixed_t zoomneeded; INT32 *scrmap; size_t scrmapsize; boolean use; -} viewmorph = {0, FRACUNIT, NULL, 0, false}; +} viewmorph = { + 0, +#ifdef WOUGHMP_WOUGHMP + 0, +#endif + FRACUNIT, + NULL, + 0, + false +}; void R_CheckViewMorph(void) { @@ -565,18 +580,39 @@ void R_CheckViewMorph(void) fixed_t temp; size_t end, vx, vy, pos, usedpos; INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; +#ifdef WOUGHMP_WOUGHMP + float fisheyemap[MAXVIDWIDTH/2 + 1]; +#endif angle_t rollangle = players[displayplayer].viewrollangle; +#ifdef WOUGHMP_WOUGHMP + fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value +#endif rollangle >>= ANGLETOFINESHIFT; rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. - if (rollangle == viewmorph.rollangle && viewmorph.scrmapsize == vid.width*vid.height) +#ifdef WOUGHMP_WOUGHMP + fisheye &= ~0x7FF; // Same +#endif + + if (rollangle == viewmorph.rollangle && +#ifdef WOUGHMP_WOUGHMP + fisheye == viewmorph.fisheye && +#endif + viewmorph.scrmapsize == vid.width*vid.height) return; // No change viewmorph.rollangle = rollangle; +#ifdef WOUGHMP_WOUGHMP + viewmorph.fisheye = fisheye; +#endif - if (viewmorph.rollangle == 0) + if (viewmorph.rollangle == 0 +#ifdef WOUGHMP_WOUGHMP + && viewmorph.fisheye == 0 +#endif + ) { viewmorph.use = false; if (viewmorph.zoomneeded != FRACUNIT) @@ -603,6 +639,22 @@ void R_CheckViewMorph(void) x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + { + float f = FIXED_TO_FLOAT(fisheye); + for (vx = 0; vx <= halfwidth; vx++) + fisheyemap[vx] = 1.0f / cos(atan(vx * f / halfwidth)); + + f = cos(atan(f)); + if (f < 1.0f) + { + x1 /= f; + y1 /= f; + } + } +#endif + temp = max(x1, y1)*FRACUNIT; if (temp < FRACUNIT) temp = FRACUNIT; @@ -632,6 +684,34 @@ void R_CheckViewMorph(void) //CONS_Printf("Top left corner is %f %f\n", x1, y1); +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + { + for (vy = 0; vy < halfheight; vy++) + { + x2 = x1; + y2 = y1; + x1 -= rollsin; + y1 += rollcos; + + for (vx = 0; vx < vid.width; vx++) + { + usedx = halfwidth + x2*fisheyemap[(int) floorf(fabsf(y2*zoomfactor))]; + usedy = halfheight + y2*fisheyemap[(int) floorf(fabsf(x2*zoomfactor))]; + + usedpos = usedx + usedy*vid.width; + + viewmorph.scrmap[pos] = usedpos; + viewmorph.scrmap[end-pos] = end-usedpos; + + x2 += rollcos; + y2 += rollsin; + pos++; + } + } + } + else +#endif for (vy = 0; vy < halfheight; vy++) { x2 = x1; From 3d432b4c60a71c5c08c418670d197e226fdc7f91 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 21:55:16 -0600 Subject: [PATCH 09/40] I think this fixes the compile errors --- src/hardware/hw_main.c | 24 ++++++++++++++++++------ src/r_main.c | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e1b5d23ff..cf78c0cc0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5969,8 +5969,12 @@ static void HWR_DrawSkyBackground(player_t *player) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails - dometransform.roll = (player->viewrollangle != 0); - dometransform.rollangle = FIXED_TO_FLOAT(AngleFixed(player->viewrollangle)); + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + dometransform.rollangle = FIXED_TO_FLOAT(rol); + dometransform.roll = true; + } dometransform.splitscreen = splitscreen; HWR_GetTexture(texturetranslation[skytexture]); @@ -6194,8 +6198,12 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - atransform.roll = (player->viewrollangle != 0); - atransform.rollangle = FIXED_TO_FLOAT(AngleFixed(player->viewrollangle)); + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + atransform.rollangle = FIXED_TO_FLOAT(rol); + atransform.roll = true; + } atransform.splitscreen = splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -6416,8 +6424,12 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - atransform.roll = (player->viewrollangle != 0); - atransform.rollangle = FIXED_TO_FLOAT(AngleFixed(player->viewrollangle)); + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + atransform.rollangle = FIXED_TO_FLOAT(rol); + atransform.roll = true; + } atransform.splitscreen = splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); diff --git a/src/r_main.c b/src/r_main.c index 689f18f2b..27c444d88 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -560,7 +560,7 @@ static struct { fixed_t zoomneeded; INT32 *scrmap; - size_t scrmapsize; + INT32 scrmapsize; boolean use; } viewmorph = { 0, @@ -578,7 +578,7 @@ void R_CheckViewMorph(void) float zoomfactor, rollcos, rollsin; float x1, y1, x2, y2; fixed_t temp; - size_t end, vx, vy, pos, usedpos; + INT32 end, vx, vy, pos, usedpos; INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; #ifdef WOUGHMP_WOUGHMP float fisheyemap[MAXVIDWIDTH/2 + 1]; From a5976b09ec3d94fa8fa6ad0c03caafe6369074d9 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 17 Jan 2020 22:03:16 -0600 Subject: [PATCH 10/40] Fix sky texture scaling wrong with fov changes --- src/r_main.h | 1 + src/r_sky.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/r_main.h b/src/r_main.h index 2378661cc..0042015f2 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -26,6 +26,7 @@ extern INT32 centerx, centery; extern fixed_t centerxfrac, centeryfrac; extern fixed_t projection, projectiony; +extern fixed_t fovtan; // field of view extern size_t validcount, linecount, loopcount, framecount; diff --git a/src/r_sky.c b/src/r_sky.c index c9d28cebc..da36eb937 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -76,5 +76,5 @@ void R_SetupSkyDraw(void) void R_SetSkyScale(void) { fixed_t difference = vid.fdupx-(vid.dupx< Date: Fri, 17 Jan 2020 23:21:11 -0600 Subject: [PATCH 11/40] Avoid rendering unused left/right edges of screen while rolling --- src/r_main.c | 24 +++++++++++++++++++++++- src/r_things.c | 39 ++++++--------------------------------- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 27c444d88..a49b0519f 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -561,6 +561,7 @@ static struct { fixed_t zoomneeded; INT32 *scrmap; INT32 scrmapsize; + INT32 x1; // clip rendering horizontally for efficiency boolean use; } viewmorph = { 0, @@ -570,6 +571,7 @@ static struct { FRACUNIT, NULL, 0, + 0, false }; @@ -615,6 +617,7 @@ void R_CheckViewMorph(void) ) { viewmorph.use = false; + viewmorph.x1 = 0; if (viewmorph.zoomneeded != FRACUNIT) R_SetViewSize(); viewmorph.zoomneeded = FRACUNIT; @@ -682,6 +685,14 @@ void R_CheckViewMorph(void) x1 = -(halfwidth * rollcos - halfheight * rollsin); y1 = -(halfheight * rollcos + halfwidth * rollsin); +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin)) * fisheyemap[halfwidth]); + else +#endif + viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin))); + //CONS_Printf("saving %d cols\n", viewmorph.x1); + //CONS_Printf("Top left corner is %f %f\n", x1, y1); #ifdef WOUGHMP_WOUGHMP @@ -1316,7 +1327,18 @@ void R_RenderPlayerView(player_t *player) validcount++; // Clear buffers. - R_ClearClipSegs(); + if (viewmorph.use) + { + portalclipstart = viewmorph.x1; + portalclipend = viewwidth-viewmorph.x1-1; + R_PortalClearClipSegs(portalclipstart, portalclipend); + } + else + { + portalclipstart = 0; + portalclipend = viewwidth-1; + R_ClearClipSegs(); + } R_ClearDrawSegs(); R_ClearPlanes(); R_ClearSprites(); diff --git a/src/r_things.c b/src/r_things.c index 8fa0f2d0e..bb98d7f15 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1307,17 +1307,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->mobj = thing; // Easy access! Tails 06-07-2002 - shadow->x1 = x1 < 0 ? 0 : x1; - shadow->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (shadow->x1 < portalclipstart) - shadow->x1 = portalclipstart; - if (shadow->x2 >= portalclipend) - shadow->x2 = portalclipend-1; - } + shadow->x1 = x1 < portalclipstart ? portalclipstart : x1; + shadow->x2 = x2 >= portalclipend ? portalclipend-1 : x2; shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 shadow->scale = FixedMul(yscale, shadowyscale); @@ -1815,17 +1806,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->mobj = thing; // Easy access! Tails 06-07-2002 - vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (vis->x1 < portalclipstart) - vis->x1 = portalclipstart; - if (vis->x2 >= portalclipend) - vis->x2 = portalclipend-1; - } + vis->x1 = x1 < portalclipstart ? portalclipstart : x1; + vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; vis->xscale = xscale; //SoM: 4/17/2000 vis->sector = thing->subsector->sector; @@ -2034,17 +2016,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->shear.tan = 0; vis->shear.offset = 0; - vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (vis->x1 < portalclipstart) - vis->x1 = portalclipstart; - if (vis->x2 >= portalclipend) - vis->x2 = portalclipend-1; - } + vis->x1 = x1 < portalclipstart ? portalclipstart : x1; + vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; vis->xscale = xscale; //SoM: 4/17/2000 vis->sector = thing->subsector->sector; From 54a844a59e8e791b14c39c3d150838b2cf13cfd6 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 18 Jan 2020 00:16:18 -0600 Subject: [PATCH 12/40] Fix lighting discrepancies between different FOVs --- src/r_draw8.c | 9 +++++---- src/r_draw8_npo2.c | 11 +++++++---- src/r_main.h | 2 ++ src/r_segs.c | 14 +++++++------- src/r_things.c | 4 ++-- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 015dac2a7..2f6bdcfa4 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -644,6 +644,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! @@ -669,7 +670,7 @@ void R_DrawTiltedSpan_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; @@ -805,7 +806,7 @@ void R_DrawTiltedTranslucentSpan_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; @@ -942,7 +943,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; @@ -1078,7 +1079,7 @@ void R_DrawTiltedSplat_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c index 748ca195c..aa38ee2d9 100644 --- a/src/r_draw8_npo2.c +++ b/src/r_draw8_npo2.c @@ -62,6 +62,9 @@ void R_DrawSpan_NPO2_8 (void) } #ifdef ESLOPE + +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) + /** \brief The R_DrawTiltedSpan_NPO2_8 function Draw slopes! Holy sheit! */ @@ -86,7 +89,7 @@ void R_DrawTiltedSpan_NPO2_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; @@ -282,7 +285,7 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; @@ -476,7 +479,7 @@ void R_DrawTiltedSplat_NPO2_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; @@ -869,7 +872,7 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; diff --git a/src/r_main.h b/src/r_main.h index 0042015f2..678d3a0a7 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -46,6 +46,8 @@ extern size_t validcount, linecount, loopcount, framecount; #define MAXLIGHTZ 128 #define LIGHTZSHIFT 20 +#define LIGHTRESOLUTIONFIX (640*fovtan/vid.width) + extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; extern lighttable_t *scalelightfixed[MAXLIGHTSCALE]; extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; diff --git a/src/r_segs.c b/src/r_segs.c index dcb5fc160..fb4238448 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -199,7 +199,7 @@ static void R_DrawWallSplats(void) // draw the columns for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep) { - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; dc_colormap = walllights[pindex]; @@ -599,7 +599,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else xwalllights = scalelight[rlight->lightnum]; - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -644,7 +644,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } // calculate lighting - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -1188,7 +1188,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else xwalllights = scalelight[lightnum]; - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1281,7 +1281,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } // calculate lighting - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -1486,7 +1486,7 @@ static void R_RenderSegLoop (void) if (segtextured) { // calculate lighting - pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1521,7 +1521,7 @@ static void R_RenderSegLoop (void) else xwalllights = scalelight[lightnum]; - pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; diff --git a/src/r_things.c b/src/r_things.c index bb98d7f15..cb9d78464 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1097,7 +1097,7 @@ static void R_SplitSprite(vissprite_t *sprite) if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { - lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); + lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; @@ -1872,7 +1872,7 @@ static void R_ProjectSprite(mobj_t *thing) else { // diminished light - lindex = FixedMul(xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); + lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; From 6d42b011e8851563f3511e5c6c590d4eb277d44d Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 18 Jan 2020 00:23:47 -0800 Subject: [PATCH 13/40] Let "+" command line parameters specify more than one argument Previously each parameter after the first would be quoted into one argument to pass to the command buffer. --- src/m_argv.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/m_argv.c b/src/m_argv.c index 935f4b9e3..129706127 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -92,36 +92,21 @@ const char *M_GetNextParm(void) void M_PushSpecialParameters(void) { INT32 i; - char s[256]; - boolean onetime = false; - for (i = 1; i < myargc; i++) { if (myargv[i][0] == '+') { - strcpy(s, &myargv[i][1]); + COM_BufAddText(&myargv[i][1]); i++; // get the parameters of the command too for (; i < myargc && myargv[i][0] != '+' && myargv[i][0] != '-'; i++) { - strcat(s, " "); - if (!onetime) - { - strcat(s, "\""); - onetime = true; - } - strcat(s, myargv[i]); + COM_BufAddText(va(" \"%s\"", myargv[i])); } - if (onetime) - { - strcat(s, "\""); - onetime = false; - } - strcat(s, "\n"); // push it - COM_BufAddText(s); + COM_BufAddText("\n"); i--; } } From 3cb64aeb77ab1da3a8e78b456d5e706fe97f3136 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 18 Jan 2020 10:53:00 -0600 Subject: [PATCH 14/40] Fully clip drawing to roll-used screen bounds --- src/r_main.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index a49b0519f..7def18b40 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -561,17 +561,24 @@ static struct { fixed_t zoomneeded; INT32 *scrmap; INT32 scrmapsize; + INT32 x1; // clip rendering horizontally for efficiency + INT16 ceilingclip[MAXVIDWIDTH], floorclip[MAXVIDWIDTH]; + boolean use; } viewmorph = { 0, #ifdef WOUGHMP_WOUGHMP 0, #endif + FRACUNIT, NULL, 0, + 0, + {}, {}, + false }; @@ -693,6 +700,47 @@ void R_CheckViewMorph(void) viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin))); //CONS_Printf("saving %d cols\n", viewmorph.x1); + // Set ceilingclip and floorclip + for (vx = 0; vx < vid.width; vx++) + { + viewmorph.ceilingclip[vx] = vid.height; + viewmorph.floorclip[vx] = -1; + } + x2 = x1; + y2 = y1; + for (vx = 0; vx < vid.width; vx++) + { + INT16 xa, ya, xb, yb; + xa = x2+halfwidth; + ya = y2+halfheight; + xb = vid.width-1-xa; + yb = vid.height-1-ya; + + viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + x2 += rollcos; + y2 += rollsin; + } + x2 = x1; + y2 = y1; + for (vy = 0; vy < vid.height; vy++) + { + INT16 xa, ya, xb, yb; + xa = x2+halfwidth; + ya = y2+halfheight; + xb = vid.width-1-xa; + yb = vid.height-1-ya; + + viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + x2 -= rollsin; + y2 += rollcos; + } + //CONS_Printf("Top left corner is %f %f\n", x1, y1); #ifdef WOUGHMP_WOUGHMP @@ -1327,11 +1375,14 @@ void R_RenderPlayerView(player_t *player) validcount++; // Clear buffers. + R_ClearPlanes(); if (viewmorph.use) { portalclipstart = viewmorph.x1; portalclipend = viewwidth-viewmorph.x1-1; R_PortalClearClipSegs(portalclipstart, portalclipend); + memcpy(ceilingclip, viewmorph.ceilingclip, sizeof(INT16)*vid.width); + memcpy(floorclip, viewmorph.floorclip, sizeof(INT16)*vid.width); } else { @@ -1340,7 +1391,6 @@ void R_RenderPlayerView(player_t *player) R_ClearClipSegs(); } R_ClearDrawSegs(); - R_ClearPlanes(); R_ClearSprites(); #ifdef FLOORSPLATS R_ClearVisibleFloorSplats(); From 964458e9819671444918762a29a863b313a69f37 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 18 Jan 2020 10:53:23 -0600 Subject: [PATCH 15/40] Remove a couple adds from each pixel of morph mapping --- src/r_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 7def18b40..9259c6902 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -770,7 +770,11 @@ void R_CheckViewMorph(void) } } else + { #endif + x1 += halfwidth; + y1 += halfheight; + for (vy = 0; vy < halfheight; vy++) { x2 = x1; @@ -780,8 +784,8 @@ void R_CheckViewMorph(void) for (vx = 0; vx < vid.width; vx++) { - usedx = halfwidth+x2; - usedy = halfheight+y2; + usedx = x2; + usedy = y2; usedpos = usedx + usedy*vid.width; @@ -793,6 +797,9 @@ void R_CheckViewMorph(void) pos++; } } +#ifdef WOUGHMP_WOUGHMP + } +#endif viewmorph.use = true; } From b5b902e064f4baec7511d45fcf0d732222d60f56 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 18 Jan 2020 10:53:45 -0600 Subject: [PATCH 16/40] Reduce the number of distinct roll angles --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 9259c6902..1592c9ab2 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -599,7 +599,7 @@ void R_CheckViewMorph(void) #endif rollangle >>= ANGLETOFINESHIFT; - rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. + rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. #ifdef WOUGHMP_WOUGHMP fisheye &= ~0x7FF; // Same From dcc66de65d88c53cd296d7aa2158c9e313dae80c Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 18 Jan 2020 11:15:36 -0600 Subject: [PATCH 17/40] Use generally higher zooms and fix fuzzy edges --- src/r_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 1592c9ab2..548f37f57 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -669,7 +669,7 @@ void R_CheckViewMorph(void) if (temp < FRACUNIT) temp = FRACUNIT; else - temp |= 0xFFF; // Limit how many times the viewport needs to be recalculated + temp |= 0x3FFF; // Limit how many times the viewport needs to be recalculated //CONS_Printf("Setting zoom to %f\n", FIXED_TO_FLOAT(temp)); @@ -712,7 +712,7 @@ void R_CheckViewMorph(void) { INT16 xa, ya, xb, yb; xa = x2+halfwidth; - ya = y2+halfheight; + ya = y2+halfheight-1; xb = vid.width-1-xa; yb = vid.height-1-ya; From 52b60d90b03d5b3b7ec9e8a4b5735981d13a9143 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 18 Jan 2020 11:19:59 -0600 Subject: [PATCH 18/40] Fix loss of aimingtody precision at high FOV --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 548f37f57..e43e3a1c3 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1045,7 +1045,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) static mobj_t *viewmobj; // WARNING: a should be unsigned but to add with 2048, it isn't! -#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS, fovtan) +#define AIMINGTODY(a) ((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)/fovtan) // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). From 99ad30796c2db4ba58ee9083c917fa889ca7c028 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 20 Jan 2020 23:14:26 -0800 Subject: [PATCH 19/40] Trim the trailing zeros off floats for cvars --- src/command.c | 14 +++++++++++--- src/m_menu.c | 3 ++- src/m_misc.c | 17 +++++++++++++++++ src/m_misc.h | 6 ++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/command.c b/src/command.c index b9ceba3cc..199115519 100644 --- a/src/command.c +++ b/src/command.c @@ -823,8 +823,13 @@ static void COM_Help_f(void) if (!stricmp(cvar->PossibleValue[MINVAL].strvalue, "MIN")) { if (floatmode) - CONS_Printf(" range from %f to %f\n", FIXED_TO_FLOAT(cvar->PossibleValue[MINVAL].value), - FIXED_TO_FLOAT(cvar->PossibleValue[MAXVAL].value)); + { + float fu = FIXED_TO_FLOAT(cvar->PossibleValue[MINVAL].value); + float ck = FIXED_TO_FLOAT(cvar->PossibleValue[MAXVAL].value); + CONS_Printf(" range from %ld%s to %ld%s\n", + (long)fu, M_Ftrim(fu), + (long)ck, M_Ftrim(ck)); + } else CONS_Printf(" range from %d to %d\n", cvar->PossibleValue[MINVAL].value, cvar->PossibleValue[MAXVAL].value); @@ -973,7 +978,10 @@ static void COM_Add_f(void) } if (( cvar->flags & CV_FLOAT )) - CV_Set(cvar, va("%f", FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2)))); + { + float n =FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2)); + CV_Set(cvar, va("%ld%s", (long)n, M_Ftrim(n))); + } else CV_AddValue(cvar, atoi(COM_Argv(2))); } diff --git a/src/m_menu.c b/src/m_menu.c index 0d19a6a43..934495733 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2915,7 +2915,8 @@ static void M_ChangeCvar(INT32 choice) || !(currentMenu->menuitems[itemOn].status & IT_CV_INTEGERSTEP)) { char s[20]; - sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f)); + float n = FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f); + sprintf(s,"%ld%s",(long)n,M_Ftrim(n)); CV_Set(cv,s); } else diff --git a/src/m_misc.c b/src/m_misc.c index 43d531110..ae8466ac8 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2581,3 +2581,20 @@ int M_JumpWordReverse(const char *line, int offset) offset--; return offset; } + +const char * M_Ftrim (double f) +{ + static char dig[9];/* "0." + 6 digits (6 is printf's default) */ + int i; + /* I know I said it's the default, but just in case... */ + sprintf(dig, "%.6g", modf(f, &f)); + if (dig[0]) + { + for (i = strlen(dig); dig[i] == '0'; --i) + ; + dig[i + 1] = '\0'; + return &dig[1];/* skip the 0 */ + } + else + return ""; +} diff --git a/src/m_misc.h b/src/m_misc.h index 3fb9f031a..ad12517c1 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -109,6 +109,12 @@ int M_JumpWord (const char *s); /* E.g. cursor = M_JumpWordReverse(line, cursor); */ int M_JumpWordReverse (const char *line, int offset); +/* +Return dot and then the fractional part of a float, without +trailing zeros, or "" if the fractional part is zero. +*/ +const char * M_Ftrim (double); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); From 23373932119f1d55ebdc36084179388f8e0e185e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartu=20=C4=B0nce?= Date: Wed, 22 Jan 2020 18:53:17 +0100 Subject: [PATCH 20/40] Added support for 10+ emblem hints --- src/m_menu.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 162 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 62bea7ae0..0a39148ec 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -231,6 +231,8 @@ static void M_Credits(INT32 choice); static void M_SoundTest(INT32 choice); static void M_PandorasBox(INT32 choice); static void M_EmblemHints(INT32 choice); +static void M_EmblemHintsFull(INT32 choice); +static void M_HandleEmblemHints(INT32 choice); static void M_HandleChecklist(INT32 choice); menu_t SR_MainDef, SR_UnlockChecklistDef; @@ -342,6 +344,7 @@ static void M_DrawAddons(void); static void M_DrawChecklist(void); static void M_DrawSoundTest(void); static void M_DrawEmblemHints(void); +static void M_DrawEmblemHintsFull(void); static void M_DrawPauseMenu(void); static void M_DrawServerMenu(void); static void M_DrawLevelPlatterMenu(void); @@ -727,8 +730,14 @@ static menuitem_t SR_SoundTestMenu[] = static menuitem_t SR_EmblemHintMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 10}, - {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 20} + {IT_STRING | IT_CALL, NULL, "Check All Hints", M_EmblemHintsFull, 10}, + {IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 20}, + {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 30} +}; + +static menuitem_t SR_EmblemHintFullMenu[] = +{ + {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleEmblemHints, 0}, }; // -------------------------------- @@ -1738,6 +1747,19 @@ menu_t SR_EmblemHintDef = NULL }; +menu_t SR_EmblemHintFullDef = +{ + MN_SR_MAIN + (MN_SR_EMBLEMHINT << 6), + NULL, + sizeof (SR_EmblemHintFullMenu)/sizeof (menuitem_t), + &SR_EmblemHintDef, + SR_EmblemHintFullMenu, + M_DrawEmblemHintsFull, + 0, 150, + 0, + NULL +}; + // Single Player menu_t SP_MainDef = //CENTERMENUSTYLE(NULL, SP_MainMenu, &MainDef, 72); { @@ -7227,10 +7249,23 @@ finishchecklist: #define NUMHINTS 5 static void M_EmblemHints(INT32 choice) { + INT32 i; + UINT32 local = 0; + emblem_t *emblem; + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + if (++local > NUMHINTS*2) + break; + } + (void)choice; - SR_EmblemHintMenu[0].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET); + SR_EmblemHintMenu[0].status = (local > NUMHINTS*2) ? (IT_STRING | IT_CALL) : (IT_DISABLED); + SR_EmblemHintMenu[1].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET); M_SetupNextMenu(&SR_EmblemHintDef); - itemOn = 1; // always start on back. + itemOn = 2; // always start on back. } static void M_DrawEmblemHints(void) @@ -7301,6 +7336,129 @@ static void M_DrawEmblemHints(void) M_DrawGenericMenu(); } +UINT32 check_on_hint = 0; + +static void M_HandleEmblemHints(INT32 choice) +{ + INT32 i; + emblem_t *emblem; + UINT32 stageemblems = 0; + + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + + stageemblems++; + } + + + UINT32 j = check_on_hint; + switch (choice) + { + case KEY_DOWNARROW: + S_StartSound(NULL, sfx_menu1); + if ((check_on_hint != stageemblems)) + { + if (++j <= stageemblems - NUMHINTS) + check_on_hint = j; + } + return; + + case KEY_UPARROW: + S_StartSound(NULL, sfx_menu1); + if (check_on_hint) + { + if (--j != -1) + check_on_hint = j; + } + return; + + case KEY_ESCAPE: + if (currentMenu->prevMenu){ + check_on_hint = 0; + M_SetupNextMenu(currentMenu->prevMenu); + }else + M_ClearMenus(true); + return; + default: + break; + } + +} + +static void M_EmblemHintsFull(INT32 choice) +{ + (void)choice; + M_SetupNextMenu(&SR_EmblemHintFullDef); + itemOn = 0; +} + + +static void M_DrawEmblemHintsFull(void) +{ + INT32 i, x, y = currentMenu->y, drawnemblems = 0; + UINT32 collected = 0, local = 0; + emblem_t *emblem; + const char *hint; + + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + local++; + } + + if (!local) + V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); + else{ + + if (check_on_hint > 0) + V_DrawString(310, y-(skullAnimCounter/5), V_YELLOWMAP, "\x1A"); + if(check_on_hint < local - NUMHINTS) + V_DrawString(310, y+8+(skullAnimCounter/5), V_YELLOWMAP, "\x1B"); + + x = 4; + y = 16; + + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + + drawnemblems++; + + if (drawnemblems > check_on_hint && drawnemblems <= (check_on_hint+NUMHINTS)){ + if (emblem->collected) + { + collected = V_GREENMAP; + V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), + R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); + } + else + { + collected = 0; + V_DrawScaledPatch(x, y+4, 0, W_CachePatchName("NEEDIT", PU_PATCH)); + } + + if (emblem->hint[0]) + hint = emblem->hint; + else + hint = M_GetText("No hint available for this emblem."); + hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); + V_DrawString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + + y += 32; + } + } + } + + //M_DrawGenericMenu(); +} + /*static void M_DrawSkyRoom(void) { INT32 i, y = 0; From 15f1636be524d39622a870ee772be4d51cab9031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartu=20=C4=B0nce?= Date: Wed, 22 Jan 2020 21:52:15 +0100 Subject: [PATCH 21/40] Extra emblems display, take 2. --- src/m_menu.c | 229 ++++++++++++++++----------------------------------- 1 file changed, 72 insertions(+), 157 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 0a39148ec..3e4d822f6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -231,8 +231,8 @@ static void M_Credits(INT32 choice); static void M_SoundTest(INT32 choice); static void M_PandorasBox(INT32 choice); static void M_EmblemHints(INT32 choice); -static void M_EmblemHintsFull(INT32 choice); static void M_HandleEmblemHints(INT32 choice); +UINT32 hintpage = 1; static void M_HandleChecklist(INT32 choice); menu_t SR_MainDef, SR_UnlockChecklistDef; @@ -344,7 +344,6 @@ static void M_DrawAddons(void); static void M_DrawChecklist(void); static void M_DrawSoundTest(void); static void M_DrawEmblemHints(void); -static void M_DrawEmblemHintsFull(void); static void M_DrawPauseMenu(void); static void M_DrawServerMenu(void); static void M_DrawLevelPlatterMenu(void); @@ -730,16 +729,11 @@ static menuitem_t SR_SoundTestMenu[] = static menuitem_t SR_EmblemHintMenu[] = { - {IT_STRING | IT_CALL, NULL, "Check All Hints", M_EmblemHintsFull, 10}, + {IT_STRING | IT_ARROWS, NULL, "Page", M_HandleEmblemHints, 10}, {IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 20}, {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 30} }; -static menuitem_t SR_EmblemHintFullMenu[] = -{ - {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleEmblemHints, 0}, -}; - // -------------------------------- // 1 Player and all of its submenus // -------------------------------- @@ -1747,19 +1741,6 @@ menu_t SR_EmblemHintDef = NULL }; -menu_t SR_EmblemHintFullDef = -{ - MN_SR_MAIN + (MN_SR_EMBLEMHINT << 6), - NULL, - sizeof (SR_EmblemHintFullMenu)/sizeof (menuitem_t), - &SR_EmblemHintDef, - SR_EmblemHintFullMenu, - M_DrawEmblemHintsFull, - 0, 150, - 0, - NULL -}; - // Single Player menu_t SP_MainDef = //CENTERMENUSTYLE(NULL, SP_MainMenu, &MainDef, 72); { @@ -7247,6 +7228,7 @@ finishchecklist: } #define NUMHINTS 5 + static void M_EmblemHints(INT32 choice) { INT32 i; @@ -7262,16 +7244,17 @@ static void M_EmblemHints(INT32 choice) } (void)choice; - SR_EmblemHintMenu[0].status = (local > NUMHINTS*2) ? (IT_STRING | IT_CALL) : (IT_DISABLED); + SR_EmblemHintMenu[0].status = (local > NUMHINTS*2) ? (IT_STRING | IT_ARROWS) : (IT_DISABLED); SR_EmblemHintMenu[1].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET); + hintpage = 1; M_SetupNextMenu(&SR_EmblemHintDef); itemOn = 2; // always start on back. } static void M_DrawEmblemHints(void) { - INT32 i, j = 0, x, y, left_hints = NUMHINTS; - UINT32 collected = 0, local = 0; + INT32 i, j = 0, x, y, left_hints = NUMHINTS, pageflag = 0; + UINT32 collected = 0, totalemblems = 0, local = 0; emblem_t *emblem; const char *hint; @@ -7280,17 +7263,34 @@ static void M_DrawEmblemHints(void) emblem = &emblemlocations[i]; if (emblem->level != gamemap || emblem->type > ET_SKIN) continue; - if (++local >= NUMHINTS*2) - break; + + local++; } x = (local > NUMHINTS ? 4 : 12); y = 8; - // If there are more than 1 page's but less than 2 pages' worth of emblems, + if (local > NUMHINTS){ + if (local > ((hintpage-1)*NUMHINTS*2) && local < ((hintpage)*NUMHINTS*2)){ + if (NUMHINTS % 2 == 1) + left_hints = (local - ((hintpage-1)*NUMHINTS*2) + 1) / 2; + else + left_hints = (local - ((hintpage-1)*NUMHINTS*2)) / 2; + }else{ + left_hints = NUMHINTS; + } + } + + if (local > NUMHINTS*2){ + if (itemOn == 0){ + pageflag = V_YELLOWMAP; + } + V_DrawString(currentMenu->x + 40, currentMenu->y + 10, pageflag, va("%d",hintpage)); + } + + // If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page, // put half (rounded up) of the hints on the left, and half (rounded down) on the right - if (local > NUMHINTS && local < (NUMHINTS*2)-1) - left_hints = (local + 1) / 2; + if (!local) V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); @@ -7300,43 +7300,51 @@ static void M_DrawEmblemHints(void) if (emblem->level != gamemap || emblem->type > ET_SKIN) continue; - if (emblem->collected) - { - collected = V_GREENMAP; - V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); - } - else - { - collected = 0; - V_DrawScaledPatch(x, y+4, 0, W_CachePatchName("NEEDIT", PU_PATCH)); - } + totalemblems++; - if (emblem->hint[0]) - hint = emblem->hint; - else - hint = M_GetText("No hint available for this emblem."); - hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); - if (local > NUMHINTS) - V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); - else - V_DrawString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + if (totalemblems >= ((hintpage-1)*(NUMHINTS*2) + 1) && totalemblems < (hintpage*NUMHINTS*2)+1){ - y += 28; + if (emblem->collected) + { + collected = V_GREENMAP; + V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), + R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); + } + else + { + collected = 0; + V_DrawScaledPatch(x, y+4, 0, W_CachePatchName("NEEDIT", PU_PATCH)); + } - if (++j == left_hints) - { - x = 4+(BASEVIDWIDTH/2); - y = 8; + if (emblem->hint[0]) + hint = emblem->hint; + else + hint = M_GetText("No hint available for this emblem."); + hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); + //always draw tiny if we have more than NUMHINTS*2, visually more appealing + if (local > NUMHINTS) + V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + else + V_DrawString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + + y += 28; + + // If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page, + // put half (rounded up) of the hints on the left, and half (rounded down) on the right + + if (++j == left_hints) + { + x = 4+(BASEVIDWIDTH/2); + y = 8; + } + else if (j >= NUMHINTS*2) + break; } - else if (j >= NUMHINTS*2) - break; } M_DrawGenericMenu(); } -UINT32 check_on_hint = 0; static void M_HandleEmblemHints(INT32 choice) { @@ -7354,109 +7362,16 @@ static void M_HandleEmblemHints(INT32 choice) } - UINT32 j = check_on_hint; - switch (choice) - { - case KEY_DOWNARROW: - S_StartSound(NULL, sfx_menu1); - if ((check_on_hint != stageemblems)) - { - if (++j <= stageemblems - NUMHINTS) - check_on_hint = j; - } - return; - - case KEY_UPARROW: - S_StartSound(NULL, sfx_menu1); - if (check_on_hint) - { - if (--j != -1) - check_on_hint = j; - } - return; - - case KEY_ESCAPE: - if (currentMenu->prevMenu){ - check_on_hint = 0; - M_SetupNextMenu(currentMenu->prevMenu); - }else - M_ClearMenus(true); - return; - default: - break; - } - -} - -static void M_EmblemHintsFull(INT32 choice) -{ - (void)choice; - M_SetupNextMenu(&SR_EmblemHintFullDef); - itemOn = 0; -} - - -static void M_DrawEmblemHintsFull(void) -{ - INT32 i, x, y = currentMenu->y, drawnemblems = 0; - UINT32 collected = 0, local = 0; - emblem_t *emblem; - const char *hint; - - for (i = 0; i < numemblems; i++) - { - emblem = &emblemlocations[i]; - if (emblem->level != gamemap || emblem->type > ET_SKIN) - continue; - local++; - } - - if (!local) - V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); - else{ - - if (check_on_hint > 0) - V_DrawString(310, y-(skullAnimCounter/5), V_YELLOWMAP, "\x1A"); - if(check_on_hint < local - NUMHINTS) - V_DrawString(310, y+8+(skullAnimCounter/5), V_YELLOWMAP, "\x1B"); - - x = 4; - y = 16; - - for (i = 0; i < numemblems; i++) - { - emblem = &emblemlocations[i]; - if (emblem->level != gamemap || emblem->type > ET_SKIN) - continue; - - drawnemblems++; - - if (drawnemblems > check_on_hint && drawnemblems <= (check_on_hint+NUMHINTS)){ - if (emblem->collected) - { - collected = V_GREENMAP; - V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); - } - else - { - collected = 0; - V_DrawScaledPatch(x, y+4, 0, W_CachePatchName("NEEDIT", PU_PATCH)); - } - - if (emblem->hint[0]) - hint = emblem->hint; - else - hint = M_GetText("No hint available for this emblem."); - hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); - V_DrawString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); - - y += 32; - } + if (choice == 0){ + if (hintpage > 1){ + hintpage--; + } + }else{ + if (hintpage < (stageemblems/(NUMHINTS*2) + 1)){ + hintpage++; } } - //M_DrawGenericMenu(); } /*static void M_DrawSkyRoom(void) From 5d3233416401e553e72d129e4ed361c1fff2b6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartu=20=C4=B0nce?= Date: Wed, 22 Jan 2020 21:57:28 +0100 Subject: [PATCH 22/40] "page x of y" --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3e4d822f6..3c19e230e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7285,7 +7285,7 @@ static void M_DrawEmblemHints(void) if (itemOn == 0){ pageflag = V_YELLOWMAP; } - V_DrawString(currentMenu->x + 40, currentMenu->y + 10, pageflag, va("%d",hintpage)); + V_DrawString(currentMenu->x + 40, currentMenu->y + 10, pageflag, va("%d of %d",hintpage, local/(NUMHINTS*2) + 1)); } // If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page, From 15ecc1358a594b30dff5fe5a55759ce19f59e2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartu=20=C4=B0nce?= Date: Wed, 22 Jan 2020 22:08:08 +0100 Subject: [PATCH 23/40] no message --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3c19e230e..957928497 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7367,7 +7367,7 @@ static void M_HandleEmblemHints(INT32 choice) hintpage--; } }else{ - if (hintpage < (stageemblems/(NUMHINTS*2) + 1)){ + if (hintpage < ((stageemblems-1)/(NUMHINTS*2) + 1)){ hintpage++; } } From 5f7cf83da85a37bb205f7ad21b7e3ab76aa31d0d Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 29 Jan 2020 13:47:55 -0300 Subject: [PATCH 24/40] Local Color Table for GIF movie mode --- src/d_netcmd.c | 1 + src/m_anigif.c | 89 ++++++++++++++++++++++++++++++++++++++------------ src/m_anigif.h | 2 +- 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 23ec00b2e..8d36cb058 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -669,6 +669,7 @@ void D_RegisterClientCommands(void) // GIF variables CV_RegisterVar(&cv_gif_optimize); CV_RegisterVar(&cv_gif_downscale); + CV_RegisterVar(&cv_gif_localcolortable); #ifdef WALLSPLATS CV_RegisterVar(&cv_splats); diff --git a/src/m_anigif.c b/src/m_anigif.c index 32fc2746d..bd90f6675 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -19,6 +19,7 @@ #include "v_video.h" #include "i_video.h" #include "m_misc.h" +#include "st_stuff.h" // st_palette #ifdef HWRENDER #include "hardware/hw_main.h" @@ -29,10 +30,12 @@ consvar_t cv_gif_optimize = {"gif_optimize", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gif_downscale = {"gif_downscale", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gif_localcolortable = {"gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output +static boolean gif_localcolortable = false; static RGBA_t *gif_palette = NULL; static FILE *gif_out = NULL; @@ -393,6 +396,41 @@ const UINT8 gifhead_nsid[19] = {0x21,0xFF,0x0B, // extension block + size 0x4E,0x45,0x54,0x53,0x43,0x41,0x50,0x45,0x32,0x2E,0x30, // NETSCAPE2.0 0x03,0x01,0xFF,0xFF,0x00}; // sub-block, repetitions + +// +// GIF_setpalette +// determine the gif palette. +// +static void GIF_setpalette(void) +{ + // In hardware mode, uses the master palette + size_t palnum = (rendermode == render_soft) ? ((gif_localcolortable) ? max(st_palette, 0) : 0) : 0; + gif_palette = ((cv_screenshot_colorprofile.value +#ifdef HWRENDER + && (rendermode == render_soft) +#endif + ) ? &pLocalPalette[palnum*256] + : &pMasterPalette[palnum*256]); +} + +// +// GIF_palwrite +// writes the gif palette. +// used both for the header and the local color table. +// +static UINT8 *GIF_palwrite(UINT8 *p) +{ + INT32 i; + RGBA_t *pal = gif_palette; + for (i = 0; i < 256; i++) + { + WRITEUINT8(p, pal[i].s.red); + WRITEUINT8(p, pal[i].s.green); + WRITEUINT8(p, pal[i].s.blue); + } + return p; +} + // // GIF_headwrite // writes the gif header to the currently open output file. @@ -402,8 +440,10 @@ static void GIF_headwrite(void) { UINT8 *gifhead = Z_Malloc(800, PU_STATIC, NULL); UINT8 *p = gifhead; - INT32 i; + UINT8 *last_p; UINT16 rwidth, rheight; + size_t totalbytes; + INT32 i; if (!gif_out) return; @@ -423,30 +463,37 @@ static void GIF_headwrite(void) rwidth = vid.width; rheight = vid.height; } + + last_p = p; WRITEUINT16(p, rwidth); WRITEUINT16(p, rheight); // colors, aspect, etc - WRITEUINT8(p, 0xF7); + WRITEUINT8(p, (gif_localcolortable ? 0xF0 : 0xF7)); // (0xF7 = 1111 0111) WRITEUINT8(p, 0x00); WRITEUINT8(p, 0x00); + // Lactozilla: should be 800 without a local color table + totalbytes = sizeof(gifhead_base) + sizeof(gifhead_nsid) + (p - last_p); + // write color table + if (!gif_localcolortable) { - RGBA_t *pal = gif_palette; - for (i = 0; i < 256; i++) - { - WRITEUINT8(p, pal[i].s.red); - WRITEUINT8(p, pal[i].s.green); - WRITEUINT8(p, pal[i].s.blue); - } + p = GIF_palwrite(p); + totalbytes += (256 * 3); + } + else + { + // write a dummy palette + for (i = 0; i < 6; i++, totalbytes++) + WRITEUINT8(p, 0); } // write extension block WRITEMEM(p, gifhead_nsid, sizeof(gifhead_nsid)); // write to file and be done with it! - fwrite(gifhead, 1, 800, gif_out); + fwrite(gifhead, 1, totalbytes, gif_out); Z_Free(gifhead); } @@ -566,7 +613,15 @@ static void GIF_framewrite(void) WRITEUINT16(p, (UINT16)(blity / scrbuf_downscaleamt)); WRITEUINT16(p, (UINT16)(blitw / scrbuf_downscaleamt)); WRITEUINT16(p, (UINT16)(blith / scrbuf_downscaleamt)); - WRITEUINT8(p, 0); // no local table of colors + + if (!gif_localcolortable) + WRITEUINT8(p, 0); // no local table of colors + else + { + WRITEUINT8(p, 0x87); // (0x87 = 1000 0111) + GIF_setpalette(); + p = GIF_palwrite(p); + } scrbuf_pos = movie_screen + blitx + (blity * vid.width); scrbuf_writeend = scrbuf_pos + (blitw - 1) + ((blith - 1) * vid.width); @@ -638,15 +693,9 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); - - // GIF color table - // In hardware mode, uses the master palette - gif_palette = ((cv_screenshot_colorprofile.value -#ifdef HWRENDER - && (rendermode == render_soft) -#endif - ) ? pLocalPalette - : pMasterPalette); + gif_localcolortable = (!!cv_gif_localcolortable.value); + if (!gif_localcolortable) + GIF_setpalette(); GIF_headwrite(); gif_frames = 0; diff --git a/src/m_anigif.h b/src/m_anigif.h index 9bdf2cc7f..9eb6faa75 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -27,6 +27,6 @@ void GIF_frame(void); INT32 GIF_close(void); #endif -extern consvar_t cv_gif_optimize, cv_gif_downscale; +extern consvar_t cv_gif_optimize, cv_gif_downscale, cv_gif_localcolortable; #endif From dac93c343f4868c5a2d6f5c1bc8f50852cc1f4c7 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 29 Jan 2020 13:52:02 -0300 Subject: [PATCH 25/40] Update the Screenshot Options menu --- src/m_menu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f8c14dd69..52889c630 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1443,6 +1443,7 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 95}, {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 100}, + {IT_STRING|IT_CVAR, NULL, "Local Color Table", &cv_gif_localcolortable, 105}, {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 95}, {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 100}, @@ -1457,9 +1458,9 @@ enum op_movie_folder = 11, op_screenshot_capture = 12, op_screenshot_gif_start = 13, - op_screenshot_gif_end = 14, - op_screenshot_apng_start = 15, - op_screenshot_apng_end = 18, + op_screenshot_gif_end = 15, + op_screenshot_apng_start = 16, + op_screenshot_apng_end = 19, }; static menuitem_t OP_EraseDataMenu[] = From 0b3aad6116ababe478f08f649c642b78a9b5d280 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 29 Jan 2020 13:56:39 -0300 Subject: [PATCH 26/40] Uh --- src/m_anigif.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index bd90f6675..82e118527 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -434,7 +434,6 @@ static UINT8 *GIF_palwrite(UINT8 *p) // // GIF_headwrite // writes the gif header to the currently open output file. -// NOTE that this code does not accomodate for palette changes. // static void GIF_headwrite(void) { From 7c8ef73b06c65219cee42a7e75383d7b520edef6 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 29 Jan 2020 17:31:27 -0300 Subject: [PATCH 27/40] Only write a Local Color Table if the frame's palette differs from the header's palette --- src/m_anigif.c | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 82e118527..f917a7b26 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -35,8 +35,12 @@ consvar_t cv_gif_localcolortable = {"gif_localcolortable", "On", CV_SAVE, CV_On #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output + +// Palette handling static boolean gif_localcolortable = false; -static RGBA_t *gif_palette = NULL; +static boolean gif_colorprofile = false; +static RGBA_t *gif_headerpalette = NULL; +static RGBA_t *gif_framepalette = NULL; static FILE *gif_out = NULL; static INT32 gif_frames = 0; @@ -398,14 +402,13 @@ const UINT8 gifhead_nsid[19] = {0x21,0xFF,0x0B, // extension block + size // -// GIF_setpalette -// determine the gif palette. +// GIF_getpalette +// determine the palette for the current frame. // -static void GIF_setpalette(void) +static RGBA_t *GIF_getpalette(size_t palnum) { // In hardware mode, uses the master palette - size_t palnum = (rendermode == render_soft) ? ((gif_localcolortable) ? max(st_palette, 0) : 0) : 0; - gif_palette = ((cv_screenshot_colorprofile.value + return ((gif_colorprofile #ifdef HWRENDER && (rendermode == render_soft) #endif @@ -416,12 +419,11 @@ static void GIF_setpalette(void) // // GIF_palwrite // writes the gif palette. -// used both for the header and the local color table. +// used both for the header and local color tables. // -static UINT8 *GIF_palwrite(UINT8 *p) +static UINT8 *GIF_palwrite(UINT8 *p, RGBA_t *pal) { INT32 i; - RGBA_t *pal = gif_palette; for (i = 0; i < 256; i++) { WRITEUINT8(p, pal[i].s.red); @@ -439,10 +441,7 @@ static void GIF_headwrite(void) { UINT8 *gifhead = Z_Malloc(800, PU_STATIC, NULL); UINT8 *p = gifhead; - UINT8 *last_p; UINT16 rwidth, rheight; - size_t totalbytes; - INT32 i; if (!gif_out) return; @@ -463,36 +462,22 @@ static void GIF_headwrite(void) rheight = vid.height; } - last_p = p; WRITEUINT16(p, rwidth); WRITEUINT16(p, rheight); // colors, aspect, etc - WRITEUINT8(p, (gif_localcolortable ? 0xF0 : 0xF7)); // (0xF7 = 1111 0111) + WRITEUINT8(p, 0xF7); // (0xF7 = 1111 0111) WRITEUINT8(p, 0x00); WRITEUINT8(p, 0x00); - // Lactozilla: should be 800 without a local color table - totalbytes = sizeof(gifhead_base) + sizeof(gifhead_nsid) + (p - last_p); - // write color table - if (!gif_localcolortable) - { - p = GIF_palwrite(p); - totalbytes += (256 * 3); - } - else - { - // write a dummy palette - for (i = 0; i < 6; i++, totalbytes++) - WRITEUINT8(p, 0); - } + p = GIF_palwrite(p, gif_headerpalette); // write extension block WRITEMEM(p, gifhead_nsid, sizeof(gifhead_nsid)); // write to file and be done with it! - fwrite(gifhead, 1, totalbytes, gif_out); + fwrite(gifhead, 1, 800, gif_out); Z_Free(gifhead); } @@ -514,7 +499,7 @@ static void hwrconvert(void) INT32 x, y; size_t i = 0; - InitColorLUT(gif_palette); + InitColorLUT(gif_framepalette); for (y = 0; y < vid.height; y++) { @@ -540,6 +525,7 @@ static void GIF_framewrite(void) UINT8 *p; UINT8 *movie_screen = screens[2]; INT32 blitx, blity, blitw, blith; + boolean palchanged; if (!gifframe_data) gifframe_data = Z_Malloc(gifframe_size, PU_STATIC, NULL); @@ -548,8 +534,18 @@ static void GIF_framewrite(void) if (!gif_out) return; + // Lactozilla: Compare the header's palette with the current frame's palette and see if it changed. + if (gif_localcolortable) + { + gif_framepalette = GIF_getpalette((rendermode == render_soft) ? ((gif_localcolortable) ? max(st_palette, 0) : 0) : 0); + palchanged = memcmp(gif_headerpalette, gif_framepalette, sizeof(RGBA_t) * 256); + } + else + palchanged = false; + // Compare image data (for optimizing GIF) - if (gif_optimize && gif_frames > 0) + // If the palette has changed, the entire frame is considered to be different. + if (gif_optimize && gif_frames > 0 && (!palchanged)) { // before blit movie_screen points to last frame, cur_screen points to this frame UINT8 *cur_screen = screens[0]; @@ -617,9 +613,14 @@ static void GIF_framewrite(void) WRITEUINT8(p, 0); // no local table of colors else { - WRITEUINT8(p, 0x87); // (0x87 = 1000 0111) - GIF_setpalette(); - p = GIF_palwrite(p); + if (palchanged) + { + // The palettes are different, so write the Local Color Table! + WRITEUINT8(p, 0x87); // (0x87 = 1000 0111) + p = GIF_palwrite(p, gif_framepalette); + } + else + WRITEUINT8(p, 0); // They are equal, no Local Color Table needed. } scrbuf_pos = movie_screen + blitx + (blity * vid.width); @@ -693,8 +694,8 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); gif_localcolortable = (!!cv_gif_localcolortable.value); - if (!gif_localcolortable) - GIF_setpalette(); + gif_colorprofile = (!!cv_screenshot_colorprofile.value); + gif_headerpalette = GIF_getpalette(0); GIF_headwrite(); gif_frames = 0; From d552e4a1c223237cdd32ee1f03657779346c7109 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 3 Feb 2020 02:12:55 -0300 Subject: [PATCH 28/40] Restore some functionality that went missing --- src/m_menu.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index d4ac61eb0..507d768cc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -320,6 +320,7 @@ menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef; menu_t OP_ServerOptionsDef; menu_t OP_MonitorToggleDef; static void M_ScreenshotOptions(INT32 choice); +static void M_SetupScreenshotMenu(void); static void M_EraseData(INT32 choice); static void M_Addons(INT32 choice); @@ -358,7 +359,6 @@ static void M_DrawMonitorToggles(void); static void M_OGL_DrawFogMenu(void); #endif #ifndef NONET -static void M_DrawScreenshotMenu(void); static void M_DrawConnectMenu(void); static void M_DrawMPMainMenu(void); static void M_DrawRoomMenu(void); @@ -1454,6 +1454,7 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = enum { op_screenshot_colorprofile = 1, + op_screenshot_storagelocation = 3, op_screenshot_folder = 4, op_movie_folder = 11, op_screenshot_capture = 12, @@ -3673,6 +3674,9 @@ void M_Ticker(void) if (--vidm_testingmode == 0) setmodeneeded = vidm_previousmode + 1; } + + if (currentMenu == &OP_ScreenshotOptionsDef) + M_SetupScreenshotMenu(); } // @@ -11090,9 +11094,27 @@ static void M_ScreenshotOptions(INT32 choice) Screenshot_option_Onchange(); Moviemode_mode_Onchange(); + M_SetupScreenshotMenu(); M_SetupNextMenu(&OP_ScreenshotOptionsDef); } +static void M_SetupScreenshotMenu(void) +{ + menuitem_t *item = &OP_ScreenshotOptionsMenu[op_screenshot_colorprofile]; + +#ifdef HWRENDER + // Hide some options based on render mode + if (rendermode == render_opengl) + { + item->status = IT_GRAYEDOUT; + if ((currentMenu == &OP_ScreenshotOptionsDef) && (itemOn == op_screenshot_colorprofile)) // Can't select that + itemOn = op_screenshot_storagelocation; + } + else +#endif + item->status = (IT_STRING | IT_CVAR); +} + // ============= // JOYSTICK MENU // ============= @@ -11953,6 +11975,15 @@ static void M_HandleVideoMode(INT32 ch) static void M_DrawScreenshotMenu(void) { M_DrawGenericScrollMenu(); +#ifdef HWRENDER + if ((rendermode == render_opengl) && (itemOn < 7)) // where it starts to go offscreen; change this number if you change the layout of the screenshot menu + { + INT32 y = currentMenu->y+currentMenu->menuitems[op_screenshot_colorprofile].alphaKey*2; + if (itemOn == 6) + y -= 10; + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, y, V_REDMAP, "Yes"); + } +#endif } // =============== From 3a6b710b2d8fcd05d64c74a47898806c695c30a3 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 3 Feb 2020 02:24:22 -0300 Subject: [PATCH 29/40] What --- src/m_anigif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 5394f569a..faa8f29e1 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -537,7 +537,7 @@ static void GIF_framewrite(void) // Lactozilla: Compare the header's palette with the current frame's palette and see if it changed. if (gif_localcolortable) { - gif_framepalette = GIF_getpalette(gif_localcolortable ? max(st_palette, 0) : 0); + gif_framepalette = GIF_getpalette(max(st_palette, 0)); palchanged = memcmp(gif_headerpalette, gif_framepalette, sizeof(RGBA_t) * 256); } else From 6568a57c58f697a49952519de680d60a5ce825f2 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 8 Feb 2020 20:29:28 -0300 Subject: [PATCH 30/40] allow models for skin/sprites with same name --- src/hardware/hw_md2.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d1d6e91a2..50c169815 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -521,15 +521,10 @@ void HWR_InitModels(void) { if (stricmp(name, sprnames[i]) == 0) { - //if (stricmp(name, "PLAY") == 0) - //continue; - - //CONS_Debug(DBG_RENDER, " Found: %s %s %f %f\n", name, filename, scale, offset); md2_models[i].scale = scale; md2_models[i].offset = offset; md2_models[i].notfound = false; strcpy(md2_models[i].filename, filename); - goto md2found; } } @@ -537,18 +532,14 @@ void HWR_InitModels(void) { if (stricmp(name, skins[s].name) == 0) { - //CONS_Printf(" Found: %s %s %f %f\n", name, filename, scale, offset); md2_playermodels[s].skin = s; md2_playermodels[s].scale = scale; md2_playermodels[s].offset = offset; md2_playermodels[s].notfound = false; strcpy(md2_playermodels[s].filename, filename); - goto md2found; } } - // no sprite/player skin name found?!? - //CONS_Printf("Unknown sprite/player skin %s detected in models.dat\n", name); -md2found: + // move on to next line... continue; } @@ -591,7 +582,6 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup } } - //CONS_Printf("Model for player skin %s not found\n", skins[skin].name); md2_playermodels[skin].notfound = true; playermd2found: fclose(f); @@ -635,7 +625,6 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s } } - //CONS_Printf("MD2 for sprite %s not found\n", sprnames[spritenum]); md2_models[spritenum].notfound = true; spritemd2found: fclose(f); From f5a46bd70fd6403188236c793ecbfa025c6a75e4 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sun, 9 Feb 2020 16:11:52 -0300 Subject: [PATCH 31/40] Don't add a TOL_ twice. --- src/dehacked.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 45f00b8cf..1c4be1d03 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -585,17 +585,26 @@ static void readfreeslots(MYFILE *f) continue; // Copy in the spr2 name and increment free_spr2. if (free_spr2 < NUMPLAYERSPRITES) { - CONS_Printf("Sprite SPR2_%s allocated.\n",word); strncpy(spr2names[free_spr2],word,4); spr2defaults[free_spr2] = 0; spr2names[free_spr2++][4] = 0; } else - CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); + deh_warning("Ran out of free SPR2 slots!\n"); } else if (fastcmp(type, "TOL")) { - if (lastcustomtol > 31) - CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); + // Search if we already have a typeoflevel by that name... + for (i = 0; i < numtolinfo; i++) + if (fastcmp(word, TYPEOFLEVEL[i].name)) + break; + + // We found it? Then don't allocate another one. + if (i < numtolinfo) + continue; + + // We don't, so freeslot it. + if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + deh_warning("Ran out of free typeoflevel slots!\n"); else { G_AddTOL((1< 31) - CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); - else - { - UINT32 newtol = (1<= numtolinfo) { + if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); + else { + UINT32 newtol = (1< Date: Sun, 9 Feb 2020 17:53:30 -0600 Subject: [PATCH 32/40] Expose stoppedclock to Lua --- src/lua_script.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 2538fb711..eb6c54ae0 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -102,6 +102,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"circuitmap")) { lua_pushboolean(L, circuitmap); return 1; + } else if (fastcmp(word,"stoppedclock")) { + lua_pushboolean(L, stoppedclock); + return 1; } else if (fastcmp(word,"netgame")) { lua_pushboolean(L, netgame); return 1; From 862f21d1b2e93cbffaa0bf8ce872a9ecfb6f053c Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 10 Feb 2020 01:00:37 -0600 Subject: [PATCH 33/40] Get rotated sprites with v.getSprite(2)Patch NOTE: since rotated sprites are offset upward by 4px from non-rotated sprites, these functions will now return a third boolean (true) if a rotated sprite was returned, so that scripters can offset accordingly. --- src/lua_hudlib.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f451944e3..9138ae1f8 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -424,7 +424,7 @@ static int libd_cachePatch(lua_State *L) return 1; } -// v.getSpritePatch(sprite, [frame, [angle]]) +// v.getSpritePatch(sprite, [frame, [angle, [rollangle]]]) static int libd_getSpritePatch(lua_State *L) { UINT32 i; // sprite prefix @@ -475,13 +475,31 @@ static int libd_getSpritePatch(lua_State *L) if (angle >= ((sprframe->rotate & SRF_3DGE) ? 16 : 8)) // out of range? return 0; +#ifdef ROTSPRITE + if (lua_isnumber(L, 4)) + { + // rotsprite????? + angle_t rollangle = luaL_checkangle(L, 4); + INT32 rot = R_GetRollAngle(rollangle); + + if (rot) { + if (!(sprframe->rotsprite.cached & (1<flip & (1<rotsprite.patch[angle][rot], META_PATCH); + lua_pushboolean(L, false); + lua_pushboolean(L, true); + return 3; + } + } +#endif + // push both the patch and it's "flip" value LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_PATCH), META_PATCH); lua_pushboolean(L, (sprframe->flip & (1<= ((sprframe->rotate & SRF_3DGE) ? 16 : 8)) // out of range? return 0; +#ifdef ROTSPRITE + if (lua_isnumber(L, 4)) + { + // rotsprite????? + angle_t rollangle = luaL_checkangle(L, 4); + INT32 rot = R_GetRollAngle(rollangle); + + if (rot) { + if (!(sprframe->rotsprite.cached & (1<flip & (1<rotsprite.patch[angle][rot], META_PATCH); + lua_pushboolean(L, false); + lua_pushboolean(L, true); + return 3; + } + } +#endif + // push both the patch and it's "flip" value LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_PATCH), META_PATCH); lua_pushboolean(L, (sprframe->flip & (1< Date: Tue, 11 Feb 2020 23:54:39 -0300 Subject: [PATCH 34/40] player model prefix --- src/hardware/hw_md2.c | 79 ++++++++++++++++++++++++++++++------------- src/hardware/hw_md2.h | 2 ++ 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 50c169815..33bed3e46 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -476,7 +476,7 @@ void HWR_InitModels(void) size_t i; INT32 s; FILE *f; - char name[18], filename[32]; + char name[22], filename[32]; float scale, offset; CONS_Printf("HWR_InitModels()...\n"); @@ -509,37 +509,51 @@ void HWR_InitModels(void) nomd2s = true; return; } - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) + + while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4) { - if (stricmp(name, "PLAY") == 0) + char *skinname = name; + size_t len = strlen(name); + + // check for the skin model prefix. + if (strnicmp(name, PLAYERMODELPREFIX, 4) == 0 && len > 4) { - CONS_Printf("Model for sprite PLAY detected in models.dat, use a player skin instead!\n"); - continue; + skinname += 4; + goto addskinmodel; } - for (i = 0; i < NUMSPRITES; i++) + // add sprite model + if (len == 4) // must be 4 characters long exactly. otherwise it's not a sprite name. { - if (stricmp(name, sprnames[i]) == 0) + for (i = 0; i < NUMSPRITES; i++) { - md2_models[i].scale = scale; - md2_models[i].offset = offset; - md2_models[i].notfound = false; - strcpy(md2_models[i].filename, filename); + if (stricmp(name, sprnames[i]) == 0) + { + md2_models[i].scale = scale; + md2_models[i].offset = offset; + md2_models[i].notfound = false; + strcpy(md2_models[i].filename, filename); + goto modelfound; + } } } +addskinmodel: + // add skin model for (s = 0; s < MAXSKINS; s++) { - if (stricmp(name, skins[s].name) == 0) + if (stricmp(skinname, skins[s].name) == 0) { md2_playermodels[s].skin = s; md2_playermodels[s].scale = scale; md2_playermodels[s].offset = offset; md2_playermodels[s].notfound = false; strcpy(md2_playermodels[s].filename, filename); + goto modelfound; } } +modelfound: // move on to next line... continue; } @@ -549,7 +563,7 @@ void HWR_InitModels(void) void HWR_AddPlayerModel(int skin) // For skins that were added after startup { FILE *f; - char name[18], filename[32]; + char name[22], filename[32]; float scale, offset; if (nomd2s) @@ -568,31 +582,37 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup return; } - // Check for any model that match the names of player skins! - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) + // Check for any models that match the names of player skins! + while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4) { - if (stricmp(name, skins[skin].name) == 0) + // ignore the skin model prefix. + char *skinname = name; + if (!strnicmp(name, PLAYERMODELPREFIX, 4)) + skinname += 4; + + if (stricmp(skinname, skins[skin].name) == 0) { md2_playermodels[skin].skin = skin; md2_playermodels[skin].scale = scale; md2_playermodels[skin].offset = offset; md2_playermodels[skin].notfound = false; strcpy(md2_playermodels[skin].filename, filename); - goto playermd2found; + goto playermodelfound; } } md2_playermodels[skin].notfound = true; -playermd2found: +playermodelfound: fclose(f); } void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after startup { FILE *f; - // name[18] is used to check for names in the models.dat file that match with sprites or player skins + // name[22] is used to check for names in the models.dat file that match with sprites or player skins // sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long - char name[18], filename[32]; + // PLAYERMODELPREFIX is 4 characters long + char name[22], filename[32]; float scale, offset; if (nomd2s) @@ -612,21 +632,32 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s return; } - // Check for any MD2s that match the names of sprite names! - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) + // Check for any models that match the names of sprite names! + while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4) { + // length of the sprite name + size_t len = strlen(name); + + // check for the skin model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, 4)) + continue; // that's not a sprite... + + // must be 4 characters long exactly. otherwise it's not a sprite name. + if (len != 4) + continue; + if (stricmp(name, sprnames[spritenum]) == 0) { md2_models[spritenum].scale = scale; md2_models[spritenum].offset = offset; md2_models[spritenum].notfound = false; strcpy(md2_models[spritenum].filename, filename); - goto spritemd2found; + goto spritemodelfound; } } md2_models[spritenum].notfound = true; -spritemd2found: +spritemodelfound: fclose(f); } diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 6f5985a44..40dbdf079 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -49,4 +49,6 @@ void HWR_AddPlayerModel(INT32 skin); void HWR_AddSpriteModel(size_t spritenum); boolean HWR_DrawModel(gr_vissprite_t *spr); +#define PLAYERMODELPREFIX "SKIN" + #endif // _HW_MD2_H_ From 83112c82486d27ddea9edadee4b1a3618da7fa0b Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 12 Feb 2020 13:41:30 -0300 Subject: [PATCH 35/40] Add MAXTOL --- src/dehacked.c | 56 +++++++++++--------------------------------------- src/doomstat.h | 9 ++++---- src/g_game.c | 42 +++++++++++++++++++++++++++++++------ 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 958eaad32..79d0b46dd 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -594,21 +594,21 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "TOL")) { // Search if we already have a typeoflevel by that name... - for (i = 0; i < numtolinfo; i++) + for (i = 0; TYPEOFLEVEL[i].name; i++) if (fastcmp(word, TYPEOFLEVEL[i].name)) break; // We found it? Then don't allocate another one. - if (i < numtolinfo) + if (TYPEOFLEVEL[i].name) continue; // We don't, so freeslot it. - if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. deh_warning("Ran out of free typeoflevel slots!\n"); else { - G_AddTOL((1<= numtolinfo) { - if (lastcustomtol > 31) // Unless you have way too many, since they're flags. + if (TYPEOFLEVEL[i].name == NULL) { + if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); else { - UINT32 newtol = (1< Date: Wed, 12 Feb 2020 13:59:08 -0300 Subject: [PATCH 36/40] Cast Moment --- src/dehacked.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 79d0b46dd..4d1147276 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -603,7 +603,7 @@ static void readfreeslots(MYFILE *f) continue; // We don't, so freeslot it. - if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. deh_warning("Ran out of free typeoflevel slots!\n"); else { @@ -10454,7 +10454,7 @@ static inline int lib_freeslot(lua_State *L) // We don't, so allocate a new one. if (TYPEOFLEVEL[i].name == NULL) { - if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags. + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); else { CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word); From fc81f2dce5a8e19f1026bc30eec8216e8a1dd477 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 15 Feb 2020 12:40:41 -0300 Subject: [PATCH 37/40] change prefix to "PLAYER" --- src/hardware/hw_md2.c | 52 +++++++++++++++++++++++++------------------ src/hardware/hw_md2.h | 2 +- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 33bed3e46..6c4801cc7 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -476,8 +476,9 @@ void HWR_InitModels(void) size_t i; INT32 s; FILE *f; - char name[22], filename[32]; + char name[24], filename[32]; float scale, offset; + size_t prefixlen; CONS_Printf("HWR_InitModels()...\n"); for (s = 0; s < MAXSKINS; s++) @@ -510,15 +511,18 @@ void HWR_InitModels(void) return; } - while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4) + // length of the player model prefix + prefixlen = strlen(PLAYERMODELPREFIX); + + while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4) { char *skinname = name; size_t len = strlen(name); - // check for the skin model prefix. - if (strnicmp(name, PLAYERMODELPREFIX, 4) == 0 && len > 4) + // check for the player model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, prefixlen) && (len > prefixlen)) { - skinname += 4; + skinname += prefixlen; goto addskinmodel; } @@ -539,7 +543,7 @@ void HWR_InitModels(void) } addskinmodel: - // add skin model + // add player model for (s = 0; s < MAXSKINS; s++) { if (stricmp(skinname, skins[s].name) == 0) @@ -563,8 +567,9 @@ modelfound: void HWR_AddPlayerModel(int skin) // For skins that were added after startup { FILE *f; - char name[22], filename[32]; + char name[24], filename[32]; float scale, offset; + size_t prefixlen; if (nomd2s) return; @@ -582,13 +587,18 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup return; } + // length of the player model prefix + prefixlen = strlen(PLAYERMODELPREFIX); + // Check for any models that match the names of player skins! - while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4) + while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4) { - // ignore the skin model prefix. char *skinname = name; - if (!strnicmp(name, PLAYERMODELPREFIX, 4)) - skinname += 4; + size_t len = strlen(name); + + // ignore the player model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, prefixlen) && (len > prefixlen)) + skinname += prefixlen; if (stricmp(skinname, skins[skin].name) == 0) { @@ -609,10 +619,10 @@ playermodelfound: void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after startup { FILE *f; - // name[22] is used to check for names in the models.dat file that match with sprites or player skins + // name[24] is used to check for names in the models.dat file that match with sprites or player skins // sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long - // PLAYERMODELPREFIX is 4 characters long - char name[22], filename[32]; + // PLAYERMODELPREFIX is 6 characters long + char name[24], filename[32]; float scale, offset; if (nomd2s) @@ -633,19 +643,17 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s } // Check for any models that match the names of sprite names! - while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4) + while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4) { // length of the sprite name size_t len = strlen(name); - - // check for the skin model prefix. - if (!strnicmp(name, PLAYERMODELPREFIX, 4)) - continue; // that's not a sprite... - - // must be 4 characters long exactly. otherwise it's not a sprite name. - if (len != 4) + if (len != 4) // must be 4 characters long exactly. otherwise it's not a sprite name. continue; + // check for the player model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, strlen(PLAYERMODELPREFIX))) + continue; // that's not a sprite... + if (stricmp(name, sprnames[spritenum]) == 0) { md2_models[spritenum].scale = scale; diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 40dbdf079..3bbe30053 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -49,6 +49,6 @@ void HWR_AddPlayerModel(INT32 skin); void HWR_AddSpriteModel(size_t spritenum); boolean HWR_DrawModel(gr_vissprite_t *spr); -#define PLAYERMODELPREFIX "SKIN" +#define PLAYERMODELPREFIX "PLAYER" #endif // _HW_MD2_H_ From 23f148f32dae1c767afb3ab8a9b9fb02705e3868 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 15 Feb 2020 13:07:53 -0300 Subject: [PATCH 38/40] Fix overtime not working --- src/g_game.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index efc96a50f..0d89a0cf6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3203,17 +3203,17 @@ UINT32 gametypedefaultrules[NUMGAMETYPES] = GTR_RACE|GTR_SPAWNENEMIES|GTR_SPAWNINVUL|GTR_ALLOWEXIT, // Match - GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_POWERSTONES|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD|GTR_DEATHPENALTY, + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_POWERSTONES|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD|GTR_DEATHPENALTY, // Team Match - GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_TEAMS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD, + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_TEAMS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD, // Tag - GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_TAG|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_STARTCOUNTDOWN|GTR_BLINDFOLDED|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY, + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_TAG|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_STARTCOUNTDOWN|GTR_BLINDFOLDED|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY, // Hide and Seek - GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_TAG|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_STARTCOUNTDOWN|GTR_BLINDFOLDED|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY, + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_TAG|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_STARTCOUNTDOWN|GTR_BLINDFOLDED|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY, // CTF - GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_TEAMS|GTR_TEAMFLAGS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_POWERSTONES|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD, + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_TEAMS|GTR_TEAMFLAGS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_POWERSTONES|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD, }; // From 4c4596a45f64be89ec57ca857bb94421e6911e22 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sun, 16 Feb 2020 20:19:24 +0100 Subject: [PATCH 39/40] Clean up the mess that is extracolormap_t::fog --- src/hardware/hw_main.c | 14 ++---------- src/p_saveg.c | 10 ++++----- src/p_spec.c | 17 +++++++-------- src/r_data.c | 48 +++++++++++++++++++++--------------------- src/r_data.h | 10 ++++----- src/r_defs.h | 5 ++++- src/r_plane.c | 15 ++----------- src/r_segs.c | 30 ++++++++++++-------------- src/r_things.c | 6 +++--- 9 files changed, 66 insertions(+), 89 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7e913c4c7..5dd222dfd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5022,12 +5022,7 @@ void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boo planeinfo[numplanes].isceiling = isceiling; planeinfo[numplanes].fixedheight = fixedheight; - - if (planecolormap && (planecolormap->fog & 1)) - planeinfo[numplanes].lightlevel = lightlevel; - else - planeinfo[numplanes].lightlevel = 255; - + planeinfo[numplanes].lightlevel = (planecolormap && (planecolormap->flags & CMF_FOG)) ? lightlevel : 255; planeinfo[numplanes].levelflat = levelflat; planeinfo[numplanes].xsub = xsub; planeinfo[numplanes].alpha = alpha; @@ -5059,12 +5054,7 @@ void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polyse polyplaneinfo[numpolyplanes].isceiling = isceiling; polyplaneinfo[numpolyplanes].fixedheight = fixedheight; - - if (planecolormap && (planecolormap->fog & 1)) - polyplaneinfo[numpolyplanes].lightlevel = lightlevel; - else - polyplaneinfo[numpolyplanes].lightlevel = 255; - + polyplaneinfo[numpolyplanes].lightlevel = (planecolormap && (planecolormap->flags & CMF_FOG)) ? lightlevel : 255; polyplaneinfo[numpolyplanes].levelflat = levelflat; polyplaneinfo[numpolyplanes].polysector = polysector; polyplaneinfo[numpolyplanes].alpha = alpha; diff --git a/src/p_saveg.c b/src/p_saveg.c index 853856880..31ac79931 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -609,7 +609,7 @@ static void P_NetArchiveColormaps(void) WRITEUINT8(save_p, exc->fadestart); WRITEUINT8(save_p, exc->fadeend); - WRITEUINT8(save_p, exc->fog); + WRITEUINT8(save_p, exc->flags); WRITEINT32(save_p, exc->rgba); WRITEINT32(save_p, exc->fadergba); @@ -639,7 +639,7 @@ static void P_NetUnArchiveColormaps(void) for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { - UINT8 fadestart, fadeend, fog; + UINT8 fadestart, fadeend, flags; INT32 rgba, fadergba; #ifdef EXTRACOLORMAPLUMPS char lumpname[9]; @@ -647,7 +647,7 @@ static void P_NetUnArchiveColormaps(void) fadestart = READUINT8(save_p); fadeend = READUINT8(save_p); - fog = READUINT8(save_p); + flags = READUINT8(save_p); rgba = READINT32(save_p); fadergba = READINT32(save_p); @@ -679,7 +679,7 @@ static void P_NetUnArchiveColormaps(void) exc->fadestart = fadestart; exc->fadeend = fadeend; - exc->fog = fog; + exc->flags = flags; exc->rgba = rgba; exc->fadergba = fadergba; @@ -689,7 +689,7 @@ static void P_NetUnArchiveColormaps(void) exc->lumpname[0] = 0; #endif - existing_exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); + existing_exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags); if (existing_exc) exc->colormap = existing_exc->colormap; diff --git a/src/p_spec.c b/src/p_spec.c index 76a80d754..28d48d5d8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3516,7 +3516,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) false, // subtract FadeA (no flag for this, just pass negative alpha) false, // subtract FadeStart (we ran out of flags) false, // subtract FadeEnd (we ran out of flags) - false, // ignore Fog (we ran out of flags) + false, // ignore Flags (we ran out of flags) line->flags & ML_DONTPEGBOTTOM, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, @@ -3883,7 +3883,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) false, // subtract FadeA (no flag for this, just pass negative alpha) false, // subtract FadeStart (we ran out of flags) false, // subtract FadeEnd (we ran out of flags) - false, // ignore Fog (we ran out of flags) + false, // ignore Flags (we ran out of flags) line->flags & ML_DONTPEGBOTTOM, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, @@ -7081,10 +7081,9 @@ void P_SpawnSpecials(boolean fromnetsave) case 202: // Fog ffloorflags = FF_EXISTS|FF_RENDERALL|FF_FOG|FF_BOTHPLANES|FF_INVERTPLANES|FF_ALLSIDES|FF_INVERTSIDES|FF_CUTEXTRA|FF_EXTRA|FF_DOUBLESHADOW|FF_CUTSPRITES; sec = sides[*lines[i].sidenum].sector - sectors; - // SoM: Because it's fog, check for an extra colormap and set - // the fog flag... + // SoM: Because it's fog, check for an extra colormap and set the fog flag... if (sectors[sec].extra_colormap) - sectors[sec].extra_colormap->fog = 1; + sectors[sec].extra_colormap->flags = CMF_FOG; P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; @@ -8472,7 +8471,7 @@ void T_FadeColormap(fadecolormap_t *d) extracolormap_t *exc; INT32 duration = d->ticbased ? d->duration : 256; fixed_t factor = min(FixedDiv(duration - d->timer, duration), 1*FRACUNIT); - INT16 cr, cg, cb, ca, fadestart, fadeend, fog; + INT16 cr, cg, cb, ca, fadestart, fadeend, flags; INT32 rgba, fadergba; // NULL failsafes (or intentionally set to signify default) @@ -8521,7 +8520,7 @@ void T_FadeColormap(fadecolormap_t *d) fadestart = APPLYFADE(d->dest_exc->fadestart, d->source_exc->fadestart, d->sector->extra_colormap->fadestart); fadeend = APPLYFADE(d->dest_exc->fadeend, d->source_exc->fadeend, d->sector->extra_colormap->fadeend); - fog = abs(factor) > FRACUNIT/2 ? d->dest_exc->fog : d->source_exc->fog; // set new fog flag halfway through fade + flags = abs(factor) > FRACUNIT/2 ? d->dest_exc->flags : d->source_exc->flags; // set new flags halfway through fade #undef APPLYFADE @@ -8529,12 +8528,12 @@ void T_FadeColormap(fadecolormap_t *d) // setup new colormap ////////////////// - if (!(d->sector->extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog))) + if (!(d->sector->extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags))) { exc = R_CreateDefaultColormap(false); exc->fadestart = fadestart; exc->fadeend = fadeend; - exc->fog = (boolean)fog; + exc->flags = flags; exc->rgba = rgba; exc->fadergba = fadergba; exc->colormap = R_CreateLightTable(exc); diff --git a/src/r_data.c b/src/r_data.c index 5608fdbde..f5a24c2c4 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1799,7 +1799,7 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable) extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->fadestart = 0; exc->fadeend = 31; - exc->fog = 0; + exc->flags = 0; exc->rgba = 0; exc->fadergba = 0x19000000; exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL; @@ -1903,17 +1903,17 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) // #ifdef EXTRACOLORMAPLUMPS boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump) + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump) #else boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog) + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags) #endif { return ( (!checkparams ? true : (fadestart == 0 && fadeend == 31 - && !fog) + && !flags) ) && (!checkrgba ? true : rgba == 0) && (!checkfadergba ? true : fadergba == 0x19000000) @@ -1930,9 +1930,9 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb return true; #ifdef EXTRACOLORMAPLUMPS - return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags, extra_colormap->lump); #else - return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags); #endif } @@ -1952,7 +1952,7 @@ boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, bo (!checkparams ? true : (exc_a->fadestart == exc_b->fadestart && exc_a->fadeend == exc_b->fadeend - && exc_a->fog == exc_b->fog) + && exc_a->flags == exc_b->flags) ) && (!checkrgba ? true : exc_a->rgba == exc_b->rgba) && (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba) @@ -1968,9 +1968,9 @@ boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, bo // NOTE: Returns NULL if no match is found // #ifdef EXTRACOLORMAPLUMPS -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump) +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump) #else -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog) +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags) #endif { extracolormap_t *exc; @@ -1982,7 +1982,7 @@ extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend - && fog == exc->fog + && flags == exc->flags #ifdef EXTRACOLORMAPLUMPS && (lump != LUMPERROR && lump == exc->lump) #endif @@ -2001,9 +2001,9 @@ extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) { #ifdef EXTRACOLORMAPLUMPS - return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags, extra_colormap->lump); #else - return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags); #endif } @@ -2035,7 +2035,7 @@ extracolormap_t *R_ColormapForName(char *name) // is no real way to tell how GL should handle a colormap lump anyway.. exc->fadestart = 0; exc->fadeend = 31; - exc->fog = 0; + exc->flags = 0; exc->rgba = 0; exc->fadergba = 0x19000000; @@ -2192,7 +2192,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // default values UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; UINT32 fadestart = 0, fadeend = 31; - UINT8 fog = 0; + UINT8 flags = 0; INT32 rgba = 0, fadergba = 0x19000000; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) @@ -2241,12 +2241,12 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) #define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) - // Get parameters like fadestart, fadeend, and the fogflag + // Get parameters like fadestart, fadeend, and flags if (p2[0] == '#') { if (p2[1]) { - fog = NUMFROMCHAR(p2[1]); + flags = NUMFROMCHAR(p2[1]); if (p2[2] && p2[3]) { fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); @@ -2313,18 +2313,18 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // Did we just make a default colormap? #ifdef EXTRACOLORMAPLUMPS - if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, flags, LUMPERROR)) return NULL; #else - if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, flags)) return NULL; #endif // Look for existing colormaps #ifdef EXTRACOLORMAPLUMPS - exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags, LUMPERROR); #else - exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags); #endif if (exc) return exc; @@ -2336,7 +2336,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; - extra_colormap->fog = fog; + extra_colormap->flags = flags; extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; @@ -2363,7 +2363,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, - boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFlags, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { @@ -2451,8 +2451,8 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex // HACK: fadeend defaults to 31, so don't add anything in this case , 31), 0); - if (!ignoreFog) // overwrite fog with new value - exc_augend->fog = exc_addend->fog; + if (!ignoreFlags) // overwrite flags with new value + exc_augend->flags = exc_addend->flags; /////////////////// // put it together diff --git a/src/r_data.h b/src/r_data.h index 145f0182b..0569893cd 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -135,12 +135,12 @@ void R_AddColormapToList(extracolormap_t *extra_colormap); #ifdef EXTRACOLORMAPLUMPS boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump); -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump); + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump); #else boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog); -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog); + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); @@ -151,7 +151,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, - boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFlags, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable); #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_defs.h b/src/r_defs.h index 88d418fc9..f2774edbc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,11 +53,14 @@ typedef struct // Could even use more than 32 levels. typedef UINT8 lighttable_t; +#define CMF_FADEFULLBRIGHTSPRITES 1 +#define CMF_FOG 4 + // ExtraColormap type. Use for extra_colormaps from now on. typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fog; // categorical value, not boolean + UINT8 flags; // store rgba values in combined bitwise // also used in OpenGL instead lighttables diff --git a/src/r_plane.c b/src/r_plane.c index 5d5e1f20d..e62e571e4 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -44,9 +44,6 @@ // Quincunx antialiasing of flats! //#define QUINCUNX -// good night sweet prince -#define SHITPLANESPARENCY - //SoM: 3/23/2000: Use Boom visplane hashing. visplane_t *visplanes[MAXVISPLANES]; @@ -995,11 +992,7 @@ void R_DrawSinglePlane(visplane_t *pl) else // Opaque, but allow transparent flat pixels spanfunctype = SPANDRAWFUNC_SPLAT; -#ifdef SHITPLANESPARENCY - if ((spanfunctype == SPANDRAWFUNC_SPLAT) != (pl->extra_colormap && (pl->extra_colormap->fog & 4))) -#else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) -#endif + if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); else light = LIGHTLEVELS-1; @@ -1053,11 +1046,7 @@ void R_DrawSinglePlane(visplane_t *pl) else // Opaque, but allow transparent flat pixels spanfunctype = SPANDRAWFUNC_SPLAT; -#ifdef SHITPLANESPARENCY - if ((spanfunctype == SPANDRAWFUNC_SPLAT) != (pl->extra_colormap && (pl->extra_colormap->fog & 4))) -#else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) -#endif + if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); else light = LIGHTLEVELS-1; diff --git a/src/r_segs.c b/src/r_segs.c index dcb5fc160..88897ab8e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -418,14 +418,14 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) rlight->extra_colormap = *light->extra_colormap; rlight->flags = light->flags; - if (rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) + if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) + || (rlight->flags & FF_FOG) + || (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG))) lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); - else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY]) - lightnum = LIGHTLEVELS - 1; else - lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); + lightnum = LIGHTLEVELS - 1; - if (rlight->extra_colormap && rlight->extra_colormap->fog) + if (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG)) ; else if (curline->v1->y == curline->v2->y) lightnum--; @@ -437,18 +437,14 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else { - if (colfunc == colfuncs[COLDRAWFUNC_FUZZY]) - { - if (frontsector->extra_colormap && frontsector->extra_colormap->fog) - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - else - lightnum = LIGHTLEVELS - 1; - } - else + if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) + || frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG)) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); + else + lightnum = LIGHTLEVELS - 1; if (colfunc == colfuncs[COLDRAWFUNC_FOG] - || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) + || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) ; else if (curline->v1->y == curline->v2->y) lightnum--; @@ -947,7 +943,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else rlight->lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); - if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) + if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG))) ; else if (curline->v1->y == curline->v2->y) rlight->lightnum--; @@ -962,7 +958,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else { // Get correct light level! - if ((frontsector->extra_colormap && frontsector->extra_colormap->fog)) + if ((frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); else if (pfloor->flags & FF_FOG) lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT); @@ -972,7 +968,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false) ->lightlevel >> LIGHTSEGSHIFT; - if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog)); + if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))); else if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) diff --git a/src/r_things.c b/src/r_things.c index ca285644f..cf81e3e04 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1094,8 +1094,8 @@ static void R_SplitSprite(vissprite_t *sprite) newsprite->extra_colormap = *sector->lightlist[i].extra_colormap; - if (!((newsprite->cut & SC_FULLBRIGHT) - && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) + if (!(newsprite->cut & SC_FULLBRIGHT) + || (newsprite->extra_colormap && (newsprite->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) { lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); @@ -1882,7 +1882,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->cut |= SC_FULLBRIGHT; if (vis->cut & SC_FULLBRIGHT - && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) + && (!vis->extra_colormap || !(vis->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) { // full bright: goggles vis->colormap = colormaps; From b8e143d253ac5e86c785bc1a41d38eef2cd4b0a8 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 16 Feb 2020 20:45:09 -0800 Subject: [PATCH 40/40] How many bruh moments can we have? --- src/r_segs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 88897ab8e..df998898f 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -438,7 +438,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else { if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) - || frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG)) + || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); else lightnum = LIGHTLEVELS - 1;