cmdlib.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #ifndef CMDLIB_H__
  2. #define CMDLIB_H__
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif
  6. #ifdef __MINGW32__
  7. #include <io.h>
  8. #endif
  9. #ifdef HAVE_CONFIG_H
  10. #include "config.h"
  11. #endif
  12. // AJM: gnu compiler fix
  13. #ifdef __GNUC__
  14. #define _alloca __builtin_alloca
  15. #define alloca __builtin_alloca
  16. #endif
  17. #include "win32fix.h"
  18. #include "mathtypes.h"
  19. #ifdef _DEBUG
  20. #define ZHLT_VERSIONSTRING "v3.9"
  21. #else
  22. #define ZHLT_VERSIONSTRING "3.9"
  23. #endif
  24. // SILENCER -->
  25. #if !defined(_WIN64)
  26. #if _M_IX86_FP == 0
  27. #define HACK_VERSIONSTRING "x86 (32b) SSE OFF"
  28. #endif
  29. #if _M_IX86_FP == 1
  30. #define HACK_VERSIONSTRING "x86 (32b) SSE1 ON"
  31. #endif
  32. #if _M_IX86_FP == 2
  33. #define HACK_VERSIONSTRING "x86 (32b) SSE2 ON"
  34. #endif
  35. #else
  36. #define HACK_VERSIONSTRING "x64 (64b) "
  37. #endif
  38. // <-- SILENCER
  39. //=====================================================================
  40. // AJM: Different features of the tools can be undefined here
  41. // these are not officially beta tested, but seem to work okay
  42. // ZHLT_* features are spread across more than one tool. Hence, changing
  43. // one of these settings probably means recompiling the whole set
  44. #define ZHLT_INFO_COMPILE_PARAMETERS // ALL TOOLS
  45. #define ZHLT_NULLTEX // HLCSG, HLBSP
  46. #define ZHLT_TEXLIGHT // HLCSG, HLRAD - triggerable texlights by LRC
  47. #define ZHLT_GENERAL // ALL TOOLS - general changes
  48. #define ZHLT_NEW_FILE_FUNCTIONS // ALL TOOLS - file path/extension extraction functions
  49. //#define ZHLT_DETAIL // HLCSG, HLBSP - detail brushes
  50. //#define ZHLT_PROGRESSFILE // ALL TOOLS - estimate progress reporting to -progressfile
  51. //#define ZHLT_NSBOB
  52. #define ZHLT_VectorMA_FIX //--vluzacn
  53. #define ZHLT_PLANETYPE_FIX // Very Important !! --vluzacn
  54. #define COMMON_HULLU // winding optimisations by hullu
  55. // tool specific settings below only mean a recompile of the tool affected
  56. #define HLCSG_CLIPECONOMY
  57. #define HLCSG_WADCFG
  58. #define HLCSG_AUTOWAD
  59. #define HLCSG_PRECISIONCLIP
  60. #define HLCSG_FASTFIND
  61. #ifdef ZHLT_NULLTEX
  62. #define HLCSG_NULLIFY_INVISIBLE //requires null textures as prerequisite
  63. #endif
  64. #define HLCSG_SORTBRUSH_FIX
  65. //#define HLBSP_THREADS // estimate for hlbsp
  66. #define HLVIS_MAXDIST
  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. #ifdef SYSTEM_WIN32
  73. #pragma warning(disable:4127 4115 4244 4786 4305 4800)
  74. #endif
  75. #ifdef STDC_HEADERS
  76. #include <stdio.h>
  77. #include <string.h>
  78. #include <stdlib.h>
  79. #include <errno.h>
  80. #include <ctype.h>
  81. #include <time.h>
  82. #include <stdarg.h>
  83. #include <limits.h>
  84. #endif
  85. #ifdef HAVE_SYS_TIME_H
  86. #include <sys/time.h>
  87. #endif
  88. #ifdef HAVE_UNISTD_H
  89. #include <unistd.h>
  90. #endif
  91. #ifdef ZHLT_NETVIS
  92. #include "c2cpp.h"
  93. #endif
  94. #ifdef SYSTEM_WIN32
  95. #define SYSTEM_SLASH_CHAR '\\'
  96. #define SYSTEM_SLASH_STR "\\"
  97. #endif
  98. #ifdef SYSTEM_POSIX
  99. #define SYSTEM_SLASH_CHAR '/'
  100. #define SYSTEM_SLASH_STR "/"
  101. #endif
  102. // the dec offsetof macro doesn't work very well...
  103. #define myoffsetof(type,identifier) ((size_t)&((type*)0)->identifier)
  104. #define sizeofElement(type,identifier) (sizeof((type*)0)->identifier)
  105. #ifdef SYSTEM_POSIX
  106. extern char* strupr(char* string);
  107. extern char* strlwr(char* string);
  108. #endif
  109. extern const char* stristr(const char* const string, const char* const substring);
  110. extern bool CDECL safe_snprintf(char* const dest, const size_t count, const char* const args, ...);
  111. extern bool safe_strncpy(char* const dest, const char* const src, const size_t count);
  112. extern bool safe_strncat(char* const dest, const char* const src, const size_t count);
  113. extern bool TerminatedString(const char* buffer, const int size);
  114. extern char* FlipSlashes(char* string);
  115. extern double I_FloatTime();
  116. extern int CheckParm(char* check);
  117. extern void DefaultExtension(char* path, const char* extension);
  118. extern void DefaultPath(char* path, char* basepath);
  119. extern void StripFilename(char* path);
  120. extern void StripExtension(char* path);
  121. extern void ExtractFile(const char* const path, char* dest);
  122. extern void ExtractFilePath(const char* const path, char* dest);
  123. extern void ExtractFileBase(const char* const path, char* dest);
  124. extern void ExtractFileExtension(const char* const path, char* dest);
  125. extern short BigShort(short l);
  126. extern short LittleShort(short l);
  127. extern int BigLong(int l);
  128. extern int LittleLong(int l);
  129. extern float BigFloat(float l);
  130. extern float LittleFloat(float l);
  131. #endif //CMDLIB_H__