1 #ifndef CMDLIB_H__ 2 #define CMDLIB_H__ 3 4 #if _MSC_VER >= 1000 5 #pragma once 6 #endif 7 8 #ifdef __MINGW32__ 9 #include <io.h> 10 #endif 11 12 #ifdef HAVE_CONFIG_H 13 #include "config.h" 14 #endif 15 16 // AJM: gnu compiler fix 17 #ifdef __GNUC__ 18 #define _alloca __builtin_alloca 19 #define alloca __builtin_alloca 20 #endif 21 22 #include "win32fix.h" 23 #include "mathtypes.h" 24 25 #define MODIFICATIONS_STRING "Submit detailed bug reports to (amckern@yahoo.com)\n" 26 27 #ifdef _DEBUG 28 #define ZHLT_VERSIONSTRING "v3.4 dbg" 29 #else 30 #define ZHLT_VERSIONSTRING "v3.4" 31 #endif 32 33 #define HACK_VERSIONSTRING "Final" 34 35 //===================================================================== 36 // AJM: Different features of the tools can be undefined here 37 // these are not officially beta tested, but seem to work okay 38 39 // ZHLT_* features are spread across more than one tool. Hence, changing 40 // one of these settings probably means recompiling the whole set 41 #define ZHLT_INFO_COMPILE_PARAMETERS // ALL TOOLS 42 #define ZHLT_NULLTEX // HLCSG, HLBSP 43 #define ZHLT_TEXLIGHT // HLCSG, HLRAD - triggerable texlights by LRC 44 #define ZHLT_GENERAL // ALL TOOLS - general changes 45 #define ZHLT_NEW_FILE_FUNCTIONS // ALL TOOLS - file path/extension extraction functions 46 //#define ZHLT_DETAIL // HLCSG, HLBSP - detail brushes 47 //#define ZHLT_PROGRESSFILE // ALL TOOLS - estimate progress reporting to -progressfile 48 //#define ZHLT_NSBOB 49 50 #define COMMON_HULLU // winding optimisations by hullu 51 52 // tool specific settings below only mean a recompile of the tool affected 53 #define HLCSG_CLIPECONOMY 54 #define HLCSG_WADCFG 55 #define HLCSG_AUTOWAD 56 57 #define HLCSG_PRECISIONCLIP 58 #define HLCSG_FASTFIND 59 #ifdef ZHLT_NULLTEX 60 #define HLCSG_NULLIFY_INVISIBLE //requires null textures as prerequisite 61 #endif 62 63 //#define HLBSP_THREADS // estimate for hlbsp 64 65 #define HLVIS_MAXDIST 66 67 #define HLRAD_INFO_TEXLIGHTS 68 #define HLRAD_WHOME // encompases all of Adam Foster's changes 69 #define HLRAD_HULLU // semi-opaque brush based entities and effects by hullu 70 #define HLRAD_FASTMATH // optimized mathutil.cpp by KGP 71 72 //===================================================================== 73 74 #ifdef SYSTEM_WIN32 75 #pragma warning(disable: 4127) // conditional expression is constant 76 #pragma warning(disable: 4115) // named type definition in parentheses 77 #pragma warning(disable: 4244) // conversion from 'type' to type', possible loss of data 78 // AJM 79 #pragma warning(disable: 4786) // identifier was truncated to '255' characters in the browser information 80 #pragma warning(disable: 4305) // truncation from 'const double' to 'float' 81 #pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' (performance warning) 82 #endif 83 84 85 #ifdef STDC_HEADERS 86 #include <stdio.h> 87 #include <string.h> 88 #include <stdlib.h> 89 #include <errno.h> 90 #include <ctype.h> 91 #include <time.h> 92 #include <stdarg.h> 93 #include <limits.h> 94 #endif 95 96 #ifdef HAVE_SYS_TIME_H 97 #include <sys/time.h> 98 #endif 99 #ifdef HAVE_UNISTD_H 100 #include <unistd.h> 101 #endif 102 103 #ifdef ZHLT_NETVIS 104 #include "c2cpp.h" 105 #endif 106 107 #ifdef SYSTEM_WIN32 108 #define SYSTEM_SLASH_CHAR '\\' 109 #define SYSTEM_SLASH_STR "\\" 110 #endif 111 #ifdef SYSTEM_POSIX 112 #define SYSTEM_SLASH_CHAR '/' 113 #define SYSTEM_SLASH_STR "/" 114 #endif 115 116 // the dec offsetof macro doesn't work very well... 117 #define myoffsetof(type,identifier) ((size_t)&((type*)0)->identifier) 118 #define sizeofElement(type,identifier) (sizeof((type*)0)->identifier) 119 120 #ifdef SYSTEM_POSIX 121 extern char* strupr(char* string); 122 extern char* strlwr(char* string); 123 #endif 124 extern const char* stristr(const char* const string, const char* const substring); 125 extern bool CDECL safe_snprintf(char* const dest, const size_t count, const char* const args, ...); 126 extern bool safe_strncpy(char* const dest, const char* const src, const size_t count); 127 extern bool safe_strncat(char* const dest, const char* const src, const size_t count); 128 extern bool TerminatedString(const char* buffer, const int size); 129 130 extern char* FlipSlashes(char* string); 131 132 extern double I_FloatTime(); 133 134 extern int CheckParm(char* check); 135 136 extern void DefaultExtension(char* path, const char* extension); 137 extern void DefaultPath(char* path, char* basepath); 138 extern void StripFilename(char* path); 139 extern void StripExtension(char* path); 140 141 extern void ExtractFile(const char* const path, char* dest); 142 extern void ExtractFilePath(const char* const path, char* dest); 143 extern void ExtractFileBase(const char* const path, char* dest); 144 extern void ExtractFileExtension(const char* const path, char* dest); 145 146 extern short BigShort(short l); 147 extern short LittleShort(short l); 148 extern int BigLong(int l); 149 extern int LittleLong(int l); 150 extern float BigFloat(float l); 151 extern float LittleFloat(float l); 152 153 #endif //CMDLIB_H__ 154