mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Factor dist() and ldist() into common.c.
git-svn-id: https://svn.eduke32.com/eduke32@3243 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
375d164138
commit
7614a78cc5
4 changed files with 34 additions and 74 deletions
|
@ -2541,22 +2541,6 @@ static void SoundDisplay(void)
|
|||
}
|
||||
// PK_ ^^^^
|
||||
|
||||
// from sector.c
|
||||
static int32_t dist(spritetype *s1,spritetype *s2)
|
||||
{
|
||||
int32_t x = klabs(s1->x-s2->x);
|
||||
int32_t y = klabs(s1->y-s2->y);
|
||||
int32_t z = klabs((s1->z-s2->z)>>4);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
if (x<z) swaplong(&x,&z);
|
||||
|
||||
{
|
||||
int32_t t = y + z;
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AmbienceToggle = 1;
|
||||
int32_t ParentalLock = 0;
|
||||
#undef T1
|
||||
|
|
|
@ -385,3 +385,36 @@ int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char
|
|||
// If 'fn' has no extension suffixed, append one.
|
||||
return (Bsnprintf(wbuf, wbufsiz, "%s%s", fn, haveext ? "" : ext) >= wbufsiz);
|
||||
}
|
||||
|
||||
|
||||
// Approximations to the 2D and 3D euclidean distances. Initial EDuke32 SVN import says
|
||||
// in jmact/mathutil.c: "Ken's reverse-engineering job".
|
||||
// Note that jmact/mathutil.c contains practically the same code, but where the
|
||||
// individual x/y(/z) distances are passed instead.
|
||||
int32_t ldist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
int32_t x = klabs(s1->x-s2->x);
|
||||
int32_t y = klabs(s1->y-s2->y);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
|
||||
{
|
||||
int32_t t = y + (y>>1);
|
||||
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
|
||||
}
|
||||
}
|
||||
|
||||
int32_t dist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
int32_t x = klabs(s1->x-s2->x);
|
||||
int32_t y = klabs(s1->y-s2->y);
|
||||
int32_t z = klabs((s1->z-s2->z)>>4);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
if (x<z) swaplong(&x,&z);
|
||||
|
||||
{
|
||||
int32_t t = y + z;
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "osd.h"
|
||||
#include "keys.h"
|
||||
#include "common.h"
|
||||
|
||||
// from macros.h
|
||||
#define rnd(X) ((krand()>>8)>=(255-(X)))
|
||||
|
@ -58,36 +59,6 @@ static instype *x_sortingstateptr;
|
|||
|
||||
//#include "m32structures.c"
|
||||
|
||||
// from sector.c vvv
|
||||
static int32_t ldist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
int32_t x= klabs(s1->x-s2->x);
|
||||
int32_t y= klabs(s1->y-s2->y);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
|
||||
{
|
||||
int32_t t = y + (y>>1);
|
||||
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t dist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
int32_t x= klabs(s1->x-s2->x);
|
||||
int32_t y= klabs(s1->y-s2->y);
|
||||
int32_t z= klabs((s1->z-s2->z)>>4);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
if (x<z) swaplong(&x,&z);
|
||||
|
||||
{
|
||||
int32_t t = y + z;
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
}
|
||||
///
|
||||
|
||||
#ifdef DEBUGGINGAIDS
|
||||
void X_Disasm(ofstype beg, int32_t size)
|
||||
{
|
||||
|
|
|
@ -192,34 +192,6 @@ int32_t isanearoperator(int32_t lotag)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t ldist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
int32_t x= klabs(s1->x-s2->x);
|
||||
int32_t y= klabs(s1->y-s2->y);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
|
||||
{
|
||||
int32_t t = y + (y>>1);
|
||||
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
|
||||
}
|
||||
}
|
||||
|
||||
int32_t dist(const spritetype *s1, const spritetype *s2)
|
||||
{
|
||||
int32_t x= klabs(s1->x-s2->x);
|
||||
int32_t y= klabs(s1->y-s2->y);
|
||||
int32_t z= klabs((s1->z-s2->z)>>4);
|
||||
|
||||
if (x<y) swaplong(&x,&y);
|
||||
if (x<z) swaplong(&x,&z);
|
||||
|
||||
{
|
||||
int32_t t = y + z;
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
}
|
||||
|
||||
static inline int32_t A_FP_ManhattanDist(const DukePlayer_t *ps, const spritetype *s)
|
||||
{
|
||||
return klabs(ps->opos.x-s->x)
|
||||
|
|
Loading…
Reference in a new issue