l_utils.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. #ifndef MAX_PATH
  19. #define MAX_PATH 64
  20. #endif
  21. #ifndef PATH_SEPERATORSTR
  22. #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
  23. #define PATHSEPERATOR_STR "\\"
  24. #else
  25. #define PATHSEPERATOR_STR "/"
  26. #endif
  27. #endif
  28. #ifndef PATH_SEPERATORCHAR
  29. #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
  30. #define PATHSEPERATOR_CHAR '\\'
  31. #else
  32. #define PATHSEPERATOR_CHAR '/'
  33. #endif
  34. #endif
  35. //random in the range [0, 1]
  36. #define random() ((rand () & 0x7fff) / ((float)0x7fff))
  37. //random in the range [-1, 1]
  38. #define crandom() (2.0 * (random() - 0.5))
  39. //min and max
  40. #define Maximum(x,y) (x > y ? x : y)
  41. #define Minimum(x,y) (x < y ? x : y)
  42. //absolute value
  43. #define FloatAbs(x) (*(float *) &((* (int *) &(x)) & 0x7FFFFFFF))
  44. #define IntAbs(x) (~(x))
  45. //coordinates
  46. #define _X 0
  47. #define _Y 1
  48. #define _Z 2
  49. typedef struct foundfile_s
  50. {
  51. int offset;
  52. int length;
  53. char filename[MAX_PATH]; //screw LCC, array must be at end of struct
  54. } foundfile_t;
  55. void Vector2Angles(vec3_t value1, vec3_t angles);
  56. //set the correct path seperators
  57. void ConvertPath(char *path);
  58. //append a path seperator to the given path not exceeding the length
  59. void AppendPathSeperator(char *path, int length);
  60. //find a file in a pak file
  61. qboolean FindFileInPak(char *pakfile, char *filename, foundfile_t *file);
  62. //find a quake file
  63. #ifdef BOTLIB
  64. qboolean FindQuakeFile(char *filename, foundfile_t *file);
  65. #else //BOTLIB
  66. qboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file);
  67. #endif //BOTLIB