/*      Netrek Configuration file       -              by Kurt Siegl
 * 
 */

#ifndef __CONFIG_H
#define __CONFIG_H

/* 
################################################################################
	All The fun defines      
################################################################################
*/

/*
   Defines
      Some possible values:
   NOTE: Only NON-system specific defines belong here
*/

/* 
   ------------------------------------------------------------
	 	Common defines
   ------------------------------------------------------------
*/


#define RCD                     /* RCD             - Support Reciever variable
                                                     distresses */

                                /* PING            - Ping statistics */
#define PING

                                /* SHORT_PACKETS   - Reduce Network load */
#define SHORT_PACKETS

                                /* SPEEDUP         - Misc improvements to make
                                                     the code faster */
#define SPEEDUP

                                /* FEATURE_PACKETS - feature packets */
#define FEATURE_PACKETS
                                /* UDP_PORTSWAP - Allow the client to
                                initiate the UDP connection first if it so
                                chooses.  This allows UDP connections through
                                some packet filtering firewalls.
                                */
#define UDP_PORTSWAP

				/* DEBUG   	   - Various useful debugging 
						     stuff.  No signal trap */
#undef  DEBUG

/* 
   ------------------------------------------------------------
	 	COW only defines
   ------------------------------------------------------------
*/

/*	NBT 			- Nick trown's macro code			*/
#define NBT

/*	MAXPLAYER		- Maximal number of players + observers 	*/
#define MAXPLAYER 36

/*	CORRUPTED_PACKETS 	- prevents some seg faults but verbose output	*/
#define CORRUPTED_PACKETS

/*	ARMY_SLIDER   		- some sort of funky status window thing	*/
#define ARMY_SLIDER

/*	META          		- show active servers via metaserver - NBT	*/
#define META

/*	PACKET_LOG    		- log packets to stdout (for bandwith measurement) */
#define PACKET_LOG

/*	NEWMACRO 		- newmacro language				*/
#define NEWMACRO 

/*	SMARTMACRO 		- macro extension (needs NEWMACRO)		*/
#define SMARTMACRO

/*	MULTILINE_MACROS	- enables multiline macros			*/
#define MULTILINE_MACROS

/*	XTREKRC_HELP 		- Hadley's xtrekrc window (stolden by KP)	*/
#define XTREKRC_HELP

/*	TOOLS			- Various tools, like shell escape, ...		*/
#define TOOLS

/*	SOUND			- support of external sound players		*/

/* Autodetect may discover sound releated problems like cygwin has no shm */
#undef SKIP_SOUND
#ifndef SKIP_SOUND
#define SOUND
#endif

/*      HOCKEY_LINES            - allow showing of hockey lines			*/
#define HOCKEY_LINES

/*	BEEPLITE		- player and planets highlighting		*/
#define BEEPLITE

/*	VSHIELD_BITMAPS		- damage dependent shields (hull)		*/
#define VSHIELD_BITMAPS
#define VARY_HULL 

/*      WARP_DEAD		- Use death detection
*/
#undef  WARP_DEAD

/*    RCM                     	- Receiver configurable Server messages 	*/
#define RCM

/* 	RACE_COLORS		- additional bitplane for race colors		*/
#define RACE_COLORS

/* XTRA_MESSAGE_UI  - Show message being typed on the local display */
#define  XTRA_MESSAGE_UI

/* SYSTEM_DEFAULTFILE		- Points to a system wide .xtrekrc file */
#define SYSTEM_DEFAULTFILE "/etc/netrek-client-cow/netrekrc"

/* WINDOWMAKER			- WindowMaker Docking support */
#ifdef linux
#define WINDOWMAKER
#endif

#define PLIST1
#define PLIST
#define CONTROL_KEY
#define DOC_WIN
#define ROTATERACE
#define FUNCTION_KEYS

/* client options */
#define IGNORE_SIGNALS_SEGV_BUS
#define MOUSE_AS_SHIFT
#define SHIFTED_MOUSE
#define TNG_FED_BITMAPS
#define MOTION_MOUSE
#define DIST_KEY_NAME
#define PHASER_STATS
#define RECORDGAME

#define CAMERA
#define FULLSCREEN

/*
##############################################################################
       All system dependencies should be defined here 
##############################################################################
*/

#define NEED_EXIT

/* Automatic generated system dependend defines 			*/

#undef HAVE_MATH_H
#undef HAVE_STDLIB_H
#undef _ALL_SOURCES
#undef HAVE_SYS_SIGNAL_H
#undef BSD_SIGNALS 
#undef SYSV_SIGNALS 
#undef POSIX_SIGNALS
#undef RESTARTABLE_SYSCALLS  
#undef NEED_MEMORY_H 
#define STDC_HEADERS 1 		/* 13/01/94 omit hosed index [007] */
#undef HAVE_WAIT3 
#undef NEED_SYS_SELECT_H 
#undef NO_FD_SET		/* Guess we suck badly if that happens :( */
#undef HAVE_UNISTD_H 
#undef HAVE_SYS_TIMEB_H
#undef TM_IN_SYS_TIME 
#undef TIME_WITH_SYS_TIME
#undef NEED_SYS_TIME_H 
#undef HAVE_SYS_PTYIO_H 
#undef HAVE_SYS_FCNTL_H
#undef HAVE_FCNTL_H
#undef HAVE_CTYPE_H
#undef HAVE_MACHINE_ENDIAN_H
#undef HAVE_SYS_RESOURCE_H
#undef HAVE_SYS_WAIT_H
#undef HAVE_NETINET_IN_H
#undef HAVE_NETINET_TCP_H
#undef HAVE_SYS_FILIO_H		/* Needed for Solaris 2.5.1 */
#undef HAVE_GMP2_H
#undef NO_U_INT 
#undef SIZEOF_LONG
#undef HAVE_USLEEP 
#undef HAVE_SETSTATE
#undef HAVE_RANDOM
#undef HAVE_STRFTIME
#undef HAVE_FTIME
#undef HAVE_STRCMPI
#undef HAVE_STRNCMPI
#undef HAVE_NINT
#undef NEED_RINT_DEC
#undef pid_t 
#undef uid_t 
#undef gid_t
#undef size_t 
#undef vfork 
#if (defined(sparc) && defined(sun))
#define vfork fork
#endif
#undef NO_PATH_MAX
#undef inline

#undef HAVE_X11
#undef HAVE_WIN32
#undef HAVE_XPM
#undef HAVE_X11_XPM_H

/* System dependend macros						*/

/* SYSV signal handling */
#ifdef SYSV_SIGNALS
#include <signal.h>
#define SIGNAL(x,y)   sigset(x,y)
#define PAUSE(x)      sigpause(x)
#define SIGSETMASK(x) { }
#else
#define SIGNAL(x,y)   signal(x,y)
#define PAUSE(x)      pause()
#define SIGSETMASK(x) sigsetmask(x)
#endif

#ifdef POSIX_SIGNALS
#define HANDLE_SIG(s,h)	signal(s,h)
#define setjmp(x) sigsetjmp(x,1)
#define longjmp(x,y) siglongjmp(x,y)
#else
#define HANDLE_SIG(s,h) {}
#endif

#ifdef STDC_HEADERS
#define INC_STRINGS	<string.h>
#else
#define INC_STRINGS	<strings.h>
#endif

#ifdef STDC_HEADERS
#define MCMP(x,y,z)     memcmp(x,y,z)
#define MCOPY(b1,b2,l)  memcpy(b2,b1,l)
#define MZERO(b1,l)     memset(b1,0,l)
#define INDEX(s,c)      strchr(s,c)
#define RINDEX(s,c)     strrchr(s,c)
#else
#define INDEX(s,c)	index(s,c)
#define RINDEX(s,c)	rindex(s,c) 
#define MCMP(x,y,z)     bcmp(x,y,z)
#define MCOPY(b1,b2,l)  bcopy(b1,b2,l)
#define MZERO(b1,l)     bzero(b1,l)
#endif

