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