vkQuake2 doxygen  1.0 dev
server.h File Reference
#include "../qcommon/qcommon.h"
#include "../game/game.h"

Go to the source code of this file.

Classes

struct  server_t
 
struct  client_frame_t
 
struct  client_s
 
struct  challenge_t
 
struct  server_static_t
 

Macros

#define MAX_MASTERS   8
 
#define EDICT_NUM(n)   ((edict_t *)((byte *)ge->edicts + ge->edict_size*(n)))
 
#define NUM_FOR_EDICT(e)   ( ((byte *)(e)-(byte *)ge->edicts ) / ge->edict_size)
 
#define LATENCY_COUNTS   16
 
#define RATE_MESSAGES   10
 
#define MAX_CHALLENGES   1024
 
#define SV_OUTPUTBUF_LENGTH   (MAX_MSGLEN - 16)
 

Typedefs

typedef struct client_s client_t
 

Enumerations

enum  server_state_t {
  ss_dead, ss_loading, ss_game, ss_cinematic,
  ss_demo, ss_pic
}
 
enum  client_state_t { cs_free, cs_zombie, cs_connected, cs_spawned }
 
enum  redirect_t { RD_NONE, RD_CLIENT, RD_PACKET }
 

Functions

void SV_FinalMessage (char *message, qboolean reconnect)
 
void SV_DropClient (client_t *drop)
 
int SV_ModelIndex (char *name)
 
int SV_SoundIndex (char *name)
 
int SV_ImageIndex (char *name)
 
void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg)
 
void SV_ExecuteUserCommand (char *s)
 
void SV_InitOperatorCommands (void)
 
void SV_SendServerinfo (client_t *client)
 
void SV_UserinfoChanged (client_t *cl)
 
void Master_Heartbeat (void)
 
void Master_Packet (void)
 
void SV_InitGame (void)
 
void SV_Map (qboolean attractloop, char *levelstring, qboolean loadgame)
 
void SV_PrepWorldFrame (void)
 
void SV_FlushRedirect (int sv_redirected, char *outputbuf)
 
void SV_DemoCompleted (void)
 
void SV_SendClientMessages (void)
 
void SV_Multicast (vec3_t origin, multicast_t to)
 
void SV_StartSound (vec3_t origin, edict_t *entity, int channel, int soundindex, float volume, float attenuation, float timeofs)
 
void SV_ClientPrintf (client_t *cl, int level, char *fmt,...)
 
void SV_BroadcastPrintf (int level, char *fmt,...)
 
void SV_BroadcastCommand (char *fmt,...)
 
void SV_Nextserver (void)
 
void SV_ExecuteClientMessage (client_t *cl)
 
void SV_ReadLevelFile (void)
 
void SV_Status_f (void)
 
void SV_WriteFrameToClient (client_t *client, sizebuf_t *msg)
 
void SV_RecordDemoMessage (void)
 
void SV_BuildClientFrame (client_t *client)
 
void SV_Error (char *error,...)
 
void SV_InitGameProgs (void)
 
void SV_ShutdownGameProgs (void)
 
void SV_InitEdict (edict_t *e)
 
void SV_ClearWorld (void)
 
void SV_UnlinkEdict (edict_t *ent)
 
void SV_LinkEdict (edict_t *ent)
 
int SV_AreaEdicts (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype)
 
int SV_PointContents (vec3_t p)
 
trace_t SV_Trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passedict, int contentmask)
 

Variables

netadr_t net_from
 
sizebuf_t net_message
 
netadr_t master_adr [MAX_MASTERS]
 
server_static_t svs
 
server_t sv
 
cvar_tsv_paused
 
cvar_tmaxclients
 
cvar_tsv_noreload
 
cvar_tsv_airaccelerate
 
cvar_tsv_enforcetime
 
client_tsv_client
 
edict_tsv_player
 
char sv_outputbuf [SV_OUTPUTBUF_LENGTH]
 
game_export_tge
 

Macro Definition Documentation

◆ EDICT_NUM

#define EDICT_NUM (   n)    ((edict_t *)((byte *)ge->edicts + ge->edict_size*(n)))

Definition at line 69 of file server.h.

◆ LATENCY_COUNTS

#define LATENCY_COUNTS   16

Definition at line 92 of file server.h.

◆ MAX_CHALLENGES

#define MAX_CHALLENGES   1024

Definition at line 148 of file server.h.

◆ MAX_MASTERS

#define MAX_MASTERS   8

Definition at line 30 of file server.h.

◆ NUM_FOR_EDICT

#define NUM_FOR_EDICT (   e)    ( ((byte *)(e)-(byte *)ge->edicts ) / ge->edict_size)

Definition at line 70 of file server.h.

◆ RATE_MESSAGES

#define RATE_MESSAGES   10

Definition at line 93 of file server.h.

◆ SV_OUTPUTBUF_LENGTH

#define SV_OUTPUTBUF_LENGTH   (MAX_MSGLEN - 16)

Definition at line 243 of file server.h.

Typedef Documentation

◆ client_t

typedef struct client_s client_t

Enumeration Type Documentation

◆ client_state_t

Enumerator
cs_free 
cs_zombie 
cs_connected 
cs_spawned 

Definition at line 73 of file server.h.

74 {
75  cs_free, // can be reused for a new connection
76  cs_zombie, // client has been disconnected, but don't reuse
77  // connection for a couple seconds
78  cs_connected, // has been assigned to a client_t, but not in game yet
79  cs_spawned // client is fully in game

◆ redirect_t

enum redirect_t
Enumerator
RD_NONE 
RD_CLIENT 
RD_PACKET 

Definition at line 242 of file server.h.

◆ server_state_t

Enumerator
ss_dead 
ss_loading 
ss_game 
ss_cinematic 
ss_demo 
ss_pic 

Definition at line 32 of file server.h.

32  {
33  ss_dead, // no map loaded
34  ss_loading, // spawning level edicts
35  ss_game, // actively running
37  ss_demo,
38  ss_pic

Function Documentation

◆ Master_Heartbeat()

void Master_Heartbeat ( void  )

Definition at line 827 of file sv_main.c.

828 {
829  char *string;
830  int i;
831 
832  // pgm post3.19 change, cvar pointer not validated before dereferencing
833  if (!dedicated || !dedicated->value)
834  return; // only dedicated servers send heartbeats
835 
836  // pgm post3.19 change, cvar pointer not validated before dereferencing
838  return; // a private dedicated game
839 
840  // check for time wraparound
843 
845  return; // not time to send yet
846 
848 
849  // send the same string that we would give for a status OOB command
850  string = SV_StatusString();
851 
852  // send to group master
853  for (i=0 ; i<MAX_MASTERS ; i++)
854  if (master_adr[i].port)
855  {
856  Com_Printf ("Sending heartbeat to %s\n", NET_AdrToString (master_adr[i]));
857  Netchan_OutOfBandPrint (NS_SERVER, master_adr[i], "heartbeat\n%s", string);
858  }
859 }

Referenced by SV_Frame().

◆ Master_Packet()

void Master_Packet ( void  )

◆ SV_AreaEdicts()

int SV_AreaEdicts ( vec3_t  mins,
vec3_t  maxs,
edict_t **  list,
int  maxcount,
int  areatype 
)

Definition at line 409 of file sv_world.c.

411 {
412  area_mins = mins;
413  area_maxs = maxs;
414  area_list = list;
415  area_count = 0;
416  area_maxcount = maxcount;
417  area_type = areatype;
418 
420 
421  return area_count;
422 }

Referenced by SV_ClipMoveToEntities(), SV_InitGameProgs(), and SV_PointContents().

◆ SV_BroadcastCommand()

void SV_BroadcastCommand ( char *  fmt,
  ... 
)

Definition at line 132 of file sv_send.c.

133 {
134  va_list argptr;
135  char string[1024];
136 
137  if (!sv.state)
138  return;
139  va_start (argptr,fmt);
140  vsnprintf (string,1024,fmt,argptr);
141  va_end (argptr);
142 
144  MSG_WriteString (&sv.multicast, string);
146 }

Referenced by SV_Map().

◆ SV_BroadcastPrintf()

void SV_BroadcastPrintf ( int  level,
char *  fmt,
  ... 
)

Definition at line 89 of file sv_send.c.

90 {
91  va_list argptr;
92  char string[2048];
93  client_t *cl;
94  int i;
95 
96  va_start (argptr,fmt);
97  vsnprintf (string,2048,fmt,argptr);
98  va_end (argptr);
99 
100  // echo to console
101  if (dedicated->value)
102  {
103  char copy[1024];
104  int i;
105 
106  // mask off high bits
107  for (i=0 ; i<1023 && string[i] ; i++)
108  copy[i] = string[i]&127;
109  copy[i] = 0;
110  Com_Printf ("%s", copy);
111  }
112 
113  for (i=0, cl = svs.clients ; i<maxclients->value; i++, cl++)
114  {
115  if (level < cl->messagelevel)
116  continue;
117  if (cl->state != cs_spawned)
118  continue;
119  MSG_WriteByte (&cl->netchan.message, svc_print);
120  MSG_WriteByte (&cl->netchan.message, level);
121  MSG_WriteString (&cl->netchan.message, string);
122  }
123 }

Referenced by SV_CheckTimeouts(), SV_InitGameProgs(), SV_Kick_f(), and SV_SendClientMessages().

◆ SV_BuildClientFrame()

void SV_BuildClientFrame ( client_t client)

Definition at line 522 of file sv_ents.c.

523 {
524  int e, i;
525  vec3_t org;
526  edict_t *ent;
527  edict_t *clent;
528  client_frame_t *frame;
529  entity_state_t *state;
530  int l;
531  int clientarea, clientcluster;
532  int leafnum;
533  int c_fullsend;
534  byte *clientphs;
535  byte *bitvector;
536 
537  clent = client->edict;
538  if (!clent->client)
539  return; // not in game yet
540 
541 #if 0
542  numprojs = 0; // no projectiles yet
543 #endif
544 
545  // this is the frame we are creating
546  frame = &client->frames[sv.framenum & UPDATE_MASK];
547 
548  frame->senttime = svs.realtime; // save it for ping calc later
549 
550  // find the client's PVS
551  for (i=0 ; i<3 ; i++)
552  org[i] = clent->client->ps.pmove.origin[i]*0.125 + clent->client->ps.viewoffset[i];
553 
554  leafnum = CM_PointLeafnum (org);
555  clientarea = CM_LeafArea (leafnum);
556  clientcluster = CM_LeafCluster (leafnum);
557 
558  // calculate the visible areas
559  frame->areabytes = CM_WriteAreaBits (frame->areabits, clientarea);
560 
561  // grab the current player_state_t
562  frame->ps = clent->client->ps;
563 
564 
565  SV_FatPVS (org);
566  clientphs = CM_ClusterPHS (clientcluster);
567 
568  // build up the list of visible entities
569  frame->num_entities = 0;
571 
572  c_fullsend = 0;
573 
574  for (e=1 ; e<ge->num_edicts ; e++)
575  {
576  ent = EDICT_NUM(e);
577 
578  // ignore ents without visible models
579  if (ent->svflags & SVF_NOCLIENT)
580  continue;
581 
582  // ignore ents without visible models unless they have an effect
583  if (!ent->s.modelindex && !ent->s.effects && !ent->s.sound
584  && !ent->s.event)
585  continue;
586 
587  // ignore if not touching a PV leaf
588  if (ent != clent)
589  {
590  // check area
591  if (!CM_AreasConnected (clientarea, ent->areanum))
592  { // doors can legally straddle two areas, so
593  // we may need to check another one
594  if (!ent->areanum2
595  || !CM_AreasConnected (clientarea, ent->areanum2))
596  continue; // blocked by a door
597  }
598 
599  // beams just check one point for PHS
600  if (ent->s.renderfx & RF_BEAM)
601  {
602  l = ent->clusternums[0];
603  if ( !(clientphs[l >> 3] & (1 << (l&7) )) )
604  continue;
605  }
606  else
607  {
608  // FIXME: if an ent has a model and a sound, but isn't
609  // in the PVS, only the PHS, clear the model
610  if (ent->s.sound)
611  {
612  bitvector = fatpvs; //clientphs;
613  }
614  else
615  bitvector = fatpvs;
616 
617  if (ent->num_clusters == -1)
618  { // too many leafs for individual check, go by headnode
619  if (!CM_HeadnodeVisible (ent->headnode, bitvector))
620  continue;
621  c_fullsend++;
622  }
623  else
624  { // check individual leafs
625  for (i=0 ; i < ent->num_clusters ; i++)
626  {
627  l = ent->clusternums[i];
628  if (bitvector[l >> 3] & (1 << (l&7) ))
629  break;
630  }
631  if (i == ent->num_clusters)
632  continue; // not visible
633  }
634 
635  if (!ent->s.modelindex)
636  { // don't send sounds if they will be attenuated away
637  vec3_t delta;
638  float len;
639 
640  VectorSubtract (org, ent->s.origin, delta);
641  len = VectorLength (delta);
642  if (len > 400)
643  continue;
644  }
645  }
646  }
647 
648 #if 0
649  if (SV_AddProjectileUpdate(ent))
650  continue; // added as a special projectile
651 #endif
652 
653  // add it to the circular client_entities array
655  if (ent->s.number != e)
656  {
657  Com_DPrintf ("FIXING ENT->S.NUMBER!!!\n");
658  ent->s.number = e;
659  }
660  *state = ent->s;
661 
662  // don't mark players missiles as solid
663  if (ent->owner == client->edict)
664  state->solid = 0;
665 
667  frame->num_entities++;
668  }
669 }

Referenced by SV_SendClientDatagram().

◆ SV_ClearWorld()

void SV_ClearWorld ( void  )

Definition at line 136 of file sv_world.c.

137 {
138  memset (sv_areanodes, 0, sizeof(sv_areanodes));
139  sv_numareanodes = 0;
140  SV_CreateAreaNode (0, sv.models[1]->mins, sv.models[1]->maxs);
141 }

Referenced by SV_CheckForSavegame(), and SV_SpawnServer().

◆ SV_ClientPrintf()

void SV_ClientPrintf ( client_t cl,
int  level,
char *  fmt,
  ... 
)

Definition at line 65 of file sv_send.c.

66 {
67  va_list argptr;
68  char string[1024];
69 
70  if (level < cl->messagelevel)
71  return;
72 
73  va_start (argptr,fmt);
74  vsnprintf (string,1024,fmt,argptr);
75  va_end (argptr);
76 
77  MSG_WriteByte (&cl->netchan.message, svc_print);
78  MSG_WriteByte (&cl->netchan.message, level);
79  MSG_WriteString (&cl->netchan.message, string);
80 }

Referenced by PF_cprintf(), SV_ConSay_f(), and SV_Kick_f().

◆ SV_DemoCompleted()

void SV_DemoCompleted ( void  )

Definition at line 440 of file sv_send.c.

441 {
442  if (sv.demofile)
443  {
444  fclose (sv.demofile);
445  sv.demofile = NULL;
446  }
447  SV_Nextserver ();
448 }

Referenced by SV_SendClientMessages().

◆ SV_DropClient()

void SV_DropClient ( client_t drop)

Definition at line 70 of file sv_main.c.

71 {
72  // add the disconnect
74 
75  if (drop->state == cs_spawned)
76  {
77  // call the prog function for removing a client
78  // this will remove the body, among other things
79  ge->ClientDisconnect (drop->edict);
80  }
81 
82  if (drop->download)
83  {
84  FS_FreeFile (drop->download);
85  drop->download = NULL;
86  }
87 
88  drop->state = cs_zombie; // become free in a few seconds
89  drop->name[0] = 0;
90 }

Referenced by SV_CheckTimeouts(), SV_Disconnect_f(), SV_ExecuteClientMessage(), SV_Kick_f(), and SV_SendClientMessages().

◆ SV_Error()

void SV_Error ( char *  error,
  ... 
)

◆ SV_ExecuteClientMessage()

void SV_ExecuteClientMessage ( client_t cl)

Definition at line 533 of file sv_user.c.

534 {
535  int c;
536  char *s;
537 
538  usercmd_t nullcmd;
539  usercmd_t oldest, oldcmd, newcmd;
540  int net_drop;
541  int stringCmdCount;
542  int checksum, calculatedChecksum;
543  int checksumIndex;
544  qboolean move_issued;
545  int lastframe;
546 
547  sv_client = cl;
549 
550  // only allow one move command
551  move_issued = false;
552  stringCmdCount = 0;
553 
554  while (1)
555  {
557  {
558  Com_Printf ("SV_ReadClientMessage: badread\n");
559  SV_DropClient (cl);
560  return;
561  }
562 
563  c = MSG_ReadByte (&net_message);
564  if (c == -1)
565  break;
566 
567  switch (c)
568  {
569  default:
570  Com_Printf ("SV_ReadClientMessage: unknown command char\n");
571  SV_DropClient (cl);
572  return;
573 
574  case clc_nop:
575  break;
576 
577  case clc_userinfo:
578  strncpy (cl->userinfo, MSG_ReadString (&net_message), sizeof(cl->userinfo)-1);
580  break;
581 
582  case clc_move:
583  if (move_issued)
584  return; // someone is trying to cheat...
585 
586  move_issued = true;
587  checksumIndex = net_message.readcount;
588  checksum = MSG_ReadByte (&net_message);
589  lastframe = MSG_ReadLong (&net_message);
590  if (lastframe != cl->lastframe) {
591  cl->lastframe = lastframe;
592  if (cl->lastframe > 0) {
593  cl->frame_latency[cl->lastframe&(LATENCY_COUNTS-1)] =
594  svs.realtime - cl->frames[cl->lastframe & UPDATE_MASK].senttime;
595  }
596  }
597 
598  memset (&nullcmd, 0, sizeof(nullcmd));
599  MSG_ReadDeltaUsercmd (&net_message, &nullcmd, &oldest);
600  MSG_ReadDeltaUsercmd (&net_message, &oldest, &oldcmd);
601  MSG_ReadDeltaUsercmd (&net_message, &oldcmd, &newcmd);
602 
603  if ( cl->state != cs_spawned )
604  {
605  cl->lastframe = -1;
606  break;
607  }
608 
609  // if the checksum fails, ignore the rest of the packet
610  calculatedChecksum = COM_BlockSequenceCRCByte (
611  net_message.data + checksumIndex + 1,
612  net_message.readcount - checksumIndex - 1,
613  cl->netchan.incoming_sequence);
614 
615  if (calculatedChecksum != checksum)
616  {
617  Com_DPrintf ("Failed command checksum for %s (%d != %d)/%d\n",
618  cl->name, calculatedChecksum, checksum,
619  cl->netchan.incoming_sequence);
620  return;
621  }
622 
623  if (!sv_paused->value)
624  {
625  net_drop = cl->netchan.dropped;
626  if (net_drop < 20)
627  {
628 
629 //if (net_drop > 2)
630 
631 // Com_Printf ("drop %i\n", net_drop);
632  while (net_drop > 2)
633  {
634  SV_ClientThink (cl, &cl->lastcmd);
635 
636  net_drop--;
637  }
638  if (net_drop > 1)
639  SV_ClientThink (cl, &oldest);
640 
641  if (net_drop > 0)
642  SV_ClientThink (cl, &oldcmd);
643 
644  }
645  SV_ClientThink (cl, &newcmd);
646  }
647 
648  cl->lastcmd = newcmd;
649  break;
650 
651  case clc_stringcmd:
653 
654  // malicious users may try using too many string commands
655  if (++stringCmdCount < MAX_STRINGCMDS)
657 
658  if (cl->state == cs_zombie)
659  return; // disconnect command
660  break;
661  }
662  }
663 }

Referenced by SV_ReadPackets().

◆ SV_ExecuteUserCommand()

void SV_ExecuteUserCommand ( char *  s)

Definition at line 477 of file sv_user.c.

478 {
479  ucmd_t *u;
480 
481  Cmd_TokenizeString (s, true);
483 
484 // SV_BeginRedirect (RD_CLIENT);
485 
486  for (u=ucmds ; u->name ; u++)
487  if (!strcmp (Cmd_Argv(0), u->name) )
488  {
489  u->func ();
490  break;
491  }
492 
493  if (!u->name && sv.state == ss_game)
495 
496 // SV_EndRedirect ();
497 }

Referenced by SV_ExecuteClientMessage().

◆ SV_FinalMessage()

void SV_FinalMessage ( char *  message,
qboolean  reconnect 
)

Definition at line 996 of file sv_main.c.

997 {
998  int i;
999  client_t *cl;
1000 
1001  SZ_Clear (&net_message);
1004  MSG_WriteString (&net_message, message);
1005 
1006  if (reconnect)
1008  else
1010 
1011  // send it twice
1012  // stagger the packets to crutch operating system limited buffers
1013 
1014  for (i=0, cl = svs.clients ; i<maxclients->value ; i++, cl++)
1015  if (cl->state >= cs_connected)
1017  , net_message.data);
1018 
1019  for (i=0, cl = svs.clients ; i<maxclients->value ; i++, cl++)
1020  if (cl->state >= cs_connected)
1022  , net_message.data);
1023 }

Referenced by SV_Shutdown().

◆ SV_FlushRedirect()

void SV_FlushRedirect ( int  sv_redirected,
char *  outputbuf 
)

Definition at line 34 of file sv_send.c.

35 {
36  if (sv_redirected == RD_PACKET)
37  {
38  Netchan_OutOfBandPrint (NS_SERVER, net_from, "print\n%s", outputbuf);
39  }
40  else if (sv_redirected == RD_CLIENT)
41  {
45  }
46 }

Referenced by SVC_RemoteCommand(), and SVC_Status().

◆ SV_ImageIndex()

int SV_ImageIndex ( char *  name)

Definition at line 74 of file sv_init.c.

75 {
76  return SV_FindIndex (name, CS_IMAGES, MAX_IMAGES, true);
77 }

Referenced by SV_InitGameProgs().

◆ SV_InitEdict()

void SV_InitEdict ( edict_t e)

◆ SV_InitGame()

void SV_InitGame ( void  )

Definition at line 289 of file sv_init.c.

290 {
291  int i;
292  edict_t *ent;
293  char idmaster[32];
294 
295  if (svs.initialized)
296  {
297  // cause any connected clients to reconnect
298  SV_Shutdown ("Server restarted\n", true);
300  }
301  else
302  {
303  // make sure the client is down
304  CL_Drop ();
306  }
307 
308  // get any latched variable changes (maxclients, etc)
310 
311  svs.initialized = true;
312 
313  if (Cvar_VariableValue ("coop") && Cvar_VariableValue ("deathmatch"))
314  {
315  Com_Printf("Deathmatch and Coop both set, disabling Coop\n");
316  Cvar_FullSet ("coop", "0", CVAR_SERVERINFO | CVAR_LATCH);
317  }
318 
319  // dedicated servers are can't be single player and are usually DM
320  // so unless they explicity set coop, force it to deathmatch
321  if (dedicated->value)
322  {
323  if (!Cvar_VariableValue ("coop"))
324  Cvar_FullSet ("deathmatch", "1", CVAR_SERVERINFO | CVAR_LATCH);
325  }
326 
327  // init clients
328  if (Cvar_VariableValue ("deathmatch"))
329  {
330  if (maxclients->value <= 1)
331  Cvar_FullSet ("maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH);
332  else if (maxclients->value > MAX_CLIENTS)
333  Cvar_FullSet ("maxclients", va("%i", MAX_CLIENTS), CVAR_SERVERINFO | CVAR_LATCH);
334  }
335  else if (Cvar_VariableValue ("coop"))
336  {
337  if (maxclients->value <= 1 || maxclients->value > 4)
338  Cvar_FullSet ("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
339 #ifdef COPYPROTECT
340  if (!sv.attractloop && !dedicated->value)
341  Sys_CopyProtect ();
342 #endif
343  }
344  else // non-deathmatch, non-coop is one player
345  {
346  Cvar_FullSet ("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH);
347 #ifdef COPYPROTECT
348  if (!sv.attractloop)
349  Sys_CopyProtect ();
350 #endif
351  }
352 
353  svs.spawncount = rand();
357 
358  // init network stuff
359  NET_Config ( (maxclients->value > 1) );
360 
361  // heartbeats will always be sent to the id master
362  svs.last_heartbeat = -99999; // send immediately
363  Com_sprintf(idmaster, sizeof(idmaster), "192.246.40.37:%i", PORT_MASTER);
364  NET_StringToAdr (idmaster, &master_adr[0]);
365 
366  // init game
367  SV_InitGameProgs ();
368  for (i=0 ; i<maxclients->value ; i++)
369  {
370  ent = EDICT_NUM(i+1);
371  ent->s.number = i+1;
372  svs.clients[i].edict = ent;
373  memset (&svs.clients[i].lastcmd, 0, sizeof(svs.clients[i].lastcmd));
374  }
375 }

Referenced by SV_Map(), and SV_ReadServerFile().

◆ SV_InitGameProgs()

void SV_InitGameProgs ( void  )

Definition at line 323 of file sv_game.c.

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

Referenced by SV_InitGame().

◆ SV_InitOperatorCommands()

void SV_InitOperatorCommands ( void  )

Definition at line 1025 of file sv_ccmds.c.

1026 {
1027  Cmd_AddCommand ("heartbeat", SV_Heartbeat_f);
1028  Cmd_AddCommand ("kick", SV_Kick_f);
1029  Cmd_AddCommand ("status", SV_Status_f);
1030  Cmd_AddCommand ("serverinfo", SV_Serverinfo_f);
1031  Cmd_AddCommand ("dumpuser", SV_DumpUser_f);
1032 
1033  Cmd_AddCommand ("map", SV_Map_f);
1034  Cmd_AddCommand ("demomap", SV_DemoMap_f);
1035  Cmd_AddCommand ("gamemap", SV_GameMap_f);
1036  Cmd_AddCommand ("setmaster", SV_SetMaster_f);
1037 
1038  if ( dedicated->value )
1039  Cmd_AddCommand ("say", SV_ConSay_f);
1040 
1041  Cmd_AddCommand ("serverrecord", SV_ServerRecord_f);
1042  Cmd_AddCommand ("serverstop", SV_ServerStop_f);
1043 
1044  Cmd_AddCommand ("save", SV_Savegame_f);
1045  Cmd_AddCommand ("load", SV_Loadgame_f);
1046 
1047  Cmd_AddCommand ("killserver", SV_KillServer_f);
1048 
1050 }

Referenced by SV_Init().

◆ SV_LinkEdict()

void SV_LinkEdict ( edict_t ent)

Definition at line 166 of file sv_world.c.

167 {
168  areanode_t *node;
169  int leafs[MAX_TOTAL_ENT_LEAFS];
170  int clusters[MAX_TOTAL_ENT_LEAFS];
171  int num_leafs;
172  int i, j, k;
173  int area;
174  int topnode;
175 
176  if (ent->area.prev)
177  SV_UnlinkEdict (ent); // unlink from old position
178 
179  if (ent == ge->edicts)
180  return; // don't add the world
181 
182  if (!ent->inuse)
183  return;
184 
185  // set the size
186  VectorSubtract (ent->maxs, ent->mins, ent->size);
187 
188  // encode the size into the entity_state for client prediction
189  if (ent->solid == SOLID_BBOX && !(ent->svflags & SVF_DEADMONSTER))
190  { // assume that x/y are equal and symetric
191  i = ent->maxs[0]/8;
192  if (i<1)
193  i = 1;
194  if (i>31)
195  i = 31;
196 
197  // z is not symetric
198  j = (-ent->mins[2])/8;
199  if (j<1)
200  j = 1;
201  if (j>31)
202  j = 31;
203 
204  // and z maxs can be negative...
205  k = (ent->maxs[2]+32)/8;
206  if (k<1)
207  k = 1;
208  if (k>63)
209  k = 63;
210 
211  ent->s.solid = (k<<10) | (j<<5) | i;
212  }
213  else if (ent->solid == SOLID_BSP)
214  {
215  ent->s.solid = 31; // a solid_bbox will never create this value
216  }
217  else
218  ent->s.solid = 0;
219 
220  // set the abs box
221  if (ent->solid == SOLID_BSP &&
222  (ent->s.angles[0] || ent->s.angles[1] || ent->s.angles[2]) )
223  { // expand for rotation
224  float max, v;
225  int i;
226 
227  max = 0;
228  for (i=0 ; i<3 ; i++)
229  {
230  v =fabs( ent->mins[i]);
231  if (v > max)
232  max = v;
233  v =fabs( ent->maxs[i]);
234  if (v > max)
235  max = v;
236  }
237  for (i=0 ; i<3 ; i++)
238  {
239  ent->absmin[i] = ent->s.origin[i] - max;
240  ent->absmax[i] = ent->s.origin[i] + max;
241  }
242  }
243  else
244  { // normal
245  VectorAdd (ent->s.origin, ent->mins, ent->absmin);
246  VectorAdd (ent->s.origin, ent->maxs, ent->absmax);
247  }
248 
249  // because movement is clipped an epsilon away from an actual edge,
250  // we must fully check even when bounding boxes don't quite touch
251  ent->absmin[0] -= 1;
252  ent->absmin[1] -= 1;
253  ent->absmin[2] -= 1;
254  ent->absmax[0] += 1;
255  ent->absmax[1] += 1;
256  ent->absmax[2] += 1;
257 
258 // link to PVS leafs
259  ent->num_clusters = 0;
260  ent->areanum = 0;
261  ent->areanum2 = 0;
262 
263  //get all leafs, including solids
264  num_leafs = CM_BoxLeafnums (ent->absmin, ent->absmax,
265  leafs, MAX_TOTAL_ENT_LEAFS, &topnode);
266 
267  // set areas
268  for (i=0 ; i<num_leafs ; i++)
269  {
270  clusters[i] = CM_LeafCluster (leafs[i]);
271  area = CM_LeafArea (leafs[i]);
272  if (area)
273  { // doors may legally straggle two areas,
274  // but nothing should evern need more than that
275  if (ent->areanum && ent->areanum != area)
276  {
277  if (ent->areanum2 && ent->areanum2 != area && sv.state == ss_loading)
278  Com_DPrintf ("Object touching 3 areas at %f %f %f\n",
279  ent->absmin[0], ent->absmin[1], ent->absmin[2]);
280  ent->areanum2 = area;
281  }
282  else
283  ent->areanum = area;
284  }
285  }
286 
287  if (num_leafs >= MAX_TOTAL_ENT_LEAFS)
288  { // assume we missed some leafs, and mark by headnode
289  ent->num_clusters = -1;
290  ent->headnode = topnode;
291  }
292  else
293  {
294  ent->num_clusters = 0;
295  for (i=0 ; i<num_leafs ; i++)
296  {
297  if (clusters[i] == -1)
298  continue; // not a visible leaf
299  for (j=0 ; j<i ; j++)
300  if (clusters[j] == clusters[i])
301  break;
302  if (j == i)
303  {
304  if (ent->num_clusters == MAX_ENT_CLUSTERS)
305  { // assume we missed some leafs, and mark by headnode
306  ent->num_clusters = -1;
307  ent->headnode = topnode;
308  break;
309  }
310 
311  ent->clusternums[ent->num_clusters++] = clusters[i];
312  }
313  }
314  }
315 
316  // if first time, make sure old_origin is valid
317  if (!ent->linkcount)
318  {
319  VectorCopy (ent->s.origin, ent->s.old_origin);
320  }
321  ent->linkcount++;
322 
323  if (ent->solid == SOLID_NOT)
324  return;
325 
326 // find the first node that the ent's box crosses
327  node = sv_areanodes;
328  while (1)
329  {
330  if (node->axis == -1)
331  break;
332  if (ent->absmin[node->axis] > node->dist)
333  node = node->children[0];
334  else if (ent->absmax[node->axis] < node->dist)
335  node = node->children[1];
336  else
337  break; // crosses the node
338  }
339 
340  // link it in
341  if (ent->solid == SOLID_TRIGGER)
342  InsertLinkBefore (&ent->area, &node->trigger_edicts);
343  else
344  InsertLinkBefore (&ent->area, &node->solid_edicts);
345 
346 }

Referenced by PF_setmodel(), and SV_InitGameProgs().

◆ SV_Map()

void SV_Map ( qboolean  attractloop,
char *  levelstring,
qboolean  loadgame 
)

Definition at line 394 of file sv_init.c.

395 {
396  char level[MAX_QPATH];
397  char *ch;
398  int l;
399  char spawnpoint[MAX_QPATH];
400 
401  sv.loadgame = loadgame;
402  sv.attractloop = attractloop;
403 
404  if (sv.state == ss_dead && !sv.loadgame)
405  SV_InitGame (); // the game is just starting
406 
407  strcpy (level, levelstring);
408 
409  // if there is a + in the map, set nextserver to the remainder
410  ch = strstr(level, "+");
411  if (ch)
412  {
413  *ch = 0;
414  Cvar_Set ("nextserver", va("gamemap \"%s\"", ch+1));
415  }
416  else
417  Cvar_Set ("nextserver", "");
418 
419  //ZOID special hack for end game screen in coop mode
420  if (Cvar_VariableValue ("coop") && !Q_stricmp(level, "victory.pcx"))
421  Cvar_Set ("nextserver", "gamemap \"*base1\"");
422 
423  // if there is a $, use the remainder as a spawnpoint
424  ch = strstr(level, "$");
425  if (ch)
426  {
427  *ch = 0;
428  strcpy (spawnpoint, ch+1);
429  }
430  else
431  spawnpoint[0] = 0;
432 
433  // skip the end-of-unit flag if necessary
434  if (level[0] == '*')
435  {
436 #ifdef __APPLE__
437  // stop XCode complaining about source and destination buffer overlap
438  char tmp[MAX_QPATH] = {0};
439  strcpy(tmp, level+1);
440  strcpy (level, tmp);
441 #else
442  strcpy (level, level+1);
443 #endif
444  }
445  l = (int)strlen(level);
446  if (l > 4 && !strcmp (level+l-4, ".cin") )
447  {
448  SCR_BeginLoadingPlaque (); // for local system
449  SV_BroadcastCommand ("changing\n");
450  SV_SpawnServer (level, spawnpoint, ss_cinematic, attractloop, loadgame);
451  }
452  else if (l > 4 && !strcmp (level+l-4, ".dm2") )
453  {
454  SCR_BeginLoadingPlaque (); // for local system
455  SV_BroadcastCommand ("changing\n");
456  SV_SpawnServer (level, spawnpoint, ss_demo, attractloop, loadgame);
457  }
458  else if (l > 4 && !strcmp (level+l-4, ".pcx") )
459  {
460  SCR_BeginLoadingPlaque (); // for local system
461  SV_BroadcastCommand ("changing\n");
462  SV_SpawnServer (level, spawnpoint, ss_pic, attractloop, loadgame);
463  }
464  else
465  {
466  SCR_BeginLoadingPlaque (); // for local system
467  SV_BroadcastCommand ("changing\n");
469  SV_SpawnServer (level, spawnpoint, ss_game, attractloop, loadgame);
470  Cbuf_CopyToDefer ();
471  }
472 
473  SV_BroadcastCommand ("reconnect\n");
474 }

Referenced by SV_DemoMap_f(), SV_GameMap_f(), and SV_Loadgame_f().

◆ SV_ModelIndex()

int SV_ModelIndex ( char *  name)

Definition at line 64 of file sv_init.c.

65 {
66  return SV_FindIndex (name, CS_MODELS, MAX_MODELS, true);
67 }

Referenced by PF_setmodel(), and SV_InitGameProgs().

◆ SV_Multicast()

void SV_Multicast ( vec3_t  origin,
multicast_t  to 
)

Definition at line 161 of file sv_send.c.

162 {
163  client_t *client;
164  byte *mask;
165  int leafnum, cluster;
166  int j;
167  qboolean reliable;
168  int area1, area2;
169 
170  reliable = false;
171 
172  if (to != MULTICAST_ALL_R && to != MULTICAST_ALL)
173  {
174  leafnum = CM_PointLeafnum (origin);
175  area1 = CM_LeafArea (leafnum);
176  }
177  else
178  {
179  leafnum = 0; // just to avoid compiler warnings
180  area1 = 0;
181  }
182 
183  // if doing a serverrecord, store everything
184  if (svs.demofile)
186 
187  switch (to)
188  {
189  case MULTICAST_ALL_R:
190  reliable = true; // intentional fallthrough
191  case MULTICAST_ALL:
192  leafnum = 0;
193  mask = NULL;
194  break;
195 
196  case MULTICAST_PHS_R:
197  reliable = true; // intentional fallthrough
198  case MULTICAST_PHS:
199  leafnum = CM_PointLeafnum (origin);
200  cluster = CM_LeafCluster (leafnum);
201  mask = CM_ClusterPHS (cluster);
202  break;
203 
204  case MULTICAST_PVS_R:
205  reliable = true; // intentional fallthrough
206  case MULTICAST_PVS:
207  leafnum = CM_PointLeafnum (origin);
208  cluster = CM_LeafCluster (leafnum);
209  mask = CM_ClusterPVS (cluster);
210  break;
211 
212  default:
213  mask = NULL;
214  Com_Error (ERR_FATAL, "SV_Multicast: bad to:%i", to);
215  }
216 
217  // send the data to all relevent clients
218  for (j = 0, client = svs.clients; j < maxclients->value; j++, client++)
219  {
220  if (client->state == cs_free || client->state == cs_zombie)
221  continue;
222  if (client->state != cs_spawned && !reliable)
223  continue;
224 
225  if (mask)
226  {
227  leafnum = CM_PointLeafnum (client->edict->s.origin);
228  cluster = CM_LeafCluster (leafnum);
229  area2 = CM_LeafArea (leafnum);
230  if (!CM_AreasConnected (area1, area2))
231  continue;
232  if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
233  continue;
234  }
235 
236  if (reliable)
238  else
240  }
241 
242  SZ_Clear (&sv.multicast);
243 }

Referenced by PF_Configstring(), SV_BroadcastCommand(), SV_FindIndex(), SV_InitGameProgs(), and SV_StartSound().

◆ SV_Nextserver()

void SV_Nextserver ( void  )

Definition at line 405 of file sv_user.c.

406 {
407  char *v;
408 
409  //ZOID, ss_pic can be nextserver'd in coop mode
410  if (sv.state == ss_game || (sv.state == ss_pic && !Cvar_VariableValue("coop")))
411  return; // can't nextserver while playing a normal game
412 
413  svs.spawncount++; // make sure another doesn't sneak in
414  v = Cvar_VariableString ("nextserver");
415  if (!v[0])
416  Cbuf_AddText ("killserver\n");
417  else
418  {
419  Cbuf_AddText (v);
420  Cbuf_AddText ("\n");
421  }
422  Cvar_Set ("nextserver","");
423 }

Referenced by SV_DemoCompleted(), and SV_Nextserver_f().

◆ SV_PointContents()

int SV_PointContents ( vec3_t  p)

Definition at line 432 of file sv_world.c.

433 {
434  edict_t *touch[MAX_EDICTS], *hit;
435  int i, num;
436  int contents, c2;
437  int headnode;
438  float *angles;
439 
440  // get base contents from world
441  contents = CM_PointContents (p, sv.models[1]->headnode);
442 
443  // or in contents from all the other entities
444  num = SV_AreaEdicts (p, p, touch, MAX_EDICTS, AREA_SOLID);
445 
446  for (i=0 ; i<num ; i++)
447  {
448  hit = touch[i];
449 
450  // might intersect, so do an exact clip
451  headnode = SV_HullForEntity (hit);
452  angles = hit->s.angles;
453  if (hit->solid != SOLID_BSP)
454  angles = vec3_origin; // boxes don't rotate
455 
456  c2 = CM_TransformedPointContents (p, headnode, hit->s.origin, hit->s.angles);
457 
458  contents |= c2;
459  }
460 
461  return contents;
462 }

Referenced by SV_InitGameProgs().

◆ SV_PrepWorldFrame()

void SV_PrepWorldFrame ( void  )

Definition at line 703 of file sv_main.c.

704 {
705  edict_t *ent;
706  int i;
707 
708  for (i=0 ; i<ge->num_edicts ; i++, ent++)
709  {
710  ent = EDICT_NUM(i);
711  // events only last for a single message
712  ent->s.event = 0;
713  }
714 
715 }

Referenced by SV_Frame().

◆ SV_ReadLevelFile()

void SV_ReadLevelFile ( void  )

Definition at line 306 of file sv_ccmds.c.

307 {
308  char name[MAX_OSPATH];
309  FILE *f;
310 
311  Com_DPrintf("SV_ReadLevelFile()\n");
312 
313  Com_sprintf (name, sizeof(name), "%s/save/current/%s.sv2", FS_Gamedir(), sv.name);
314  f = fopen(name, "rb");
315  if (!f)
316  {
317  Com_Printf ("Failed to open %s\n", name);
318  return;
319  }
320  FS_Read (sv.configstrings, sizeof(sv.configstrings), f);
321  CM_ReadPortalState (f);
322  fclose (f);
323 
324  Com_sprintf (name, sizeof(name), "%s/save/current/%s.sav", FS_Gamedir(), sv.name);
325  ge->ReadLevel (name);
326 }

Referenced by SV_CheckForSavegame().

◆ SV_RecordDemoMessage()

void SV_RecordDemoMessage ( void  )

Definition at line 680 of file sv_ents.c.

681 {
682  int e;
683  edict_t *ent;
684  entity_state_t nostate;
685  sizebuf_t buf;
686  byte buf_data[32768];
687  int len;
688 
689  if (!svs.demofile)
690  return;
691 
692  memset (&nostate, 0, sizeof(nostate));
693  SZ_Init (&buf, buf_data, sizeof(buf_data));
694 
695  // write a frame message that doesn't contain a player_state_t
696  MSG_WriteByte (&buf, svc_frame);
697  MSG_WriteLong (&buf, sv.framenum);
698 
700 
701  e = 1;
702  ent = EDICT_NUM(e);
703  while (e < ge->num_edicts)
704  {
705  // ignore ents without visible models unless they have an effect
706  if (ent->inuse &&
707  ent->s.number &&
708  (ent->s.modelindex || ent->s.effects || ent->s.sound || ent->s.event) &&
709  !(ent->svflags & SVF_NOCLIENT))
710  MSG_WriteDeltaEntity (&nostate, &ent->s, &buf, false, true);
711 
712  e++;
713  ent = EDICT_NUM(e);
714  }
715 
716  MSG_WriteShort (&buf, 0); // end of packetentities
717 
718  // now add the accumulated multicast information
721 
722  // now write the entire message to the file, prefixed by the length
723  len = LittleLong (buf.cursize);
724  fwrite (&len, 4, 1, svs.demofile);
725  fwrite (buf.data, buf.cursize, 1, svs.demofile);
726 }

Referenced by SV_Frame().

◆ SV_SendClientMessages()

void SV_SendClientMessages ( void  )

Definition at line 490 of file sv_send.c.

491 {
492  int i;
493  client_t *c;
494  int msglen;
495  byte msgbuf[MAX_MSGLEN];
496  size_t r;
497 
498  msglen = 0;
499 
500  // read the next demo message if needed
501  if (sv.state == ss_demo && sv.demofile)
502  {
503  if (sv_paused->value)
504  msglen = 0;
505  else
506  {
507  // get the next message
508  r = fread (&msglen, 4, 1, sv.demofile);
509  if (r != 1)
510  {
511  SV_DemoCompleted ();
512  return;
513  }
514  msglen = LittleLong (msglen);
515  if (msglen == -1)
516  {
517  SV_DemoCompleted ();
518  return;
519  }
520  if (msglen > MAX_MSGLEN)
521  Com_Error (ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN");
522  r = fread (msgbuf, msglen, 1, sv.demofile);
523  if (r != 1)
524  {
525  SV_DemoCompleted ();
526  return;
527  }
528  }
529  }
530 
531  // send a message to each connected client
532  for (i=0, c = svs.clients ; i<maxclients->value; i++, c++)
533  {
534  if (!c->state)
535  continue;
536  // if the reliable message overflowed,
537  // drop the client
538  if (c->netchan.message.overflowed)
539  {
540  SZ_Clear (&c->netchan.message);
541  SZ_Clear (&c->datagram);
542  SV_BroadcastPrintf (PRINT_HIGH, "%s overflowed\n", c->name);
543  SV_DropClient (c);
544  }
545 
546  if (sv.state == ss_cinematic
547  || sv.state == ss_demo
548  || sv.state == ss_pic
549  )
550  Netchan_Transmit (&c->netchan, msglen, msgbuf);
551  else if (c->state == cs_spawned)
552  {
553  // don't overrun bandwidth
554  if (SV_RateDrop (c))
555  continue;
556 
558  }
559  else
560  {
561  // just update reliable if needed
562  if (c->netchan.message.cursize || curtime - c->netchan.last_sent > 1000 )
563  Netchan_Transmit (&c->netchan, 0, NULL);
564  }
565  }
566 }

Referenced by SV_Frame(), and SV_Map().

◆ SV_SendServerinfo()

void SV_SendServerinfo ( client_t client)

◆ SV_ShutdownGameProgs()

void SV_ShutdownGameProgs ( void  )

Definition at line 305 of file sv_game.c.

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

Referenced by SV_InitGameProgs().

◆ SV_SoundIndex()

int SV_SoundIndex ( char *  name)

Definition at line 69 of file sv_init.c.

70 {
71  return SV_FindIndex (name, CS_SOUNDS, MAX_SOUNDS, true);
72 }

Referenced by SV_InitGameProgs().

◆ SV_StartSound()

void SV_StartSound ( vec3_t  origin,
edict_t entity,
int  channel,
int  soundindex,
float  volume,
float  attenuation,
float  timeofs 
)

Definition at line 272 of file sv_send.c.

275 {
276  int sendchan;
277  int flags;
278  int i;
279  int ent;
280  vec3_t origin_v;
281  qboolean use_phs;
282 
283  if (volume < 0 || volume > 1.0)
284  Com_Error (ERR_FATAL, "SV_StartSound: volume = %f", volume);
285 
286  if (attenuation < 0 || attenuation > 4)
287  Com_Error (ERR_FATAL, "SV_StartSound: attenuation = %f", attenuation);
288 
289 // if (channel < 0 || channel > 15)
290 // Com_Error (ERR_FATAL, "SV_StartSound: channel = %i", channel);
291 
292  if (timeofs < 0 || timeofs > 0.255)
293  Com_Error (ERR_FATAL, "SV_StartSound: timeofs = %f", timeofs);
294 
295  ent = NUM_FOR_EDICT(entity);
296 
297  if (channel & 8) // no PHS flag
298  {
299  use_phs = false;
300  channel &= 7;
301  }
302  else
303  use_phs = true;
304 
305  sendchan = (ent<<3) | (channel&7);
306 
307  flags = 0;
308  if (volume != DEFAULT_SOUND_PACKET_VOLUME)
309  flags |= SND_VOLUME;
310  if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
311  flags |= SND_ATTENUATION;
312 
313  // the client doesn't know that bmodels have weird origins
314  // the origin can also be explicitly set
315  if ( (entity->svflags & SVF_NOCLIENT)
316  || (entity->solid == SOLID_BSP)
317  || origin )
318  flags |= SND_POS;
319 
320  // always send the entity number for channel overrides
321  flags |= SND_ENT;
322 
323  if (timeofs)
324  flags |= SND_OFFSET;
325 
326  // use the entity origin unless it is a bmodel or explicitly specified
327  if (!origin)
328  {
329  origin = origin_v;
330  if (entity->solid == SOLID_BSP)
331  {
332  for (i=0 ; i<3 ; i++)
333  origin_v[i] = entity->s.origin[i]+0.5*(entity->mins[i]+entity->maxs[i]);
334  }
335  else
336  {
337  VectorCopy (entity->s.origin, origin_v);
338  }
339  }
340 
342  MSG_WriteByte (&sv.multicast, flags);
343  MSG_WriteByte (&sv.multicast, soundindex);
344 
345  if (flags & SND_VOLUME)
346  MSG_WriteByte (&sv.multicast, volume*255);
347  if (flags & SND_ATTENUATION)
348  MSG_WriteByte (&sv.multicast, attenuation*64);
349  if (flags & SND_OFFSET)
350  MSG_WriteByte (&sv.multicast, timeofs*1000);
351 
352  if (flags & SND_ENT)
353  MSG_WriteShort (&sv.multicast, sendchan);
354 
355  if (flags & SND_POS)
356  MSG_WritePos (&sv.multicast, origin);
357 
358  // if the sound doesn't attenuate,send it to everyone
359  // (global radio chatter, voiceovers, etc)
360  if (attenuation == ATTN_NONE)
361  use_phs = false;
362 
363  if (channel & CHAN_RELIABLE)
364  {
365  if (use_phs)
366  SV_Multicast (origin, MULTICAST_PHS_R);
367  else
368  SV_Multicast (origin, MULTICAST_ALL_R);
369  }
370  else
371  {
372  if (use_phs)
373  SV_Multicast (origin, MULTICAST_PHS);
374  else
375  SV_Multicast (origin, MULTICAST_ALL);
376  }
377 }

Referenced by PF_StartSound(), and SV_InitGameProgs().

◆ SV_Status_f()

void SV_Status_f ( void  )

Definition at line 737 of file sv_ccmds.c.

738 {
739  int i, j, l;
740  client_t *cl;
741  char *s;
742  int ping;
743  if (!svs.clients)
744  {
745  Com_Printf ("No server running.\n");
746  return;
747  }
748  Com_Printf ("map : %s\n", sv.name);
749 
750  Com_Printf ("num score ping name lastmsg address qport \n");
751  Com_Printf ("--- ----- ---- --------------- ------- --------------------- ------\n");
752  for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++)
753  {
754  if (!cl->state)
755  continue;
756  Com_Printf ("%3i ", i);
757  Com_Printf ("%5i ", cl->edict->client->ps.stats[STAT_FRAGS]);
758 
759  if (cl->state == cs_connected)
760  Com_Printf ("CNCT ");
761  else if (cl->state == cs_zombie)
762  Com_Printf ("ZMBI ");
763  else
764  {
765  ping = cl->ping < 9999 ? cl->ping : 9999;
766  Com_Printf ("%4i ", ping);
767  }
768 
769  Com_Printf ("%s", cl->name);
770  l = 16 - (int)strlen(cl->name);
771  for (j=0 ; j<l ; j++)
772  Com_Printf (" ");
773 
774  Com_Printf ("%7i ", svs.realtime - cl->lastmessage );
775 
776  s = NET_AdrToString ( cl->netchan.remote_address);
777  Com_Printf ("%s", s);
778  l = 22 - (int)strlen(s);
779  for (j=0 ; j<l ; j++)
780  Com_Printf (" ");
781 
782  Com_Printf ("%5i", cl->netchan.qport);
783 
784  Com_Printf ("\n");
785  }
786  Com_Printf ("\n");
787 }

Referenced by SV_InitOperatorCommands().

◆ SV_Trace()

trace_t SV_Trace ( vec3_t  start,
vec3_t  mins,
vec3_t  maxs,
vec3_t  end,
edict_t passedict,
int  contentmask 
)

Definition at line 625 of file sv_world.c.

626 {
627  moveclip_t clip;
628 
629  if (!mins)
630  mins = vec3_origin;
631  if (!maxs)
632  maxs = vec3_origin;
633 
634  memset ( &clip, 0, sizeof ( moveclip_t ) );
635 
636  // clip to world
637  clip.trace = CM_BoxTrace (start, end, mins, maxs, 0, contentmask);
638  clip.trace.ent = ge->edicts;
639  if (clip.trace.fraction == 0)
640  return clip.trace; // blocked by the world
641 
642  clip.contentmask = contentmask;
643  clip.start = start;
644  clip.end = end;
645  clip.mins = mins;
646  clip.maxs = maxs;
647  clip.passedict = passedict;
648 
649  VectorCopy (mins, clip.mins2);
650  VectorCopy (maxs, clip.maxs2);
651 
652  // create the bounding box of the entire move
653  SV_TraceBounds ( start, clip.mins2, clip.maxs2, end, clip.boxmins, clip.boxmaxs );
654 
655  // clip to other solid entities
656  SV_ClipMoveToEntities ( &clip );
657 
658  return clip.trace;
659 }

Referenced by SV_InitGameProgs().

◆ SV_UnlinkEdict()

void SV_UnlinkEdict ( edict_t ent)

Definition at line 150 of file sv_world.c.

151 {
152  if (!ent->area.prev)
153  return; // not linked in anywhere
154  RemoveLink (&ent->area);
155  ent->area.prev = ent->area.next = NULL;
156 }

Referenced by SV_InitGameProgs(), and SV_LinkEdict().

◆ SV_UserinfoChanged()

void SV_UserinfoChanged ( client_t cl)

Definition at line 901 of file sv_main.c.

902 {
903  char *val;
904  int i;
905 
906  // call prog code to allow overrides
907  ge->ClientUserinfoChanged (cl->edict, cl->userinfo);
908 
909  // name for C code
910  strncpy (cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name)-1);
911  // mask off high bit
912  for (i=0 ; i<sizeof(cl->name) ; i++)
913  cl->name[i] &= 127;
914 
915  // rate command
916  val = Info_ValueForKey (cl->userinfo, "rate");
917  if (strlen(val))
918  {
919  i = atoi(val);
920  cl->rate = i;
921  if (cl->rate < 100)
922  cl->rate = 100;
923  if (cl->rate > 15000)
924  cl->rate = 15000;
925  }
926  else
927  cl->rate = 5000;
928 
929  // msg command
930  val = Info_ValueForKey (cl->userinfo, "msg");
931  if (strlen(val))
932  {
933  cl->messagelevel = atoi(val);
934  }
935 
936 }

Referenced by SV_ExecuteClientMessage(), and SVC_DirectConnect().

◆ SV_WriteClientdataToMessage()

void SV_WriteClientdataToMessage ( client_t client,
sizebuf_t msg 
)

◆ SV_WriteFrameToClient()

void SV_WriteFrameToClient ( client_t client,
sizebuf_t msg 
)

Definition at line 413 of file sv_ents.c.

414 {
415  client_frame_t *frame, *oldframe;
416  int lastframe;
417 
418 //Com_Printf ("%i -> %i\n", client->lastframe, sv.framenum);
419  // this is the frame we are creating
420  frame = &client->frames[sv.framenum & UPDATE_MASK];
421 
422  if (client->lastframe <= 0)
423  { // client is asking for a retransmit
424  oldframe = NULL;
425  lastframe = -1;
426  }
427  else if (sv.framenum - client->lastframe >= (UPDATE_BACKUP - 3) )
428  { // client hasn't gotten a good message through in a long time
429 // Com_Printf ("%s: Delta request from out-of-date packet.\n", client->name);
430  oldframe = NULL;
431  lastframe = -1;
432  }
433  else
434  { // we have a valid message to delta from
435  oldframe = &client->frames[client->lastframe & UPDATE_MASK];
436  lastframe = client->lastframe;
437  }
438 
441  MSG_WriteLong (msg, lastframe); // what we are delta'ing from
442  MSG_WriteByte (msg, client->surpressCount); // rate dropped packets
443  client->surpressCount = 0;
444 
445  // send over the areabits
446  MSG_WriteByte (msg, frame->areabytes);
447  SZ_Write (msg, frame->areabits, frame->areabytes);
448 
449  // delta encode the playerstate
450  SV_WritePlayerstateToClient (oldframe, frame, msg);
451 
452  // delta encode the entities
453  SV_EmitPacketEntities (oldframe, frame, msg);
454 }

Referenced by SV_SendClientDatagram().

Variable Documentation

◆ ge

◆ master_adr

netadr_t master_adr[MAX_MASTERS]

Definition at line 23 of file sv_main.c.

Referenced by Master_Heartbeat(), Master_Shutdown(), SV_InitGame(), and SV_SetMaster_f().

◆ maxclients

◆ net_from

◆ net_message

◆ sv

◆ sv_airaccelerate

cvar_t* sv_airaccelerate

Definition at line 43 of file sv_main.c.

Referenced by SV_Init(), and SV_SpawnServer().

◆ sv_client

◆ sv_enforcetime

cvar_t* sv_enforcetime

Definition at line 30 of file sv_main.c.

Referenced by SV_ClientThink(), and SV_Init().

◆ sv_noreload

cvar_t* sv_noreload

Definition at line 45 of file sv_main.c.

Referenced by SV_CheckForSavegame(), and SV_Init().

◆ sv_outputbuf

char sv_outputbuf[SV_OUTPUTBUF_LENGTH]

Definition at line 32 of file sv_send.c.

Referenced by SVC_RemoteCommand(), and SVC_Status().

◆ sv_paused

cvar_t* sv_paused

Definition at line 27 of file sv_main.c.

Referenced by SV_ExecuteClientMessage(), SV_Init(), SV_RunGameFrame(), and SV_SendClientMessages().

◆ sv_player

edict_t* sv_player

Definition at line 24 of file sv_user.c.

Referenced by SV_Begin_f(), SV_ExecuteClientMessage(), SV_ExecuteUserCommand(), and SV_SetPlayer().

◆ svs

client_s::lastframe
int lastframe
Definition: server.h:101
entity_state_s::old_origin
vec3_t old_origin
Definition: q_shared.h:1151
game_import_t
Definition: game.h:102
server_t::framenum
int framenum
Definition: server.h:51
SV_TraceBounds
void SV_TraceBounds(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, vec3_t boxmins, vec3_t boxmaxs)
Definition: sv_world.c:590
areanode_s::solid_edicts
link_t solid_edicts
Definition: sv_world.c:47
CL_Drop
void CL_Drop(void)
Definition: cl_main.c:399
cs_zombie
@ cs_zombie
Definition: server.h:76
MAX_CLIENTS
#define MAX_CLIENTS
Definition: q_shared.h:86
sv
server_t sv
Definition: sv_init.c:24
SV_DemoCompleted
void SV_DemoCompleted(void)
Definition: sv_send.c:440
edict_s::s
entity_state_t s
Definition: g_local.h:970
sv_player
edict_t * sv_player
Definition: sv_user.c:24
CM_BoxTrace
trace_t CM_BoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headnode, int brushmask)
Definition: cmodel.c:1350
FS_Read
void FS_Read(void *buffer, int len, FILE *f)
Definition: files.c:350
SV_ExecuteUserCommand
void SV_ExecuteUserCommand(char *s)
Definition: sv_user.c:477
area_maxcount
int area_maxcount
Definition: sv_world.c:58
dedicated
cvar_t * dedicated
Definition: common.c:47
curtime
int curtime
Definition: q_shwin.c:119
client_frame_t::num_entities
int num_entities
Definition: server.h:87
sizebuf_s
Definition: qcommon.h:92
value
GLfloat value
Definition: qgl_win.c:63
client_frame_t::areabits
byte areabits[MAX_MAP_AREAS/8]
Definition: server.h:85
client_s::datagram
sizebuf_t datagram
Definition: server.h:120
SV_Serverinfo_f
void SV_Serverinfo_f(void)
Definition: sv_ccmds.c:842
GAME_API_VERSION
#define GAME_API_VERSION
Definition: game.h:23
Sys_CopyProtect
void Sys_CopyProtect(void)
Definition: sys_win.c:191
SND_POS
#define SND_POS
Definition: qcommon.h:303
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:80
entity_state_s::solid
int solid
Definition: q_shared.h:1158
MAX_MODELS
#define MAX_MODELS
Definition: q_shared.h:89
server_static_t::spawncount
int spawncount
Definition: server.h:165
SND_OFFSET
#define SND_OFFSET
Definition: qcommon.h:305
Z_TagMalloc
void * Z_TagMalloc(int size, int tag)
Definition: common.c:1172
client_state_t::frames
frame_t frames[UPDATE_BACKUP]
Definition: client.h:118
CS_SOUNDS
#define CS_SOUNDS
Definition: q_shared.h:1113
trace_t::fraction
float fraction
Definition: q_shared.h:457
client_frame_t::ps
player_state_t ps
Definition: server.h:86
PF_WritePos
void PF_WritePos(vec3_t pos)
Definition: sv_game.c:222
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
area_count
int area_count
Definition: sv_world.c:58
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:163
NS_SERVER
@ NS_SERVER
Definition: qcommon.h:549
cmodel_s::maxs
vec3_t maxs
Definition: q_shared.h:434
RD_CLIENT
@ RD_CLIENT
Definition: server.h:242
edict_s::absmax
vec3_t absmax
Definition: g_local.h:991
svc_frame
@ svc_frame
Definition: qcommon.h:246
maxclients
cvar_t * maxclients
Definition: g_main.c:44
moveclip_t::maxs
float * maxs
Definition: sv_world.c:469
SOLID_BBOX
@ SOLID_BBOX
Definition: game.h:37
SV_FatPVS
void SV_FatPVS(vec3_t org)
Definition: sv_ents.c:475
PF_setmodel
void PF_setmodel(edict_t *ent, char *name)
Definition: sv_game.c:162
entity_state_s::renderfx
int renderfx
Definition: q_shared.h:1157
SV_WritePlayerstateToClient
void SV_WritePlayerstateToClient(client_frame_t *from, client_frame_t *to, sizebuf_t *msg)
Definition: sv_ents.c:220
net_message
sizebuf_t net_message
Definition: net_chan.c:82
v
GLdouble v
Definition: qgl_win.c:143
InsertLinkBefore
void InsertLinkBefore(link_t *l, link_t *before)
Definition: sv_world.c:76
PF_WriteByte
void PF_WriteByte(int c)
Definition: sv_game.c:217
entity_state_s
Definition: q_shared.h:1145
PORT_MASTER
#define PORT_MASTER
Definition: qcommon.h:201
game_export_t::edicts
struct edict_s * edicts
Definition: game.h:229
SV_LinkEdict
void SV_LinkEdict(edict_t *ent)
Definition: sv_world.c:166
SV_SpawnServer
void SV_SpawnServer(char *server, char *spawnpoint, server_state_t serverstate, qboolean attractloop, qboolean loadgame)
Definition: sv_init.c:169
netchan_t::message
sizebuf_t message
Definition: qcommon.h:608
game_export_t::Shutdown
void(* Shutdown)(void)
Definition: game.h:189
PF_WriteDir
void PF_WriteDir(vec3_t dir)
Definition: sv_game.c:223
entity_state_s::origin
vec3_t origin
Definition: q_shared.h:1149
game_export_t::apiversion
int apiversion
Definition: game.h:183
edict_s::linkcount
int linkcount
Definition: g_local.h:977
SVF_NOCLIENT
#define SVF_NOCLIENT
Definition: game.h:27
net_from
netadr_t net_from
Definition: net_chan.c:81
moveclip_t::passedict
edict_t * passedict
Definition: sv_world.c:473
sizebuf_s::overflowed
qboolean overflowed
Definition: qcommon.h:95
SV_DemoMap_f
void SV_DemoMap_f(void)
Definition: sv_ccmds.c:465
UPDATE_BACKUP
#define UPDATE_BACKUP
Definition: qcommon.h:207
DEFAULT_SOUND_PACKET_VOLUME
#define DEFAULT_SOUND_PACKET_VOLUME
Definition: qcommon.h:307
server_static_t::realtime
int realtime
Definition: server.h:161
sizebuf_s::readcount
int readcount
Definition: qcommon.h:99
moveclip_t::contentmask
int contentmask
Definition: sv_world.c:474
CS_MODELS
#define CS_MODELS
Definition: q_shared.h:1112
qboolean
qboolean
Definition: q_shared.h:63
edict_s::inuse
qboolean inuse
Definition: g_local.h:976
SV_ServerRecord_f
void SV_ServerRecord_f(void)
Definition: sv_ccmds.c:882
edict_s::areanum2
int areanum2
Definition: g_local.h:985
MAX_TOTAL_ENT_LEAFS
#define MAX_TOTAL_ENT_LEAFS
Definition: sv_world.c:165
MAX_MASTERS
#define MAX_MASTERS
Definition: server.h:30
i
int i
Definition: q_shared.c:305
sv
server_t sv
Definition: sv_init.c:24
server_t::multicast
sizebuf_t multicast
Definition: server.h:61
cs_connected
@ cs_connected
Definition: server.h:78
moveclip_t::boxmins
vec3_t boxmins
Definition: sv_world.c:468
SV_HullForEntity
int SV_HullForEntity(edict_t *ent)
Definition: sv_world.c:489
CM_WriteAreaBits
int CM_WriteAreaBits(byte *buffer, int area)
Definition: cmodel.c:1686
CM_TransformedPointContents
int CM_TransformedPointContents(vec3_t p, int headnode, vec3_t origin, vec3_t angles)
Definition: cmodel.c:937
SV_AreaEdicts_r
void SV_AreaEdicts_r(areanode_t *node)
Definition: sv_world.c:355
SOLID_TRIGGER
@ SOLID_TRIGGER
Definition: game.h:36
game_export_t::Init
void(* Init)(void)
Definition: game.h:188
edict_s::client
struct gclient_s * client
Definition: g_local.h:971
entity_state_s::event
int event
Definition: q_shared.h:1162
MSG_WriteLong
void MSG_WriteLong(sizebuf_t *sb, int c)
Definition: common.c:330
SV_BroadcastPrintf
void SV_BroadcastPrintf(int level, char *fmt,...)
Definition: sv_send.c:89
area_mins
float * area_mins
Definition: sv_world.c:56
SV_GameMap_f
void SV_GameMap_f(void)
Definition: sv_ccmds.c:488
sv_numareanodes
int sv_numareanodes
Definition: sv_world.c:54
NET_AdrToString
char * NET_AdrToString(netadr_t a)
Definition: net_wins.c:161
server_static_t::next_client_entities
int next_client_entities
Definition: server.h:170
client_s::name
char name[32]
Definition: server.h:115
PF_WriteChar
void PF_WriteChar(int c)
Definition: sv_game.c:216
client_frame_t::first_entity
int first_entity
Definition: server.h:88
SZ_Init
void SZ_Init(sizebuf_t *buf, byte *data, int length)
Definition: common.c:885
SV_ShutdownGameProgs
void SV_ShutdownGameProgs(void)
Definition: sv_game.c:305
client_s::state
client_state_t state
Definition: server.h:97
edict_s::mins
vec3_t mins
Definition: g_local.h:990
Sys_UnloadGame
void Sys_UnloadGame(void)
Definition: sys_win.c:488
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:234
sizebuf_s::data
byte * data
Definition: qcommon.h:96
edict_s::clusternums
int clusternums[MAX_ENT_CLUSTERS]
Definition: g_local.h:983
server_t::demofile
FILE * demofile
Definition: server.h:65
SCR_BeginLoadingPlaque
void SCR_BeginLoadingPlaque(void)
Definition: cl_scrn.c:562
MAX_STRINGCMDS
#define MAX_STRINGCMDS
Definition: sv_user.c:525
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
CHAN_RELIABLE
#define CHAN_RELIABLE
Definition: q_shared.h:990
SZ_Write
void SZ_Write(sizebuf_t *buf, void *data, int length)
Definition: common.c:921
SV_BroadcastCommand
void SV_BroadcastCommand(char *fmt,...)
Definition: sv_send.c:132
areanode_s::trigger_edicts
link_t trigger_edicts
Definition: sv_world.c:46
SZ_Clear
void SZ_Clear(sizebuf_t *buf)
Definition: common.c:892
PF_WriteLong
void PF_WriteLong(int c)
Definition: sv_game.c:219
game_export_t::ClientDisconnect
void(* ClientDisconnect)(edict_t *ent)
Definition: game.h:209
area_maxs
float * area_maxs
Definition: sv_world.c:56
edict_s::areanum
int areanum
Definition: g_local.h:985
moveclip_t::mins
float * mins
Definition: sv_world.c:469
STAT_FRAGS
#define STAT_FRAGS
Definition: q_shared.h:1015
SV_EmitPacketEntities
void SV_EmitPacketEntities(client_frame_t *from, client_frame_t *to, sizebuf_t *msg)
Definition: sv_ents.c:125
CM_LeafArea
int CM_LeafArea(int leafnum)
Definition: cmodel.c:681
entity_state_s::effects
unsigned int effects
Definition: q_shared.h:1156
SV_Map_f
void SV_Map_f(void)
Definition: sv_ccmds.c:557
CVAR_SERVERINFO
#define CVAR_SERVERINFO
Definition: q_shared.h:318
game_export_t::ClientUserinfoChanged
void(* ClientUserinfoChanged)(edict_t *ent, char *userinfo)
Definition: game.h:208
SV_AreaEdicts
int SV_AreaEdicts(vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype)
Definition: sv_world.c:409
cmodel_s::headnode
int headnode
Definition: q_shared.h:436
server_state_t
server_state_t
Definition: server.h:32
PF_dprintf
void PF_dprintf(char *fmt,...)
Definition: sv_game.c:64
Cmd_TokenizeString
void Cmd_TokenizeString(char *text, qboolean macroExpand)
Definition: cmd.c:620
j
GLint j
Definition: qgl_win.c:150
entity_state_s::sound
int sound
Definition: q_shared.h:1161
NET_StringToAdr
qboolean NET_StringToAdr(char *s, netadr_t *a)
Definition: net_wins.c:262
CM_PointContents
int CM_PointContents(vec3_t p, int headnode)
Definition: cmodel.c:917
Cmd_Argv
char * Cmd_Argv(int arg)
Definition: cmd.c:517
va
char * va(char *format,...)
Definition: q_shared.c:1050
SV_Status_f
void SV_Status_f(void)
Definition: sv_ccmds.c:737
msg
cvar_t * msg
Definition: cl_main.c:83
server_static_t::client_entities
entity_state_t * client_entities
Definition: server.h:171
RemoveLink
void RemoveLink(link_t *l)
Definition: sv_world.c:70
Cmd_Argc
int Cmd_Argc(void)
Definition: cmd.c:507
game_export_t::ClientCommand
void(* ClientCommand)(edict_t *ent)
Definition: game.h:210
SVF_DEADMONSTER
#define SVF_DEADMONSTER
Definition: game.h:28
ATTN_NONE
#define ATTN_NONE
Definition: q_shared.h:994
Cvar_ForceSet
cvar_t * Cvar_ForceSet(char *var_name, char *value)
Definition: cvar.c:268
CS_IMAGES
#define CS_IMAGES
Definition: q_shared.h:1114
server_static_t::clients
client_t * clients
Definition: server.h:168
SV_DumpUser_f
void SV_DumpUser_f(void)
Definition: sv_ccmds.c:856
MULTICAST_PHS
@ MULTICAST_PHS
Definition: q_shared.h:117
RF_BEAM
#define RF_BEAM
Definition: q_shared.h:606
HEARTBEAT_SECONDS
#define HEARTBEAT_SECONDS
Definition: sv_main.c:826
u
static int u
Definition: r_part.c:472
client_s::netchan
netchan_t netchan
Definition: server.h:134
ss_cinematic
@ ss_cinematic
Definition: server.h:36
edict_s::svflags
int svflags
Definition: g_local.h:989
SND_ATTENUATION
#define SND_ATTENUATION
Definition: qcommon.h:302
SV_AreaEdicts
int SV_AreaEdicts(vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype)
Definition: sv_world.c:409
client_frame_t::areabytes
int areabytes
Definition: server.h:84
moveclip_t::trace
trace_t trace
Definition: sv_world.c:472
edict_s
Definition: g_local.h:968
SV_FindIndex
int SV_FindIndex(char *name, int start, int max, qboolean create)
Definition: sv_init.c:32
CM_ClusterPVS
byte * CM_ClusterPVS(int cluster)
Definition: cmodel.c:1575
server_static_t::num_client_entities
int num_client_entities
Definition: server.h:169
ucmd_t
Definition: sv_user.c:445
r
GLdouble GLdouble r
Definition: qgl_win.c:336
CM_AreasConnected
qboolean CM_AreasConnected(int area1, int area2)
Definition: cmodel.c:1662
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
SV_UnlinkEdict
void SV_UnlinkEdict(edict_t *ent)
Definition: sv_world.c:150
moveclip_t::boxmaxs
vec3_t boxmaxs
Definition: sv_world.c:468
Cvar_FullSet
cvar_t * Cvar_FullSet(char *var_name, char *value, int flags)
Definition: cvar.c:288
client_s::download
byte * download
Definition: server.h:125
COM_BlockSequenceCRCByte
byte COM_BlockSequenceCRCByte(byte *base, int length, int sequence)
Definition: common.c:1338
public_server
cvar_t * public_server
Definition: sv_main.c:51
PF_Unicast
void PF_Unicast(edict_t *ent, qboolean reliable)
Definition: sv_game.c:34
SV_KillServer_f
void SV_KillServer_f(void)
Definition: sv_ccmds.c:991
netchan_t::last_sent
int last_sent
Definition: qcommon.h:591
NUM_FOR_EDICT
#define NUM_FOR_EDICT(e)
Definition: server.h:70
ge
game_export_t * ge
Definition: sv_game.c:24
VectorLength
vec_t VectorLength(vec3_t v)
Definition: q_shared.c:762
svs
server_static_t svs
Definition: sv_init.c:23
player_state_t::pmove
pmove_state_t pmove
Definition: q_shared.h:1176
ss_demo
@ ss_demo
Definition: server.h:37
SV_InitGameProgs
void SV_InitGameProgs(void)
Definition: sv_game.c:323
client_s::frames
client_frame_t frames[UPDATE_BACKUP]
Definition: server.h:123
SV_Kick_f
void SV_Kick_f(void)
Definition: sv_ccmds.c:706
SV_Heartbeat_f
void SV_Heartbeat_f(void)
Definition: sv_ccmds.c:829
area_list
edict_t ** area_list
Definition: sv_world.c:57
edict_s::owner
edict_t * owner
Definition: g_local.h:994
fatpvs
byte fatpvs[65536/8]
Definition: sv_ents.c:465
Info_ValueForKey
char * Info_ValueForKey(char *s, char *key)
Definition: q_shared.c:1253
player_state_t::viewoffset
vec3_t viewoffset
Definition: q_shared.h:1181
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
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:115
client_s::lastcmd
usercmd_t lastcmd
Definition: server.h:102
sv_client
client_t * sv_client
Definition: sv_main.c:25
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:625
cs_free
@ cs_free
Definition: server.h:75
SV_DropClient
void SV_DropClient(client_t *drop)
Definition: sv_main.c:70
MULTICAST_ALL_R
@ MULTICAST_ALL_R
Definition: q_shared.h:119
SV_Multicast
void SV_Multicast(vec3_t origin, multicast_t to)
Definition: sv_send.c:161
DEFAULT_SOUND_PACKET_ATTENUATION
#define DEFAULT_SOUND_PACKET_ATTENUATION
Definition: qcommon.h:308
Cbuf_AddText
void Cbuf_AddText(char *text)
Definition: cmd.c:90
cvar_s::value
float value
Definition: q_shared.h:331
MSG_ReadByte
int MSG_ReadByte(sizebuf_t *msg_read)
Definition: common.c:703
server_t::models
struct cmodel_s * models[MAX_MODELS]
Definition: server.h:54
MAX_OSPATH
#define MAX_OSPATH
Definition: q_shared.h:81
cmodel_s::mins
vec3_t mins
Definition: q_shared.h:434
MSG_WritePos
void MSG_WritePos(sizebuf_t *sb, vec3_t pos)
Definition: common.c:369
PRINT_HIGH
#define PRINT_HIGH
Definition: q_shared.h:99
ucmds
ucmd_t ucmds[]
Definition: sv_user.c:451
master_adr
netadr_t master_adr[MAX_MASTERS]
Definition: sv_main.c:23
sv_areanodes
areanode_t sv_areanodes[AREA_NODES]
Definition: sv_world.c:53
moveclip_t::start
float * start
Definition: sv_world.c:471
SV_Nextserver
void SV_Nextserver(void)
Definition: sv_user.c:405
gclient_s::ps
player_state_t ps
Definition: g_local.h:886
MSG_WriteString
void MSG_WriteString(sizebuf_t *sb, char *s)
Definition: common.c:356
entity_state_s::number
int number
Definition: q_shared.h:1147
NULL
#define NULL
Definition: q_shared.h:67
edict_s::solid
solid_t solid
Definition: g_local.h:992
CVAR_LATCH
#define CVAR_LATCH
Definition: q_shared.h:321
MSG_WriteShort
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition: common.c:316
server_t::attractloop
qboolean attractloop
Definition: server.h:47
game_export_t::ReadLevel
void(* ReadLevel)(char *filename)
Definition: game.h:204
MSG_WriteByte
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition: common.c:303
client_state_t
client_state_t
Definition: server.h:73
SV_SetMaster_f
void SV_SetMaster_f(void)
Definition: sv_ccmds.c:39
Com_Error
void Com_Error(int code, char *fmt,...)
Definition: common.c:181
areanode_s
Definition: sv_world.c:41
client_frame_t
Definition: server.h:82
clc_userinfo
@ clc_userinfo
Definition: qcommon.h:259
Z_Malloc
void * Z_Malloc(int size)
Definition: common.c:1200
server_t::loadgame
qboolean loadgame
Definition: server.h:48
PF_error
void PF_error(char *fmt,...)
Definition: sv_game.c:142
SV_StatusString
char * SV_StatusString(void)
Definition: sv_main.c:109
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
areanode_s::dist
float dist
Definition: sv_world.c:44
Q_stricmp
int Q_stricmp(char *s1, char *s2)
Definition: q_shared.c:1180
moveclip_t::maxs2
vec3_t maxs2
Definition: sv_world.c:470
svs
server_static_t svs
Definition: sv_init.c:23
CM_ReadPortalState
void CM_ReadPortalState(FILE *f)
Definition: cmodel.c:1734
SOLID_NOT
@ SOLID_NOT
Definition: game.h:35
svc_disconnect
@ svc_disconnect
Definition: qcommon.h:233
SV_Multicast
void SV_Multicast(vec3_t origin, multicast_t to)
Definition: sv_send.c:161
name
cvar_t * name
Definition: cl_main.c:79
MAX_EDICTS
#define MAX_EDICTS
Definition: q_shared.h:87
SND_VOLUME
#define SND_VOLUME
Definition: qcommon.h:301
CM_BoxLeafnums
int CM_BoxLeafnums(vec3_t mins, vec3_t maxs, int *list, int listsize, int *topnode)
Definition: cmodel.c:903
SV_Savegame_f
void SV_Savegame_f(void)
Definition: sv_ccmds.c:641
NET_Config
void NET_Config(qboolean multiplayer)
Definition: net_wins.c:695
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
SV_SendClientMessages
void SV_SendClientMessages(void)
Definition: sv_send.c:490
server_static_t::last_heartbeat
int last_heartbeat
Definition: server.h:173
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:164
SV_ClipMoveToEntities
void SV_ClipMoveToEntities(moveclip_t *clip)
Definition: sv_world.c:518
s
static fixed16_t s
Definition: r_scan.c:30
MAX_MSGLEN
#define MAX_MSGLEN
Definition: qcommon.h:544
PF_WriteFloat
void PF_WriteFloat(float f)
Definition: sv_game.c:220
moveclip_t::end
float * end
Definition: sv_world.c:471
SV_Shutdown
void SV_Shutdown(char *finalmsg, qboolean reconnect)
Definition: sv_main.c:1035
server_static_t::initialized
qboolean initialized
Definition: server.h:160
client_frame_t::senttime
int senttime
Definition: server.h:89
client_s::surpressCount
int surpressCount
Definition: server.h:112
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
game_export_t
Definition: game.h:181
SV_UserinfoChanged
void SV_UserinfoChanged(client_t *cl)
Definition: sv_main.c:901
SV_RateDrop
qboolean SV_RateDrop(client_t *c)
Definition: sv_send.c:459
CM_ClusterPHS
byte * CM_ClusterPHS(int cluster)
Definition: cmodel.c:1584
areanode_s::axis
int axis
Definition: sv_world.c:43
cs_spawned
@ cs_spawned
Definition: server.h:79
ge
game_export_t * ge
Definition: sv_game.c:24
redirect_t
redirect_t
Definition: server.h:242
vec3_origin
vec3_t vec3_origin
Definition: q_shared.c:24
MSG_ReadLong
int MSG_ReadLong(sizebuf_t *msg_read)
Definition: common.c:731
Z_Free
void Z_Free(void *ptr)
Definition: common.c:1122
usercmd_s
Definition: q_shared.h:517
Cbuf_CopyToDefer
void Cbuf_CopyToDefer(void)
Definition: cmd.c:147
AREA_SOLID
#define AREA_SOLID
Definition: q_shared.h:407
MULTICAST_PHS_R
@ MULTICAST_PHS_R
Definition: q_shared.h:120
SV_PointContents
int SV_PointContents(vec3_t p)
Definition: sv_world.c:432
SV_ServerCommand_f
void SV_ServerCommand_f(void)
Definition: sv_ccmds.c:1007
MSG_ReadString
char * MSG_ReadString(sizebuf_t *msg_read)
Definition: common.c:773
level
GLint level
Definition: qgl_win.c:116
FS_Gamedir
char * FS_Gamedir(void)
Definition: files.c:559
PF_inPHS
qboolean PF_inPHS(vec3_t p1, vec3_t p2)
Definition: sv_game.c:264
CM_LeafCluster
int CM_LeafCluster(int leafnum)
Definition: cmodel.c:674
SV_SoundIndex
int SV_SoundIndex(char *name)
Definition: sv_init.c:69
MSG_ReadDeltaUsercmd
void MSG_ReadDeltaUsercmd(sizebuf_t *msg_read, usercmd_t *from, usercmd_t *move)
Definition: common.c:835
MAX_SOUNDS
#define MAX_SOUNDS
Definition: q_shared.h:90
Cvar_GetLatchedVars
void Cvar_GetLatchedVars(void)
Definition: cvar.c:336
SV_ConSay_f
void SV_ConSay_f(void)
Definition: sv_ccmds.c:794
SV_UnlinkEdict
void SV_UnlinkEdict(edict_t *ent)
Definition: sv_world.c:150
MULTICAST_PVS_R
@ MULTICAST_PVS_R
Definition: q_shared.h:121
SOLID_BSP
@ SOLID_BSP
Definition: game.h:38
ss_game
@ ss_game
Definition: server.h:35
edict_s::maxs
vec3_t maxs
Definition: g_local.h:990
SV_InitGame
void SV_InitGame(void)
Definition: sv_init.c:289
SV_CreateAreaNode
areanode_t * SV_CreateAreaNode(int depth, vec3_t mins, vec3_t maxs)
Definition: sv_world.c:91
moveclip_t::mins2
vec3_t mins2
Definition: sv_world.c:470
entity_state_s::modelindex
int modelindex
Definition: q_shared.h:1152
SV_SendClientDatagram
qboolean SV_SendClientDatagram(client_t *client)
Definition: sv_send.c:395
Netchan_Transmit
void Netchan_Transmit(netchan_t *chan, int length, byte *data)
Definition: net_chan.c:213
server_t::state
server_state_t state
Definition: server.h:45
trace_t::ent
struct edict_s * ent
Definition: q_shared.h:462
sizebuf_s::cursize
int cursize
Definition: qcommon.h:98
SV_ImageIndex
int SV_ImageIndex(char *name)
Definition: sv_init.c:74
edict_s::num_clusters
int num_clusters
Definition: g_local.h:982
Netchan_OutOfBandPrint
void Netchan_OutOfBandPrint(int net_socket, netadr_t adr, char *format,...)
Definition: net_chan.c:132
Cvar_Set
cvar_t * Cvar_Set(char *var_name, char *value)
Definition: cvar.c:278
sv_paused
cvar_t * sv_paused
Definition: sv_main.c:27
RD_NONE
@ RD_NONE
Definition: server.h:242
Com_DPrintf
void Com_DPrintf(char *fmt,...)
Definition: common.c:157
Pmove
void Pmove(pmove_t *pmove)
Definition: pmove.c:1240
client_s
Definition: server.h:95
svc_packetentities
@ svc_packetentities
Definition: qcommon.h:244
FS_FreeFile
void FS_FreeFile(void *buffer)
Definition: files.c:437
moveclip_t
Definition: sv_world.c:466
edict_s::headnode
int headnode
Definition: g_local.h:984
pmove_state_t::origin
short origin[3]
Definition: q_shared.h:498
SCR_DebugGraph
void SCR_DebugGraph(float value, int color)
Definition: cl_scrn.c:137
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:104
MULTICAST_ALL
@ MULTICAST_ALL
Definition: q_shared.h:116
EDICT_NUM
#define EDICT_NUM(n)
Definition: server.h:69
svc_reconnect
@ svc_reconnect
Definition: qcommon.h:234
SND_ENT
#define SND_ENT
Definition: qcommon.h:304
SV_ShutdownGameProgs
void SV_ShutdownGameProgs(void)
Definition: sv_game.c:305
edict_s::area
link_t area
Definition: g_local.h:980
clc_stringcmd
@ clc_stringcmd
Definition: qcommon.h:260
areanode_s::children
struct areanode_s * children[2]
Definition: sv_world.c:45
server_t::configstrings
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
Definition: server.h:56
clc_move
@ clc_move
Definition: qcommon.h:258
Cvar_VariableString
char * Cvar_VariableString(char *var_name)
Definition: cvar.c:79
MSG_WriteDeltaEntity
void MSG_WriteDeltaEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, qboolean newentity)
Definition: common.c:483
mask
GLint GLuint mask
Definition: qgl_win.c:317
svc_sound
@ svc_sound
Definition: qcommon.h:235
CM_SetAreaPortalState
void CM_SetAreaPortalState(int portalnum, qboolean open)
Definition: cmodel.c:1653
SV_ServerStop_f
void SV_ServerStop_f(void)
Definition: sv_ccmds.c:970
ss_pic
@ ss_pic
Definition: server.h:38
PF_cprintf
void PF_cprintf(edict_t *ent, int level, char *fmt,...)
Definition: sv_game.c:84
SV_Loadgame_f
void SV_Loadgame_f(void)
Definition: sv_ccmds.c:594
edict_s::size
vec3_t size
Definition: g_local.h:991
server_static_t::demo_multicast
sizebuf_t demo_multicast
Definition: server.h:179
ss_loading
@ ss_loading
Definition: server.h:34
channel
Definition: jar_mod.h:142
SV_ClientThink
void SV_ClientThink(client_t *cl, usercmd_t *cmd)
Definition: sv_user.c:509
master_adr
netadr_t master_adr[MAX_MASTERS]
Definition: sv_main.c:23
area_type
int area_type
Definition: sv_world.c:59
svc_stufftext
@ svc_stufftext
Definition: qcommon.h:237
PF_WriteAngle
void PF_WriteAngle(float f)
Definition: sv_game.c:224
UPDATE_MASK
#define UPDATE_MASK
Definition: qcommon.h:209
entity_state_s::angles
vec3_t angles
Definition: q_shared.h:1150
RD_PACKET
@ RD_PACKET
Definition: server.h:242
cl
client_state_t cl
Definition: cl_main.c:91
CM_HeadnodeVisible
qboolean CM_HeadnodeVisible(int nodenum, byte *visbits)
Definition: cmodel.c:1748
MAX_ENT_CLUSTERS
#define MAX_ENT_CLUSTERS
Definition: game.h:49
SV_ModelIndex
int SV_ModelIndex(char *name)
Definition: sv_init.c:64
MAX_IMAGES
#define MAX_IMAGES
Definition: q_shared.h:91
max
#define max(a, b)
Definition: vk_local.h:75
MULTICAST_PVS
@ MULTICAST_PVS
Definition: q_shared.h:118
clc_nop
@ clc_nop
Definition: qcommon.h:257
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
edict_s::absmin
vec3_t absmin
Definition: g_local.h:991
server_t::name
char name[MAX_QPATH]
Definition: server.h:53
ss_dead
@ ss_dead
Definition: server.h:33
Sys_GetGameAPI
void * Sys_GetGameAPI(void *parms)
Definition: sys_win.c:502
CM_PointLeafnum
int CM_PointLeafnum(vec3_t p)
Definition: cmodel.c:826
svc_print
@ svc_print
Definition: qcommon.h:236
LATENCY_COUNTS
#define LATENCY_COUNTS
Definition: server.h:92
PF_WriteShort
void PF_WriteShort(int c)
Definition: sv_game.c:218
game_export_t::num_edicts
int num_edicts
Definition: game.h:231
server_static_t::demofile
FILE * demofile
Definition: server.h:178
PF_StartSound
void PF_StartSound(edict_t *entity, int channel, int sound_num, float volume, float attenuation, float timeofs)
Definition: sv_game.c:287
PF_Configstring
void PF_Configstring(int index, char *val)
Definition: sv_game.c:192
PF_WriteString
void PF_WriteString(char *s)
Definition: sv_game.c:221
Z_FreeTags
void Z_FreeTags(int tag)
Definition: common.c:1155
SV_BroadcastPrintf
void SV_BroadcastPrintf(int level, char *fmt,...)
Definition: sv_send.c:89
client_s::edict
edict_t * edict
Definition: server.h:114
Cvar_VariableValue
float Cvar_VariableValue(char *var_name)
Definition: cvar.c:63