2012-03-26 22:03:20 +00:00
//
// 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_
2019-12-17 22:25:07 +00:00
2018-11-18 18:09:48 +00:00
# include "compat.h"
2014-08-31 11:15:17 +00:00
# include "pragmas.h" // klabs
2018-11-18 18:09:48 +00:00
# include "scriptfile.h"
2020-05-10 10:42:47 +00:00
# include "mathutil.h"
2014-08-31 11:15:17 +00:00
2019-09-18 22:19:02 +00:00
extern bool playing_rr ;
2019-09-19 21:02:57 +00:00
extern bool playing_blood ;
2019-09-18 22:19:02 +00:00
2012-03-26 22:03:20 +00:00
//// TYPES
struct strllist
{
struct strllist * next ;
char * str ;
} ;
2012-03-26 22:05:23 +00:00
typedef struct
{
const char * text ;
int32_t tokenid ;
}
tokenlist ;
2012-03-28 19:41:57 +00:00
2012-03-26 22:05:23 +00:00
enum
{
T_EOF = - 2 ,
T_ERROR = - 1 ,
} ;
2012-03-26 22:03:20 +00:00
//// EXTERN DECLS
2014-07-24 14:01:44 +00:00
extern const char * s_buildRev ;
extern const char * s_buildTimestamp ;
2012-03-26 22:03:20 +00:00
//// FUNCTIONS
2014-07-28 06:43:46 +00:00
2013-11-03 04:02:23 +00:00
void G_AddDef ( const char * buffer ) ;
void G_AddDefModule ( const char * buffer ) ;
2012-03-26 22:03:20 +00:00
2014-10-25 03:30:38 +00:00
// returns a buffer of size BMAX_PATH
static inline char * dup_filename ( const char * fn )
{
char * const buf = ( char * ) Xmalloc ( BMAX_PATH ) ;
return Bstrncpyz ( buf , fn , BMAX_PATH ) ;
}
2015-01-25 12:17:59 +00:00
static inline void realloc_copy ( char * * fn , const char * buf )
{
uint8_t len = Bstrlen ( buf ) + 1 ;
* fn = ( char * ) Xrealloc ( * fn , len ) ;
Bstrncpy ( * fn , buf , len ) ;
}
2012-03-26 22:05:23 +00:00
int32_t getatoken ( scriptfile * sf , const tokenlist * tl , int32_t ntokens ) ;
2012-09-08 22:18:31 +00:00
int32_t maybe_append_ext ( char * wbuf , int32_t wbufsiz , const char * fn , const char * ext ) ;
2012-03-28 19:43:39 +00:00
2012-11-29 14:08:03 +00:00
2012-12-25 16:13:50 +00:00
void COMMON_clearbackground ( int32_t numcols , int32_t numrows ) ;
2012-04-04 18:57:42 +00:00
// timer defs for profiling function chunks the simple way
2018-04-12 21:02:51 +00:00
# define EDUKE32_TMRDEF int32_t t[20], ti=0; const char *tmrstr=__func__; fprintf(stderr,"%s\n",tmrstr); t[ti++]=timerGetTicks();
# define EDUKE32_TMRTIC t[ti++]=timerGetTicks()
2012-04-04 18:57:42 +00:00
# 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)
2012-03-26 22:03:20 +00:00
# endif