diff --git a/src/m_misc.c b/src/m_misc.c
index 66d2c390..af5994c8 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
diff --git a/src/p_setup.c b/src/p_setup.c
index 8ab6d004..4e66bebb 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -382,30 +382,26 @@ static inline void P_LoadVertexes(lumpnum_t lumpnum)
Z_Free(data);
}
-
-//
-// Computes the line length in fracunits, the OpenGL render needs this
-//
-
/** Computes the length of a seg in fracunits.
- * This is needed for splats.
*
* \param seg Seg to compute length for.
* \return Length in fracunits.
*/
fixed_t P_SegLength(seg_t *seg)
{
- fixed_t dx, dy;
-
- // make a vector (start at origin)
- dx = seg->v2->x - seg->v1->x;
- dy = seg->v2->y - seg->v1->y;
-
- return FixedHypot(dx, dy);
+ INT64 dx = (seg->v2->x - seg->v1->x)>>1;
+ INT64 dy = (seg->v2->y - seg->v1->y)>>1;
+ return FixedHypot(dx, dy)<<1;
}
#ifdef HWRENDER
-static inline float P_SegLengthf(seg_t *seg)
+/** Computes the length of a seg as a float.
+ * This is needed for OpenGL.
+ *
+ * \param seg Seg to compute length for.
+ * \return Length as a float.
+ */
+static inline float P_SegLengthFloat(seg_t *seg)
{
float dx, dy;
@@ -441,11 +437,11 @@ static void P_LoadRawSegs(UINT8 *data, size_t i)
li->v1 = &vertexes[SHORT(ml->v1)];
li->v2 = &vertexes[SHORT(ml->v2)];
-#ifdef HWRENDER // not win32 only 19990829 by Kin
- // used for the hardware render
- if (rendermode != render_soft && rendermode != render_none)
+ li->length = P_SegLength(li);
+#ifdef HWRENDER
+ if (rendermode == render_opengl)
{
- li->flength = P_SegLengthf(li);
+ li->flength = P_SegLengthFloat(li);
//Hurdler: 04/12/2000: for now, only used in hardware mode
li->lightmaps = NULL; // list of static lightmap for this seg
}
@@ -2632,7 +2628,7 @@ static boolean P_CanSave(void)
{
// Saving is completely ignored under these conditions:
if ((cursaveslot < 0) // Playing without saving
- || (!modifiedgame || savemoddata) // Game is modified
+ || (!modifiedgame || savemoddata) // Game is modified
|| (netgame || multiplayer) // Not in single-player
|| (demoplayback || demorecording || metalrecording) // Currently in demo
|| (players[consoleplayer].lives <= 0) // Completely dead
@@ -2643,7 +2639,7 @@ static boolean P_CanSave(void)
return true; // Saving should ALWAYS happen!
else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER)
return false; // Saving should NEVER happen!
-
+
// Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload.
return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
&& (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)
diff --git a/src/r_bsp.c b/src/r_bsp.c
index a41c6403..cae66844 100644
--- a/src/r_bsp.c
+++ b/src/r_bsp.c
@@ -403,17 +403,17 @@ static void R_AddLine(seg_t *line)
{
INT32 x1, x2;
angle_t angle1, angle2, span, tspan;
- static sector_t tempsec; // ceiling/water hack
+ static sector_t tempsec;
+
+ portalline = false;
if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES))
return;
+ // big room fix
+ angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y);
+ angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y);
curline = line;
- portalline = false;
-
- // OPTIMIZE: quickly reject orthogonal back sides.
- angle1 = R_PointToAngle(line->v1->x, line->v1->y);
- angle2 = R_PointToAngle(line->v2->x, line->v2->y);
// Clip to view edges.
span = angle1 - angle2;
@@ -592,69 +592,35 @@ INT32 checkcoord[12][4] =
{2, 1, 3, 0}
};
-static boolean R_CheckBBox(fixed_t *bspcoord)
+static boolean R_CheckBBox(const fixed_t *bspcoord)
{
- INT32 boxpos, sx1, sx2;
- fixed_t px1, py1, px2, py2;
- angle_t angle1, angle2, span, tspan;
+ angle_t angle1, angle2;
+ INT32 sx1, sx2, boxpos;
+ const INT32* check;
cliprange_t *start;
// Find the corners of the box that define the edges from current viewpoint.
- if (viewx <= bspcoord[BOXLEFT])
- boxpos = 0;
- else if (viewx < bspcoord[BOXRIGHT])
- boxpos = 1;
- else
- boxpos = 2;
-
- if (viewy >= bspcoord[BOXTOP])
- boxpos |= 0;
- else if (viewy > bspcoord[BOXBOTTOM])
- boxpos |= 1<<2;
- else
- boxpos |= 2<<2;
-
- if (boxpos == 5)
+ if ((boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8)) == 5)
return true;
- px1 = bspcoord[checkcoord[boxpos][0]];
- py1 = bspcoord[checkcoord[boxpos][1]];
- px2 = bspcoord[checkcoord[boxpos][2]];
- py2 = bspcoord[checkcoord[boxpos][3]];
+ check = checkcoord[boxpos];
- // check clip list for an open space
- angle1 = R_PointToAngle2(viewx>>1, viewy>>1, px1>>1, py1>>1) - viewangle;
- angle2 = R_PointToAngle2(viewx>>1, viewy>>1, px2>>1, py2>>1) - viewangle;
+ // big room fix
+ angle1 = R_PointToAngleEx(viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]) - viewangle;
+ angle2 = R_PointToAngleEx(viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]) - viewangle;
- span = angle1 - angle2;
-
- // Sitting on a line?
- if (span >= ANGLE_180)
- return true;
-
- tspan = angle1 + clipangle;
-
- if (tspan > doubleclipangle)
+ if ((signed)angle1 < (signed)angle2)
{
- tspan -= doubleclipangle;
-
- // Totally off the left edge?
- if (tspan >= span)
- return false;
-
- angle1 = clipangle;
+ if ((angle1 >= ANGLE_180) && (angle1 < ANGLE_270))
+ angle1 = ANGLE_180-1;
+ else
+ angle2 = -ANGLE_180;
}
- tspan = clipangle - angle2;
- if (tspan > doubleclipangle)
- {
- tspan -= doubleclipangle;
- // Totally off the left edge?
- if (tspan >= span)
- return false;
-
- angle2 = -(signed)clipangle;
- }
+ if ((signed)angle2 >= (signed)clipangle) return false;
+ if ((signed)angle1 <= -(signed)clipangle) return false;
+ if ((signed)angle1 >= (signed)clipangle) angle1 = clipangle;
+ if ((signed)angle2 <= -(signed)clipangle) angle2 = 0-clipangle;
// Find the first clippost that touches the source post (adjacent pixels are touching).
angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT;
@@ -663,9 +629,7 @@ static boolean R_CheckBBox(fixed_t *bspcoord)
sx2 = viewangletox[angle2];
// Does not cross a pixel.
- if (sx1 == sx2)
- return false;
- sx2--;
+ if (sx1 >= sx2) return false;
start = solidsegs;
while (start->last < sx2)
diff --git a/src/r_defs.h b/src/r_defs.h
index b936c7e7..1cb4e081 100644
--- a/src/r_defs.h
+++ b/src/r_defs.h
@@ -573,6 +573,7 @@ typedef struct seg_s
sector_t *frontsector;
sector_t *backsector;
+ fixed_t length; // precalculated seg length
#ifdef HWRENDER
// new pointers so that AdjustSegs doesn't mess with v1/v2
void *pv1; // polyvertex_t
diff --git a/src/r_main.c b/src/r_main.c
index 2b0fbc39..94945af5 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -355,6 +355,29 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y)
return R_PointToDist2(viewx, viewy, x, y);
}
+angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1)
+{
+ INT64 dx = x1-x2;
+ INT64 dy = y1-y2;
+ if (dx < INT32_MIN || dx > INT32_MAX || dy < INT32_MIN || dy > INT32_MAX)
+ {
+ x1 = (int)(dx / 2 + x2);
+ y1 = (int)(dy / 2 + y2);
+ }
+ return (y1 -= y2, (x1 -= x2) || y1) ?
+ x1 >= 0 ?
+ y1 >= 0 ?
+ (x1 > y1) ? tantoangle[SlopeDivEx(y1,x1)] : // octant 0
+ ANGLE_90-tantoangle[SlopeDivEx(x1,y1)] : // octant 1
+ x1 > (y1 = -y1) ? 0-tantoangle[SlopeDivEx(y1,x1)] : // octant 8
+ ANGLE_270+tantoangle[SlopeDivEx(x1,y1)] : // octant 7
+ y1 >= 0 ? (x1 = -x1) > y1 ? ANGLE_180-tantoangle[SlopeDivEx(y1,x1)] : // octant 3
+ ANGLE_90 + tantoangle[SlopeDivEx(x1,y1)] : // octant 2
+ (x1 = -x1) > (y1 = -y1) ? ANGLE_180+tantoangle[SlopeDivEx(y1,x1)] : // octant 4
+ ANGLE_270-tantoangle[SlopeDivEx(x1,y1)] : // octant 5
+ 0;
+}
+
//
// R_ScaleFromGlobalAngle
// Returns the texture mapping scale for the current line (horizontal span)
diff --git a/src/r_main.h b/src/r_main.h
index 81fa13de..6ae5aa22 100644
--- a/src/r_main.h
+++ b/src/r_main.h
@@ -58,6 +58,7 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node);
INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line);
angle_t R_PointToAngle(fixed_t x, fixed_t y);
angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
+angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1);
fixed_t R_PointToDist(fixed_t x, fixed_t y);
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
diff --git a/src/r_segs.c b/src/r_segs.c
index 1637ce90..6d6ba1ef 100644
--- a/src/r_segs.c
+++ b/src/r_segs.c
@@ -1647,6 +1647,23 @@ static void R_RenderSegLoop (void)
}
}
+// Uses precalculated seg->length
+static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2)
+{
+ if (!seg->linedef->dy)
+ return llabs(y2 - seg->v1->y);
+ else if (!seg->linedef->dx)
+ return llabs(x2 - seg->v1->x);
+ else
+ {
+ INT64 dx = (seg->v2->x)-(seg->v1->x);
+ INT64 dy = (seg->v2->y)-(seg->v1->y);
+ INT64 vdx = x2-(seg->v1->x);
+ INT64 vdy = y2-(seg->v1->y);
+ return ((dy*vdx)-(dx*vdy))/(seg->length);
+ }
+}
+
//
// R_StoreWallRange
// A wall segment will be drawn
@@ -1657,6 +1674,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
fixed_t hyp;
fixed_t sineval;
angle_t distangle, offsetangle;
+ boolean longboi;
#ifndef ESLOPE
fixed_t vtop;
#endif
@@ -1702,10 +1720,15 @@ void R_StoreWallRange(INT32 start, INT32 stop)
offsetangle = ANGLE_90;
distangle = ANGLE_90 - offsetangle;
- hyp = R_PointToDist (curline->v1->x, curline->v1->y);
sineval = FINESINE(distangle>>ANGLETOFINESHIFT);
- rw_distance = FixedMul (hyp, sineval);
+ hyp = R_PointToDist(curline->v1->x, curline->v1->y);
+ rw_distance = FixedMul(hyp, sineval);
+ longboi = (hyp >= INT32_MAX);
+
+ // big room fix
+ if (longboi)
+ rw_distance = (fixed_t)R_CalcSegDist(curline,viewx,viewy);
ds_p->x1 = rw_x = start;
ds_p->x2 = stop;
@@ -2562,8 +2585,18 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (offsetangle > ANGLE_90)
offsetangle = ANGLE_90;
- sineval = FINESINE(offsetangle >>ANGLETOFINESHIFT);
- rw_offset = FixedMul (hyp, sineval);
+ sineval = FINESINE(offsetangle>>ANGLETOFINESHIFT);
+ rw_offset = FixedMul(hyp, sineval);
+
+ // big room fix
+ if (longboi)
+ {
+ INT64 dx = (curline->v2->x)-(curline->v1->x);
+ INT64 dy = (curline->v2->y)-(curline->v1->y);
+ INT64 vdx = viewx-(curline->v1->x);
+ INT64 vdy = viewy-(curline->v1->y);
+ rw_offset = ((dx*vdx-dy*vdy))/(curline->length);
+ }
if (rw_normalangle-rw_angle1 < ANGLE_180)
rw_offset = -rw_offset;
diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj
index 3e4a9ebb..00ed0db3 100644
--- a/src/sdl/Srb2SDL-vc10.vcxproj
+++ b/src/sdl/Srb2SDL-vc10.vcxproj
@@ -297,7 +297,7 @@
-
+
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
diff --git a/src/tables.c b/src/tables.c
index d4e0e5df..7d513707 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -37,6 +37,15 @@ unsigned SlopeDiv(unsigned num, unsigned den)
return ans <= SLOPERANGE ? ans : SLOPERANGE;
}
+UINT64 SlopeDivEx(unsigned int num, unsigned int den)
+{
+ UINT64 ans;
+ if (den < 512)
+ return SLOPERANGE;
+ ans = ((UINT64)num<<3)/(den>>8);
+ return ans <= SLOPERANGE ? ans : SLOPERANGE;
+}
+
fixed_t AngleFixed(angle_t af)
{
angle_t wa = ANGLE_180;
diff --git a/src/tables.h b/src/tables.h
index 1ea49a62..e82b147d 100644
--- a/src/tables.h
+++ b/src/tables.h
@@ -83,6 +83,8 @@ extern angle_t tantoangle[SLOPERANGE+1];
// Utility function, called by R_PointToAngle.
FUNCMATH unsigned SlopeDiv(unsigned num, unsigned den);
+// Only called by R_PointToAngleEx
+UINT64 SlopeDivEx(unsigned int num, unsigned int den);
// 360 - angle_t(ANGLE_45) = ANGLE_315
FUNCMATH FUNCINLINE static ATTRINLINE angle_t InvAngle(angle_t a)
diff --git a/src/win32/Srb2win-vc10.vcxproj b/src/win32/Srb2win-vc10.vcxproj
index 5bfa29b8..ed6b46b8 100644
--- a/src/win32/Srb2win-vc10.vcxproj
+++ b/src/win32/Srb2win-vc10.vcxproj
@@ -132,7 +132,7 @@
-
+