2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2002-11-02 15:10:52 +01:00
|
|
|
|
*
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
|
|
|
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
|
|
|
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
|
|
|
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
|
|
|
|
* Enno Rehling (enno@eressea-pbem.de)
|
|
|
|
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
|
*
|
|
|
|
|
* based on:
|
|
|
|
|
*
|
|
|
|
|
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
|
|
|
|
* Atlantis v1.7 Copyright 1996 by Alex Schr<EFBFBD>der
|
|
|
|
|
*
|
|
|
|
|
* This program may not be used, modified or distributed without
|
|
|
|
|
* prior permission by the authors of Eressea.
|
|
|
|
|
* This program may not be sold or used commercially without prior written
|
|
|
|
|
* permission from the authors.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef CONFIG_H
|
|
|
|
|
#define CONFIG_H
|
|
|
|
|
|
2004-04-12 01:56:47 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
# include <cstdio>
|
|
|
|
|
# include <cstdlib>
|
|
|
|
|
extern "C" {
|
|
|
|
|
#else
|
|
|
|
|
# include <stdio.h>
|
|
|
|
|
# include <stdlib.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/**** ****
|
|
|
|
|
** Debugging Libraries **
|
|
|
|
|
**** ****/
|
2005-05-07 01:25:08 +02:00
|
|
|
|
#if defined __GNUC__
|
|
|
|
|
# define HAVE_INLINE
|
2005-06-15 23:04:37 +02:00
|
|
|
|
# define INLINE_FUNCTION static __inline
|
2005-05-07 01:25:08 +02:00
|
|
|
|
#endif
|
2005-05-07 12:07:06 +02:00
|
|
|
|
|
|
|
|
|
/* define USE_DMALLOC to enable use of the dmalloc library */
|
|
|
|
|
#ifdef USE_DMALLOC
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# include <stdlib.h>
|
2005-05-07 12:07:06 +02:00
|
|
|
|
# include <string.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# include <dmalloc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-05-07 12:07:06 +02:00
|
|
|
|
/* define CRTDBG to enable MSVC CRT Debug library functions */
|
|
|
|
|
#if defined(_DEBUG) && defined(_MSC_VER) && defined(CRTDBG)
|
|
|
|
|
# include <crtdbg.h>
|
|
|
|
|
# define _CRTDBG_MAP_ALLOC
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**** ****
|
|
|
|
|
** Architecture Dependent **
|
|
|
|
|
**** ****/
|
|
|
|
|
|
|
|
|
|
/* f<>r solaris: */
|
|
|
|
|
#ifdef SOLARIS
|
|
|
|
|
# define _SYS_PROCSET_H
|
|
|
|
|
# define _XOPEN_SOURCE
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
# pragma warning (disable: 4201 4214 4514 4115 4711)
|
|
|
|
|
# pragma warning(disable: 4056)
|
|
|
|
|
/* warning C4056: overflow in floating point constant arithmetic */
|
|
|
|
|
# pragma warning(disable: 4201)
|
|
|
|
|
/* warning C4201: Nicht dem Standard entsprechende Erweiterung : Struktur/Union ohne Namen */
|
|
|
|
|
# pragma warning(disable: 4214)
|
|
|
|
|
/* warning C4214: Nicht dem Standard entsprechende Erweiterung : Basistyp fuer Bitfeld ist nicht int */
|
|
|
|
|
# pragma warning(disable: 4100)
|
|
|
|
|
/* warning C4100: <name> : unreferenced formal parameter */
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-04-21 12:52:05 +02:00
|
|
|
|
#ifdef __GNUC__
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# ifndef _BSD_SOURCE
|
|
|
|
|
# define _BSD_SOURCE
|
|
|
|
|
# define __USE_BSD
|
|
|
|
|
# endif
|
|
|
|
|
# include <features.h>
|
|
|
|
|
# include <strings.h> /* strncasecmp-Prototyp */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef _BSD_SOURCE
|
|
|
|
|
# define __EXTENSIONS__
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-04-12 01:56:47 +02:00
|
|
|
|
#ifdef WIN32
|
2001-02-03 14:45:35 +01:00
|
|
|
|
# include <common/util/windir.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# define HAVE_READDIR
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(__USE_SVID) || defined(_BSD_SOURCE) || defined(__USE_XOPEN_EXTENDED) || defined(_BE_SETUP_H) || defined(CYGWIN)
|
|
|
|
|
# include <unistd.h>
|
|
|
|
|
# define HAVE_STRCASECMP
|
|
|
|
|
# define HAVE_STRNCASECMP
|
|
|
|
|
# define HAVE_ACCESS
|
2005-04-27 14:18:05 +02:00
|
|
|
|
# define HAVE_STAT
|
|
|
|
|
typedef struct stat stat_type;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# include <dirent.h>
|
|
|
|
|
# define HAVE_READDIR
|
|
|
|
|
# define HAVE_OPENDIR
|
|
|
|
|
# define HAVE_MKDIR_WITH_PERMISSION
|
|
|
|
|
# include <string.h>
|
|
|
|
|
# define HAVE_STRDUP
|
2001-02-05 17:11:59 +01:00
|
|
|
|
# define HAVE_SNPRINTF
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* egcpp 4 dos */
|
|
|
|
|
#ifdef MSDOS
|
|
|
|
|
# include <dir.h>
|
|
|
|
|
# define HAVE_MKDIR_WITH_PERMISSION
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* lcc-win32 */
|
|
|
|
|
#ifdef __LCC__
|
|
|
|
|
# include <string.h>
|
|
|
|
|
# include <direct.h>
|
|
|
|
|
# include <io.h>
|
|
|
|
|
# define HAVE_MKDIR_WITHOUT_PERMISSION
|
|
|
|
|
# define HAVE_ACCESS
|
2005-04-27 14:18:05 +02:00
|
|
|
|
# define HAVE_STAT
|
|
|
|
|
typedef struct stat stat_type;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# define HAVE_STRICMP
|
|
|
|
|
# define HAVE_STRNICMP
|
|
|
|
|
# define HAVE_STRDUP
|
2001-02-05 17:11:59 +01:00
|
|
|
|
# define snprintf _snprintf
|
|
|
|
|
# define HAVE_SNPRINTF
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# undef HAVE_STRCASECMP
|
|
|
|
|
# undef HAVE_STRNCASECMP
|
|
|
|
|
# define R_OK 4
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Microsoft Visual C */
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
# define R_OK 4
|
|
|
|
|
# define HAVE__MKDIR_WITHOUT_PERMISSION
|
|
|
|
|
|
2005-05-07 01:25:08 +02:00
|
|
|
|
# define HAVE_INLINE
|
|
|
|
|
# define INLINE_FUNCTION __inline
|
2005-05-07 00:30:19 +02:00
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
# define snprintf _snprintf
|
|
|
|
|
# define HAVE_SNPRINTF
|
|
|
|
|
|
2005-04-27 14:18:05 +02:00
|
|
|
|
/* MSVC has _access, not access */
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# define access(f, m) _access(f, m)
|
|
|
|
|
# define HAVE_ACCESS
|
|
|
|
|
|
2005-04-27 14:18:05 +02:00
|
|
|
|
/* MSVC has _stat, not stat */
|
|
|
|
|
# define HAVE_STAT
|
|
|
|
|
# define stat(a, b) _stat(a, b)
|
|
|
|
|
typedef struct _stat stat_type;
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* MSVC has _strdup */
|
2004-06-21 18:45:27 +02:00
|
|
|
|
# define strdup _strdup
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# define HAVE_STRDUP
|
|
|
|
|
|
|
|
|
|
# define stricmp(a, b) _stricmp(a, b)
|
|
|
|
|
# define HAVE_STRICMP
|
|
|
|
|
|
|
|
|
|
# define strnicmp(a, b, c) _strnicmp(a, b, c)
|
|
|
|
|
# define HAVE_STRNICMP
|
|
|
|
|
# undef HAVE_STRCASECMP
|
|
|
|
|
# undef HAVE_STRNCASECMP
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* replacements for missing functions: */
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_STRCASECMP
|
|
|
|
|
# if defined(HAVE_STRICMP)
|
|
|
|
|
# define strcasecmp stricmp
|
|
|
|
|
# elif defined(HAVE__STRICMP)
|
|
|
|
|
# define strcasecmp _stricmp
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_STRNCASECMP
|
|
|
|
|
# if defined(HAVE_STRNICMP)
|
|
|
|
|
# define strncasecmp strnicmp
|
|
|
|
|
# elif defined(HAVE__STRNICMP)
|
|
|
|
|
# define strncasecmp _strnicmp
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_MKDIR_WITH_PERMISSION
|
|
|
|
|
# define makedir(d, p) mkdir(d, p)
|
|
|
|
|
#elif defined(HAVE_MKDIR_WITHOUT_PERMISSION)
|
|
|
|
|
# define makedir(d, p) mkdir(d)
|
|
|
|
|
#elif defined(HAVE__MKDIR_WITHOUT_PERMISSION)
|
|
|
|
|
_CRTIMP int __cdecl _mkdir(const char *);
|
|
|
|
|
# define makedir(d, p) _mkdir(d)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_STRDUP
|
|
|
|
|
extern char * strdup(const char *s);
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-02-03 14:45:35 +01:00
|
|
|
|
#if !defined(MAX_PATH)
|
|
|
|
|
# ifdef WIN32
|
|
|
|
|
# define MAX_PATH _MAX_PATH
|
|
|
|
|
# elif defined(PATH_MAX)
|
|
|
|
|
# define MAX_PATH PATH_MAX
|
|
|
|
|
# else
|
|
|
|
|
# define MAX_PATH 1024
|
|
|
|
|
# endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**** ****
|
|
|
|
|
** min/max macros **
|
|
|
|
|
**** ****/
|
|
|
|
|
|
|
|
|
|
#ifndef NOMINMAX
|
|
|
|
|
#ifndef min
|
|
|
|
|
# define min(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef max
|
|
|
|
|
# define max(a,b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
- Neue Messages fertig
Messages werden jetzt in einem anderen Meta-Format (message* of
message_type*) gespeichert, das man in beliebige Formate (CR oder NR)
rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht
wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.
- make_message
Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
eine neue Nachricht, die dann einfach mit add_message wie bisher an die
Nachrichtenliste gehängt werden kann.
TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
unabhängig sind. Das spart einigen Speicher.
- CR Version erhöht.
Weil die MESSAGETYPES Blocks anders sind als früher
- OFFENSIVE_DELAY
Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den
Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
Status der letzten Runde wird in neuem Attribut at_moved gespeichert.
- SHORT_ATTACKS
ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.
- XML Parser
xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
übergibt, die nach dem Parsen eines tokens aufgerufen werden.
2001-04-12 19:21:57 +02:00
|
|
|
|
#define unused(var) var = var
|
|
|
|
|
|
2002-03-24 12:19:10 +01:00
|
|
|
|
|
|
|
|
|
/**** ****
|
|
|
|
|
** The Eressea boolean type **
|
|
|
|
|
**** ****/
|
2005-05-08 19:32:01 +02:00
|
|
|
|
#ifdef __cplusplus
|
2005-05-08 20:17:08 +02:00
|
|
|
|
typedef int boolean; /* not bool! wrong size. */
|
2005-05-08 19:32:01 +02:00
|
|
|
|
#else
|
2002-03-24 12:19:10 +01:00
|
|
|
|
typedef int boolean;
|
|
|
|
|
# define false ((boolean)0)
|
|
|
|
|
# define true ((boolean)!false)
|
|
|
|
|
#endif
|
2004-04-12 01:56:47 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2002-03-24 12:19:10 +01:00
|
|
|
|
|
2005-05-07 01:25:08 +02:00
|
|
|
|
#ifndef INLINE_FUNCTION
|
|
|
|
|
# define INLINE_FUNCTION
|
|
|
|
|
#endif
|
2003-12-14 11:02:29 +01:00
|
|
|
|
/* this function must be implemented in a .o file */
|
|
|
|
|
extern char * strnzcpy(char * dst, const char *src, size_t len);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif
|
2002-05-01 21:09:00 +02:00
|
|
|
|
|