#ifdef SPEEDUP          /* strncpy is terrible slow */
#ifdef NEED_MEMORY_H
#include <memory.h>
#else
#include <string.h>
#endif
/* #define STRNCPY(x,y,z)	memcpy(x,y,z) */
#define STRNCPY(x,y,z)  memccpy(x,y,'\0',z) 
#else
#define STRNCPY(x,y,z)	strncpy(x,y,z)
#endif

#ifndef HAVE_WAIT3
#define WAIT3(x,y,z)  waitpid(-1, x, y ) 
#else
#define WAIT3(x,y,z)  wait3(x, y, z)
#endif

#if (defined(HAVE_RANDOM) && defined(HAVE_SETSTATE)) || !defined(HAVE_RANDOM)
#define RANDOM()        random()
#define SRANDOM(x)      srandom(x)
#else
#define RANDOM()        rrandom()
#define SRANDOM(x)      ssrandom(x)
extern void ssrandom ();
extern long rrandom ();
#endif

#if !defined(HAVE_RANDOM)
extern void srandom ();
extern long random ();
#endif

#if (SIZEOF_LONG == 8)
#define _64BIT
#define LONG int
#define U_LONG u_int
#else
#define LONG long
#define U_LONG u_long
#endif

/*  System dependend Include files */

#define NULLFILE        	"null"

#ifdef NEED_SYS_SELECT_H
#define INC_SYS_SELECT <sys/select.h>
#else
#define INC_SYS_SELECT NULLFILE
#endif
#define SELECT select

#ifdef HAVE_UNISTD_H
#define INC_UNISTD      <unistd.h>
#else
#define INC_UNISTD      NULLFILE
#endif

#ifdef HAVE_SYS_SIGNAL_H
#define INC_SYS_SIGNAL   <sys/signal.h>
#else
#define INC_SYS_SIGNAL   NULLFILE
#endif

#ifdef HAVE_SYS_FCNTL_H
#define INC_SYS_FCNTL   <sys/fcntl.h>
#else
#define INC_SYS_FCNTL   NULLFILE
#endif

#ifdef HAVE_FCNTL_H
#define INC_FCNTL       <fcntl.h>
#else
#define INC_FCNTL       NULLFILE
#endif

/* Some systems don't include <sys/time.h> in <time.h>  */
#if defined(TM_IN_SYS_TIME) || defined(NEED_SYS_TIME_H)
#define INC_SYS_TIME <sys/time.h>
#else
#define INC_SYS_TIME NULLFILE
#endif

#ifdef HAVE_SYS_PTYIO_H
#define INC_SYS_PTYIO <sys/ptyio.h>
#else
#define INC_SYS_PTYIO NULLFILE
#endif

#ifdef HAVE_CTYPE_H
#define INC_CTYPE	<ctype.h>
#else
#define INC_CTYPE 	NULLFILE
#endif

#ifdef HAVE_MACHINE_ENDIAN_H
#define INC_MACHINE_ENDIAN <machine/endian.h>
#else
#define INC_MACHINE_ENDIAN NULLFILE
#endif

#ifdef HAVE_SYS_RESOURCE_H
#define INC_SYS_RESOURCE <sys/resource.h>
#else
#define INC_SYS_RESOURCE NULLFILE
#endif

#ifdef HAVE_SYS_WAIT_H
#define INC_SYS_WAIT 	<sys/wait.h>
#else
#define INC_SYS_WAIT 	NULLFILE
#endif
 
#ifdef HAVE_NETINET_IN_H
#define INC_NETINET_IN 	<netinet/in.h>
#else
#define INC_NETINET_IN 	NULLFILE
#endif 

#ifdef HAVE_NETINET_TCP_H
#define INC_NETINET_TCP  <netinet/tcp.h>
#else
#define INC_NETINET_TCP  NULLFILE
#endif

/* Replace outdated ftime with gettimeofday */
#if defined(HAVE_SYS_TIMEB_H) && defined(HAVE_FTIME)
#define INC_SYS_TIMEB   <sys/timeb.h>
#else
#define NOTIMEB
#define INC_SYS_TIMEB   <sys/time.h>
#endif

