From 01f1933f69e09ccac0d0651465c412e93a354a20 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Dec 2018 14:05:58 -0500 Subject: [PATCH 01/32] Force directsound to fix wrong-pitch sound effects --- src/sdl/mixer_sound.c | 6 ++++++ src/sdl/sdl_sound.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 3f9b09f1..083ef005 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -92,6 +92,12 @@ void I_StartupSound(void) { I_Assert(!sound_started); +#ifdef _WIN32 + // Force DirectSound instead of WASAPI + // SDL 2.0.6+ defaults to the latter and it screws up our sound effects + SDL_setenv("SDL_AUDIODRIVER", "directsound", 1); +#endif + // EE inits audio first so we're following along. if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) { diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index f4796cd8..7fec9202 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1186,6 +1186,12 @@ void I_StartupSound(void) // Configure sound device CONS_Printf("I_StartupSound:\n"); + #ifdef _WIN32 + // Force DirectSound instead of WASAPI + // SDL 2.0.6+ defaults to the latter and it screws up our sound effects + SDL_setenv("SDL_AUDIODRIVER", "directsound", 1); + #endif + // EE inits audio first so we're following along. if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) CONS_Printf("SDL Audio already started\n"); From 47ee3525afed8c071c4bd2dec7251dec9db53214 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Dec 2018 14:10:09 -0500 Subject: [PATCH 02/32] Indentation --- src/sdl/sdl_sound.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 7fec9202..41210279 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1186,11 +1186,11 @@ void I_StartupSound(void) // Configure sound device CONS_Printf("I_StartupSound:\n"); - #ifdef _WIN32 - // Force DirectSound instead of WASAPI - // SDL 2.0.6+ defaults to the latter and it screws up our sound effects - SDL_setenv("SDL_AUDIODRIVER", "directsound", 1); - #endif +#ifdef _WIN32 + // Force DirectSound instead of WASAPI + // SDL 2.0.6+ defaults to the latter and it screws up our sound effects + SDL_setenv("SDL_AUDIODRIVER", "directsound", 1); +#endif // EE inits audio first so we're following along. if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) From 6b22dc183b11fc06cb0f43507f7f3336e64a4c44 Mon Sep 17 00:00:00 2001 From: MPC Date: Wed, 12 Dec 2018 18:01:52 -0300 Subject: [PATCH 03/32] Fix the automap --- src/am_map.c | 362 +++++++++++------------------------------ src/am_map.h | 3 + src/d_main.c | 23 ++- src/hardware/hw_draw.c | 12 -- src/hardware/hw_main.h | 1 - src/p_local.h | 3 - 6 files changed, 116 insertions(+), 288 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 6b97dd28..ee690017 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -11,8 +11,8 @@ /// \file am_map.c /// \brief Code for the 'automap', former Doom feature used for DEVMODE testing -#include "g_game.h" #include "am_map.h" +#include "g_game.h" #include "g_input.h" #include "p_local.h" #include "p_slopes.h" @@ -33,7 +33,6 @@ static const UINT8 GRAYSRANGE = 16; static const UINT8 BROWNS = (3*16); static const UINT8 YELLOWS = (7*16); static const UINT8 GREENS = (10*16); -static const UINT8 GREENRANGE = 16; static const UINT8 DBLACK = 31; static const UINT8 DWHITE = 0; @@ -50,8 +49,6 @@ static const UINT8 NOCLIMBYELLOWS = (11*16); // Automap colors #define BACKGROUND DBLACK -#define YOURCOLORS DWHITE -#define YOURRANGE 0 #define WALLCOLORS (REDS + REDRANGE/2) #define WALLRANGE (REDRANGE/2) #define NOCLIMBWALLCOLORS (NOCLIMBREDS + NOCLIMBREDRANGE/2) @@ -68,31 +65,23 @@ static const UINT8 NOCLIMBYELLOWS = (11*16); #define CDWALLCOLORS YELLOWS #define NOCLIMBCDWALLCOLORS NOCLIMBYELLOWS #define THINGCOLORS GREENS -#define THINGRANGE GREENRANGE -#define SECRETWALLCOLORS WALLCOLORS -#define SECRETWALLRANGE WALLRANGE #define GRIDCOLORS (GRAYS + GRAYSRANGE/2) -#define GRIDRANGE 0 #define XHAIRCOLORS GRAYS -// drawing stuff -#define FB 0 - -#define AM_PANDOWNKEY KEY_DOWNARROW +// controls #define AM_PANUPKEY KEY_UPARROW -#define AM_PANRIGHTKEY KEY_RIGHTARROW +#define AM_PANDOWNKEY KEY_DOWNARROW #define AM_PANLEFTKEY KEY_LEFTARROW +#define AM_PANRIGHTKEY KEY_RIGHTARROW + #define AM_ZOOMINKEY '=' #define AM_ZOOMOUTKEY '-' -#define AM_STARTKEY KEY_TAB -#define AM_ENDKEY KEY_TAB #define AM_GOBIGKEY '0' + #define AM_FOLLOWKEY 'f' #define AM_GRIDKEY 'g' -#define AM_MARKKEY 'm' -#define AM_CLEARMARKKEY 'c' -#define AM_NUMMARKPOINTS 10 +#define AM_TOGGLEKEY KEY_TAB // scale on entry #define INITSCALEMTOF (FRACUNIT/5) @@ -110,8 +99,11 @@ static const UINT8 NOCLIMBYELLOWS = (11*16); #define FTOM(x) FixedMul(((x)<>FRACBITS) // translates between frame-buffer and map coordinates -#define CXMTOF(x) (f_x + MTOF((x)-m_x)) -#define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) +#define CXMTOF(x) (f_x - (f_x/2) + MTOF((x)-m_x)) +#define CYMTOF(y) (f_y - (f_y/2) + (f_h - MTOF((y)-m_y))) + +#define MAPBITS (FRACBITS-4) +#define FRACTOMAPBITS (FRACBITS-MAPBITS) typedef struct { @@ -133,7 +125,10 @@ typedef struct // A line drawing of the player pointing right, // starting from the middle. // + +#define PLAYERRADIUS (16*(1< @@ -166,27 +161,15 @@ static const mline_t thintriangle_guy[] = { #undef R #define NUMTHINTRIANGLEGUYLINES (sizeof (thintriangle_guy)/sizeof (mline_t)) -static INT32 bigstate; //added : 24-01-98 : moved here, toggle between - // user view and large view (full map view) - -static INT32 grid = 0; - -static INT32 leveljuststarted = 1; // kluge until AM_LevelInit() is called +static boolean bigstate; // user view and large view (full map view) +static boolean draw_grid = false; boolean automapactive = false; boolean am_recalc = false; //added : 05-02-98 : true when screen size changes +static boolean am_stopped = true; -// location of window on screen -static INT32 f_x; -static INT32 f_y; - -// size of window on screen -static INT32 f_w; -static INT32 f_h; - -static INT32 lightlev; // used for funky strobing effect -static UINT8 *fb; // pseudo-frame buffer -static INT32 amclock; +static INT32 f_x, f_y; // location of window on screen (always zero for both) +static INT32 f_w, f_h; // size of window on screen (always the screen width and height respectively) static mpoint_t m_paninc; // how far the window pans each tic (map coords) static fixed_t mtof_zoommul; // how far the window zooms in each tic (map coords) @@ -210,11 +193,6 @@ static fixed_t max_y; static fixed_t max_w; // max_x-min_x, static fixed_t max_h; // max_y-min_y -// based on player size -static fixed_t min_w; -static fixed_t min_h; - - static fixed_t min_scale_mtof; // used to tell when to stop zooming out static fixed_t max_scale_mtof; // used to tell when to stop zooming in @@ -232,13 +210,7 @@ static fixed_t scale_ftom; static player_t *plr; // the player represented by an arrow -static patch_t *marknums[10]; // numbers used for marking by the automap -static mpoint_t markpoints[AM_NUMMARKPOINTS]; // where the points are -static INT32 markpointnum = 0; // next point to be assigned - -static INT32 followplayer = 1; // specifies whether to follow the player around - -static boolean stopped = true; +static INT32 followplayer = true; // specifies whether to follow the player around // function for drawing lines, depends on rendermode typedef void (*AMDRAWFLINEFUNC) (const fline_t *fl, INT32 color); @@ -277,8 +249,8 @@ static inline void AM_restoreScaleAndLoc(void) } else { - m_x = plr->mo->x - m_w/2; - m_y = plr->mo->y - m_h/2; + m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; + m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; } m_x2 = m_x + m_w; m_y2 = m_y + m_h; @@ -288,15 +260,6 @@ static inline void AM_restoreScaleAndLoc(void) scale_ftom = FixedDiv(FRACUNIT, scale_mtof); } -/** Adds a marker at the current location. - */ -static inline void AM_addMark(void) -{ - markpoints[markpointnum].x = m_x + m_w/2; - markpoints[markpointnum].y = m_y + m_h/2; - markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS; -} - /** Determines the bounding box around all vertices. * This is used to set global variables controlling the zoom range. */ @@ -322,11 +285,8 @@ static void AM_findMinMaxBoundaries(void) max_y = vertexes[i].y; } - max_w = max_x - min_x; - max_h = max_y - min_y; - - min_w = 2*PLAYERRADIUS; // const? never changed? - min_h = 2*PLAYERRADIUS; + max_w = (max_x >>= FRACTOMAPBITS) - (min_x >>= FRACTOMAPBITS); + max_h = (max_y >>= FRACTOMAPBITS) - (min_y >>= FRACTOMAPBITS); a = FixedDiv(f_w<mo->x - m_w/2; - m_y = plr->mo->y - m_h/2; + if (plr != NULL && plr->mo != NULL) + { + m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; + m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; + } AM_changeWindowLoc(); // for saving & restoring @@ -396,41 +355,27 @@ static void AM_initVariables(void) old_m_h = m_h; } -static const UINT8 *maplump; // pointer to the raw data for the automap background. - -/** Clears all map markers. - */ -static void AM_clearMarks(void) -{ - INT32 i; - - for (i = 0; i < AM_NUMMARKPOINTS; i++) - markpoints[i].x = -1; // means empty - markpointnum = 0; -} - // // should be called at the start of every level // right now, i figure it out myself // static void AM_LevelInit(void) { - leveljuststarted = 0; - f_x = f_y = 0; f_w = vid.width; f_h = vid.height; - if (rendermode == render_soft) - AM_drawFline = AM_drawFline_soft; -#ifdef HWRENDER // not win32 only 19990829 by Kin - else if (rendermode != render_none) + // Jimita +#ifdef MINIAUTOMAP + f_x = f_w / 2; + f_y = f_h / 2; +#endif + + AM_drawFline = AM_drawFline_soft; +#ifdef HWRENDER + if (rendermode == render_opengl) AM_drawFline = HWR_drawAMline; #endif - else - I_Error("Automap can't run without a render system"); - - AM_clearMarks(); AM_findMinMaxBoundaries(); scale_mtof = FixedDiv(min_scale_mtof*10, 7*FRACUNIT); @@ -446,7 +391,7 @@ static void AM_LevelInit(void) void AM_Stop(void) { automapactive = false; - stopped = true; + am_stopped = true; } /** Enables automap. @@ -457,15 +402,14 @@ static inline void AM_Start(void) { static INT32 lastlevel = -1; - if (!stopped) + if (!am_stopped) AM_Stop(); - stopped = false; + am_stopped = false; if (lastlevel != gamemap || am_recalc) // screen size changed { - am_recalc = false; - AM_LevelInit(); lastlevel = gamemap; + am_recalc = false; } AM_initVariables(); } @@ -503,7 +447,7 @@ boolean AM_Responder(event_t *ev) { if (!automapactive) { - if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) + if (ev->type == ev_keydown && ev->data1 == AM_TOGGLEKEY) { //faB: prevent alt-tab in win32 version to activate automap just before // minimizing the app; doesn't do any harm to the DOS version @@ -515,10 +459,8 @@ boolean AM_Responder(event_t *ev) } } } - else if (ev->type == ev_keydown) { - rc = true; switch (ev->data1) { @@ -554,7 +496,7 @@ boolean AM_Responder(event_t *ev) mtof_zoommul = M_ZOOMIN; ftom_zoommul = M_ZOOMOUT; break; - case AM_ENDKEY: + case AM_TOGGLEKEY: AM_Stop(); break; case AM_GOBIGKEY: @@ -572,13 +514,7 @@ boolean AM_Responder(event_t *ev) f_oldloc.x = INT32_MAX; break; case AM_GRIDKEY: - grid = !grid; - break; - case AM_MARKKEY: - AM_addMark(); - break; - case AM_CLEARMARKKEY: - AM_clearMarks(); + draw_grid = !draw_grid; break; default: rc = false; @@ -632,8 +568,8 @@ static inline void AM_doFollowPlayer(void) { if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { - m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; - m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; + m_x = FTOM(MTOF(plr->mo->x >> FRACTOMAPBITS)) - m_w/2; + m_y = FTOM(MTOF(plr->mo->y >> FRACTOMAPBITS)) - m_h/2; m_x2 = m_x + m_w; m_y2 = m_y + m_h; f_oldloc.x = plr->mo->x; @@ -651,8 +587,6 @@ void AM_Ticker(void) if (dedicated || !automapactive) return; - amclock++; - if (followplayer) AM_doFollowPlayer(); @@ -671,72 +605,7 @@ void AM_Ticker(void) */ static void AM_clearFB(INT32 color) { -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - { - HWR_clearAutomap(); - return; - } -#endif - - if (!maplump) - memset(fb, color, f_w*f_h*vid.bpp); - else - { - INT32 dmapx, dmapy, i, y; - static INT32 mapxstart, mapystart; - UINT8 *dest = screens[0]; - const UINT8 *src; -#define MAPLUMPHEIGHT (200 - 42) - - if (followplayer) - { - static vertex_t oldplr; - - dmapx = MTOF(plr->mo->x) - MTOF(oldplr.x); //fixed point - dmapy = MTOF(oldplr.y) - MTOF(plr->mo->y); - - oldplr.x = plr->mo->x; - oldplr.y = plr->mo->y; - mapxstart += dmapx>>1; - mapystart += dmapy>>1; - - while (mapxstart >= BASEVIDWIDTH) - mapxstart -= BASEVIDWIDTH; - while (mapxstart < 0) - mapxstart += BASEVIDWIDTH; - while (mapystart >= MAPLUMPHEIGHT) - mapystart -= MAPLUMPHEIGHT; - while (mapystart < 0) - mapystart += MAPLUMPHEIGHT; - } - else - { - mapxstart += (MTOF(m_paninc.x)>>1); - mapystart -= (MTOF(m_paninc.y)>>1); - if (mapxstart >= BASEVIDWIDTH) - mapxstart -= BASEVIDWIDTH; - if (mapxstart < 0) - mapxstart += BASEVIDWIDTH; - if (mapystart >= MAPLUMPHEIGHT) - mapystart -= MAPLUMPHEIGHT; - if (mapystart < 0) - mapystart += MAPLUMPHEIGHT; - } - - //blit the automap background to the screen. - for (y = 0; y < f_h; y++) - { - src = maplump + mapxstart + (y + mapystart)*BASEVIDWIDTH; - for (i = 0; i < BASEVIDWIDTH*vid.dupx; i++) - { - while (src > maplump + BASEVIDWIDTH*MAPLUMPHEIGHT) - src -= BASEVIDWIDTH*MAPLUMPHEIGHT; - *dest++ = *src++; - } - dest += vid.width - vid.dupx*BASEVIDWIDTH; - } - } + V_DrawFill(f_x, f_y, f_w, f_h, color|V_NOSCALESTART); } /** Performs automap clipping of lines. @@ -871,7 +740,7 @@ static boolean AM_clipMline(const mline_t *ml, fline_t *fl) // static void AM_drawFline_soft(const fline_t *fl, INT32 color) { - register INT32 x, y, dx, dy, sx, sy, ax, ay, d; + fixed_t x, y, dx, dy, sx, sy, ax, ay, d; #ifdef _DEBUG static INT32 num = 0; @@ -887,7 +756,8 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) } #endif -#define PUTDOT(xx,yy,cc) fb[(yy)*f_w + (xx)]=(UINT8)(cc) + #define PUTDOT(xx,yy,cc) V_DrawFill(xx,yy,1,1,cc|V_NOSCALESTART); + #define CLIPDOT (x >= f_x && y >= f_y && x < f_x + f_w && y < f_y + f_h) dx = fl->b.x - fl->a.x; ax = 2 * (dx < 0 ? -dx : dx); @@ -905,7 +775,8 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) d = ay - ax/2; for (;;) { - PUTDOT(x, y, color); + if (CLIPDOT) + PUTDOT(x, y, color) if (x == fl->b.x) return; if (d >= 0) @@ -922,7 +793,8 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) d = ax - ay/2; for (;;) { - PUTDOT(x, y, color); + if (CLIPDOT) + PUTDOT(x, y, color) if (y == fl->b.y) return; if (d >= 0) @@ -934,6 +806,9 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) d += ax; } } + + #undef CLIPDOT + #undef PUTDOT } // @@ -1004,15 +879,15 @@ static inline void AM_drawWalls(void) for (i = 0; i < numlines; i++) { - l.a.x = lines[i].v1->x; - l.a.y = lines[i].v1->y; - l.b.x = lines[i].v2->x; - l.b.y = lines[i].v2->y; + l.a.x = lines[i].v1->x >> FRACTOMAPBITS; + l.a.y = lines[i].v1->y >> FRACTOMAPBITS; + l.b.x = lines[i].v2->x >> FRACTOMAPBITS; + l.b.y = lines[i].v2->y >> FRACTOMAPBITS; #ifdef ESLOPE #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ - end1 = P_GetZAt(slope, l.a.x, l.a.y); \ - end2 = P_GetZAt(slope, l.b.x, l.b.y); \ + end1 = P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y); \ + end2 = P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y); \ } else \ end1 = end2 = normalheight; @@ -1025,17 +900,12 @@ static inline void AM_drawWalls(void) #undef SLOPEPARAMS #endif -// AM_drawMline(&l, GRAYS + 3); // Old, everything-is-gray automap if (!lines[i].backsector) // 1-sided { if (lines[i].flags & ML_NOCLIMB) - { - AM_drawMline(&l, NOCLIMBWALLCOLORS+lightlev); - } + AM_drawMline(&l, NOCLIMBWALLCOLORS); else - { - AM_drawMline(&l, WALLCOLORS+lightlev); - } + AM_drawMline(&l, WALLCOLORS); } #ifdef ESLOPE else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier @@ -1052,24 +922,16 @@ static inline void AM_drawWalls(void) #endif { if (lines[i].flags & ML_NOCLIMB) - { - AM_drawMline(&l, NOCLIMBTSWALLCOLORS+lightlev); - } + AM_drawMline(&l, NOCLIMBTSWALLCOLORS); else - { - AM_drawMline(&l, TSWALLCOLORS+lightlev); - } + AM_drawMline(&l, TSWALLCOLORS); } else { if (lines[i].flags & ML_NOCLIMB) - { - AM_drawMline(&l, NOCLIMBTHOKWALLCOLORS+lightlev); - } + AM_drawMline(&l, NOCLIMBTHOKWALLCOLORS); else - { - AM_drawMline(&l, THOKWALLCOLORS+lightlev); - } + AM_drawMline(&l, THOKWALLCOLORS); } } else @@ -1081,7 +943,7 @@ static inline void AM_drawWalls(void) if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) { #endif - AM_drawMline(&l, NOCLIMBFDWALLCOLORS + lightlev); // floor level change + AM_drawMline(&l, NOCLIMBFDWALLCOLORS); // floor level change } #ifdef ESLOPE else if (backc1 != frontc1 || backc2 != frontc2) { @@ -1089,11 +951,10 @@ static inline void AM_drawWalls(void) else if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) { #endif - AM_drawMline(&l, NOCLIMBCDWALLCOLORS+lightlev); // ceiling level change - } - else { - AM_drawMline(&l, NOCLIMBTSWALLCOLORS+lightlev); + AM_drawMline(&l, NOCLIMBCDWALLCOLORS); // ceiling level change } + else + AM_drawMline(&l, NOCLIMBTSWALLCOLORS); } else { @@ -1103,7 +964,7 @@ static inline void AM_drawWalls(void) if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) { #endif - AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change + AM_drawMline(&l, FDWALLCOLORS); // floor level change } #ifdef ESLOPE else if (backc1 != frontc1 || backc2 != frontc2) { @@ -1111,11 +972,10 @@ static inline void AM_drawWalls(void) else if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) { #endif - AM_drawMline(&l, CDWALLCOLORS+lightlev); // ceiling level change - } - else { - AM_drawMline(&l, TSWALLCOLORS+lightlev); + AM_drawMline(&l, CDWALLCOLORS); // ceiling level change } + else + AM_drawMline(&l, TSWALLCOLORS); } } } @@ -1176,6 +1036,11 @@ static void AM_drawLineCharacter(const mline_t *lineguy, size_t lineguylines, fi l.b.x += x; l.b.y += y; + l.a.x >>= FRACTOMAPBITS; + l.a.y >>= FRACTOMAPBITS; + l.b.x >>= FRACTOMAPBITS; + l.b.y >>= FRACTOMAPBITS; + AM_drawMline(&l, color); } } @@ -1184,83 +1049,51 @@ static inline void AM_drawPlayers(void) { INT32 i; player_t *p; - INT32 color; + INT32 color = GREENS; if (!multiplayer) { - AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, - plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y); + AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y); return; } - // multiplayer + // multiplayer (how??) for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) continue; p = &players[i]; - if (p->skincolor == 0) - color = GREENS; - else + if (p->skincolor > 0) color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8]; - AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, - color, p->mo->x, p->mo->y); + AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y); } } -static inline void AM_drawThings(INT32 colors, INT32 colorrange) +static inline void AM_drawThings(UINT8 colors) { size_t i; mobj_t *t; - (void)colorrange; for (i = 0; i < numsectors; i++) { t = sectors[i].thinglist; while (t) { - AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, - 16<angle, colors + lightlev, t->x, t->y); + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); t = t->snext; } } } -static inline void AM_drawMarks(void) -{ - INT32 i, fx, fy, w, h; - - for (i = 0; i < AM_NUMMARKPOINTS; i++) - { - if (markpoints[i].x != -1 && marknums[i]) - { - // w = SHORT(marknums[i]->width); - // h = SHORT(marknums[i]->height); - w = 5; // because something's wrong with the wad, i guess - h = 6; // because something's wrong with the wad, i guess - fx = CXMTOF(markpoints[i].x); - fy = CYMTOF(markpoints[i].y); - if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) - V_DrawPatch(fx, fy, FB, marknums[i]); - } - } -} - /** Draws the crosshair, actually just a dot in software mode. * * \param color Color for the crosshair. */ -static inline void AM_drawCrosshair(INT32 color) +static inline void AM_drawCrosshair(UINT8 color) { - if (rendermode != render_soft) - return; // BP: should be putpixel here - - if (scr_bpp == 1) - fb[(f_w*(f_h + 1))/2] = (UINT8)color; // single point for now - else - *((INT16 *)(void *)fb + (f_w*(f_h + 1))/2) = (INT16)color; + V_DrawFill(f_w/2 + f_x, f_h/2 + f_y, 1, 1, color|V_NOSCALESTART); } /** Draws the automap. @@ -1271,13 +1104,10 @@ void AM_Drawer(void) return; AM_clearFB(BACKGROUND); - if (grid) - AM_drawGrid(GRIDCOLORS); + if (draw_grid) AM_drawGrid(GRIDCOLORS); AM_drawWalls(); AM_drawPlayers(); - AM_drawThings(THINGCOLORS, THINGRANGE); + AM_drawThings(THINGCOLORS); AM_drawCrosshair(XHAIRCOLORS); - - AM_drawMarks(); } diff --git a/src/am_map.h b/src/am_map.h index 4e8c782a..bd4221fb 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -31,6 +31,9 @@ typedef struct #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) +// Jimita +//#define MINIAUTOMAP + extern boolean am_recalc; // true if screen size changes extern boolean automapactive; // In AutoMap mode? diff --git a/src/d_main.c b/src/d_main.c index 23835136..773ff91b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -319,8 +319,6 @@ static void D_Display(void) if (!gametic) break; HU_Erase(); - if (automapactive) - AM_Drawer(); break; case GS_INTERMISSION: @@ -374,12 +372,22 @@ static void D_Display(void) break; } - // clean up border stuff - // see if the border needs to be initially drawn if (gamestate == GS_LEVEL) { // draw the view directly - if (!automapactive && !dedicated && cv_renderview.value) + boolean dorenderview = cv_renderview.value; + boolean dorenderautomap = false; + + // Jimita + if (automapactive) + { + dorenderautomap = true; +#ifndef MINIAUTOMAP + dorenderview = false; +#endif + } + + if (dorenderview) { if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) { @@ -436,8 +444,11 @@ static void D_Display(void) lastdraw = false; } - ST_Drawer(); + // Jimita + if (dorenderautomap) + AM_Drawer(); + ST_Drawer(); HU_Drawer(); } diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 75523f3d..3963fd93 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -770,18 +770,6 @@ void HWR_DrawViewBorder(INT32 clearlines) // AM_MAP.C DRAWING STUFF // ========================================================================== -// Clear the automap part of the screen -void HWR_clearAutomap(void) -{ - FRGBAFloat fColor = {0, 0, 0, 1}; - - // minx,miny,maxx,maxy - HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); - HWD.pfnClearBuffer(true, true, &fColor); - HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); -} - - // -----------------+ // HWR_drawAMline : draw a line of the automap (the clipping is already done in automap code) // Arg : color is a RGB 888 value diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index b0a14d3b..c7284371 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -31,7 +31,6 @@ void HWR_Startup(void); void HWR_Shutdown(void); -void HWR_clearAutomap(void); void HWR_drawAMline(const fline_t *fl, INT32 color); void HWR_FadeScreenMenuBack(UINT32 color, INT32 height); void HWR_DrawConsoleBack(UINT32 color, INT32 height); diff --git a/src/p_local.h b/src/p_local.h index e09b4951..9164fa7a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -41,9 +41,6 @@ // Convenience macro to fix issue with collision along bottom/left edges of blockmap -Red #define BMBOUNDFIX(xl, xh, yl, yh) {if (xl > xh) xl = 0; if (yl > yh) yl = 0;} -// player radius used only in am_map.c -#define PLAYERRADIUS (16*FRACUNIT) - // MAXRADIUS is for precalculated sector block boxes // the spider demon is larger, // but we do not have any moving sectors nearby From 649b6c9ca19648602996f2fae9c86cd0c301342b Mon Sep 17 00:00:00 2001 From: MPC Date: Wed, 12 Dec 2018 18:53:13 -0300 Subject: [PATCH 04/32] Remove MINIAUTOMAP code --- src/am_map.c | 14 ++------------ src/am_map.h | 3 --- src/d_main.c | 19 ++----------------- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index ee690017..36fd69e9 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -365,12 +365,6 @@ static void AM_LevelInit(void) f_w = vid.width; f_h = vid.height; - // Jimita -#ifdef MINIAUTOMAP - f_x = f_w / 2; - f_y = f_h / 2; -#endif - AM_drawFline = AM_drawFline_soft; #ifdef HWRENDER if (rendermode == render_opengl) @@ -757,7 +751,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) #endif #define PUTDOT(xx,yy,cc) V_DrawFill(xx,yy,1,1,cc|V_NOSCALESTART); - #define CLIPDOT (x >= f_x && y >= f_y && x < f_x + f_w && y < f_y + f_h) dx = fl->b.x - fl->a.x; ax = 2 * (dx < 0 ? -dx : dx); @@ -775,8 +768,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) d = ay - ax/2; for (;;) { - if (CLIPDOT) - PUTDOT(x, y, color) + PUTDOT(x, y, color) if (x == fl->b.x) return; if (d >= 0) @@ -793,8 +785,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) d = ax - ay/2; for (;;) { - if (CLIPDOT) - PUTDOT(x, y, color) + PUTDOT(x, y, color) if (y == fl->b.y) return; if (d >= 0) @@ -807,7 +798,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color) } } - #undef CLIPDOT #undef PUTDOT } diff --git a/src/am_map.h b/src/am_map.h index bd4221fb..4e8c782a 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -31,9 +31,6 @@ typedef struct #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) -// Jimita -//#define MINIAUTOMAP - extern boolean am_recalc; // true if screen size changes extern boolean automapactive; // In AutoMap mode? diff --git a/src/d_main.c b/src/d_main.c index 773ff91b..df422232 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -319,6 +319,7 @@ static void D_Display(void) if (!gametic) break; HU_Erase(); + AM_Drawer(); break; case GS_INTERMISSION: @@ -375,19 +376,7 @@ static void D_Display(void) if (gamestate == GS_LEVEL) { // draw the view directly - boolean dorenderview = cv_renderview.value; - boolean dorenderautomap = false; - - // Jimita - if (automapactive) - { - dorenderautomap = true; -#ifndef MINIAUTOMAP - dorenderview = false; -#endif - } - - if (dorenderview) + if (cv_renderview.value && !automapactive) { if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) { @@ -444,10 +433,6 @@ static void D_Display(void) lastdraw = false; } - // Jimita - if (dorenderautomap) - AM_Drawer(); - ST_Drawer(); HU_Drawer(); } From a5874019cbc1d5b2d68a1668f7c147b8accd743a Mon Sep 17 00:00:00 2001 From: Jimita <16945067+monster-psychic-cat@users.noreply.github.com> Date: Wed, 12 Dec 2018 19:57:52 -0200 Subject: [PATCH 05/32] Update am_map.c --- src/am_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/am_map.c b/src/am_map.c index 36fd69e9..5ee3feaf 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -734,7 +734,7 @@ static boolean AM_clipMline(const mline_t *ml, fline_t *fl) // static void AM_drawFline_soft(const fline_t *fl, INT32 color) { - fixed_t x, y, dx, dy, sx, sy, ax, ay, d; + INT32 x, y, dx, dy, sx, sy, ax, ay, d; #ifdef _DEBUG static INT32 num = 0; From e628d98f20b5145e45f718b798f0b838c1f6934e Mon Sep 17 00:00:00 2001 From: Jimita <16945067+monster-psychic-cat@users.noreply.github.com> Date: Wed, 12 Dec 2018 19:59:21 -0200 Subject: [PATCH 06/32] Update am_map.c --- src/am_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 5ee3feaf..5e73d2ec 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -99,8 +99,8 @@ static const UINT8 NOCLIMBYELLOWS = (11*16); #define FTOM(x) FixedMul(((x)<>FRACBITS) // translates between frame-buffer and map coordinates -#define CXMTOF(x) (f_x - (f_x/2) + MTOF((x)-m_x)) -#define CYMTOF(y) (f_y - (f_y/2) + (f_h - MTOF((y)-m_y))) +#define CXMTOF(x) (f_x + MTOF((x)-m_x)) +#define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) #define MAPBITS (FRACBITS-4) #define FRACTOMAPBITS (FRACBITS-MAPBITS) From 9c2197db172c289d5ed30350de4758ed0c3bb59b Mon Sep 17 00:00:00 2001 From: MPC Date: Fri, 14 Dec 2018 14:08:25 -0300 Subject: [PATCH 07/32] Software plane fixes --- src/console.c | 5 +- src/r_bsp.c | 2 - src/r_main.c | 289 +++++++++++++++++++++++-------------------------- src/r_plane.c | 78 ++++++------- src/r_plane.h | 25 +---- src/r_segs.c | 48 ++------ src/r_splats.c | 22 ++-- src/r_things.c | 6 +- src/screen.c | 8 -- 9 files changed, 202 insertions(+), 281 deletions(-) diff --git a/src/console.c b/src/console.c index 2c148bc6..11bf4cb1 100644 --- a/src/console.c +++ b/src/console.c @@ -58,10 +58,7 @@ static boolean consoleready; // console prompt is ready INT32 con_destlines; // vid lines used by console at final position static INT32 con_curlines; // vid lines currently used by console - INT32 con_clipviewtop; // clip value for planes & sprites, so that the - // part of the view covered by the console is not - // drawn when not needed, this must be -1 when - // console is off + INT32 con_clipviewtop; // (useless) static INT32 con_hudlines; // number of console heads up message lines static INT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines diff --git a/src/r_bsp.c b/src/r_bsp.c index 35543827..a41c6403 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1119,7 +1119,6 @@ static void R_Subsector(size_t num) } light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); - light = 0; ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic, polysec->lightlevel, xoff, yoff, polysec->floorpic_angle-po->angle, @@ -1167,7 +1166,6 @@ static void R_Subsector(size_t num) } light = R_GetPlaneLight(frontsector, polysec->ceilingheight, viewz < polysec->ceilingheight); - light = 0; ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle, NULL, NULL diff --git a/src/r_main.c b/src/r_main.c index 23eff452..2b0fbc39 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -551,13 +551,11 @@ void R_SetViewSize(void) // void R_ExecuteSetViewSize(void) { - fixed_t cosadj; fixed_t dy; INT32 i; INT32 j; INT32 level; INT32 startmapl; - INT32 aspectx; //added : 02-02-98 : for aspect ratio calc. below... setsizeneeded = false; @@ -597,31 +595,22 @@ void R_ExecuteSetViewSize(void) for (i = 0; i < viewwidth; i++) screenheightarray[i] = (INT16)viewheight; - // setup sky scaling (uses pspriteyscale) + // setup sky scaling R_SetSkyScale(); // planes - //aspectx = (((vid.height*centerx*BASEVIDWIDTH)/BASEVIDHEIGHT)/vid.width); - aspectx = centerx; - if (rendermode == render_soft) { // this is only used for planes rendering in software mode - j = viewheight*8; + j = viewheight*16; for (i = 0; i < j; i++) { - dy = ((i - viewheight*2)<>ANGLETOFINESHIFT)); - distscale[i] = FixedDiv(FRACUNIT, cosadj); - } - memset(scalelight, 0xFF, sizeof(scalelight)); // Calculate the light levels to use for each level/scale combination. @@ -734,9 +723,136 @@ static mobj_t *viewmobj; // WARNING: a should be unsigned but to add with 2048, it isn't! #define AIMINGTODY(a) ((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS) -void R_SkyboxFrame(player_t *player) +// recalc necessary stuff for mouseaiming +// slopes are already calculated for the full possible view (which is 4*viewheight). +// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) +static void R_SetupFreelook(void) { INT32 dy = 0; + if (rendermode == render_soft) + { + // clip it in the case we are looking a hardware 90 degrees full aiming + // (lmps, network and use F12...) + G_SoftwareClipAimingPitch((INT32 *)&aimingangle); + dy = AIMINGTODY(aimingangle) * viewwidth/BASEVIDWIDTH; + yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)]; + } + centery = (viewheight/2) + dy; + centeryfrac = centery<climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD) + chasecam = true; // force chasecam on + else if (player->spectator) // no spectator chasecam + chasecam = false; // force chasecam off + + if (chasecam && !thiscam->chase) + { + P_ResetCamera(player, thiscam); + thiscam->chase = true; + } + else if (!chasecam) + thiscam->chase = false; + + viewsky = !skybox; + if (player->awayviewtics) + { + // cut-away view stuff + viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN + I_Assert(viewmobj != NULL); + viewz = viewmobj->z + 20*FRACUNIT; + aimingangle = player->awayviewaiming; + viewangle = viewmobj->angle; + } + else if (!player->spectator && chasecam) + // use outside cam view + { + viewmobj = NULL; + viewz = thiscam->z + (thiscam->height>>1); + aimingangle = thiscam->aiming; + viewangle = thiscam->angle; + } + else + // use the player's eyes view + { + viewz = player->viewz; + + viewmobj = player->mo; + I_Assert(viewmobj != NULL); + + aimingangle = player->aiming; + viewangle = viewmobj->angle; + + if (!demoplayback && player->playerstate != PST_DEAD) + { + if (player == &players[consoleplayer]) + { + viewangle = localangle; // WARNING: camera uses this + aimingangle = localaiming; + } + else if (player == &players[secondarydisplayplayer]) + { + viewangle = localangle2; + aimingangle = localaiming2; + } + } + } + viewz += quake.z; + + viewplayer = player; + + if (chasecam && !player->awayviewtics && !player->spectator) + { + viewx = thiscam->x; + viewy = thiscam->y; + viewx += quake.x; + viewy += quake.y; + + if (thiscam->subsector) + viewsector = thiscam->subsector->sector; + else + viewsector = R_PointInSubsector(viewx, viewy)->sector; + } + else + { + viewx = viewmobj->x; + viewy = viewmobj->y; + viewx += quake.x; + viewy += quake.y; + + if (viewmobj->subsector) + viewsector = viewmobj->subsector->sector; + else + viewsector = R_PointInSubsector(viewx, viewy)->sector; + } + + viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); + viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + + R_SetupFreelook(); +} + +void R_SkyboxFrame(player_t *player) +{ camera_t *thiscam; if (splitscreen && player == &players[secondarydisplayplayer] @@ -950,146 +1066,7 @@ void R_SkyboxFrame(player_t *player) viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - // recalc necessary stuff for mouseaiming - // slopes are already calculated for the full possible view (which is 4*viewheight). - // 18/08/18: (No it's actually 8*viewheight, thanks MPC aka Jimita for finding this out) - - if (rendermode == render_soft) - { - // clip it in the case we are looking a hardware 90 degrees full aiming - // (lmps, network and use F12...) - G_SoftwareClipAimingPitch((INT32 *)&aimingangle); - - dy = AIMINGTODY(aimingangle) * viewwidth/BASEVIDWIDTH; - - yslope = &yslopetab[(3*viewheight/2) - dy]; - } - centery = (viewheight/2) + dy; - centeryfrac = centery<climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD) - chasecam = true; // force chasecam on - else if (player->spectator) // no spectator chasecam - chasecam = false; // force chasecam off - - if (chasecam && !thiscam->chase) - { - P_ResetCamera(player, thiscam); - thiscam->chase = true; - } - else if (!chasecam) - thiscam->chase = false; - - viewsky = !skybox; - if (player->awayviewtics) - { - // cut-away view stuff - viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN - I_Assert(viewmobj != NULL); - viewz = viewmobj->z + 20*FRACUNIT; - aimingangle = player->awayviewaiming; - viewangle = viewmobj->angle; - } - else if (!player->spectator && chasecam) - // use outside cam view - { - viewmobj = NULL; - viewz = thiscam->z + (thiscam->height>>1); - aimingangle = thiscam->aiming; - viewangle = thiscam->angle; - } - else - // use the player's eyes view - { - viewz = player->viewz; - - viewmobj = player->mo; - I_Assert(viewmobj != NULL); - - aimingangle = player->aiming; - viewangle = viewmobj->angle; - - if (!demoplayback && player->playerstate != PST_DEAD) - { - if (player == &players[consoleplayer]) - { - viewangle = localangle; // WARNING: camera uses this - aimingangle = localaiming; - } - else if (player == &players[secondarydisplayplayer]) - { - viewangle = localangle2; - aimingangle = localaiming2; - } - } - } - viewz += quake.z; - - viewplayer = player; - - if (chasecam && !player->awayviewtics && !player->spectator) - { - viewx = thiscam->x; - viewy = thiscam->y; - viewx += quake.x; - viewy += quake.y; - - if (thiscam->subsector) - viewsector = thiscam->subsector->sector; - else - viewsector = R_PointInSubsector(viewx, viewy)->sector; - } - else - { - viewx = viewmobj->x; - viewy = viewmobj->y; - viewx += quake.x; - viewy += quake.y; - - if (viewmobj->subsector) - viewsector = viewmobj->subsector->sector; - else - viewsector = R_PointInSubsector(viewx, viewy)->sector; - } - - viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - - // recalc necessary stuff for mouseaiming - // slopes are already calculated for the full possible view (which is 4*viewheight). - // 18/08/18: (No it's actually 8*viewheight, thanks MPC aka Jimita for finding this out) - - if (rendermode == render_soft) - { - // clip it in the case we are looking a hardware 90 degrees full aiming - // (lmps, network and use F12...) - G_SoftwareClipAimingPitch((INT32 *)&aimingangle); - - dy = AIMINGTODY(aimingangle) * viewwidth/BASEVIDWIDTH; - - yslope = &yslopetab[(3*viewheight/2) - dy]; - } - centery = (viewheight/2) + dy; - centeryfrac = centery<= vid.width) x1 = vid.width - 1; + angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; + planecos = FINECOSINE(angle); + planesin = FINESINE(angle); + if (planeheight != cachedheight[y]) { cachedheight[y] = planeheight; distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); ds_xstep = cachedxstep[y] = FixedMul(distance, basexscale); ds_ystep = cachedystep[y] = FixedMul(distance, baseyscale); + + if ((span = abs(centery-y))) + { + ds_xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; + ds_ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; + } } else { @@ -301,13 +296,8 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_ystep = cachedystep[y]; } - length = FixedMul (distance,distscale[x1]); - angle = (currentplane->viewangle + currentplane->plangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; - /// \note Wouldn't it be faster just to add viewx and viewy - // to the plane's x/yoffs anyway?? - - ds_xfrac = FixedMul(FINECOSINE(angle), length) + xoffs; - ds_yfrac = yoffs - FixedMul(FINESINE(angle), length); + ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; + ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; #ifndef NOWATER if (itswater) @@ -315,8 +305,9 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) const INT32 yay = (wtofs + (distance>>9) ) & 8191; // ripples da water texture bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; + angle = (currentplane->viewangle + currentplane->plangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; - angle = (angle + 2048) & 8191; //90� + angle = (angle + 2048) & 8191; // 90 degrees ds_xfrac += FixedMul(FINECOSINE(angle), (bgofs<> LIGHTZSHIFT; - if (pindex >= MAXLIGHTZ) pindex = MAXLIGHTZ - 1; @@ -365,8 +355,6 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) // R_ClearPlanes // At begining of frame. // -// NOTE: Uses con_clipviewtop, so that when console is on, -// we don't draw the part of the view hidden under the console. void R_ClearPlanes(void) { INT32 i, p; @@ -376,12 +364,12 @@ void R_ClearPlanes(void) for (i = 0; i < viewwidth; i++) { floorclip[i] = (INT16)viewheight; - ceilingclip[i] = (INT16)con_clipviewtop; + ceilingclip[i] = -1; frontscale[i] = INT32_MAX; for (p = 0; p < MAXFFLOORS; p++) { ffloor[p].f_clip[i] = (INT16)viewheight; - ffloor[p].c_clip[i] = (INT16)con_clipviewtop; + ffloor[p].c_clip[i] = -1; } } diff --git a/src/r_plane.h b/src/r_plane.h index 2ab1e83f..53ecc82e 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -37,27 +37,14 @@ typedef struct visplane_s // colormaps per sector extracolormap_t *extra_colormap; + UINT16 padding; - // leave pads for [minx-1]/[maxx+1] - - // words sucks .. should get rid of that.. but eats memory - // THIS IS UNSIGNED! VERY IMPORTANT!! - UINT16 pad1; UINT16 top[MAXVIDWIDTH]; - UINT16 pad2; - UINT16 pad3; UINT16 bottom[MAXVIDWIDTH]; - UINT16 pad4; - INT32 high, low; // R_PlaneBounds should set these. fixed_t xoffs, yoffs; // Scrolling flats. - // SoM: frontscale should be stored in the first seg of the subsector - // where the planes themselves are stored. I'm doing this now because - // the old way caused trouble with the drawseg array was re-sized. - INT32 scaleseg; - struct ffloor_s *ffloor; #ifdef POLYOBJECTS_PLANES polyobj_t *polyobj; @@ -75,17 +62,15 @@ extern INT16 *lastopening, *openings; extern size_t maxopenings; extern INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH]; -extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*8]; +extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16]; extern fixed_t cachedheight[MAXVIDHEIGHT]; extern fixed_t cacheddistance[MAXVIDHEIGHT]; extern fixed_t cachedxstep[MAXVIDHEIGHT]; extern fixed_t cachedystep[MAXVIDHEIGHT]; extern fixed_t basexscale, baseyscale; -extern lighttable_t **planezlight; - extern fixed_t *yslope; -extern fixed_t distscale[MAXVIDWIDTH]; +extern lighttable_t **planezlight; void R_InitPlanes(void); void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); @@ -134,8 +119,8 @@ typedef struct planemgr_s #ifdef POLYOBJECTS_PLANES polyobj_t *polyobj; #endif -} planemgr_t; +} visffloor_t; -extern planemgr_t ffloor[MAXFFLOORS]; +extern visffloor_t ffloor[MAXFFLOORS]; extern INT32 numffloors; #endif diff --git a/src/r_segs.c b/src/r_segs.c index 2122cba1..1637ce90 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1344,24 +1344,12 @@ static void R_RenderSegLoop (void) if (markfloor) { -#if 0 // Old Doom Legacy code - bottom = floorclip[rw_x]-1; - if (top <= ceilingclip[rw_x]) - top = ceilingclip[rw_x]+1; - if (top <= bottom && floorplane) - { - floorplane->top[rw_x] = (INT16)top; - floorplane->bottom[rw_x] = (INT16)bottom; - } -#else // Spiffy new PRBoom code - top = yh < ceilingclip[rw_x] ? ceilingclip[rw_x] : yh; - + top = yh < ceilingclip[rw_x] ? ceilingclip[rw_x] : yh; if (++top <= bottom && floorplane) { floorplane->top[rw_x] = (INT16)top; floorplane->bottom[rw_x] = (INT16)bottom; } -#endif } if (numffloors) @@ -1645,26 +1633,11 @@ static void R_RenderSegLoop (void) } for (i = 0; i < numffloors; i++) - { -#ifdef POLYOBJECTS_PLANES - if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) - continue; -#endif - ffloor[i].f_frac += ffloor[i].f_step; - } for (i = 0; i < numbackffloors; i++) { - INT32 y_w; - -#ifdef POLYOBJECTS_PLANES - if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) - continue; -#endif - y_w = ffloor[i].b_frac >> HEIGHTBITS; - - ffloor[i].f_clip[rw_x] = ffloor[i].c_clip[rw_x] = (INT16)(y_w & 0xFFFF); + ffloor[i].f_clip[rw_x] = ffloor[i].c_clip[rw_x] = (INT16)((ffloor[i].b_frac >> HEIGHTBITS) & 0xFFFF); ffloor[i].b_frac += ffloor[i].b_step; } @@ -2775,11 +2748,6 @@ void R_StoreWallRange(INT32 start, INT32 stop) { for (i = 0; i < numffloors; i++) { -#ifdef POLYOBJECTS_PLANES - if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) - continue; -#endif - ffloor[i].f_pos >>= 4; #ifdef ESLOPE ffloor[i].f_pos_slope >>= 4; @@ -3060,7 +3028,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); else - markceiling = 0; + markceiling = false; + + // Don't render the ceiling again when rendering polyobjects + if (curline->polyseg) + markceiling = false; } // get a new or use the same visplane @@ -3069,7 +3041,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (floorplane) //SoM: 3/29/2000: Check for null planes floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); else - markfloor = 0; + markfloor = false; + + // Don't render the floor again when rendering polyobjects + if (curline->polyseg) + markfloor = false; } ds_p->numffloorplanes = 0; diff --git a/src/r_splats.c b/src/r_splats.c index 8d0a84fa..9ab67127 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -365,9 +365,8 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe #else lighttable_t **planezlight; fixed_t planeheight; - angle_t angle; - fixed_t distance; - fixed_t length; + angle_t angle, planecos, planesin; + fixed_t distance, span; size_t indexr; INT32 light; #endif @@ -473,12 +472,22 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe if (x2 >= vid.width) x2 = vid.width - 1; + angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT; + planecos = FINECOSINE(angle); + planesin = FINESINE(angle); + if (planeheight != cachedheight[y]) { cachedheight[y] = planeheight; distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]); ds_xstep = cachedxstep[y] = FixedMul(distance,basexscale); ds_ystep = cachedystep[y] = FixedMul(distance,baseyscale); + + if ((span = abs(centery-y))) + { + ds_xstep = cachedxstep[y] = FixedMul(planesin, planeheight) / span; + ds_ystep = cachedystep[y] = FixedMul(planecos, planeheight) / span; + } } else { @@ -486,10 +495,9 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe ds_xstep = cachedxstep[y]; ds_ystep = cachedystep[y]; } - length = FixedMul(distance, distscale[x1]); - angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; - ds_xfrac = viewx + FixedMul(FINECOSINE(angle), length); - ds_yfrac = -viewy - FixedMul(FINESINE(angle), length); + + ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; + ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; ds_xfrac -= offsetx; ds_yfrac += offsety; diff --git a/src/r_things.c b/src/r_things.c index b7c925e3..67a45a76 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1733,7 +1733,7 @@ static void R_CreateDrawNodes(void) plane = ds->curline->polyseg->visplane; R_PlaneBounds(plane); - if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low) + if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) ; else { // Put it in! @@ -1762,7 +1762,7 @@ static void R_CreateDrawNodes(void) plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); - if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low || plane->polyobj) + if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low || plane->polyobj) { ds->ffloorplanes[p] = NULL; continue; @@ -1799,7 +1799,7 @@ static void R_CreateDrawNodes(void) plane = PolyObjects[i].visplane; R_PlaneBounds(plane); - if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low) + if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) { PolyObjects[i].visplane = NULL; continue; diff --git a/src/screen.c b/src/screen.c index d5beaf36..af6aed03 100644 --- a/src/screen.c +++ b/src/screen.c @@ -309,14 +309,6 @@ void SCR_Recalc(void) if (automapactive) AM_Stop(); - // r_plane stuff: visplanes, openings, floorclip, ceilingclip, spanstart, - // spanstop, yslope, distscale, cachedheight, cacheddistance, - // cachedxstep, cachedystep - // -> allocated at the maximum vidsize, static. - - // r_main: xtoviewangle, allocated at the maximum size. - // r_things: negonearray, screenheightarray allocated max. size. - // set the screen[x] ptrs on the new vidbuffers V_Init(); From 3a125dbbd585587330f52a5dc74b317d40defa50 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 17:14:03 +0000 Subject: [PATCH 08/32] compare with actual doubles, not ints --- src/hardware/hw_bsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index a180697d..f9f310a6 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -193,14 +193,14 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v2dy = bsp->dy; den = v2dy*v1dx - v2dx*v1dy; - if (den == 0) + if (den == 0.0) return NULL; // parallel // first check the frac along the polygon segment, // (do not accept hit with the extensions) num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; frac = num / den; - if (frac < 0 || frac > 1) + if (frac < 0.0 || frac > 1.0) return NULL; // now get the frac along the BSP line From 4089b6b8e9da1075c8e3c463ec7f268b384bda58 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:00:08 +0000 Subject: [PATCH 09/32] use continue if NULL instead of a big if block if ...not NULL also, SplitPoly returns if ps < 0, so there's no need to check for ps >= 0 afterwards --- src/hardware/hw_bsp.c | 144 +++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index f9f310a6..271d832a 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -294,57 +294,57 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line // start & end points pv = fracdivline(bsp, &poly->pts[i], &poly->pts[j]); - if (pv) + if (pv == NULL) + continue; + + if (ps < 0) { - if (ps < 0) + // first point + ps = i; + vs = *pv; + fracs = bspfrac; + } + else + { + //the partition line traverse a junction between two segments + // or the two points are so close, they can be considered as one + // thus, don't accept, since split 2 must be another vertex + if (SameVertice(pv, &lastpv)) { - // first point - ps = i; - vs = *pv; - fracs = bspfrac; - } - else - { - //the partition line traverse a junction between two segments - // or the two points are so close, they can be considered as one - // thus, don't accept, since split 2 must be another vertex - if (SameVertice(pv, &lastpv)) + if (pe < 0) { - if (pe < 0) - { - ps = i; - psonline = 1; - } - else - { - pe = i; - peonline = 1; - } + ps = i; + psonline = 1; } else { - if (pe < 0) - { - pe = i; - ve = *pv; - frace = bspfrac; - } - else - { - // a frac, not same vertice as last one - // we already got pt2 so pt 2 is not on the line, - // so we probably got back to the start point - // which is on the line - if (SameVertice(pv, &vs)) - psonline = 1; - break; - } + pe = i; + peonline = 1; + } + } + else + { + if (pe < 0) + { + pe = i; + ve = *pv; + frace = bspfrac; + } + else + { + // a frac, not same vertice as last one + // we already got pt2 so pt 2 is not on the line, + // so we probably got back to the start point + // which is on the line + if (SameVertice(pv, &vs)) + psonline = 1; + break; } } - - // remember last point intercept to detect identical points - lastpv = *pv; } + + // remember last point intercept to detect identical points + lastpv = *pv; } // no split: the partition line is either parallel and @@ -368,7 +368,7 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line return; } - if (ps >= 0 && pe < 0) + if (pe < 0) { //I_Error("SplitPoly: only one point for split line (%d %d)", ps, pe); *frontpoly = poly; @@ -482,42 +482,42 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) pv = fracdivline(&cutseg, &poly->pts[i], &poly->pts[j]); - if (pv) + if (pv == NULL) + continue; + + if (ps < 0) { - if (ps < 0) + ps = i; + vs = *pv; + fracs = bspfrac; + } + else + { + //frac 1 on previous segment, + // 0 on the next, + //the split line goes through one of the convex poly + // vertices, happens quite often since the convex + // poly is already adjacent to the subsector segs + // on most borders + if (SameVertice(pv, &vs)) + continue; + + if (fracs <= bspfrac) { + nump = 2 + poly->numpts - (i-ps); + pe = ps; ps = i; - vs = *pv; - fracs = bspfrac; + ve = *pv; } else { - //frac 1 on previous segment, - // 0 on the next, - //the split line goes through one of the convex poly - // vertices, happens quite often since the convex - // poly is already adjacent to the subsector segs - // on most borders - if (SameVertice(pv, &vs)) - continue; - - if (fracs <= bspfrac) - { - nump = 2 + poly->numpts - (i-ps); - pe = ps; - ps = i; - ve = *pv; - } - else - { - nump = 2 + (i-ps); - pe = i; - ve = vs; - vs = *pv; - } - //found 2nd point - break; + nump = 2 + (i-ps); + pe = i; + ve = vs; + vs = *pv; } + //found 2nd point + break; } } From 02fc845a723effa6a40797cd5c6bbead9b0bae3a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:01:18 +0000 Subject: [PATCH 10/32] Make sure nptfront is explicitly > 0, so we don't alloc a poly for negative number points at all --- src/hardware/hw_bsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 271d832a..c75d0b48 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -387,7 +387,7 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line *backpoly = HWR_AllocPoly(2 + nptback); else *backpoly = NULL; - if (nptfront) + if (nptfront > 0) *frontpoly = HWR_AllocPoly(2 + nptfront); else *frontpoly = NULL; From 52fd3dcbed185f78e367cc5d2183d4a39ddfc092 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:11:30 +0000 Subject: [PATCH 11/32] split loading status code into a separate function --- src/hardware/hw_bsp.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index c75d0b48..09620263 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -589,10 +589,36 @@ static inline void SearchDivline(node_t *bsp, fdivline_t *divline) divline->dy = FIXED_TO_FLOAT(bsp->dy); } +#ifdef HWR_LOADING_SCREEN //Hurdler: implement a loading status static size_t ls_count = 0; static UINT8 ls_percent = 0; +static void loading_status(void) +{ + char s[16]; + int x, y; + + I_OsPolling(); + CON_Drawer(); + sprintf(s, "%d%%", (++ls_percent)<<1); + x = BASEVIDWIDTH/2; + y = BASEVIDHEIGHT/2; + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect + //V_DrawPatchFill(W_CachePatchName("SRB2BACK",PU_CACHE)); // SRB2 background, ehhh too bright. + M_DrawTextBox(x-58, y-8, 13, 1); + V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); + V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); + + // Is this really necessary at this point..? + V_DrawCenteredString(BASEVIDWIDTH/2, 40, V_YELLOWMAP, "OPENGL MODE IS INCOMPLETE AND MAY"); + V_DrawCenteredString(BASEVIDWIDTH/2, 50, V_YELLOWMAP, "NOT DISPLAY SOME SURFACES."); + V_DrawCenteredString(BASEVIDWIDTH/2, 70, V_YELLOWMAP, "USE AT SONIC'S RISK."); + + I_UpdateNoVsync(); +} +#endif + // poly : the convex polygon that encloses all child subsectors static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *bbox) { @@ -631,32 +657,13 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b else { HWR_SubsecPoly(bspnum&(~NF_SUBSECTOR), poly); - //Hurdler: implement a loading status + //Hurdler: implement a loading status #ifdef HWR_LOADING_SCREEN if (ls_count-- <= 0) { - char s[16]; - int x, y; - - I_OsPolling(); ls_count = numsubsectors/50; - CON_Drawer(); - sprintf(s, "%d%%", (++ls_percent)<<1); - x = BASEVIDWIDTH/2; - y = BASEVIDHEIGHT/2; - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect - //V_DrawPatchFill(W_CachePatchName("SRB2BACK",PU_CACHE)); // SRB2 background, ehhh too bright. - M_DrawTextBox(x-58, y-8, 13, 1); - V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); - V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); - - // Is this really necessary at this point..? - V_DrawCenteredString(BASEVIDWIDTH/2, 40, V_YELLOWMAP, "OPENGL MODE IS INCOMPLETE AND MAY"); - V_DrawCenteredString(BASEVIDWIDTH/2, 50, V_YELLOWMAP, "NOT DISPLAY SOME SURFACES."); - V_DrawCenteredString(BASEVIDWIDTH/2, 70, V_YELLOWMAP, "USE AT SONIC'S RISK."); - - I_UpdateNoVsync(); + loading_status(); } #endif } @@ -968,7 +975,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum) fixed_t rootbbox[4]; CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n"); +#ifdef HWR_LOADING_SCREEN ls_count = ls_percent = 0; // reset the loading status +#endif CON_Drawer(); //let the user know what we are doing I_FinishUpdate(); // page flip or blit buffer From b42c306ef36213496910f20ebbd5d593deb59b2b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:14:08 +0000 Subject: [PATCH 12/32] remove code from SearchDivline that was disabled ...and doesn't seem to exist anymore anyway --- src/hardware/hw_bsp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 09620263..95978c48 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -581,8 +581,6 @@ static inline void HWR_SubsecPoly(INT32 num, poly_t *poly) // search for the segs source of this divline static inline void SearchDivline(node_t *bsp, fdivline_t *divline) { -#if 0 // MAR - If you don't use the same partition line that the BSP uses, the front/back polys won't match the subsectors in the BSP! -#endif divline->x = FIXED_TO_FLOAT(bsp->x); divline->y = FIXED_TO_FLOAT(bsp->y); divline->dx = FIXED_TO_FLOAT(bsp->dx); From 9c04a066d96ab24530c383a0d43a84aaa4741986 Mon Sep 17 00:00:00 2001 From: MPC Date: Fri, 14 Dec 2018 15:49:32 -0300 Subject: [PATCH 13/32] Update r_plane.h --- src/r_plane.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/r_plane.h b/src/r_plane.h index 53ecc82e..6e6a6d49 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -21,7 +21,6 @@ // // Now what is a visplane, anyway? // Simple: kinda floor/ceiling polygon optimised for SRB2 rendering. -// 7764 bytes! (for win32, anyway) // typedef struct visplane_s { @@ -37,10 +36,10 @@ typedef struct visplane_s // colormaps per sector extracolormap_t *extra_colormap; - UINT16 padding; - UINT16 top[MAXVIDWIDTH]; - UINT16 bottom[MAXVIDWIDTH]; + // leave pads for [minx-1]/[maxx+1] + UINT16 padtopstart, top[MAXVIDWIDTH], padtopend; + UINT16 padbottomstart, bottom[MAXVIDWIDTH], padbottomend; INT32 high, low; // R_PlaneBounds should set these. fixed_t xoffs, yoffs; // Scrolling flats. From 623d1574cec726852364ad242bdababaf4e291da Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 21:00:53 +0000 Subject: [PATCH 14/32] minor cleanup --- src/hardware/hw_bsp.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 95978c48..8fec4f96 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -654,7 +654,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b } else { - HWR_SubsecPoly(bspnum&(~NF_SUBSECTOR), poly); + HWR_SubsecPoly(bspnum & ~NF_SUBSECTOR, poly); //Hurdler: implement a loading status #ifdef HWR_LOADING_SCREEN @@ -666,7 +666,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b #endif } M_ClearBox(bbox); - poly = extrasubsectors[bspnum&~NF_SUBSECTOR].planepoly; + poly = extrasubsectors[bspnum & ~NF_SUBSECTOR].planepoly; for (i = 0, pt = poly->pts; i < poly->numpts; i++,pt++) M_AddToBox(bbox, FLOAT_TO_FIXED(pt->x), FLOAT_TO_FIXED(pt->y)); @@ -698,14 +698,13 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b if (backpoly) { // Correct back bbox to include floor/ceiling convex polygon - WalkBSPNode(bsp->children[1], backpoly, &bsp->children[1], - bsp->bbox[1]); + WalkBSPNode(bsp->children[1], backpoly, &bsp->children[1], bsp->bbox[1]); - // enlarge bbox with seconde child + // enlarge bbox with second child M_AddToBox(bbox, bsp->bbox[1][BOXLEFT ], - bsp->bbox[1][BOXTOP ]); + bsp->bbox[1][BOXTOP ]); M_AddToBox(bbox, bsp->bbox[1][BOXRIGHT ], - bsp->bbox[1][BOXBOTTOM]); + bsp->bbox[1][BOXBOTTOM]); } } @@ -785,9 +784,9 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) if (bspnum & NF_SUBSECTOR) { - if (bspnum!=-1) + if (bspnum != -1) { - bspnum&=~NF_SUBSECTOR; + bspnum &= ~NF_SUBSECTOR; q = extrasubsectors[bspnum].planepoly; if (poly == q || !q) return; From 09d9a555c65e0fed2329bc79860bb572e2969a22 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 16:21:07 -0500 Subject: [PATCH 15/32] compiler SSE tweak for 32-bit --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index fbf75f26..36cd1608 100644 --- a/src/Makefile +++ b/src/Makefile @@ -288,7 +288,8 @@ OPTS += -DCOMPVERSION ifndef NONX86 ifndef GCC29 - M5=-march=pentium + #M5=-march=pentium + M5=-march=nocona -msse -mfpmath=sse M4=-march=i486 else M5=-mpentium From c1e0041a0bf1becf6902a8290d08c7fe18a36cf8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 21:22:13 +0000 Subject: [PATCH 16/32] copy doom legacy's replacement for the den == 0.0 calc in fracdivline --- src/hardware/hw_bsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 8fec4f96..e0ab5b0d 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -193,7 +193,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v2dy = bsp->dy; den = v2dy*v1dx - v2dx*v1dy; - if (den == 0.0) + if (fabs(den) < 1.0E-36f) // avoid checking exactly for 0.0 return NULL; // parallel // first check the frac along the polygon segment, From abae63a64bb99ded02e91d1edf29f33fff5aeb1a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 16:47:24 -0500 Subject: [PATCH 17/32] SameVertice floating point match; fixes 64-bit OGL holes --- src/hardware/hw_bsp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index e0ab5b0d..dc49908b 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -254,10 +254,21 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) if (diff < -1.5f || diff > 1.5f) return false; #else +#if 0 if (p1->x != p2->x) return false; if (p1->y != p2->y) return false; +#else +#define DIVLINE_VERTEX_DIFF 0.45f + float ep = DIVLINE_VERTEX_DIFF; + if (fabsf( p2->x - p1->x ) > ep ) + return false; + if (fabsf( p2->y - p1->y ) > ep ) + return false; + // p1 and p2 are considered the same vertex + return true; +#endif #endif // p1 and p2 are considered the same vertex return true; From de96fe8e7b9c00eab7eeef2c8a907a85b19ac5cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 16:47:38 -0500 Subject: [PATCH 18/32] Revert "compiler SSE tweak for 32-bit" This reverts commit 09d9a555c65e0fed2329bc79860bb572e2969a22. --- src/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 36cd1608..fbf75f26 100644 --- a/src/Makefile +++ b/src/Makefile @@ -288,8 +288,7 @@ OPTS += -DCOMPVERSION ifndef NONX86 ifndef GCC29 - #M5=-march=pentium - M5=-march=nocona -msse -mfpmath=sse + M5=-march=pentium M4=-march=i486 else M5=-mpentium From e0079ea1a29c918b8493183f3aeb1622684b7714 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 23:28:07 +0000 Subject: [PATCH 19/32] remove NearVertice (which was unused anyway), clean up maz's changes --- src/hardware/hw_bsp.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index dc49908b..53602cc7 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -217,29 +217,6 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, return &pt; } -#if 0 -//Hurdler: it's not used anymore -static boolean NearVertice (polyvertex_t *p1, polyvertex_t *p2) -{ -#if 1 - float diff; - diff = p2->x - p1->x; - if (diff < -1.5f || diff > 1.5f) - return false; - diff = p2->y - p1->y; - if (diff < -1.5f || diff > 1.5f) - return false; -#else - if (p1->x != p2->x) - return false; - if (p1->y != p2->y) - return false; -#endif - // p1 and p2 are considered the same vertex - return true; -} -#endif - // if two vertice coords have a x and/or y difference // of less or equal than 1 FRACUNIT, they are considered the same // point. Note: hardcoded value, 1.0f could be anything else. @@ -253,8 +230,7 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) diff = p2->y - p1->y; if (diff < -1.5f || diff > 1.5f) return false; -#else -#if 0 +#elif 0 if (p1->x != p2->x) return false; if (p1->y != p2->y) @@ -263,12 +239,9 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) #define DIVLINE_VERTEX_DIFF 0.45f float ep = DIVLINE_VERTEX_DIFF; if (fabsf( p2->x - p1->x ) > ep ) - return false; - if (fabsf( p2->y - p1->y ) > ep ) - return false; - // p1 and p2 are considered the same vertex - return true; -#endif + return false; + if (fabsf( p2->y - p1->y ) > ep ) + return false; #endif // p1 and p2 are considered the same vertex return true; From 6fd66bdb49fe85b675216b1d24ab5fd10ae45a85 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 14 Dec 2018 19:33:40 -0500 Subject: [PATCH 20/32] Clear float equal warnings --- src/Makefile.cfg | 4 +--- src/command.c | 2 +- src/hardware/hw_bsp.c | 9 +++++++-- src/hardware/hw_draw.c | 12 ++++++------ src/hardware/hw_main.c | 10 +++++----- src/hardware/r_opengl/r_opengl.c | 11 +++++++---- src/r_data.c | 2 +- src/sdl/mixer_sound.c | 6 ++++-- 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index cdd4c3c7..1238050b 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -112,9 +112,7 @@ ifndef GCC295 WFLAGS+=-Wno-div-by-zero endif #WFLAGS+=-Wsystem-headers -ifndef ERRORMODE -#WFLAGS+=-Wfloat-equal -endif +WFLAGS+=-Wfloat-equal #WFLAGS+=-Wtraditional ifdef VCHELP WFLAGS+=-Wdeclaration-after-statement diff --git a/src/command.c b/src/command.c index 16f18749..3183ba70 100644 --- a/src/command.c +++ b/src/command.c @@ -1102,7 +1102,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth) if (var->flags & CV_FLOAT) { double d = atof(valstr); - if (!d && valstr[0] != '0') + if (fpclassify(d) == FP_ZERO && valstr[0] != '0') v = INT32_MIN; else v = (INT32)(d * FRACUNIT); diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index a180697d..98f10c95 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -193,7 +193,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v2dy = bsp->dy; den = v2dy*v1dx - v2dx*v1dy; - if (den == 0) + if (fabsf(den) < 1.0E-36f) return NULL; // parallel // first check the frac along the polygon segment, @@ -253,11 +253,16 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) diff = p2->y - p1->y; if (diff < -1.5f || diff > 1.5f) return false; -#else +#elif 0 if (p1->x != p2->x) return false; if (p1->y != p2->y) return false; +#else + if (fabsf( p2->x - p1->x ) > 1.0E-36f ) + return false; + if (fabsf( p2->y - p1->y ) > 1.0E-36f ) + return false; #endif // p1 and p2 are considered the same vertex return true; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 75523f3d..a2ebcb05 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -227,14 +227,14 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, Z_Free(realpatch); } // centre screen - if ((float)vid.width != (float)BASEVIDWIDTH * dupx) + if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) { if (option & V_SNAPTORIGHT) cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; } - if ((float)vid.height != (float)BASEVIDHEIGHT * dupy) + if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); @@ -375,14 +375,14 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal Z_Free(realpatch); } // centre screen - if ((float)vid.width != (float)BASEVIDWIDTH * dupx) + if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) { if (option & V_SNAPTORIGHT) cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; } - if ((float)vid.height != (float)BASEVIDHEIGHT * dupy) + if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); @@ -846,14 +846,14 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fw *= dupx; fh *= dupy; - if ((float)vid.width != (float)BASEVIDWIDTH * dupx) + if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) { if (color & V_SNAPTORIGHT) fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; } - if ((float)vid.height != (float)BASEVIDHEIGHT * dupy) + if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { // same thing here if (color & V_SNAPTOBOTTOM) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb5e2a71..2c31c01e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4137,7 +4137,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t swallVerts[0].z = swallVerts[3].z = spr->z1; swallVerts[2].z = swallVerts[1].z = spr->z2; - if (spr->mobj && this_scale != 1.0f) + if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) { // Always a pixel above the floor, perfectly flat. swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->ty - gpatch->topoffset * this_scale - (floorheight+3); @@ -4305,7 +4305,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[1].z = wallVerts[2].z = spr->z2; wallVerts[2].y = wallVerts[3].y = spr->ty; - if (spr->mobj && this_scale != 1.0f) + if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale; else wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; @@ -4585,7 +4585,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) wallVerts[0].x = wallVerts[3].x = spr->x1; wallVerts[2].x = wallVerts[1].x = spr->x2; wallVerts[2].y = wallVerts[3].y = spr->ty; - if (spr->mobj && this_scale != 1.0f) + if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale; else wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; @@ -4831,7 +4831,7 @@ static void HWR_SortVisSprites(void) best = ds; } // order visprites of same scale by dispoffset, smallest first - else if (ds->tz == bestdist && ds->dispoffset < bestdispoffset) + else if (fabsf(ds->tz - bestdist) < 1.0E-36f && ds->dispoffset < bestdispoffset) { bestdispoffset = ds->dispoffset; best = ds; @@ -5752,7 +5752,7 @@ void HWR_SetViewSize(void) gr_viewwindowx = (vid.width - gr_viewwidth) / 2; gr_windowcenterx = (float)(vid.width / 2); - if (gr_viewwidth == vid.width) + if (fabsf(gr_viewwidth - vid.width) < 1.0E-36f) { gr_baseviewwindowy = 0; gr_basewindowcentery = gr_viewheight / 2; // window top left corner at 0,0 diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 2d9f4219..773fe74a 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -602,7 +602,8 @@ static void GLPerspective(GLdouble fovy, GLdouble aspect) const GLdouble deltaZ = zFar - zNear; GLdouble cotangent; - if ((deltaZ == 0.0f) || (sine == 0.0f) || (aspect == 0.0f)) { + if ((fabsf(deltaZ) < 1.0E-36f) || fpclassify(sine) == FP_ZERO || fpclassify(aspect) == FP_ZERO) + { return; } cotangent = cos(radians) / sine; @@ -641,7 +642,7 @@ static void GLProject(GLdouble objX, GLdouble objY, GLdouble objZ, out[2] * projMatrix[2*4+i] + out[3] * projMatrix[3*4+i]; } - if (in[3] == 0.0f) return; + if (fpclassify(in[3]) == FP_ZERO) return; in[0] /= in[3]; in[1] /= in[3]; in[2] /= in[3]; @@ -1986,7 +1987,7 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, pglTexCoord2f(s, t); - if (!nextframe || pol == 0.0f) + if (!nextframe || fpclassify(pol) == FP_ZERO) { pglNormal3f(frame->vertices[pindex].normal[0], frame->vertices[pindex].normal[1], @@ -2055,6 +2056,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) pglLoadIdentity(); if (stransform) { + boolean fovx90; // keep a trace of the transformation for md2 memcpy(&md2_transform, stransform, sizeof (md2_transform)); @@ -2069,7 +2071,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) pglMatrixMode(GL_PROJECTION); pglLoadIdentity(); - special_splitscreen = (stransform->splitscreen && stransform->fovxangle == 90.0f); + fovx90 = stransform->fovxangle > 0.0f && fabsf(stransform->fovxangle - 90.0f) < 0.5f; + special_splitscreen = (stransform->splitscreen && fovx90); if (special_splitscreen) GLPerspective(53.13l, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5) else diff --git a/src/r_data.c b/src/r_data.c index 453ef69e..abac871d 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1220,7 +1220,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) continue; if (maskcolor == extra_colormaps[i].maskcolor && fadecolor == extra_colormaps[i].fadecolor - && (float)maskamt == (float)extra_colormaps[i].maskamt + && fabsf(maskamt - extra_colormaps[i].maskamt) < 1.0E-36f && fadestart == extra_colormaps[i].fadestart && fadeend == extra_colormaps[i].fadeend && fog == extra_colormaps[i].fog) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 3f9b09f1..f43be8bc 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -759,6 +759,7 @@ void I_UnloadSong(void) boolean I_PlaySong(boolean looping) { + boolean lpz = fpclassify(loop_point) == FP_ZERO; #ifdef HAVE_LIBGME if (gme) { @@ -772,14 +773,15 @@ boolean I_PlaySong(boolean looping) if (!music) return false; - if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1) + + if (Mix_PlayMusic(music, looping && lpz ? -1 : 0) == -1) { CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); return false; } Mix_VolumeMusic((UINT32)music_volume*128/31); - if (loop_point != 0.0f) + if (!lpz) Mix_HookMusicFinished(music_loop); return true; } From 78634679f1759ef91ac05de655bb5836069460f0 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 14 Dec 2018 20:42:37 -0500 Subject: [PATCH 21/32] fix compiling for MSVC --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 773fe74a..b324fced 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -602,7 +602,7 @@ static void GLPerspective(GLdouble fovy, GLdouble aspect) const GLdouble deltaZ = zFar - zNear; GLdouble cotangent; - if ((fabsf(deltaZ) < 1.0E-36f) || fpclassify(sine) == FP_ZERO || fpclassify(aspect) == FP_ZERO) + if ((fabsf((float)deltaZ) < 1.0E-36f) || fpclassify(sine) == FP_ZERO || fpclassify(aspect) == FP_ZERO) { return; } From 15d067368513dec677986b8a39d9c96be65ff0d8 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 14 Dec 2018 21:31:00 -0500 Subject: [PATCH 22/32] fix compiling for clang --- src/hardware/hw_bsp.c | 2 +- src/r_data.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 98f10c95..2348d71a 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -193,7 +193,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v2dy = bsp->dy; den = v2dy*v1dx - v2dx*v1dy; - if (fabsf(den) < 1.0E-36f) + if (fabsf((float)den) < 1.0E-36f) return NULL; // parallel // first check the frac along the polygon segment, diff --git a/src/r_data.c b/src/r_data.c index abac871d..e0b9a814 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1220,7 +1220,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) continue; if (maskcolor == extra_colormaps[i].maskcolor && fadecolor == extra_colormaps[i].fadecolor - && fabsf(maskamt - extra_colormaps[i].maskamt) < 1.0E-36f + && fabsf((float)(maskamt - extra_colormaps[i].maskamt)) < 1.0E-36f && fadestart == extra_colormaps[i].fadestart && fadeend == extra_colormaps[i].fadeend && fog == extra_colormaps[i].fog) From 6e79722437560d3444f6e1a993cbc6c2dd5e5d05 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sun, 16 Dec 2018 14:01:28 -0500 Subject: [PATCH 23/32] Fix float-equal warning in Win32 interface --- src/win32/win_vid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index a9dd097b..cca7810b 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -996,7 +996,7 @@ static INT32 WINAPI VID_SetDirectDrawMode(viddef_t *lvid, vmode_t *currentmode) // but rather render to memory bitmap buffer lvid->direct = NULL; - if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT)) + if (!cv_stretch.value && fabsf((float)vid.width/vid.height - ((float)BASEVIDWIDTH/BASEVIDHEIGHT)) > 1.0E-36f) vid.height = (int)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match return 1; From cc22ef3f050073aabd1d311ac746d297a63ce482 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sun, 16 Dec 2018 16:05:18 -0500 Subject: [PATCH 24/32] Add deprecation warning to admin --- src/dehacked.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dehacked.c b/src/dehacked.c index db1d6eed..dd671fd7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8303,6 +8303,7 @@ static inline int lib_getenum(lua_State *L) LUA_PushUserdata(L, &players[serverplayer], META_PLAYER); return 1; } else if (fastcmp(word,"admin")) { // BACKWARDS COMPATIBILITY HACK: This was replaced with IsPlayerAdmin(), but some 2.1 Lua scripts still use the admin variable. It now points to the first admin player in the array. + LUA_Deprecated(L, "admin", "IsPlayerAdmin(player)"); if (!playeringame[adminplayers[0]] || IsPlayerAdmin(serverplayer)) return 0; LUA_PushUserdata(L, &players[adminplayers[0]], META_PLAYER); From 67cd6dcdd2479fcf4b58a4299cc17a57b9102304 Mon Sep 17 00:00:00 2001 From: Azeonus Date: Tue, 18 Dec 2018 16:37:01 -0500 Subject: [PATCH 25/32] dispoffset OGL fix [by Azeonus] --- src/hardware/hw_main.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb5e2a71..d7ab4f39 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4333,7 +4333,17 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[3].tow = wallVerts[2].tow = 0; wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t; } - + + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) { + float co = -gr_viewcos*(0.05*spr->dispoffset); + float si = -gr_viewsin*(0.05*spr->dispoffset); + wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; + wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; + wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; + wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + } + realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; towtop = wallVerts[3].tow; @@ -4634,7 +4644,17 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) //////////////////// HWR_DrawSpriteShadow(spr, gpatch, this_scale); } - + + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) { + float co = -gr_viewcos*(0.05*spr->dispoffset); + float si = -gr_viewsin*(0.05*spr->dispoffset); + wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; + wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; + wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; + wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + } + // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured From 96cad09db674c5810a9992124aa694ccad1f1877 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Dec 2018 16:59:59 -0500 Subject: [PATCH 26/32] Change 0.05 to 0.05f --- src/hardware/hw_main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d7ab4f39..db679223 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4333,17 +4333,17 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[3].tow = wallVerts[2].tow = 0; wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t; } - + // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { - float co = -gr_viewcos*(0.05*spr->dispoffset); - float si = -gr_viewsin*(0.05*spr->dispoffset); + float co = -gr_viewcos*(0.05f*spr->dispoffset); + float si = -gr_viewsin*(0.05f*spr->dispoffset); wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; } - + realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; towtop = wallVerts[3].tow; @@ -4644,17 +4644,17 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) //////////////////// HWR_DrawSpriteShadow(spr, gpatch, this_scale); } - + // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { - float co = -gr_viewcos*(0.05*spr->dispoffset); - float si = -gr_viewsin*(0.05*spr->dispoffset); + float co = -gr_viewcos*(0.05f*spr->dispoffset); + float si = -gr_viewsin*(0.05f*spr->dispoffset); wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; } - + // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured From 78501dcd0c5ed09d7cd65b7da2d72b39579cb3a3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 20 Dec 2018 01:11:07 -0500 Subject: [PATCH 27/32] Comment out stray PK3 blockmap message --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 93eb7558..2e568800 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2000,7 +2000,7 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count, const char *lumpname if (!count || count >= 0x20000) return false; - CONS_Printf("Reading blockmap lump for pk3...\n"); + //CONS_Printf("Reading blockmap lump for pk3...\n"); // no need to malloc anything, assume the data is uncompressed for now count /= 2; From 7f8d16d3cd1326a3cc621852f3c62cacee2e32ce Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 20 Dec 2018 02:25:36 -0500 Subject: [PATCH 28/32] Add DEVELOP build flag to version string --- src/d_netcmd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8abfb870..bc641726 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3440,7 +3440,7 @@ static void Command_Version_f(void) #elif defined(__linux__) CONS_Printf("Linux "); #elif defined(MACOSX) - CONS_Printf("macOS" ); + CONS_Printf("macOS "); #elif defined(UNIXCOMMON) CONS_Printf("Unix (Common) "); #else @@ -3465,6 +3465,11 @@ static void Command_Version_f(void) CONS_Printf("\x85" "DEBUG " "\x80"); #endif + // DEVELOP build +#ifdef DEVELOP + CONS_Printf("\x87" "DEVELOP " "\x80"); +#endif + CONS_Printf("\n"); } From b57204fc129b4d865cd0da05163aced4c9fea988 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 20 Dec 2018 16:37:49 -0500 Subject: [PATCH 29/32] Fix 2p control menu graying out --- src/m_menu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1e1b1e69..c7b1b24f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6837,9 +6837,10 @@ static void M_Setup2PControlsMenu(INT32 choice) OP_MPControlsMenu[0].status = IT_GRAYEDOUT2; OP_MPControlsMenu[1].status = IT_GRAYEDOUT2; OP_MPControlsMenu[2].status = IT_GRAYEDOUT2; - // Hide the pause/console controls too + // Hide the pause/console and system menu controls too OP_MiscControlsMenu[3].status = IT_GRAYEDOUT2; - OP_MiscControlsMenu[4].status = IT_GRAYEDOUT2; + OP_MiscControlsMenu[6].status = IT_GRAYEDOUT2; + OP_MiscControlsMenu[8].status = IT_GRAYEDOUT2; OP_ControlListDef.prevMenu = &OP_P2ControlsDef; M_SetupNextMenu(&OP_ControlListDef); From 0519d8c52d298fe9d258d6174c8e2dc6176754b9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 20 Dec 2018 16:46:40 -0500 Subject: [PATCH 30/32] Update CMake paths for Windows DLLs --- src/sdl/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index a3626970..f7b7c7ba 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -278,13 +278,13 @@ if(${SDL2_FOUND}) if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles") if(${SRB2_SYSTEM_BITS} EQUAL 64) find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/Bin/Resources/x86_64 + HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin ) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/Bin/Resources/i686 + HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin ) @@ -292,13 +292,13 @@ if(${SDL2_FOUND}) else() if(${SRB2_SYSTEM_BITS} EQUAL 64) find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/Bin/Resources/x86_64 + HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64 ) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" - HINTS ${CMAKE_SOURCE_DIR}/Bin/Resources/i686 + HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86 ) From 1291d35e08c057c9b52a863afbf28c7168696dce Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Thu, 4 Oct 2018 22:06:56 -0400 Subject: [PATCH 31/32] Don't allow non-keyboard keys to screenshot/gif in menus --- src/m_misc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/m_misc.c b/src/m_misc.c index a4f53c71..80c58d64 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1531,6 +1531,10 @@ boolean M_ScreenshotResponder(event_t *ev) return false; ch = ev->data1; + + if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! + return false; + if (ch == KEY_F8 || ch == gamecontrol[gc_screenshot][0] || ch == gamecontrol[gc_screenshot][1]) // remappable F8 M_ScreenShot(); else if (ch == KEY_F9 || ch == gamecontrol[gc_recordgif][0] || ch == gamecontrol[gc_recordgif][1]) // remappable F9 From 8707b2f40ac9ae47dbb2956435a5fbf4904cc88a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 22 Dec 2018 01:43:58 -0500 Subject: [PATCH 32/32] Center window on current monitor during vidmode change --- src/sdl/i_video.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 2c199c2d..dad3b941 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -200,7 +200,10 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) } // Reposition window only in windowed mode SDL_SetWindowSize(window, width, height); - SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + SDL_SetWindowPosition(window, + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); } } else