mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
77dc743f09
And use these in jmact/mathutil.c's FindDistance2D()/FindDistance3D(). The main use is to allow passing dx/dy instead of sprite positions; the code that actually uses this is not committed. git-svn-id: https://svn.eduke32.com/eduke32@4579 1a8010ca-5511-0410-912e-c29ae57300e0
139 lines
3.3 KiB
C
139 lines
3.3 KiB
C
//
|
|
// Definitions of common non-engine data structures/functions
|
|
// (and declarations of data appearing in both)
|
|
// for EDuke32 and Mapster32
|
|
//
|
|
|
|
#ifndef EDUKE32_COMMON_H_
|
|
#define EDUKE32_COMMON_H_
|
|
|
|
#include <stdint.h>
|
|
#include "scriptfile.h"
|
|
#include "cache1d.h"
|
|
#include "pragmas.h" // klabs
|
|
#include "build.h"
|
|
|
|
|
|
#ifdef EXTERNC
|
|
extern "C" {
|
|
#endif
|
|
|
|
//// TYPES
|
|
struct strllist
|
|
{
|
|
struct strllist *next;
|
|
char *str;
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
const char *text;
|
|
int32_t tokenid;
|
|
}
|
|
tokenlist;
|
|
|
|
typedef struct
|
|
{
|
|
CACHE1D_FIND_REC *finddirs, *findfiles;
|
|
int32_t numdirs, numfiles;
|
|
}
|
|
fnlist_t;
|
|
|
|
#define FNLIST_INITIALIZER { NULL, NULL, 0, 0 }
|
|
|
|
enum
|
|
{
|
|
T_EOF = -2,
|
|
T_ERROR = -1,
|
|
};
|
|
|
|
|
|
//// EXTERN DECLS
|
|
extern struct strllist *CommandPaths, *CommandGrps;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
extern const char *s_buildRev;
|
|
extern const char *s_buildTimestamp;
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
extern const char *s_buildInfo;
|
|
|
|
//// FUNCTIONS
|
|
extern void clearDefNamePtr(void);
|
|
|
|
void G_AddGroup(const char *buffer);
|
|
void G_AddPath(const char *buffer);
|
|
void G_AddDef(const char *buffer);
|
|
void G_AddDefModule(const char *buffer);
|
|
#ifdef HAVE_CLIPSHAPE_FEATURE
|
|
void G_AddClipMap(const char *buffer);
|
|
#endif
|
|
|
|
int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens);
|
|
|
|
int32_t G_CheckCmdSwitch(int32_t argc, const char **argv, const char *str);
|
|
|
|
int32_t testkopen(const char *filename, char searchfirst); // full-blown kopen4load
|
|
int32_t check_file_exist(const char *fn); // findfrompath with pathsearchmode=1 / search in zips
|
|
|
|
void fnlist_clearnames(fnlist_t *fnl);
|
|
int32_t fnlist_getnames(fnlist_t *fnl, const char *dirname, const char *pattern,
|
|
int32_t dirflags, int32_t fileflags);
|
|
|
|
char *dup_filename(const char *fn);
|
|
int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char *ext);
|
|
|
|
// Approximations to 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.
|
|
static inline int32_t sepldist(const int32_t dx, const int32_t dy)
|
|
{
|
|
int32_t x = klabs(dx);
|
|
int32_t y = klabs(dy);
|
|
|
|
if (x < y)
|
|
swaplong(&x, &y);
|
|
|
|
{
|
|
int32_t t = y + (y>>1);
|
|
return x - (x>>5) - (x>>7) + (t>>2) + (t>>6);
|
|
}
|
|
}
|
|
|
|
// dz: in Build coordinates
|
|
static inline int32_t sepdist(int32_t dx, int32_t dy, int32_t dz)
|
|
{
|
|
int32_t x = klabs(dx);
|
|
int32_t y = klabs(dy);
|
|
int32_t z = klabs(dz>>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 ldist(const spritetype *s1, const spritetype *s2);
|
|
int32_t dist(const spritetype *s1, const spritetype *s2);
|
|
|
|
void COMMON_clearbackground(int32_t numcols, int32_t numrows);
|
|
|
|
// timer defs for profiling function chunks the simple way
|
|
#define EDUKE32_TMRDEF int32_t t[20], ti=0; const char *tmrstr=__func__; fprintf(stderr,"%s\n",tmrstr); t[ti++]=getticks();
|
|
#define EDUKE32_TMRTIC t[ti++]=getticks()
|
|
#define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; ii<ti; ii++) fprintf(stderr,"%d ", t[ii]-t[ii-1]); fprintf(stderr,"\n"); } while (0)
|
|
|
|
#ifdef EXTERNC
|
|
}
|
|
#endif
|
|
|
|
#endif
|