home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 15 / MA_Cover_15.iso / source / winquake / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-25  |  5.4 KB  |  194 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  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.
  8.  
  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.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  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.
  18.  
  19. */
  20. // comndef.h  -- general definitions
  21.  
  22. #if !defined BYTE_DEFINED
  23. typedef unsigned char         byte;
  24. #define BYTE_DEFINED 1
  25. #endif
  26.  
  27. #ifdef __STORM__
  28.  
  29. #define false 0
  30. #define true  1
  31. typedef unsigned int qboolean;
  32.  
  33. #else
  34.  
  35. #undef true
  36. #undef false
  37.  
  38. typedef enum {false, true}    qboolean;
  39.  
  40. #endif
  41.  
  42. //============================================================================
  43.  
  44. typedef struct sizebuf_s
  45. {
  46.     qboolean    allowoverflow;    // if false, do a Sys_Error
  47.     qboolean    overflowed;        // set to true if the buffer size failed
  48.     byte    *data;
  49.     int        maxsize;
  50.     int        cursize;
  51. } sizebuf_t;
  52.  
  53. void SZ_Alloc (sizebuf_t *buf, int startsize);
  54. void SZ_Free (sizebuf_t *buf);
  55. void SZ_Clear (sizebuf_t *buf);
  56. void *SZ_GetSpace (sizebuf_t *buf, int length);
  57. void SZ_Write (sizebuf_t *buf, void *data, int length);
  58. void SZ_Print (sizebuf_t *buf, char *data);    // strcats onto the sizebuf
  59.  
  60. //============================================================================
  61.  
  62. typedef struct link_s
  63. {
  64.     struct link_s    *prev, *next;
  65. } link_t;
  66.  
  67.  
  68. void ClearLink (link_t *l);
  69. void RemoveLink (link_t *l);
  70. void InsertLinkBefore (link_t *l, link_t *before);
  71. void InsertLinkAfter (link_t *l, link_t *after);
  72.  
  73. // (type *)STRUCT_FROM_LINK(link_t *link, type, member)
  74. // ent = STRUCT_FROM_LINK(link,entity_t,order)
  75. // FIXME: remove this mess!
  76. #define    STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
  77.  
  78. //============================================================================
  79.  
  80. #ifndef NULL
  81. #define NULL ((void *)0)
  82. #endif
  83.  
  84. #define Q_MAXCHAR ((char)0x7f)
  85. #define Q_MAXSHORT ((short)0x7fff)
  86. #define Q_MAXINT    ((int)0x7fffffff)
  87. #define Q_MAXLONG ((int)0x7fffffff)
  88. #define Q_MAXFLOAT ((int)0x7fffffff)
  89.  
  90. #define Q_MINCHAR ((char)0x80)
  91. #define Q_MINSHORT ((short)0x8000)
  92. #define Q_MININT     ((int)0x80000000)
  93. #define Q_MINLONG ((int)0x80000000)
  94. #define Q_MINFLOAT ((int)0x7fffffff)
  95.  
  96. //============================================================================
  97.  
  98. extern    qboolean        bigendien;
  99.  
  100. extern    short    (*BigShort) (short l);
  101. extern    short    (*LittleShort) (short l);
  102. extern    int    (*BigLong) (int l);
  103. extern    int    (*LittleLong) (int l);
  104. extern    float    (*BigFloat) (float l);
  105. extern    float    (*LittleFloat) (float l);
  106.  
  107. //============================================================================
  108.  
  109. void MSG_WriteChar (sizebuf_t *sb, int c);
  110. void MSG_WriteByte (sizebuf_t *sb, int c);
  111. void MSG_WriteShort (sizebuf_t *sb, int c);
  112. void MSG_WriteLong (sizebuf_t *sb, int c);
  113. void MSG_WriteFloat (sizebuf_t *sb, float f);
  114. void MSG_WriteString (sizebuf_t *sb, char *s);
  115. void MSG_WriteCoord (sizebuf_t *sb, float f);
  116. void MSG_WriteAngle (sizebuf_t *sb, float f);
  117.  
  118. extern    int            msg_readcount;
  119. extern    qboolean    msg_badread;        // set if a read goes beyond end of message
  120.  
  121. void MSG_BeginReading (void);
  122. int MSG_ReadChar (void);
  123. int MSG_ReadByte (void);
  124. int MSG_ReadShort (void);
  125. int MSG_ReadLong (void);
  126. float MSG_ReadFloat (void);
  127. char *MSG_ReadString (void);
  128.  
  129. float MSG_ReadCoord (void);
  130. float MSG_ReadAngle (void);
  131.  
  132. //============================================================================
  133.  
  134. void Q_memset (void *dest, int fill, int count);
  135. void Q_memcpy (void *dest, void *src, int count);
  136. int Q_memcmp (void *m1, void *m2, int count);
  137. void Q_strcpy (char *dest, char *src);
  138. void Q_strncpy (char *dest, char *src, int count);
  139. int Q_strlen (char *str);
  140. char *Q_strrchr (char *s, char c);
  141. void Q_strcat (char *dest, char *src);
  142. int Q_strcmp (char *s1, char *s2);
  143. int Q_strncmp (char *s1, char *s2, int count);
  144. int Q_strcasecmp (char *s1, char *s2);
  145. int Q_strncasecmp (char *s1, char *s2, int n);
  146. int    Q_atoi (char *str);
  147. float Q_atof (char *str);
  148.  
  149. //============================================================================
  150.  
  151. extern    char        com_token[1024];
  152. extern    qboolean    com_eof;
  153.  
  154. char *COM_Parse (char *data);
  155.  
  156.  
  157. extern    int        com_argc;
  158. extern    char    **com_argv;
  159.  
  160. int COM_CheckParm (char *parm);
  161. void COM_Init (char *path);
  162. void COM_InitArgv (int argc, char **argv);
  163.  
  164. char *COM_SkipPath (char *pathname);
  165. void COM_StripExtension (char *in, char *out);
  166. void COM_FileBase (char *in, char *out);
  167. void COM_DefaultExtension (char *path, char *extension);
  168.  
  169. char    *va(char *format, ...);
  170. // does a varargs printf into a temp buffer
  171.  
  172.  
  173. //============================================================================
  174.  
  175. extern int com_filesize;
  176. struct cache_user_s;
  177.  
  178. extern    char    com_gamedir[MAX_OSPATH];
  179.  
  180. void COM_WriteFile (char *filename, void *data, int len);
  181. int COM_OpenFile (char *filename, int *hndl);
  182. int COM_FOpenFile (char *filename, FILE **file);
  183. void COM_CloseFile (int h);
  184.  
  185. byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
  186. byte *COM_LoadTempFile (char *path);
  187. byte *COM_LoadHunkFile (char *path);
  188. void COM_LoadCacheFile (char *path, struct cache_user_s *cu);
  189.  
  190.  
  191. extern    struct cvar_s    registered;
  192.  
  193. extern qboolean        standard_quake, rogue, hipnotic;
  194.