icculus quake2 doxygen  1.0 dev
sv_game.c File Reference
#include "server.h"

Go to the source code of this file.

Functions

void PF_Unicast (edict_t *ent, qboolean reliable)
 
void PF_dprintf (char *fmt,...)
 
void PF_cprintf (edict_t *ent, int level, char *fmt,...)
 
void PF_centerprintf (edict_t *ent, char *fmt,...)
 
void PF_error (char *fmt,...)
 
void PF_setmodel (edict_t *ent, char *name)
 
void PF_Configstring (int index, char *val)
 
void PF_WriteChar (int c)
 
void PF_WriteByte (int c)
 
void PF_WriteShort (int c)
 
void PF_WriteLong (int c)
 
void PF_WriteFloat (float f)
 
void PF_WriteString (char *s)
 
void PF_WritePos (vec3_t pos)
 
void PF_WriteDir (vec3_t dir)
 
void PF_WriteAngle (float f)
 
qboolean PF_inPVS (vec3_t p1, vec3_t p2)
 
qboolean PF_inPHS (vec3_t p1, vec3_t p2)
 
void PF_StartSound (edict_t *entity, int channel, int sound_num, float volume, float attenuation, float timeofs)
 
void SV_ShutdownGameProgs (void)
 
void SCR_DebugGraph (float value, int color)
 
void SV_InitGameProgs (void)
 

Variables

game_export_tge
 

Function Documentation

◆ PF_centerprintf()

void PF_centerprintf ( edict_t ent,
char *  fmt,
  ... 
)

Definition at line 116 of file sv_game.c.

117 {
118  char msg[1024];
119  va_list argptr;
120  int n;
121 
122  n = NUM_FOR_EDICT(ent);
123  if (n < 1 || n > maxclients->value)
124  return; // Com_Error (ERR_DROP, "centerprintf to a non-client");
125 
126  va_start (argptr,fmt);
127  vsprintf (msg, fmt, argptr);
128  va_end (argptr);
129 
132  PF_Unicast (ent, true);
133 }

Referenced by SV_InitGameProgs().

◆ PF_Configstring()

void PF_Configstring ( int  index,
char *  val 
)

Definition at line 193 of file sv_game.c.

194 {
195  if (index < 0 || index >= MAX_CONFIGSTRINGS)
196  Com_Error (ERR_DROP, "configstring: bad index %i\n", index);
197 
198  if (!val)
199  val = "";
200 
201  // change the string in sv
202  strcpy (sv.configstrings[index], val);
203 
204 
205  if (sv.state != ss_loading)
206  { // send the update to everyone
207  SZ_Clear (&sv.multicast);
209  MSG_WriteShort (&sv.multicast, index);
210  MSG_WriteString (&sv.multicast, val);
211 
213  }
214 }

Referenced by SV_InitGameProgs().

◆ PF_cprintf()

void PF_cprintf ( edict_t ent,
int  level,
char *  fmt,
  ... 
)

Definition at line 84 of file sv_game.c.

85 {
86  char msg[1024];
87  va_list argptr;
88  int n;
89 
90  n = 0;
91  if (ent)
92  {
93  n = NUM_FOR_EDICT(ent);
94  if (n < 1 || n > maxclients->value)
95  Com_Error (ERR_DROP, "cprintf to a non-client");
96  }
97 
98  va_start (argptr,fmt);
99  vsprintf (msg, fmt, argptr);
100  va_end (argptr);
101 
102  if (ent)
103  SV_ClientPrintf (svs.clients+(n-1), level, "%s", msg);
104  else
105  Com_Printf ("%s", msg);
106 }

Referenced by SV_InitGameProgs().

◆ PF_dprintf()

void PF_dprintf ( char *  fmt,
  ... 
)

Definition at line 64 of file sv_game.c.

65 {
66  char msg[1024];
67  va_list argptr;
68 
69  va_start (argptr,fmt);
70  vsprintf (msg, fmt, argptr);
71  va_end (argptr);
72 
73  Com_Printf ("%s", msg);
74 }

Referenced by SV_InitGameProgs().

◆ PF_error()

void PF_error ( char *  fmt,
  ... 
)

Definition at line 143 of file sv_game.c.

144 {
145  char msg[1024];
146  va_list argptr;
147 
148  va_start (argptr,fmt);
149  vsprintf (msg, fmt, argptr);
150  va_end (argptr);
151 
152  Com_Error (ERR_DROP, "Game Error: %s", msg);
153 }

Referenced by SV_InitGameProgs().

◆ PF_inPHS()

qboolean PF_inPHS ( vec3_t  p1,
vec3_t  p2 
)

Definition at line 266 of file sv_game.c.

267 {
268  int leafnum;
269  int cluster;
270  int area1, area2;
271  byte *mask;
272 
273  leafnum = CM_PointLeafnum (p1);
274  cluster = CM_LeafCluster (leafnum);
275  area1 = CM_LeafArea (leafnum);
276  mask = CM_ClusterPHS (cluster);
277 
278  leafnum = CM_PointLeafnum (p2);
279  cluster = CM_LeafCluster (leafnum);
280  area2 = CM_LeafArea (leafnum);
281  if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
282  return false; // more than one bounce away
283  if (!CM_AreasConnected (area1, area2))
284  return false; // a door blocks hearing
285 
286  return true;
287 }

Referenced by SV_InitGameProgs().

◆ PF_inPVS()

qboolean PF_inPVS ( vec3_t  p1,
vec3_t  p2 
)

Definition at line 236 of file sv_game.c.

237 {
238  int leafnum;
239  int cluster;
240  int area1, area2;
241  byte *mask;
242 
243  leafnum = CM_PointLeafnum (p1);
244  cluster = CM_LeafCluster (leafnum);
245  area1 = CM_LeafArea (leafnum);
246  mask = CM_ClusterPVS (cluster);
247 
248  leafnum = CM_PointLeafnum (p2);
249  cluster = CM_LeafCluster (leafnum);
250  area2 = CM_LeafArea (leafnum);
251  if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
252  return false;
253  if (!CM_AreasConnected (area1, area2))
254  return false; // a door blocks sight
255  return true;
256 }

Referenced by SV_InitGameProgs().

◆ PF_setmodel()

void PF_setmodel ( edict_t ent,
char *  name 
)

Definition at line 163 of file sv_game.c.

164 {
165  int i;
166  cmodel_t *mod;
167 
168  if (!name)
169  Com_Error (ERR_DROP, "PF_setmodel: NULL");
170 
171  i = SV_ModelIndex (name);
172 
173 // ent->model = name;
174  ent->s.modelindex = i;
175 
176 // if it is an inline model, get the size information for it
177  if (name[0] == '*')
178  {
179  mod = CM_InlineModel (name);
180  VectorCopy (mod->mins, ent->mins);
181  VectorCopy (mod->maxs, ent->maxs);
182  SV_LinkEdict (ent);
183  }
184 
185 }

Referenced by SV_InitGameProgs().

◆ PF_StartSound()

void PF_StartSound ( edict_t entity,
int  channel,
int  sound_num,
float  volume,
float  attenuation,
float  timeofs 
)

Definition at line 289 of file sv_game.c.

291 {
292  if (!entity)
293  return;
294  SV_StartSound (NULL, entity, channel, sound_num, volume, attenuation, timeofs);
295 }

Referenced by SV_InitGameProgs().

◆ PF_Unicast()

void PF_Unicast ( edict_t ent,
qboolean  reliable 
)

Definition at line 34 of file sv_game.c.

35 {
36  int p;
37  client_t *client;
38 
39  if (!ent)
40  return;
41 
42  p = NUM_FOR_EDICT(ent);
43  if (p < 1 || p > maxclients->value)
44  return;
45 
46  client = svs.clients + (p-1);
47 
48  if (reliable)
50  else
52 
54 }

Referenced by PF_centerprintf(), and SV_InitGameProgs().

◆ PF_WriteAngle()

void PF_WriteAngle ( float  f)

Definition at line 226 of file sv_game.c.

226 {MSG_WriteAngle (&sv.multicast, f);}

Referenced by SV_InitGameProgs().

◆ PF_WriteByte()

void PF_WriteByte ( int  c)

Definition at line 219 of file sv_game.c.

219 {MSG_WriteByte (&sv.multicast, c);}

Referenced by SV_InitGameProgs().

◆ PF_WriteChar()

void PF_WriteChar ( int  c)

Definition at line 218 of file sv_game.c.

218 {MSG_WriteChar (&sv.multicast, c);}

Referenced by SV_InitGameProgs().

◆ PF_WriteDir()

void PF_WriteDir ( vec3_t  dir)

Definition at line 225 of file sv_game.c.

225 {MSG_WriteDir (&sv.multicast, dir);}

Referenced by SV_InitGameProgs().

◆ PF_WriteFloat()

void PF_WriteFloat ( float  f)

Definition at line 222 of file sv_game.c.

222 {MSG_WriteFloat (&sv.multicast, f);}

Referenced by SV_InitGameProgs().

◆ PF_WriteLong()

void PF_WriteLong ( int  c)

Definition at line 221 of file sv_game.c.

221 {MSG_WriteLong (&sv.multicast, c);}

Referenced by SV_InitGameProgs().

◆ PF_WritePos()

void PF_WritePos ( vec3_t  pos)

Definition at line 224 of file sv_game.c.

224 {MSG_WritePos (&sv.multicast, pos);}

Referenced by SV_InitGameProgs().

◆ PF_WriteShort()

void PF_WriteShort ( int  c)

Definition at line 220 of file sv_game.c.

220 {MSG_WriteShort (&sv.multicast, c);}

Referenced by SV_InitGameProgs().

◆ PF_WriteString()

void PF_WriteString ( char *  s)

Definition at line 223 of file sv_game.c.

Referenced by SV_InitGameProgs().

◆ SCR_DebugGraph()

void SCR_DebugGraph ( float  value,
int  color 
)

Definition at line 139 of file cl_scrn.c.

140 {
141  values[current&1023].value = value;
142  values[current&1023].color = color;
143  current++;
144 }

Referenced by CL_AddNetgraph(), SCR_UpdateScreen(), and SV_InitGameProgs().

◆ SV_InitGameProgs()

void SV_InitGameProgs ( void  )

Definition at line 325 of file sv_game.c.

326 {
327  game_import_t import;
328 
329  // unload anything we have now
330  if (ge)
332 
333 
334  // load a new game dll
335  import.multicast = SV_Multicast;
336  import.unicast = PF_Unicast;
337  import.bprintf = SV_BroadcastPrintf;
338  import.dprintf = PF_dprintf;
339  import.cprintf = PF_cprintf;
340  import.centerprintf = PF_centerprintf;
341  import.error = PF_error;
342 
343  import.linkentity = SV_LinkEdict;
344  import.unlinkentity = SV_UnlinkEdict;
345  import.BoxEdicts = SV_AreaEdicts;
346  import.trace = SV_Trace;
347  import.pointcontents = SV_PointContents;
348  import.setmodel = PF_setmodel;
349  import.inPVS = PF_inPVS;
350  import.inPHS = PF_inPHS;
351  import.Pmove = Pmove;
352 
353  import.modelindex = SV_ModelIndex;
354  import.soundindex = SV_SoundIndex;
355  import.imageindex = SV_ImageIndex;
356 
357  import.configstring = PF_Configstring;
358  import.sound = PF_StartSound;
359  import.positioned_sound = SV_StartSound;
360 
361  import.WriteChar = PF_WriteChar;
362  import.WriteByte = PF_WriteByte;
363  import.WriteShort = PF_WriteShort;
364  import.WriteLong = PF_WriteLong;
365  import.WriteFloat = PF_WriteFloat;
366  import.WriteString = PF_WriteString;
367  import.WritePosition = PF_WritePos;
368  import.WriteDir = PF_WriteDir;
369  import.WriteAngle = PF_WriteAngle;
370 
371  import.TagMalloc = Z_TagMalloc;
372  import.TagFree = Z_Free;
373  import.FreeTags = Z_FreeTags;
374 
375  import.cvar = Cvar_Get;
376  import.cvar_set = Cvar_Set;
377  import.cvar_forceset = Cvar_ForceSet;
378 
379  import.argc = Cmd_Argc;
380  import.argv = Cmd_Argv;
381  import.args = Cmd_Args;
382  import.AddCommandString = Cbuf_AddText;
383 
384  import.DebugGraph = SCR_DebugGraph;
385  import.SetAreaPortalState = CM_SetAreaPortalState;
386  import.AreasConnected = CM_AreasConnected;
387 
388  ge = (game_export_t *)Sys_GetGameAPI (&import);
389 
390  if (!ge)
391  Com_Error (ERR_DROP, "failed to load game DLL");
393  Com_Error (ERR_DROP, "game is version %i, not %i", ge->apiversion,
395 
396  ge->Init ();
397 }

Referenced by SV_InitGame().

◆ SV_ShutdownGameProgs()

void SV_ShutdownGameProgs ( void  )

Definition at line 307 of file sv_game.c.

308 {
309  if (!ge)
310  return;
311  ge->Shutdown ();
312  Sys_UnloadGame ();
313  ge = NULL;
314 }

Referenced by SV_InitGameProgs(), and SV_Shutdown().

Variable Documentation

◆ ge

game_import_t
Definition: game.h:102
sv
server_t sv
Definition: sv_init.c:24
edict_s::s
entity_state_t s
Definition: g_local.h:964
value
GLfloat value
Definition: qgl_win.c:63
svc_centerprint
@ svc_centerprint
Definition: qcommon.h:224
client_s::datagram
sizebuf_t datagram
Definition: server.h:120
GAME_API_VERSION
#define GAME_API_VERSION
Definition: game.h:23
Z_TagMalloc
void * Z_TagMalloc(int size, int tag)
Definition: common.c:1194
PF_WritePos
void PF_WritePos(vec3_t pos)
Definition: sv_game.c:224
cmodel_s::maxs
vec3_t maxs
Definition: q_shared.h:430
maxclients
cvar_t * maxclients
Definition: g_main.c:44
PF_setmodel
void PF_setmodel(edict_t *ent, char *name)
Definition: sv_game.c:163
PF_WriteByte
void PF_WriteByte(int c)
Definition: sv_game.c:219
SV_LinkEdict
void SV_LinkEdict(edict_t *ent)
Definition: sv_world.c:165
netchan_t::message
sizebuf_t message
Definition: qcommon.h:600
game_export_t::Shutdown
void(* Shutdown)(void)
Definition: game.h:189
PF_WriteDir
void PF_WriteDir(vec3_t dir)
Definition: sv_game.c:225
game_export_t::apiversion
int apiversion
Definition: game.h:183
i
int i
Definition: q_shared.c:305
server_t::multicast
sizebuf_t multicast
Definition: server.h:61
game_export_t::Init
void(* Init)(void)
Definition: game.h:188
MSG_WriteLong
void MSG_WriteLong(sizebuf_t *sb, int c)
Definition: common.c:349
SV_BroadcastPrintf
void SV_BroadcastPrintf(int level, char *fmt,...)
Definition: sv_send.c:89
PF_WriteChar
void PF_WriteChar(int c)
Definition: sv_game.c:218
SV_ShutdownGameProgs
void SV_ShutdownGameProgs(void)
Definition: sv_game.c:307
edict_s::mins
vec3_t mins
Definition: g_local.h:984
Sys_UnloadGame
void Sys_UnloadGame(void)
Definition: sys_win.c:458
Cmd_Args
char * Cmd_Args(void)
Definition: cmd.c:531
PF_inPVS
qboolean PF_inPVS(vec3_t p1, vec3_t p2)
Definition: sv_game.c:236
sizebuf_s::data
byte * data
Definition: qcommon.h:79
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
SZ_Write
void SZ_Write(sizebuf_t *buf, void *data, int length)
Definition: common.c:940
SZ_Clear
void SZ_Clear(sizebuf_t *buf)
Definition: common.c:911
PF_WriteLong
void PF_WriteLong(int c)
Definition: sv_game.c:221
CM_LeafArea
int CM_LeafArea(int leafnum)
Definition: cmodel.c:681
PF_dprintf
void PF_dprintf(char *fmt,...)
Definition: sv_game.c:64
Cmd_Argv
char * Cmd_Argv(int arg)
Definition: cmd.c:517
msg
cvar_t * msg
Definition: cl_main.c:98
Cmd_Argc
int Cmd_Argc(void)
Definition: cmd.c:507
Cvar_ForceSet
cvar_t * Cvar_ForceSet(char *var_name, char *value)
Definition: cvar.c:268
server_static_t::clients
client_t * clients
Definition: server.h:168
client_s::netchan
netchan_t netchan
Definition: server.h:134
SV_AreaEdicts
int SV_AreaEdicts(vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype)
Definition: sv_world.c:408
CM_ClusterPVS
byte * CM_ClusterPVS(int cluster)
Definition: cmodel.c:1575
CM_AreasConnected
qboolean CM_AreasConnected(int area1, int area2)
Definition: cmodel.c:1662
SV_UnlinkEdict
void SV_UnlinkEdict(edict_t *ent)
Definition: sv_world.c:149
PF_Unicast
void PF_Unicast(edict_t *ent, qboolean reliable)
Definition: sv_game.c:34
NUM_FOR_EDICT
#define NUM_FOR_EDICT(e)
Definition: server.h:70
MSG_WriteDir
void MSG_WriteDir(sizebuf_t *sb, vec3_t dir)
Definition: common.c:457
SV_StartSound
void SV_StartSound(vec3_t origin, edict_t *entity, int channel, int soundindex, float volume, float attenuation, float timeofs)
Definition: sv_send.c:272
PF_centerprintf
void PF_centerprintf(edict_t *ent, char *fmt,...)
Definition: sv_game.c:116
SV_Trace
trace_t SV_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passedict, int contentmask)
Definition: sv_world.c:624
MULTICAST_ALL_R
@ MULTICAST_ALL_R
Definition: q_shared.h:112
Cbuf_AddText
void Cbuf_AddText(char *text)
Definition: cmd.c:90
cvar_s::value
float value
Definition: q_shared.h:324
cmodel_s::mins
vec3_t mins
Definition: q_shared.h:430
MSG_WritePos
void MSG_WritePos(sizebuf_t *sb, vec3_t pos)
Definition: common.c:388
MSG_WriteString
void MSG_WriteString(sizebuf_t *sb, char *s)
Definition: common.c:375
NULL
#define NULL
Definition: q_shared.h:60
MSG_WriteShort
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition: common.c:335
graphsamp_t::color
int color
Definition: cl_scrn.c:128
MSG_WriteByte
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition: common.c:322
Com_Error
void Com_Error(int code, char *fmt,...)
Definition: common.c:203
cmodel_s
Definition: q_shared.h:428
current
static int current
Definition: cl_scrn.c:131
PF_error
void PF_error(char *fmt,...)
Definition: sv_game.c:143
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:736
CM_InlineModel
cmodel_t * CM_InlineModel(char *name)
Definition: cmodel.c:639
svs
server_static_t svs
Definition: sv_init.c:23
MSG_WriteChar
void MSG_WriteChar(sizebuf_t *sb, int c)
Definition: common.c:309
MAX_CONFIGSTRINGS
#define MAX_CONFIGSTRINGS
Definition: q_shared.h:1143
SV_Multicast
void SV_Multicast(vec3_t origin, multicast_t to)
Definition: sv_send.c:161
name
cvar_t * name
Definition: cl_main.c:94
PF_WriteFloat
void PF_WriteFloat(float f)
Definition: sv_game.c:222
graphsamp_t::value
float value
Definition: cl_scrn.c:127
SV_ClientPrintf
void SV_ClientPrintf(client_t *cl, int level, char *fmt,...)
Definition: sv_send.c:65
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:158
game_export_t
Definition: game.h:181
CM_ClusterPHS
byte * CM_ClusterPHS(int cluster)
Definition: cmodel.c:1584
ge
game_export_t * ge
Definition: sv_game.c:24
vec3_origin
vec3_t vec3_origin
Definition: q_shared.c:24
Z_Free
void Z_Free(void *ptr)
Definition: common.c:1141
MSG_WriteAngle
void MSG_WriteAngle(sizebuf_t *sb, float f)
Definition: common.c:395
SV_PointContents
int SV_PointContents(vec3_t p)
Definition: sv_world.c:431
level
GLint level
Definition: qgl_win.c:116
svc_configstring
@ svc_configstring
Definition: qcommon.h:222
PF_inPHS
qboolean PF_inPHS(vec3_t p1, vec3_t p2)
Definition: sv_game.c:266
CM_LeafCluster
int CM_LeafCluster(int leafnum)
Definition: cmodel.c:674
SV_SoundIndex
int SV_SoundIndex(char *name)
Definition: sv_init.c:69
edict_s::maxs
vec3_t maxs
Definition: g_local.h:984
entity_state_s::modelindex
int modelindex
Definition: q_shared.h:1176
server_t::state
server_state_t state
Definition: server.h:45
sizebuf_s::cursize
int cursize
Definition: qcommon.h:81
SV_ImageIndex
int SV_ImageIndex(char *name)
Definition: sv_init.c:74
Cvar_Set
cvar_t * Cvar_Set(char *var_name, char *value)
Definition: cvar.c:278
Pmove
void Pmove(pmove_t *pmove)
Definition: pmove.c:1240
client_s
Definition: server.h:95
values
static graphsamp_t values[1024]
Definition: cl_scrn.c:132
SCR_DebugGraph
void SCR_DebugGraph(float value, int color)
Definition: cl_scrn.c:139
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:102
MSG_WriteFloat
void MSG_WriteFloat(sizebuf_t *sb, float f)
Definition: common.c:360
server_t::configstrings
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
Definition: server.h:56
mask
GLint GLuint mask
Definition: qgl_win.c:317
CM_SetAreaPortalState
void CM_SetAreaPortalState(int portalnum, qboolean open)
Definition: cmodel.c:1653
PF_cprintf
void PF_cprintf(edict_t *ent, int level, char *fmt,...)
Definition: sv_game.c:84
ss_loading
@ ss_loading
Definition: server.h:34
PF_WriteAngle
void PF_WriteAngle(float f)
Definition: sv_game.c:226
SV_ModelIndex
int SV_ModelIndex(char *name)
Definition: sv_init.c:64
Sys_GetGameAPI
void * Sys_GetGameAPI(void *parms)
Definition: sys_win.c:472
CM_PointLeafnum
int CM_PointLeafnum(vec3_t p)
Definition: cmodel.c:826
PF_WriteShort
void PF_WriteShort(int c)
Definition: sv_game.c:220
PF_StartSound
void PF_StartSound(edict_t *entity, int channel, int sound_num, float volume, float attenuation, float timeofs)
Definition: sv_game.c:289
PF_Configstring
void PF_Configstring(int index, char *val)
Definition: sv_game.c:193
PF_WriteString
void PF_WriteString(char *s)
Definition: sv_game.c:223
Z_FreeTags
void Z_FreeTags(int tag)
Definition: common.c:1177