/* Configuration-related definitions for Xconq.
   Copyright (C) 1987-1989, 1991-2000 Stanley T. Shebs.

Xconq is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.  See the file COPYING.  */

/*! \file kernel/config.h
 * \brief Configuration-related definitions for Xconq.
 *
 * This file has definitions that can be tweaked for local
 * preferences.  In general, there will not be any need to touch
 * these.
 * 
 * System dependencies can also go here, although it is much
 * preferable to write things so that they are not needed in the first
 * place.
 */

/* Universally required include files. */

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>

/* Is the autogenerated header available? If so, then use it. */
#ifdef HAVE_ACDEFS_H
#include "acdefs.h"
#endif

#ifdef UNIX
#ifdef __cplusplus
extern "C" {
#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __cplusplus
}
#endif
#endif

/* Prototypes for snprintf(3) and vsnprintf(3). */
#include "snprintf.h"

/* Declarations of missing time structs and functions. */
#include "timestuff.h"

// Some common typedefs.
namespace Xconq {
    typedef signed char		Z8;
    typedef unsigned char	Byte;
    typedef short		Z16;
    typedef unsigned short	Z16u;
#ifdef HAVE_ACDEFS_H
#if (SIZEOF_INT == 4)
    typedef int			Z32;
    typedef unsigned int	Z32u;
#else
    typedef long		Z32;
    typedef unsigned long	Z32u;
#endif // sizeof int == 4
#if (SIZEOF_LONG == 8)
    typedef long		Z64;
    typedef unsigned long	Z64u;
#else
    typedef long long		Z64;
    typedef unsigned long long	Z64u;
#endif // sizeof long == 8
#else
// No autogenerated defs available.
    typedef int			Z32;
    typedef unsigned int	Z32u;
    // Hope that we have long long, and that it is not 128 bits.
    typedef long long		Z64;
    typedef unsigned long long	Z64u;
#endif
}

/* Implementation of offsetof. (Is it safe?) (Should add to 'missing' dir.) */
#ifndef offsetof
#define offsetof(TYPE,FLD)	\
    ((unsigned int) (((char *) (&(((TYPE *) NULL)->FLD))) - ((char *) NULL)))
#endif

/* Assume 32-bit INT_*. (Need to do the right thing at some point.) */
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN (-INT_MAX -1)
#endif

/* Some platform-specific flags. */
#if (defined (MAC) && !defined (AVOID_OBSTACK))
#define AVOID_OBSTACK
#endif

/* Default names for special files. */

#ifndef NEWSFILE
/*! \brief News file. */
#ifdef WIN32
#define NEWSFILE "XconqNews.txt"
#else
#define NEWSFILE "XconqNews"
#endif
#endif

#ifndef SCOREFILE
/*! \brief Scores file. */
#ifdef WIN32
#define SCOREFILE "XconqScores.txt"
#else
#define SCOREFILE "XconqScores"
#endif
#endif
#ifndef OLD_SCOREFILE
#define OLD_SCOREFILE "scores.xcq"
#endif

#ifndef STATSFILE
/*! \brief Statistics file. */
#ifdef WIN32
#define STATSFILE "XconqStats.txt"
#else
#define STATSFILE "XconqStats"
#endif
#endif

#ifndef SAVEFILE
/*! \brief Save file. */
#define SAVEFILE "Save.xcq"
#endif

/* (This gets overridden by the individual platforms.) */
#ifndef CHECKPOINTFILE
/*! \brief Checkpoint file. */
#define CHECKPOINTFILE "check.xcq"
#endif

#ifndef ERRORFILE
/*! \brief Error save file. */
#define ERRORFILE "ErrorSave.xcq"
#endif

#ifndef PREFERENCESFILE
/*! \brief preferences file. */
#ifdef WIN32
#define PREFERENCESFILE "XconqPrefs.txt"
#else
#define PREFERENCESFILE "XconqPrefs"
#endif
#endif
#ifndef OLD_PREFERENCESFILE
#define OLD_PREFERENCESFILE "prefs.xcq"
#endif

/* The name of the default game. */

#ifndef STANDARD_GAME
/*! \brief Default game. */
#define STANDARD_GAME "standard"
#endif

/* The name of the introductory game. */

#ifndef INTRO_GAME
/*! \brief Introductory game file. */
#define INTRO_GAME "intro"
#endif


#ifndef DEFAULTWIDTH
/*! \brief Default world width. 
 *
 * Default random world size.  Adjust these to taste - for the standard
 * game, 60x60 is a moderate length game, 30x30 is short, 360x120 is
 * L-O-N-G !  (Remember to multiply the two numbers to get an idea of the
 * number of cells that will be in the world!)  Defaults can also be set
 * by modules explicitly, so this is really a "default default" :-) .
 */
#define DEFAULTWIDTH 60
#endif
#ifndef DEFAULTHEIGHT
/*! \brief Default world height.
 *
 * \see DEFAULTWIDTH 
 */
#define DEFAULTHEIGHT 30
#endif

#ifndef DEFAULTCIRCUMFERENCE
/*! \brief Default world circumference.
 *
 * If this matches the default width, then the game area
 * wraps around in x; otherwise it will be a polygon.
 */
#define DEFAULTCIRCUMFERENCE 360
#endif

#ifndef MAXSIDES
/*! \brief Absolute maximum number of sides that can play.
 *
 * This cannot be set higher than 30 without hacking up
 * side mask machinery.  Smaller values will incur fewer
 * assorted memory penalties, and in any case games with
 * lots of sides don't usually play very well.
 *
 * IMPORTANT! The actual number of sides, including the
 * independents (side 0) is MAXSIDES + 1. All arrays 
 * should be allocated accordingly: foo[MAXSIDES + 1].
 */
#define MAXSIDES 15
#endif

/*! \brief Maximum numbers of types of AIs. */
#define MAXAITYPES 10

/*! \brief Default string buffer size.
 *
 * All names, phrases, and messages must be able to fit in statically
 * allocated buffers of this size.
 */
#define BUFSIZE 255

/*! \brief Default string buffer size.
 *
 * The game blurb must be able to fit in statically
 * allocated buffers of this size.
 */
#define BLURBSIZE 480

/*! \brief Default path buffer size.
 *
 * All path names must be able to fit in statically
 * allocated buffers of this size.
 */
#define PATH_SIZE 8192

/*! \brief Default buffer size for the tprintf() family.
 *
 * The concatenating printf() functions must only fill a buffer up 
 * to this size.
 */
#define TBUFSIZE 300

/* \note The following options are (should be anyway) mostly independent of
   each other, and settable at will. */

/*! \brief Message rudeness.
 *
 * When defined, messages will be somewhat nastier.  Set this to be
 * appropriate for your intended audience, heh-heh :-)
 */
#define RUDE

/*! \brief Design mode availability.
 *
 * If defined, then an editing mode is available.  This is also a
 * powerful way to cheat, which is why it can be disabled.
 */
#define DESIGNERS

/*! \brief DEBUG flag.
 *
 * If defined, some (actually a lot) debugging code will be included.
 */
#define DEBUGGING
#include <assert.h>
#if (0)
#define NDEBUG
#endif
