This commit is contained in:
MPC 2018-12-20 18:52:51 -03:00
parent fcb65951b8
commit 9d93f54b67
3 changed files with 5 additions and 24 deletions

View File

@ -121,16 +121,6 @@ fixed_t FixedHypot(fixed_t x, fixed_t y)
return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2)
} }
fixed_t FixedEuclidean(fixed_t x2, fixed_t y2, fixed_t x1, fixed_t y1)
{
INT64 dx = x2-x1;
INT64 dy = y2-y1;
union {INT64 i; float x;} u;
u.x = (dx*dx+dy*dy);
u.i = (1<<29) + (u.i >> 1) - (1<<22);
return (fixed_t)llrintf(u.x);
}
vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y) vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y)
{ {
vec->x = x; vec->x = x;

View File

@ -237,17 +237,6 @@ FUNCMATH fixed_t FixedSqrt(fixed_t x);
*/ */
FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y); FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y);
/** \brief The FixedEuclidean function
\param x fixed_t number
\param y fixed_t number
\return sqrt(x*x+y*y)
*/
fixed_t FixedEuclidean(fixed_t x2, fixed_t y2, fixed_t x1, fixed_t y1);
/** \brief The FixedFloor function /** \brief The FixedFloor function
\param x fixed_t number \param x fixed_t number

View File

@ -389,7 +389,9 @@ static inline void P_LoadVertexes(lumpnum_t lumpnum)
*/ */
fixed_t P_SegLength(seg_t *seg) fixed_t P_SegLength(seg_t *seg)
{ {
return FixedEuclidean(seg->v2->x,seg->v2->y,seg->v1->x,seg->v1->y); 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 #ifdef HWRENDER
@ -2626,7 +2628,7 @@ static boolean P_CanSave(void)
{ {
// Saving is completely ignored under these conditions: // Saving is completely ignored under these conditions:
if ((cursaveslot < 0) // Playing without saving if ((cursaveslot < 0) // Playing without saving
|| (!modifiedgame || savemoddata) // Game is modified || (!modifiedgame || savemoddata) // Game is modified
|| (netgame || multiplayer) // Not in single-player || (netgame || multiplayer) // Not in single-player
|| (demoplayback || demorecording || metalrecording) // Currently in demo || (demoplayback || demorecording || metalrecording) // Currently in demo
|| (players[consoleplayer].lives <= 0) // Completely dead || (players[consoleplayer].lives <= 0) // Completely dead
@ -2637,7 +2639,7 @@ static boolean P_CanSave(void)
return true; // Saving should ALWAYS happen! return true; // Saving should ALWAYS happen!
else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER) else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER)
return false; // Saving should NEVER happen! 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. // 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) return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
&& (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete) && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)