Indentation cleanup.
[AROS-Contrib.git] / Games / Quake / common.h
blob87d4a55ea7d043bd9a6be966d8489fe08b0e4a76
1 /*
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
25 #endif
27 #undef true
28 #undef false
30 typedef enum {false, true} qboolean;
32 //============================================================================
34 typedef struct sizebuf_s
36 qboolean allowoverflow; // if false, do a Sys_Error
37 qboolean overflowed; // set to true if the buffer size failed
38 byte *data;
39 int maxsize;
40 int cursize;
41 } sizebuf_t;
43 void SZ_Alloc (sizebuf_t *buf, int startsize);
44 void SZ_Free (sizebuf_t *buf);
45 void SZ_Clear (sizebuf_t *buf);
46 void *SZ_GetSpace (sizebuf_t *buf, int length);
47 void SZ_Write (sizebuf_t *buf, void *data, int length);
48 void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
50 //============================================================================
52 typedef struct link_s
54 struct link_s *prev, *next;
55 } link_t;
58 void ClearLink (link_t *l);
59 void RemoveLink (link_t *l);
60 void InsertLinkBefore (link_t *l, link_t *before);
61 void InsertLinkAfter (link_t *l, link_t *after);
63 // (type *)STRUCT_FROM_LINK(link_t *link, type, member)
64 // ent = STRUCT_FROM_LINK(link,entity_t,order)
65 // FIXME: remove this mess!
66 #define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
68 //============================================================================
70 #ifndef NULL
71 #define NULL ((void *)0)
72 #endif
74 #define Q_MAXCHAR ((char)0x7f)
75 #define Q_MAXSHORT ((short)0x7fff)
76 #define Q_MAXINT ((int)0x7fffffff)
77 #define Q_MAXLONG ((int)0x7fffffff)
78 #define Q_MAXFLOAT ((int)0x7fffffff)
80 #define Q_MINCHAR ((char)0x80)
81 #define Q_MINSHORT ((short)0x8000)
82 #define Q_MININT ((int)0x80000000)
83 #define Q_MINLONG ((int)0x80000000)
84 #define Q_MINFLOAT ((int)0x7fffffff)
86 //============================================================================
88 extern qboolean bigendien;
90 extern short (*BigShort) (short l);
91 extern short (*LittleShort) (short l);
92 extern int (*BigLong) (int l);
93 extern int (*LittleLong) (int l);
94 extern float (*BigFloat) (float l);
95 extern float (*LittleFloat) (float l);
97 //============================================================================
99 void MSG_WriteChar (sizebuf_t *sb, int c);
100 void MSG_WriteByte (sizebuf_t *sb, int c);
101 void MSG_WriteShort (sizebuf_t *sb, int c);
102 void MSG_WriteLong (sizebuf_t *sb, int c);
103 void MSG_WriteFloat (sizebuf_t *sb, float f);
104 void MSG_WriteString (sizebuf_t *sb, char *s);
105 void MSG_WriteCoord (sizebuf_t *sb, float f);
106 void MSG_WriteAngle (sizebuf_t *sb, float f);
108 extern int msg_readcount;
109 extern qboolean msg_badread; // set if a read goes beyond end of message
111 void MSG_BeginReading (void);
112 int MSG_ReadChar (void);
113 int MSG_ReadByte (void);
114 int MSG_ReadShort (void);
115 int MSG_ReadLong (void);
116 float MSG_ReadFloat (void);
117 char *MSG_ReadString (void);
119 float MSG_ReadCoord (void);
120 float MSG_ReadAngle (void);
122 //============================================================================
124 void Q_memset (void *dest, int fill, int count);
125 void Q_memcpy (void *dest, void *src, int count);
126 int Q_memcmp (void *m1, void *m2, int count);
127 void Q_strcpy (char *dest, char *src);
128 void Q_strncpy (char *dest, char *src, int count);
129 int Q_strlen (char *str);
130 char *Q_strrchr (char *s, char c);
131 void Q_strcat (char *dest, char *src);
132 int Q_strcmp (char *s1, char *s2);
133 int Q_strncmp (char *s1, char *s2, int count);
134 int Q_strcasecmp (char *s1, char *s2);
135 int Q_strncasecmp (char *s1, char *s2, int n);
136 int Q_atoi (char *str);
137 float Q_atof (char *str);
139 //============================================================================
141 extern char com_token[1024];
142 extern qboolean com_eof;
144 char *COM_Parse (char *data);
147 extern int com_argc;
148 extern char **com_argv;
150 int COM_CheckParm (char *parm);
151 void COM_Init (char *path);
152 void COM_InitArgv (int argc, char **argv);
154 char *COM_SkipPath (char *pathname);
155 void COM_StripExtension (char *in, char *out);
156 void COM_FileBase (char *in, char *out);
157 void COM_DefaultExtension (char *path, char *extension);
159 char *va(char *format, ...);
160 // does a varargs printf into a temp buffer
163 //============================================================================
165 extern int com_filesize;
166 struct cache_user_s;
168 extern char com_gamedir[MAX_OSPATH];
170 void COM_WriteFile (char *filename, void *data, int len);
171 int COM_OpenFile (char *filename, int *hndl);
172 int COM_FOpenFile (char *filename, FILE **file);
173 void COM_CloseFile (int h);
175 byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
176 byte *COM_LoadTempFile (char *path);
177 byte *COM_LoadHunkFile (char *path);
178 void COM_LoadCacheFile (char *path, struct cache_user_s *cu);
181 extern struct cvar_s registered;
183 extern qboolean standard_quake, rogue, hipnotic;