cmdlib.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.7"
  21. #else
  22. #define ZHLT_VERSIONSTRING "3.7"
  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 COMMON_HULLU // winding optimisations by hullu
  53. // tool specific settings below only mean a recompile of the tool affected
  54. #define HLCSG_CLIPECONOMY
  55. #define HLCSG_WADCFG
  56. #define HLCSG_AUTOWAD
  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. //#define HLBSP_THREADS // estimate for hlbsp
  63. #define HLVIS_MAXDIST
  64. #define HLRAD_INFO_TEXLIGHTS
  65. #define HLRAD_WHOME // encompases all of Adam Foster's changes
  66. #define HLRAD_HULLU // semi-opaque brush based entities and effects by hullu
  67. #define HLRAD_FASTMATH // optimized mathutil.cpp by KGP
  68. //=====================================================================
  69. #ifdef SYSTEM_WIN32
  70. #pragma warning(disable:4127 4115 4244 4786 4305 4800)
  71. #endif
  72. #ifdef STDC_HEADERS
  73. #include <stdio.h>
  74. #include <string.h>
  75. #include <stdlib.h>
  76. #include <errno.h>
  77. #include <ctype.h>
  78. #include <time.h>
  79. #include <stdarg.h>
  80. #include <limits.h>
  81. #endif
  82. #ifdef HAVE_SYS_TIME_H
  83. #include <sys/time.h>
  84. #endif
  85. #ifdef HAVE_UNISTD_H
  86. #include <unistd.h>
  87. #endif
  88. #ifdef ZHLT_NETVIS
  89. #include "c2cpp.h"
  90. #endif
  91. #ifdef SYSTEM_WIN32
  92. #define SYSTEM_SLASH_CHAR '\\'
  93. #define SYSTEM_SLASH_STR "\\"
  94. #endif
  95. #ifdef SYSTEM_POSIX
  96. #define SYSTEM_SLASH_CHAR '/'
  97. #define SYSTEM_SLASH_STR "/"
  98. #endif
  99. // the dec offsetof macro doesn't work very well...
  100. #define myoffsetof(type,identifier) ((size_t)&((type*)0)->identifier)
  101. #define sizeofElement(type,identifier) (sizeof((type*)0)->identifier)
  102. #ifdef SYSTEM_POSIX
  103. extern char* strupr(char* string);
  104. extern char* strlwr(char* string);
  105. #endif
  106. extern const char* stristr(const char* const string, const char* const substring);
  107. extern bool CDECL safe_snprintf(char* const dest, const size_t count, const char* const args, ...);
  108. extern bool safe_strncpy(char* const dest, const char* const src, const size_t count);
  109. extern bool safe_strncat(char* const dest, const char* const src, const size_t count);
  110. extern bool TerminatedString(const char* buffer, const int size);
  111. extern char* FlipSlashes(char* string);
  112. extern double I_FloatTime();
  113. extern int CheckParm(char* check);
  114. extern void DefaultExtension(char* path, const char* extension);
  115. extern void DefaultPath(char* path, char* basepath);
  116. extern void StripFilename(char* path);
  117. extern void StripExtension(char* path);
  118. extern void ExtractFile(const char* const path, char* dest);
  119. extern void ExtractFilePath(const char* const path, char* dest);
  120. extern void ExtractFileBase(const char* const path, char* dest);
  121. extern void ExtractFileExtension(const char* const path, char* dest);
  122. extern short BigShort(short l);
  123. extern short LittleShort(short l);
  124. extern int BigLong(int l);
  125. extern int LittleLong(int l);
  126. extern float BigFloat(float l);
  127. extern float LittleFloat(float l);
  128. #endif //CMDLIB_H__