Odamex
Setting the Standard in Multiplayer Doom
common/doomtype.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*-
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: doomtype.h 2117 2011-02-22 20:33:04Z mike $
00005 //
00006 // Copyright (C) 1993-1996 by id Software, Inc.
00007 // Copyright (C) 2006-2010 by The Odamex Team.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // DESCRIPTION:
00020 //      Simple basic typedefs, isolated here to make it easier
00021 //       separating modules.
00022 //
00023 //-----------------------------------------------------------------------------
00024 
00025 
00026 #ifndef __DOOMTYPE__
00027 #define __DOOMTYPE__
00028 
00029 #include "version.h"
00030 
00031 #ifdef GEKKO
00032 #include <gctypes.h>
00033 #endif
00034 
00035 #ifndef __BYTEBOOL__
00036 #define __BYTEBOOL__
00037 // [RH] Some windows includes already define this
00038 #if !defined(_WINDEF_) && !defined(__wtypes_h__) && !defined(GEKKO)
00039 typedef int BOOL;
00040 #endif
00041 #ifndef __cplusplus
00042 #define false (0)
00043 #define true (1)
00044 #endif
00045 typedef unsigned char byte;
00046 #endif
00047 
00048 #ifdef __cplusplus
00049 typedef bool dboolean;
00050 #else
00051 typedef enum {false, true} dboolean;
00052 #endif
00053 
00054 #if defined(_MSC_VER) || defined(__WATCOMC__)
00055 #define STACK_ARGS __cdecl
00056 #else
00057 #define STACK_ARGS
00058 #endif
00059 
00060 // Predefined with some OS.
00061 #ifndef UNIX
00062 #ifndef _MSC_VER
00063 #ifndef GEKKO
00064 #include <values.h>
00065 #endif
00066 #endif
00067 #endif
00068 
00069 #if defined(__GNUC__) && !defined(OSF1)
00070 #define __int64 long long
00071 #endif
00072 
00073 #ifdef OSF1
00074 #define __int64 long
00075 #endif
00076 
00077 #ifdef _XBOX
00078 typedef unsigned __int64 uint64_t;
00079 typedef unsigned __int32 uint32_t;
00080 #endif
00081 
00082 #ifdef UNIX
00083 #define stricmp strcasecmp
00084 #define strnicmp strncasecmp
00085 #endif
00086 
00087 #ifndef MAXCHAR
00088 #define MAXCHAR                 ((char)0x7f)
00089 #endif
00090 #ifndef MAXSHORT
00091 #define MAXSHORT                ((short)0x7fff)
00092 #endif
00093 
00094 // Max pos 32-bit int.
00095 #ifndef MAXINT
00096 #define MAXINT                  ((int)0x7fffffff)
00097 #endif
00098 #ifndef MAXLONG
00099 #ifndef ALPHA
00100 #define MAXLONG                 ((long)0x7fffffff)
00101 #else
00102 #define MAXLONG                 ((long)0x7fffffffffffffff)
00103 #endif
00104 #endif
00105 
00106 #ifndef MINCHAR
00107 #define MINCHAR                 ((char)0x80)
00108 #endif
00109 #ifndef MINSHORT
00110 #define MINSHORT                ((short)0x8000)
00111 #endif
00112 
00113 // Max negative 32-bit integer.
00114 #ifndef MININT
00115 #define MININT                  ((int)0x80000000)
00116 #endif
00117 #ifndef MINLONG
00118 #ifndef ALPHA
00119 #define MINLONG                 ((long)0x80000000)
00120 #else
00121 #define MINLONG                 ((long)0x8000000000000000)
00122 #endif
00123 #endif
00124 
00125 typedef unsigned char           BYTE;
00126 typedef signed char                     SBYTE;
00127 
00128 typedef unsigned short          WORD;
00129 typedef signed short            SWORD;
00130 
00131 // denis - todo - this 64 bit fix conflicts with windows' idea of long
00132 #ifndef WIN32
00133 typedef unsigned int            DWORD;
00134 typedef signed int                      SDWORD;
00135 #else
00136 typedef unsigned long           DWORD;
00137 typedef signed long                     SDWORD;
00138 #endif
00139 
00140 typedef unsigned __int64        QWORD;
00141 typedef signed __int64          SQWORD;
00142 
00143 typedef DWORD                           BITFIELD;
00144 
00145 #ifndef NOASM
00146 #ifndef USEASM
00147 #define USEASM 1
00148 #endif
00149 #else
00150 #ifdef USEASM
00151 #undef USEASM
00152 #endif
00153 #endif
00154 
00155 #ifdef _WIN32
00156 #define PATHSEP "\\"
00157 #define PATHSEPCHAR '\\'
00158 #else
00159 #define PATHSEP "/"
00160 #define PATHSEPCHAR '/'
00161 #endif
00162 
00163 // [RH] This gets used all over; define it here:
00164 int STACK_ARGS Printf (int printlevel, const char *, ...);
00165 // [Russell] Prints a bold green message to the console
00166 int STACK_ARGS Printf_Bold (const char *format, ...);
00167 // [RH] Same here:
00168 int STACK_ARGS DPrintf (const char *, ...);
00169 
00170 // Simple log file
00171 #include <fstream>
00172 
00173 extern std::ofstream LOG;
00174 extern const char *LOG_FILE; //  Default is "odamex.log"
00175 
00176 extern std::ifstream CON;
00177 
00178 // game print flags
00179 #define PRINT_LOW                       0               // pickup messages
00180 #define PRINT_MEDIUM            1               // death messages
00181 #define PRINT_HIGH                      2               // critical messages
00182 #define PRINT_CHAT                      3               // chat messages
00183 #define PRINT_TEAMCHAT          4               // chat messages from a teammate
00184 
00185 
00186 //==========================================================================
00187 //
00188 // MIN
00189 //
00190 // Returns the minimum of a and b.
00191 //==========================================================================
00192 
00193 #ifdef MIN
00194 #undef MIN
00195 #endif
00196 template<class T>
00197 inline
00198 const T MIN (const T a, const T b)
00199 {
00200         return a < b ? a : b;
00201 }
00202 
00203 //==========================================================================
00204 //
00205 // MAX
00206 //
00207 // Returns the maximum of a and b.
00208 //==========================================================================
00209 
00210 #ifdef MAX
00211 #undef MAX
00212 #endif
00213 template<class T>
00214 inline
00215 const T MAX (const T a, const T b)
00216 {
00217         return a > b ? a : b;
00218 }
00219 
00220 
00221 
00222 
00223 //==========================================================================
00224 //
00225 // clamp
00226 //
00227 // Clamps in to the range [min,max].
00228 //==========================================================================
00229 #ifdef clamp
00230 #undef clamp
00231 #endif
00232 template<class T>
00233 inline
00234 T clamp (const T in, const T min, const T max)
00235 {
00236         return in <= min ? min : in >= max ? max : in;
00237 }
00238 
00239 
00240 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends