common.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. Copyright (C) 2004 Michael Liebscher <johnnycanuck@users.sourceforge.net>
  3. Copyright (C) 1997-2001 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.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. /*
  17. * common.h: Common definitions between client and server.
  18. *
  19. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  20. *
  21. * Acknowledgement:
  22. * This code was derived from Quake II, and was originally
  23. * written by Id Software, Inc.
  24. *
  25. */
  26. /*
  27. Notes:
  28. This module is implemented by common.c.
  29. */
  30. #ifndef __COMMON_H__
  31. #define __COMMON_H__
  32. //============================================================================
  33. typedef struct sizebuf_s
  34. {
  35. _boolean allowoverflow; // if false, do a Com_Error
  36. _boolean overflowed; // set to true if the buffer size failed
  37. W8 *data;
  38. int maxsize;
  39. int cursize;
  40. int readcount;
  41. } sizebuf_t;
  42. extern void SZ_Init( sizebuf_t *buf, PW8 data, int length );
  43. extern void SZ_Clear( sizebuf_t *buf );
  44. extern void *SZ_GetSpace( sizebuf_t *buf, int length );
  45. extern void SZ_Write( sizebuf_t *buf, void *data, int length );
  46. extern void SZ_Print( sizebuf_t *buf, W8 *data ); // memcpy onto the sizebuf
  47. //============================================================================
  48. extern int COM_Argc( void );
  49. extern char *COM_Argv( int arg ); // range and null checked
  50. extern void COM_ClearArgv( int arg );
  51. extern int COM_CheckParm( char *parm );
  52. extern void COM_AddParm( char *parm );
  53. extern void COM_Init( void );
  54. extern void COM_InitArgv( int argc, char *argv[] );
  55. extern char *COM_Parse( char **data_p );
  56. // data is an in/out parm, returns a parsed out token
  57. //============================================================================
  58. /////////////////////////////////////////////////////////////////////
  59. //
  60. // Colour
  61. //
  62. /////////////////////////////////////////////////////////////////////
  63. extern colour3_t colourBlack;
  64. extern colour3_t colourRed;
  65. extern colour3_t colourBlue;
  66. extern colour3_t colourGreen;
  67. extern colour3_t colourWhite;
  68. /////////////////////////////////////////////////////////////////////
  69. // End Colour
  70. /////////////////////////////////////////////////////////////////////
  71. /*
  72. ==============================================================
  73. MISC
  74. ==============================================================
  75. */
  76. #define ERR_FATAL 0 // exit the entire game with a popup window
  77. #define ERR_DROP 1 // print to console and disconnect from game
  78. #define ERR_QUIT 2 // not an error, just a normal exit
  79. #define ERR_DISCONNECT 4 // don't kill server
  80. #define EXEC_NOW 0 // don't return until completed
  81. #define EXEC_INSERT 1 // insert at current position, but don't run yet
  82. #define EXEC_APPEND 2 // add to end of the command buffer
  83. #define PRINT_ALL 0
  84. #define PRINT_DEVELOPER 1 // only print when "developer 1"
  85. extern void Com_BeginRedirect( int target, char *buffer, int buffersize, void (*flush) );
  86. extern void Com_EndRedirect( void );
  87. extern void Com_Printf( const char *fmt, ... );
  88. extern void Com_DPrintf( const char *fmt, ... );
  89. extern void Com_Error( int code, const char *fmt, ... );
  90. extern char *va( char *format, ... );
  91. extern cvar_t *developer;
  92. extern cvar_t *log_stats;
  93. extern cvar_t *logfile_active;
  94. extern FILE *log_stats_file;
  95. extern void common_Init( int argc, char *argv[] );
  96. extern void common_Frame( int msec );
  97. /*
  98. ==============================================================
  99. NON-PORTABLE SYSTEM SERVICES
  100. ==============================================================
  101. */
  102. extern char *Sys_ConsoleInput( void );
  103. extern void Sys_ConsoleOutput( const char *string );
  104. extern void Sys_SendKeyEvents( void );
  105. extern void Sys_Error( const char *format, ... );
  106. extern void Sys_Quit( void );
  107. extern char *Sys_GetClipboardData( void );
  108. extern void Sys_CopyProtect( void );
  109. /*
  110. ==============================================================
  111. CLIENT / SERVER SYSTEMS
  112. ==============================================================
  113. */
  114. extern void Client_Init( void );
  115. //
  116. // button bits
  117. //
  118. #define BUTTON_ATTACK 1
  119. #define BUTTON_USE 2
  120. #define BUTTON_ANY 128 // any key whatsoever
  121. // usercmd_t is sent to the server each client frame
  122. typedef struct usercmd_s
  123. {
  124. W8 msec;
  125. W8 buttons;
  126. short angles[ 3 ];
  127. short forwardmove, sidemove, upmove;
  128. W8 impulse; // remove?
  129. W8 lightlevel; // light level the player is standing on
  130. } usercmd_t;
  131. #endif /* __COMMON_H__ */