#ifdef HAVE_GMP2_H
#define INC_MP <gmp.h>
#define MPTYPEDEF typedef mpz_t MPTYPE; 

#define assignItom(x,i) {mpz_init(x); mpz_set_ui(x,i);}
#define madd(x, y, z) mpz_add(z, x, y)
#define msub(x, y, z) mpz_sub(z, x, y)
#define mult(x, y, z) mpz_mul(z, x, y)
#define mdiv(n, d, q, r) mpz_fdiv_qr(q, r, n, d)
#define sdiv(n, d, q, r) *r = mpz_fdiv_q_ui(q, n, d)
#define msqrt(x, y, z) mpz_sqrt(z, x, y)
#define mp_pow(x, y, z, a) mpz_powm(a, x, y, z)
#define gcd(x, y, z) mpz_gcd(z, x, y)
#define mcmp(x, y) mpz_cmp(x, y)
#define min(x) mpz_min(x)
#define mout(x) mpz_mout(x)
#define mfree(x) mpz_clear(x)
 
#else
#define MPTYPEDEF typedef MINT *MPTYPE;
#define assignItom(x,i) x= itom(i)
#define mp_pow(x, y, z, a) pow(x, y, z, a)
#define INC_MP <mp.h>
#endif

#ifdef NO_PATH_MAX
#define PATH_MAX 255
#define INC_LIMITS	NULLFILE
#else
#define INC_LIMITS	<limits.h>
#endif

#ifdef HAVE_XPM
#ifdef HAVE_X11_XPM_H
#define INC_XPM <X11/xpm.h>
#else
#define INC_XPM <xpm.h>
#endif
#else
#define INC_XPM NULLFILE
#endif

/* Unchecked machine dependencies */

#ifdef linux
#define SHMFLAG         sizeof(struct memory)
#else
#define SHMFLAG         0
#endif

#if defined(sun3)
#define INC_STDLIB 	NULLFILE
#else
#define INC_STDLIB	<stdlib.h>
#endif

#ifndef sun4
#if defined(HAVE_NINT) && defined(HAVE_MATH_H)
#define INC_MATH	<math.h>
#else
#if defined(NEED_RINT_DEC)
extern double rint(double);
#define INC_MATH        NULLFILE
#else
#define INC_MATH        <math.h>
#endif
#define  nint(x) ((int) rint(x))
#endif
#endif

/*
   Some systems, most notably SunOS 4.1.3, don't include function definitions
   in the libraries.  This results in some warning we don't want.
   This header defines the type for all these functions.
*/

#ifdef sun4
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>

int close(int);
int connect(int, struct sockaddr *, int);
int fprintf(FILE *, const char *, ...);
int fputs(char *, FILE *);
char *memccpy(char *, char *, int, int);
int perror(char *);
int socket(int, int, int);
int sscanf(char *, char *, ...);
char *strdup(char *arg);

char _filbuf(FILE *);
int _flsbuf(unsigned char, FILE *);

#endif /* defined sun4 */

#ifdef WIN32
typedef unsigned short int ushort;
#define strncasecmp strncmp
#ifdef THREADED
#define THREAD(fn) { DWORD junk; CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)fn, 0, 0, &junk); }
#define ENDTHREAD ExitThread(0);
typedef unsigned long int SEMAPHORE;
#define CREATE_SEMAPHORE(initstate) CreateEvent(NULL, 1, initstate, NULL)
#define SET_SEMAPHORE(sem) SetEvent((HANDLE)sem)
#define RESET_SEMAPHORE(sem) ResetEvent((HANDLE)sem)
#endif
#endif

#ifdef _MSC_VER
#define INC_STRINGS     <ntstring.h>
#define INC_IO     <ntio.h>
#else
#define INC_IO       NULLFILE
#endif

	/* Solaris specific stuff */

#if defined(HAVE_SYS_FILIO_H)
#define INC_SYS_FILIO <sys/filio.h>
#else
#define INC_SYS_FILIO NULLFILE
#endif

/* define this if you have the SDL library (checked by configure.in) */
#undef HAVE_SDL

#endif  /* __CONFIG_H */
