2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // comndef.h -- general definitions
22 #if !defined BYTE_DEFINED
23 typedef unsigned char byte
;
24 #define BYTE_DEFINED 1
31 typedef enum {qfalse
, qtrue
} qboolean
;
33 typedef enum {false, true} qboolean
;
37 #define min_b(a, b) ((a) < (b) ? (a) : (b))
40 #define max_b(a, b) ((a) > (b) ? (a) : (b))
44 #define bound(a, b, c) ((a) >= (c) ? (a) : (b) < (a) ? (a) : (b) > (c) ? (c) : (b))
46 //============================================================================
48 typedef struct sizebuf_s
50 qboolean allowoverflow
; // if false, do a Sys_Error
51 qboolean overflowed
; // set to true if the buffer size failed
57 void SZ_Alloc (sizebuf_t
*buf
, int startsize
);
58 void SZ_Free (sizebuf_t
*buf
);
59 void SZ_Clear (sizebuf_t
*buf
);
60 void *SZ_GetSpace (sizebuf_t
*buf
, int length
);
61 void SZ_Write (sizebuf_t
*buf
, void *data
, int length
);
62 void SZ_Print (sizebuf_t
*buf
, char *data
); // strcats onto the sizebuf
64 //============================================================================
68 struct link_s
*prev
, *next
;
72 void ClearLink (link_t
*l
);
73 void RemoveLink (link_t
*l
);
74 void InsertLinkBefore (link_t
*l
, link_t
*before
);
75 void InsertLinkAfter (link_t
*l
, link_t
*after
);
77 // (type *)STRUCT_FROM_LINK(link_t *link, type, member)
78 // ent = STRUCT_FROM_LINK(link,entity_t,order)
79 // FIXME: remove this mess!
80 #define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
82 //============================================================================
85 #define NULL ((void *)0)
88 #define Q_MAXCHAR ((char)0x7f)
89 #define Q_MAXSHORT ((short)0x7fff)
90 #define Q_MAXINT ((int)0x7fffffff)
91 #define Q_MAXLONG ((int)0x7fffffff)
92 #define Q_MAXFLOAT ((int)0x7fffffff)
94 #define Q_MINCHAR ((char)0x80)
95 #define Q_MINSHORT ((short)0x8000)
96 #define Q_MININT ((int)0x80000000)
97 #define Q_MINLONG ((int)0x80000000)
98 #define Q_MINFLOAT ((int)0x7fffffff)
100 //============================================================================
102 extern qboolean bigendien
;
104 extern short (*BigShort
) (short l
);
105 extern short (*LittleShort
) (short l
);
106 extern int (*BigLong
) (int l
);
107 extern int (*LittleLong
) (int l
);
108 extern float (*BigFloat
) (float l
);
109 extern float (*LittleFloat
) (float l
);
111 //============================================================================
113 void MSG_WriteChar (sizebuf_t
*sb
, int c
);
114 void MSG_WriteByte (sizebuf_t
*sb
, int c
);
115 void MSG_WriteShort (sizebuf_t
*sb
, int c
);
116 void MSG_WriteLong (sizebuf_t
*sb
, int c
);
117 void MSG_WriteFloat (sizebuf_t
*sb
, float f
);
118 void MSG_WriteString (sizebuf_t
*sb
, char *s
);
119 void MSG_WriteCoord (sizebuf_t
*sb
, float f
);
120 void MSG_WriteAngle (sizebuf_t
*sb
, float f
);
121 void MSG_WritePreciseAngle (sizebuf_t
*sb
, float f
); // JPG - precise aim!!
123 extern int msg_readcount
;
124 extern qboolean msg_badread
; // set if a read goes beyond end of message
126 void MSG_BeginReading (void);
127 int MSG_ReadChar (void);
128 int MSG_ReadByte (void);
129 int MSG_ReadShort (void);
130 int MSG_ReadLong (void);
131 float MSG_ReadFloat (void);
132 char *MSG_ReadString (void);
134 float MSG_ReadCoord (void);
135 float MSG_ReadAngle (void);
136 float MSG_ReadPreciseAngle (void); // JPG - precise aim!!
138 //============================================================================
140 void Q_memset (void *dest
, int fill
, int count
);
141 void Q_memcpy (void *dest
, void *src
, int count
);
142 int Q_memcmp (void *m1
, void *m2
, int count
);
143 void Q_strcpy (char *dest
, char *src
);
144 void Q_strncpy (char *dest
, char *src
, int count
);
145 int Q_strlen (char *str
);
146 char *Q_strrchr (char *s
, char c
);
147 void Q_strcat (char *dest
, char *src
);
148 int Q_strcmp (char *s1
, char *s2
);
149 int Q_strncmp (char *s1
, char *s2
, int count
);
150 int Q_strcasecmp (char *s1
, char *s2
);
151 int Q_strncasecmp (char *s1
, char *s2
, int n
);
152 int Q_atoi (char *str
);
153 float Q_atof (char *str
);
155 //============================================================================
157 extern char com_token
[1024];
158 extern qboolean com_eof
;
160 char *COM_Parse (char *data
);
164 extern char **com_argv
;
166 int COM_CheckParm (char *parm
);
167 void COM_Init (char *path
);
168 void COM_InitArgv (int argc
, char **argv
);
170 char *COM_SkipPath (char *pathname
);
171 void COM_StripExtension (char *in
, char *out
);
172 void COM_FileBase (char *in
, char *out
);
173 void COM_DefaultExtension (char *path
, char *extension
);
175 char *va(char *format
, ...);
176 // does a varargs printf into a temp buffer
179 //============================================================================
181 extern int com_filesize
;
184 extern char com_gamedir
[MAX_OSPATH
];
186 void COM_WriteFile (char *filename
, void *data
, int len
);
187 int COM_OpenFile (char *filename
, int *hndl
);
188 int COM_FOpenFile (char *filename
, int *file
);
189 void COM_CloseFile (int h
);
191 byte
*COM_LoadStackFile (char *path
, void *buffer
, int bufsize
);
192 byte
*COM_LoadTempFile (char *path
);
193 byte
*COM_LoadHunkFile (char *path
);
194 void COM_LoadCacheFile (char *path
, struct cache_user_s
*cu
);
197 extern struct cvar_s registered
;
199 extern qboolean standard_quake
, rogue
, hipnotic
, kurok
;