PageRenderTime 37ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/quakeforge/trunk/nq/include/server.h

#
C++ Header | 285 lines | 176 code | 66 blank | 43 comment | 0 complexity | 97b3c6d35da69cc8f8532a9efe11e560 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-3.0, AGPL-1.0, Unlicense
  1. /*
  2. server.h
  3. @description@
  4. Copyright (C) 1996-1997 Id Software, Inc.
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. 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.
  12. See the GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to:
  15. Free Software Foundation, Inc.
  16. 59 Temple Place - Suite 330
  17. Boston, MA 02111-1307, USA
  18. $Id: server.h 11862 2010-01-13 06:42:26Z taniwha $
  19. */
  20. #ifndef __server_h
  21. #define __server_h
  22. #include <setjmp.h>
  23. #include "QF/info.h"
  24. #include "QF/model.h"
  25. #include "QF/quakeio.h"
  26. #include "QF/sizebuf.h"
  27. #include "client.h"
  28. #include "netmain.h"
  29. #include "protocol.h"
  30. #include "sv_progs.h"
  31. extern progs_t sv_pr_state;
  32. typedef struct
  33. {
  34. int maxclients;
  35. int maxclientslimit;
  36. struct client_s *clients; // [maxclients]
  37. int serverflags; // episode completion information
  38. qboolean changelevel_issued; // cleared when at SV_SpawnServer
  39. } server_static_t;
  40. //=============================================================================
  41. typedef enum {ss_loading, ss_active} server_state_t;
  42. typedef struct
  43. {
  44. qboolean active; // false if only a net client
  45. qboolean paused;
  46. qboolean loadgame; // handle connections specially
  47. double time;
  48. int lastcheck; // used by PF_checkclient
  49. double lastchecktime;
  50. char name[64]; // map name
  51. char modelname[64]; // maps/<name>.bsp, for model_precache[0]
  52. struct model_s *worldmodel;
  53. const char *model_precache[MAX_MODELS]; // NULL terminated
  54. struct model_s *models[MAX_MODELS];
  55. const char *sound_precache[MAX_SOUNDS]; // NULL terminated
  56. const char *lightstyles[MAX_LIGHTSTYLES];
  57. int num_edicts;
  58. int max_edicts;
  59. edict_t *edicts; // can NOT be array indexed, because
  60. // edict_t is variable sized, but can
  61. // be used to reference the world ent
  62. server_state_t state; // some actions are valid only during load
  63. sizebuf_t datagram;
  64. byte datagram_buf[MAX_DATAGRAM];
  65. sizebuf_t reliable_datagram; // copied to all clients at end of frame
  66. byte reliable_datagram_buf[MAX_DATAGRAM];
  67. sizebuf_t signon;
  68. byte signon_buf[8192];
  69. } server_t;
  70. #define NUM_PING_TIMES 16
  71. #define NUM_SPAWN_PARMS 16
  72. typedef struct client_s
  73. {
  74. qboolean active; // false = client is free
  75. qboolean spawned; // false = don't send datagrams
  76. qboolean dropasap; // has been told to go to another level
  77. qboolean privileged; // can execute any host command
  78. qboolean sendsignon; // valid only before spawned
  79. double last_message; // reliable messages must be sent
  80. // periodically
  81. struct qsocket_s *netconnection; // communications handle
  82. usercmd_t cmd; // movement
  83. vec3_t wishdir; // intended motion calced from cmd
  84. sizebuf_t message; // can be added to at any time,
  85. // copied and clear once per frame
  86. byte msgbuf[MAX_MSGLEN];
  87. edict_t *edict; // EDICT_NUM(clientnum+1)
  88. char name[32]; // for printing to other people
  89. int colors;
  90. float ping_times[NUM_PING_TIMES];
  91. int num_pings; // ping_times[num_pings%NUM_PING_TIMES]
  92. // spawn parms are carried from level to level
  93. float spawn_parms[NUM_SPAWN_PARMS];
  94. // client known data for deltas
  95. int old_frags;
  96. } client_t;
  97. //=============================================================================
  98. // edict->movetype values
  99. #define MOVETYPE_NONE 0 // never moves
  100. #define MOVETYPE_ANGLENOCLIP 1
  101. #define MOVETYPE_ANGLECLIP 2
  102. #define MOVETYPE_WALK 3 // gravity
  103. #define MOVETYPE_STEP 4 // gravity, special edge handling
  104. #define MOVETYPE_FLY 5
  105. #define MOVETYPE_TOSS 6 // gravity
  106. #define MOVETYPE_PUSH 7 // no clip to world, push and crush
  107. #define MOVETYPE_NOCLIP 8
  108. #define MOVETYPE_FLYMISSILE 9 // extra size to monsters
  109. #define MOVETYPE_BOUNCE 10
  110. // edict->solid values
  111. #define SOLID_NOT 0 // no interaction with other objects
  112. #define SOLID_TRIGGER 1 // touch on edge, but not blocking
  113. #define SOLID_BBOX 2 // touch on edge, block
  114. #define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
  115. #define SOLID_BSP 4 // bsp clip, touch on edge, block
  116. // edict->deadflag values
  117. #define DEAD_NO 0
  118. #define DEAD_DYING 1
  119. #define DEAD_DEAD 2
  120. #define DAMAGE_NO 0
  121. #define DAMAGE_YES 1
  122. #define DAMAGE_AIM 2
  123. // edict->flags
  124. #define FL_FLY 1
  125. #define FL_SWIM 2
  126. //#define FL_GLIMPSE 4
  127. #define FL_CONVEYOR 4
  128. #define FL_CLIENT 8
  129. #define FL_INWATER 16
  130. #define FL_MONSTER 32
  131. #define FL_GODMODE 64
  132. #define FL_NOTARGET 128
  133. #define FL_ITEM 256
  134. #define FL_ONGROUND 512
  135. #define FL_PARTIALGROUND 1024 // not all corners are valid
  136. #define FL_WATERJUMP 2048 // player jumping out of water
  137. #define FL_JUMPRELEASED 4096 // for jump debouncing
  138. // entity effects
  139. #define EF_BRIGHTFIELD 1
  140. #define EF_MUZZLEFLASH 2
  141. #define EF_BRIGHTLIGHT 4
  142. #define EF_DIMLIGHT 8
  143. #define SPAWNFLAG_NOT_EASY 256
  144. #define SPAWNFLAG_NOT_MEDIUM 512
  145. #define SPAWNFLAG_NOT_HARD 1024
  146. #define SPAWNFLAG_NOT_DEATHMATCH 2048
  147. //============================================================================
  148. extern struct cvar_s *teamplay;
  149. extern struct cvar_s *skill;
  150. extern struct cvar_s *deathmatch;
  151. extern struct cvar_s *coop;
  152. extern struct cvar_s *fraglimit;
  153. extern struct cvar_s *timelimit;
  154. extern struct cvar_s *sv_maxvelocity;
  155. extern struct cvar_s *sv_gravity;
  156. extern struct cvar_s *sv_nostep;
  157. extern struct cvar_s *sv_friction;
  158. extern struct cvar_s *sv_edgefriction;
  159. extern struct cvar_s *sv_stopspeed;
  160. extern struct cvar_s *sv_maxspeed;
  161. extern struct cvar_s *sv_accelerate;
  162. extern struct cvar_s *sv_idealpitchscale;
  163. extern struct cvar_s *sv_aim;
  164. extern struct cvar_s *sv_friction;
  165. extern struct cvar_s *sv_stopspeed;
  166. extern server_static_t svs; // persistant server info
  167. extern server_t sv; // local server
  168. extern client_t *host_client;
  169. extern jmp_buf host_abortserver;
  170. extern double host_time;
  171. extern edict_t *sv_player;
  172. //===========================================================
  173. void SV_Init (void);
  174. void SV_PR_Cmds_Init (void);
  175. void SV_StartParticle (const vec3_t org, const vec3_t dir, int color,
  176. int count);
  177. void SV_StartSound (edict_t *entity, int channel, const char *sample,
  178. int volume, float attenuation);
  179. void SV_DropClient (qboolean crash);
  180. void SV_SendClientMessages (void);
  181. void SV_ClearDatagram (void);
  182. int SV_ModelIndex (const char *name);
  183. void SV_SetIdealPitch (void);
  184. void SV_AddUpdates (void);
  185. void SV_ClientThink (void);
  186. void SV_AddClientToServer (struct qsocket_s *ret);
  187. void SV_ClientPrintf (const char *fmt, ...) __attribute__((format(printf,1,2)));
  188. void SV_BroadcastPrintf (const char *fmt, ...) __attribute__((format(printf,1,2)));
  189. struct trace_s SV_PushEntity (edict_t *ent, vec3_t push);
  190. int SV_FlyMove (edict_t *ent, float time, struct trace_s *steptrace);
  191. void SV_CheckVelocity (edict_t *ent);
  192. qboolean SV_RunThink (edict_t *ent);
  193. void SV_AddGravity (edict_t *ent);
  194. void SV_Physics_Toss (edict_t *ent);
  195. void SV_Physics_Client (edict_t *ent, int num);
  196. void SV_Physics (void);
  197. qboolean SV_CheckBottom (edict_t *ent);
  198. qboolean SV_movestep (edict_t *ent, const vec3_t move, qboolean relink);
  199. void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg);
  200. void SV_MoveToGoal (progs_t *pr);
  201. void SV_CheckForNewClients (void);
  202. void SV_RunClients (void);
  203. void SV_SaveSpawnparms (void);
  204. void SV_SpawnServer (const char *server);
  205. void SV_LoadProgs (void);
  206. void SV_Progs_Init (void);
  207. void SV_Progs_Init_Cvars (void);
  208. void Cvar_Info (struct cvar_s *var);
  209. #define STOP_EPSILON 0.1
  210. extern struct clip_hull_s *pf_hull_list[];
  211. #endif // __server_h