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.
24 // MSVC has a different name for several standard functions
26 # define snprintf _snprintf
27 # define vsnprintf _vsnprintf
28 # define strcasecmp stricmp
29 # define strncasecmp strnicmp
33 //============================================================================
35 typedef struct sizebuf_s
37 qboolean allowoverflow; // if false, do a Sys_Error
38 qboolean overflowed; // set to true if the buffer size failed
45 void SZ_Alloc (sizebuf_t *buf, int startsize, const char *name);
46 void SZ_Free (sizebuf_t *buf);
47 void SZ_Clear (sizebuf_t *buf);
48 void *SZ_GetSpace (sizebuf_t *buf, int length);
49 void SZ_Write (sizebuf_t *buf, const void *data, int length);
50 void SZ_Print (sizebuf_t *buf, const char *data); // strcats onto the sizebuf
51 void SZ_HexDumpToConsole(const sizebuf_t *buf);
53 void Com_HexDumpToConsole(const qbyte *data, int size);
55 //============================================================================
56 #if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
57 #if defined(__i386__) || defined(__ia64__) || defined(WIN32) || (defined(__alpha__) || defined(__alpha)) || defined(__arm__) || (defined(__mips__) && defined(__MIPSEL__)) || defined(__LITTLE_ENDIAN__)
64 short ShortSwap (short l);
66 float FloatSwap (float f);
70 #define BigShort(l) ShortSwap(l)
71 #define LittleShort(l) (l)
72 #define BigLong(l) LongSwap(l)
73 #define LittleLong(l) (l)
74 #define BigFloat(l) FloatSwap(l)
75 #define LittleFloat(l) (l)
78 #define BigShort(l) (l)
79 #define LittleShort(l) ShortSwap(l)
80 #define BigLong(l) (l)
81 #define LittleLong(l) LongSwap(l)
82 #define BigFloat(l) (l)
83 #define LittleFloat(l) FloatSwap(l)
85 // figure it out at runtime
86 extern short (*BigShort) (short l);
87 extern short (*LittleShort) (short l);
88 extern int (*BigLong) (int l);
89 extern int (*LittleLong) (int l);
90 extern float (*BigFloat) (float l);
91 extern float (*LittleFloat) (float l);
94 //============================================================================
96 void MSG_WriteChar (sizebuf_t *sb, int c);
97 void MSG_WriteByte (sizebuf_t *sb, int c);
98 void MSG_WriteShort (sizebuf_t *sb, int c);
99 void MSG_WriteLong (sizebuf_t *sb, int c);
100 void MSG_WriteFloat (sizebuf_t *sb, float f);
101 void MSG_WriteString (sizebuf_t *sb, const char *s);
102 void MSG_WriteCoord (sizebuf_t *sb, float f);
103 void MSG_WriteAngle (sizebuf_t *sb, float f);
104 void MSG_WritePreciseAngle (sizebuf_t *sb, float f);
105 void MSG_WriteDPCoord (sizebuf_t *sb, float f);
107 extern int msg_readcount;
108 extern qboolean msg_badread; // set if a read goes beyond end of message
110 void MSG_BeginReading (void);
111 int MSG_ReadShort (void);
112 int MSG_ReadLong (void);
113 float MSG_ReadFloat (void);
114 char *MSG_ReadString (void);
116 #define MSG_ReadChar() (msg_readcount >= net_message.cursize ? (msg_badread = true, -1) : (signed char)net_message.data[msg_readcount++])
117 #define MSG_ReadByte() (msg_readcount >= net_message.cursize ? (msg_badread = true, -1) : (unsigned char)net_message.data[msg_readcount++])
119 float MSG_ReadCoord (void);
121 float MSG_ReadDPCoord (void);
123 #define MSG_ReadAngle() (MSG_ReadByte() * (360.0f / 256.0f))
124 #define MSG_ReadPreciseAngle() (MSG_ReadShort() * (360.0f / 65536.0f))
126 #define MSG_ReadVector(v) {(v)[0] = MSG_ReadCoord();(v)[1] = MSG_ReadCoord();(v)[2] = MSG_ReadCoord();}
128 extern int dpprotocol;
130 //============================================================================
132 extern char com_token[1024];
134 int COM_ParseToken (const char **data);
137 extern const char **com_argv;
139 int COM_CheckParm (const char *parm);
140 void COM_Init (void);
141 void COM_InitArgv (void);
142 void COM_InitGameType (void);
144 char *va(const char *format, ...);
145 // does a varargs printf into a temp buffer
148 //============================================================================
150 extern struct cvar_s registered;
152 #define GAME_NORMAL 0
153 #define GAME_HIPNOTIC 1
155 #define GAME_NEHAHRA 3
156 #define GAME_NEXIUZ 4
157 #define GAME_TRANSFUSION 5
160 extern char *gamename;
161 extern char *gamedirname;
162 extern char com_modname[MAX_OSPATH];
164 // LordHavoc: useful...
165 void COM_ToLowerString(const char *in, char *out);
166 void COM_ToUpperString(const char *in, char *out);
167 int COM_StringBeginsWith(const char *s, const char *match);
169 typedef struct stringlist_s
171 struct stringlist_s *next;
175 int matchpattern(char *in, char *pattern, int caseinsensitive);
176 stringlist_t *listdirectory(char *path);
177 void freedirectory(stringlist_t *list);