Quake II RTX doxygen  1.0 dev
client.h File Reference
#include "../server.h"
#include <setjmp.h>

Go to the source code of this file.

Classes

struct  mvd_cs_s
 
struct  mvd_player_t
 
struct  mvd_client_t
 
struct  mvd_snap_t
 
struct  mvd_s
 

Macros

#define MVD_Malloc(size)   Z_TagMalloc(size, TAG_MVD)
 
#define MVD_Mallocz(size)   Z_TagMallocz(size, TAG_MVD)
 
#define MVD_CopyString(s)   Z_TagCopyString(s, TAG_MVD)
 
#define FOR_EACH_MVD(mvd)   LIST_FOR_EACH(mvd_t, mvd, &mvd_channel_list, entry)
 
#define FOR_EACH_MVDCL(cl, mvd)   LIST_FOR_EACH(mvd_client_t, cl, &(mvd)->clients, entry)
 
#define EDICT_MVDCL(ent)   ((mvd_client_t *)((ent)->client))
 
#define CS_NUM(c, n)   ((char *)(c) + (n) * MAX_QPATH)
 
#define MVD_InfoSet(var, val)   Cvar_FullSet(var, val, CVAR_SERVERINFO | CVAR_GAME, FROM_CODE)
 
#define MVD_FEATURES   (GMF_CLIENTNUM | GMF_PROPERINUSE | GMF_WANT_ALL_DISCONNECTS)
 
#define LAYOUT_MSEC   3000
 
#define FLOOD_SAMPLES   16
 
#define FLOOD_MASK   (FLOOD_SAMPLES - 1)
 
#define MAX_MVD_NAME   16
 

Typedefs

typedef struct mvd_cs_s mvd_cs_t
 
typedef struct mvd_s mvd_t
 

Enumerations

enum  mvd_layout_t {
  LAYOUT_NONE, LAYOUT_FOLLOW, LAYOUT_SCORES, LAYOUT_OLDSCORES,
  LAYOUT_MENU, LAYOUT_CLIENTS, LAYOUT_CHANNELS
}
 
enum  mvd_state_t { MVD_DEAD, MVD_WAITING, MVD_READING, MVD_NUM_STATES }
 

Functions

void MVD_Destroyf (mvd_t *mvd, const char *fmt,...) q_noreturn q_printf(2
 
void void MVD_Shutdown (void)
 
mvd_tMVD_SetChannel (int arg)
 
void MVD_File_g (genctx_t *ctx)
 
void MVD_Spawn (void)
 
void MVD_StopRecord (mvd_t *mvd)
 
void MVD_StreamedStop_f (void)
 
void MVD_StreamedRecord_f (void)
 
void MVD_Register (void)
 
int MVD_Frame (void)
 
qboolean MVD_ParseMessage (mvd_t *mvd)
 
void MVD_ParseEntityString (mvd_t *mvd, const char *data)
 
void MVD_ClearState (mvd_t *mvd, qboolean full)
 
void MVD_SwitchChannel (mvd_client_t *client, mvd_t *mvd)
 
void MVD_RemoveClient (client_t *client)
 
void MVD_BroadcastPrintf (mvd_t *mvd, int level, int mask, const char *fmt,...) q_printf(4
 
void void MVD_PrepWorldFrame (void)
 
void MVD_GameClientNameChanged (edict_t *ent, const char *name)
 
void MVD_GameClientDrop (edict_t *ent, const char *prefix, const char *reason)
 
void MVD_UpdateClients (mvd_t *mvd)
 
void MVD_FreePlayer (mvd_player_t *player)
 
void MVD_UpdateConfigstring (mvd_t *mvd, int index)
 
void MVD_SetPlayerNames (mvd_t *mvd)
 
void MVD_LinkEdict (mvd_t *mvd, edict_t *ent)
 

Variables

list_t mvd_channel_list
 
mvd_t mvd_waitingRoom
 
qboolean mvd_dirty
 
qboolean mvd_active
 
unsigned mvd_last_activity
 
jmp_buf mvd_jmpbuf
 
mvd_client_tmvd_clients
 

Macro Definition Documentation

◆ CS_NUM

#define CS_NUM (   c,
 
)    ((char *)(c) + (n) * MAX_QPATH)

Definition at line 33 of file client.h.

◆ EDICT_MVDCL

#define EDICT_MVDCL (   ent)    ((mvd_client_t *)((ent)->client))

Definition at line 32 of file client.h.

◆ FLOOD_MASK

#define FLOOD_MASK   (FLOOD_SAMPLES - 1)

Definition at line 54 of file client.h.

◆ FLOOD_SAMPLES

#define FLOOD_SAMPLES   16

Definition at line 53 of file client.h.

◆ FOR_EACH_MVD

#define FOR_EACH_MVD (   mvd)    LIST_FOR_EACH(mvd_t, mvd, &mvd_channel_list, entry)

Definition at line 26 of file client.h.

◆ FOR_EACH_MVDCL

#define FOR_EACH_MVDCL (   cl,
  mvd 
)    LIST_FOR_EACH(mvd_client_t, cl, &(mvd)->clients, entry)

Definition at line 29 of file client.h.

◆ LAYOUT_MSEC

#define LAYOUT_MSEC   3000

Definition at line 41 of file client.h.

◆ MAX_MVD_NAME

#define MAX_MVD_NAME   16

Definition at line 105 of file client.h.

◆ MVD_CopyString

#define MVD_CopyString (   s)    Z_TagCopyString(s, TAG_MVD)

Definition at line 24 of file client.h.

◆ MVD_FEATURES

#define MVD_FEATURES   (GMF_CLIENTNUM | GMF_PROPERINUSE | GMF_WANT_ALL_DISCONNECTS)

Definition at line 39 of file client.h.

◆ MVD_InfoSet

#define MVD_InfoSet (   var,
  val 
)    Cvar_FullSet(var, val, CVAR_SERVERINFO | CVAR_GAME, FROM_CODE)

Definition at line 35 of file client.h.

◆ MVD_Malloc

#define MVD_Malloc (   size)    Z_TagMalloc(size, TAG_MVD)

Definition at line 22 of file client.h.

◆ MVD_Mallocz

#define MVD_Mallocz (   size)    Z_TagMallocz(size, TAG_MVD)

Definition at line 23 of file client.h.

Typedef Documentation

◆ mvd_cs_t

typedef struct mvd_cs_s mvd_cs_t

◆ mvd_t

typedef struct mvd_s mvd_t

Enumeration Type Documentation

◆ mvd_layout_t

Enumerator
LAYOUT_NONE 
LAYOUT_FOLLOW 
LAYOUT_SCORES 
LAYOUT_OLDSCORES 
LAYOUT_MENU 
LAYOUT_CLIENTS 
LAYOUT_CHANNELS 

Definition at line 43 of file client.h.

43  {
44  LAYOUT_NONE, // no layout at all
45  LAYOUT_FOLLOW, // display chase target name
46  LAYOUT_SCORES, // layout of the MVD dummy
47  LAYOUT_OLDSCORES, // saved at intermission time
48  LAYOUT_MENU, // MVD main menu
49  LAYOUT_CLIENTS, // MVD clients list
50  LAYOUT_CHANNELS // MVD channel list
51 } mvd_layout_t;

◆ mvd_state_t

Enumerator
MVD_DEAD 
MVD_WAITING 
MVD_READING 
MVD_NUM_STATES 

Definition at line 107 of file client.h.

107  {
108  MVD_DEAD, // no gamestate received yet, unusable for observers
109  MVD_WAITING, // buffering more frames, stalled
110  MVD_READING, // reading frames
111 
113 } mvd_state_t;

Function Documentation

◆ MVD_BroadcastPrintf()

void MVD_BroadcastPrintf ( mvd_t mvd,
int  level,
int  mask,
const char *  fmt,
  ... 
)

◆ MVD_ClearState()

void MVD_ClearState ( mvd_t mvd,
qboolean  full 
)

Definition at line 856 of file parse.c.

857 {
858  mvd_player_t *player;
859  mvd_snap_t *snap, *next;
860  int i;
861 
862  // clear all entities, don't trust num_edicts as it is possible
863  // to miscount removed but seen entities
864  memset(mvd->edicts, 0, sizeof(mvd->edicts));
865  mvd->pool.num_edicts = 0;
866 
867  // clear all players
868  for (i = 0; i < mvd->maxclients; i++) {
869  player = &mvd->players[i];
870  MVD_FreePlayer(player);
871  memset(player, 0, sizeof(*player));
872  }
873 
874  mvd->numplayers = 0;
875 
876  if (!full)
877  return;
878 
879  // free all snapshots
880  LIST_FOR_EACH_SAFE(mvd_snap_t, snap, next, &mvd->snapshots, entry) {
881  Z_Free(snap);
882  }
883 
884  List_Init(&mvd->snapshots);
885 
886  // free current map
887  CM_FreeMap(&mvd->cm);
888 
889  if (mvd->intermission) {
890  // save oldscores
891  //strcpy(mvd->oldscores, mvd->layout);
892  }
893 
894  memset(mvd->configstrings, 0, sizeof(mvd->configstrings));
895  mvd->layout[0] = 0;
896 
897  mvd->framenum = 0;
898  // intermission flag will be cleared in MVD_ChangeLevel
899 }

Referenced by MVD_ParseServerData(), and MVD_Seek_f().

◆ MVD_Destroyf()

void MVD_Destroyf ( mvd_t mvd,
const char *  fmt,
  ... 
)

◆ MVD_File_g()

void MVD_File_g ( genctx_t *  ctx)

Definition at line 2406 of file client.c.

2407 {
2408  FS_File_g("demos", "*.mvd2;*.mvd2.gz", FS_SEARCH_SAVEPATH | FS_SEARCH_BYFILTER, ctx);
2409 }

Referenced by MVD_Play_c().

◆ MVD_Frame()

int MVD_Frame ( void  )

Definition at line 406 of file client.c.

407 {
408  gtv_t *gtv, *next;
409  int connections = 0;
410 
411  if (sv.state == ss_broadcast) {
412  set_mvd_active();
413  }
414 
415  // run all GTV connections (but not demos)
416  LIST_FOR_EACH_SAFE(gtv_t, gtv, next, &mvd_gtv_list, entry) {
417  if (setjmp(mvd_jmpbuf)) {
419  continue;
420  }
421 
422  gtv->run(gtv);
423 
424  connections++;
425  }
426 
427  return connections;
428 }

Referenced by SV_Frame().

◆ MVD_FreePlayer()

void MVD_FreePlayer ( mvd_player_t player)

Definition at line 1540 of file game.c.

1541 {
1542  mvd_cs_t *cs, *next;
1543 
1544  for (cs = player->configstrings; cs; cs = next) {
1545  next = cs->next;
1546  Z_Free(cs);
1547  }
1548  player->configstrings = NULL;
1549 }

Referenced by MVD_ClearState(), and MVD_Free().

◆ MVD_GameClientDrop()

void MVD_GameClientDrop ( edict_t *  ent,
const char *  prefix,
const char *  reason 
)

Definition at line 1934 of file game.c.

1935 {
1936  mvd_client_t *client = EDICT_MVDCL(ent);
1937  client_t *cl = client->cl;
1938 
1939  if (client->begin_time && MVD_PartFilter(client)) {
1940  MVD_BroadcastPrintf(client->mvd, PRINT_MEDIUM, UF_MUTE_MISC,
1941  "[MVD] %s%s%s\n", cl->name, prefix, reason);
1942  }
1943 
1944  client->begin_time = 0;
1945 }

Referenced by print_drop_reason().

◆ MVD_GameClientNameChanged()

void MVD_GameClientNameChanged ( edict_t *  ent,
const char *  name 
)

Definition at line 1922 of file game.c.

1923 {
1924  mvd_client_t *client = EDICT_MVDCL(ent);
1925  client_t *cl = client->cl;
1926 
1927  if (client->begin_time && MVD_PartFilter(client)) {
1928  MVD_BroadcastPrintf(client->mvd, PRINT_MEDIUM, UF_MUTE_MISC,
1929  "[MVD] %s changed name to %s\n", cl->name, name);
1930  }
1931 }

Referenced by SV_UserinfoChanged().

◆ MVD_LinkEdict()

void MVD_LinkEdict ( mvd_t mvd,
edict_t *  ent 
)

Definition at line 1652 of file game.c.

1653 {
1654  int index;
1655  mmodel_t *cm;
1656  bsp_t *cache = mvd->cm.cache;
1657 
1658  if (!cache) {
1659  return;
1660  }
1661 
1662  if (ent->s.solid == PACKED_BSP) {
1663  index = ent->s.modelindex;
1664  if (index < 1 || index > cache->nummodels) {
1665  Com_WPrintf("%s: entity %d: bad inline model index: %d\n",
1666  __func__, ent->s.number, index);
1667  return;
1668  }
1669  cm = &cache->models[index - 1];
1670  VectorCopy(cm->mins, ent->mins);
1671  VectorCopy(cm->maxs, ent->maxs);
1672  ent->solid = SOLID_BSP;
1673  } else if (ent->s.solid) {
1674  MSG_UnpackSolid16(ent->s.solid, ent->mins, ent->maxs);
1675  ent->solid = SOLID_BBOX;
1676  } else {
1677  VectorClear(ent->mins);
1678  VectorClear(ent->maxs);
1679  ent->solid = SOLID_NOT;
1680  }
1681 
1682  SV_LinkEdict(&mvd->cm, ent);
1683 }

Referenced by MVD_ParsePacketEntities(), MVD_PlayerToEntityStates(), and MVD_Seek_f().

◆ MVD_ParseEntityString()

void MVD_ParseEntityString ( mvd_t mvd,
const char *  data 
)

Definition at line 64 of file parse.c.

65 {
66  const char *p;
67  char key[MAX_STRING_CHARS];
68  char value[MAX_STRING_CHARS];
69  char classname[MAX_QPATH];
70  vec3_t origin;
71  vec3_t angles;
72 
73  while (data) {
74  p = COM_Parse(&data);
75  if (!p[0]) {
76  break;
77  }
78  if (p[0] != '{') {
79  Com_Error(ERR_DROP, "expected '{', found '%s'", p);
80  }
81 
82  classname[0] = 0;
83  VectorClear(origin);
84  VectorClear(angles);
85  while (1) {
86  p = COM_Parse(&data);
87  if (p[0] == '}') {
88  break;
89  }
90  if (p[0] == '{') {
91  Com_Error(ERR_DROP, "expected key, found '{'");
92  }
93 
94  Q_strlcpy(key, p, sizeof(key));
95 
96  p = COM_Parse(&data);
97  if (!data) {
98  Com_Error(ERR_DROP, "expected key/value pair, found EOF");
99  }
100  if (p[0] == '}' || p[0] == '{') {
101  Com_Error(ERR_DROP, "expected value, found '%s'", p);
102  }
103 
104  if (!strcmp(key, "classname")) {
105  Q_strlcpy(classname, p, sizeof(classname));
106  continue;
107  }
108 
109  Q_strlcpy(value, p, sizeof(value));
110 
111  p = value;
112  if (!strcmp(key, "origin")) {
113  origin[0] = atof(COM_Parse(&p));
114  origin[1] = atof(COM_Parse(&p));
115  origin[2] = atof(COM_Parse(&p));
116  } else if (!strncmp(key, "angle", 5)) {
117  if (key[5] == 0) {
118  angles[0] = 0;
119  angles[1] = atof(COM_Parse(&p));
120  angles[2] = 0;
121  } else if (key[5] == 's' && key[6] == 0) {
122  angles[0] = atof(COM_Parse(&p));
123  angles[1] = atof(COM_Parse(&p));
124  angles[2] = atof(COM_Parse(&p));
125  }
126  }
127  }
128 
129  if (!classname[0]) {
130  Com_Error(ERR_DROP, "entity with no classname");
131  }
132 
133  if (strncmp(classname, "info_player_", 12)) {
134  continue;
135  }
136 
137  if (!strcmp(classname + 12, "intermission")) {
138  VectorCopy(origin, mvd->spawnOrigin);
139  VectorCopy(angles, mvd->spawnAngles);
140  break;
141  }
142 
143  if (!strcmp(classname + 12, "start") ||
144  !strcmp(classname + 12, "deathmatch")) {
145  VectorCopy(origin, mvd->spawnOrigin);
146  VectorCopy(angles, mvd->spawnAngles);
147  }
148 
149  }
150 }

Referenced by MVD_GameInit(), and MVD_ParseServerData().

◆ MVD_ParseMessage()

qboolean MVD_ParseMessage ( mvd_t mvd)

Definition at line 1098 of file parse.c.

1099 {
1100  int cmd, extrabits;
1101  qboolean ret = qfalse;
1102 
1103 #ifdef _DEBUG
1104  if (mvd_shownet->integer == 1) {
1105  Com_Printf("%"PRIz" ", msg_read.cursize);
1106  } else if (mvd_shownet->integer > 1) {
1107  Com_Printf("------------------\n");
1108  }
1109 #endif
1110 
1111 //
1112 // parse the message
1113 //
1114  match_ended_hack = qfalse;
1115  while (1) {
1116  if (msg_read.readcount > msg_read.cursize) {
1117  MVD_Destroyf(mvd, "Read past end of message");
1118  }
1119  if (msg_read.readcount == msg_read.cursize) {
1120  SHOWNET(1, "%3"PRIz":END OF MESSAGE\n", msg_read.readcount - 1);
1121  break;
1122  }
1123 
1124  cmd = MSG_ReadByte();
1125  extrabits = cmd >> SVCMD_BITS;
1126  cmd &= SVCMD_MASK;
1127 
1128 #ifdef _DEBUG
1129  if (mvd_shownet->integer > 1) {
1130  MVD_ShowSVC(cmd);
1131  }
1132 #endif
1133 
1134  switch (cmd) {
1135  case mvd_serverdata:
1136  MVD_ParseServerData(mvd, extrabits);
1137  ret |= qtrue;
1138  break;
1139  case mvd_multicast_all:
1140  case mvd_multicast_pvs:
1141  case mvd_multicast_phs:
1142  case mvd_multicast_all_r:
1143  case mvd_multicast_pvs_r:
1144  case mvd_multicast_phs_r:
1145  MVD_ParseMulticast(mvd, cmd, extrabits);
1146  break;
1147  case mvd_unicast:
1148  case mvd_unicast_r:
1149  MVD_ParseUnicast(mvd, cmd, extrabits);
1150  break;
1151  case mvd_configstring:
1153  break;
1154  case mvd_frame:
1156  break;
1157  case mvd_sound:
1158  MVD_ParseSound(mvd, extrabits);
1159  break;
1160  case mvd_print:
1162  break;
1163  case mvd_nop:
1164  break;
1165  default:
1166  MVD_Destroyf(mvd, "Illegible command at %"PRIz": %d",
1167  msg_read.readcount - 1, cmd);
1168  }
1169  }
1170 
1171  return ret;
1172 }

Referenced by demo_play_next(), demo_read_frame(), gtv_read_frame(), MVD_Seek_f(), and parse_stream_data().

◆ MVD_PrepWorldFrame()

void void MVD_PrepWorldFrame ( void  )

Definition at line 2263 of file game.c.

2264 {
2265  mvd_t *mvd;
2266  edict_t *ent;
2267  int i;
2268 
2269  // reset events and old origins
2270  FOR_EACH_MVD(mvd) {
2271  for (i = 1; i < mvd->pool.num_edicts; i++) {
2272  ent = &mvd->edicts[i];
2273  if (!ent->inuse) {
2274  continue;
2275  }
2276  if (!(ent->s.renderfx & RF_BEAM)) {
2277  VectorCopy(ent->s.origin, ent->s.old_origin);
2278  }
2279  ent->s.event = 0;
2280  }
2281  }
2282 }

Referenced by SV_PrepWorldFrame().

◆ MVD_Register()

void MVD_Register ( void  )

Definition at line 2582 of file client.c.

2583 {
2584 #ifdef _DEBUG
2585  mvd_shownet = Cvar_Get("mvd_shownet", "0", 0);
2586 #endif
2587  mvd_timeout = Cvar_Get("mvd_timeout", "90", 0);
2588  mvd_suspend_time = Cvar_Get("mvd_suspend_time", "5", 0);
2589  mvd_wait_delay = Cvar_Get("mvd_wait_delay", "20", 0);
2590  mvd_wait_percent = Cvar_Get("mvd_wait_percent", "35", 0);
2591  mvd_buffer_size = Cvar_Get("mvd_buffer_size", "3", 0);
2592  mvd_username = Cvar_Get("mvd_username", "unnamed", 0);
2593  mvd_password = Cvar_Get("mvd_password", "", CVAR_PRIVATE);
2594  mvd_snaps = Cvar_Get("mvd_snaps", "10", 0);
2595 
2597 }

Referenced by SV_Init().

◆ MVD_RemoveClient()

void MVD_RemoveClient ( client_t client)

Definition at line 1685 of file game.c.

1686 {
1687  int index = client - svs.client_pool;
1688  mvd_client_t *cl = &mvd_clients[index];
1689 
1690  List_Remove(&cl->entry);
1691 
1692  memset(cl, 0, sizeof(*cl));
1693  cl->cl = client;
1694 }

Referenced by SV_RemoveClient().

◆ MVD_SetChannel()

mvd_t* MVD_SetChannel ( int  arg)

Definition at line 230 of file client.c.

231 {
232  char *s = Cmd_Argv(arg);
233  mvd_t *mvd;
234  int id;
235 
236  if (LIST_EMPTY(&mvd_channel_list)) {
237  Com_Printf("No active channels.\n");
238  return NULL;
239  }
240 
241  if (!*s) {
242  if (LIST_SINGLE(&mvd_channel_list)) {
243  return LIST_FIRST(mvd_t, &mvd_channel_list, entry);
244  }
245  Com_Printf("Please specify an exact channel ID.\n");
246  return NULL;
247  }
248 
249 #if USE_CLIENT
250  // special value of @@ returns the channel local client is on
251  if (!dedicated->integer && !strcmp(s, "@@")) {
252  if ((mvd = find_local_channel()) != NULL) {
253  return mvd;
254  }
255  } else
256 #endif
257  if (COM_IsUint(s)) {
258  id = atoi(s);
259  FOR_EACH_MVD(mvd) {
260  if (mvd->id == id) {
261  return mvd;
262  }
263  }
264  } else {
265  FOR_EACH_MVD(mvd) {
266  if (!strcmp(mvd->name, s)) {
267  return mvd;
268  }
269  }
270  }
271 
272  Com_Printf("No such channel ID: %s\n", s);
273  return NULL;
274 }

Referenced by MVD_Control_f(), MVD_Join_f(), MVD_Kill_f(), MVD_Pause_f(), MVD_Play_f(), MVD_Seek_f(), MVD_Skip_f(), MVD_StreamedRecord_f(), and MVD_StreamedStop_f().

◆ MVD_SetPlayerNames()

void MVD_SetPlayerNames ( mvd_t mvd)

Definition at line 1607 of file game.c.

1608 {
1609  int i;
1610 
1611  for (i = 0; i < mvd->maxclients; i++) {
1612  set_player_name(mvd, i);
1613  }
1614 }

Referenced by MVD_ParseServerData(), and MVD_Seek_f().

◆ MVD_Shutdown()

void void MVD_Shutdown ( void  )

Definition at line 2528 of file client.c.

2529 {
2530  gtv_t *gtv, *gtv_next;
2531  mvd_t *mvd, *mvd_next;
2532 
2533  // kill all GTV connections
2534  LIST_FOR_EACH_SAFE(gtv_t, gtv, gtv_next, &mvd_gtv_list, entry) {
2535  gtv->destroy(gtv);
2536  }
2537 
2538  // kill all MVD channels (including demo GTVs)
2539  LIST_FOR_EACH_SAFE(mvd_t, mvd, mvd_next, &mvd_channel_list, entry) {
2540  if (mvd->gtv) {
2541  mvd->gtv->mvd = NULL; // don't double destroy
2542  mvd->gtv->destroy(mvd->gtv);
2543  }
2544  MVD_Free(mvd);
2545  }
2546 
2547  List_Init(&mvd_gtv_list);
2548  List_Init(&mvd_channel_list);
2549 
2551  mvd_clients = NULL;
2552 
2553  mvd_chanid = 0;
2554 
2555  mvd_active = qfalse;
2556 
2557  Z_LeakTest(TAG_MVD);
2558 }

Referenced by MVD_GameShutdown(), and SV_Shutdown().

◆ MVD_Spawn()

void MVD_Spawn ( void  )

Definition at line 1653 of file client.c.

1654 {
1655  Cvar_SetInteger(sv_running, ss_broadcast, FROM_CODE);
1656  Cvar_Set("sv_paused", "0");
1657  Cvar_Set("timedemo", "0");
1658  SV_InfoSet("port", net_port->string);
1659 
1660 #if USE_SYSCON
1661  SV_SetConsoleTitle();
1662 #endif
1663 
1664  // generate spawncount for Waiting Room
1665  sv.spawncount = (rand() | (rand() << 16)) ^ Sys_Milliseconds();
1666  sv.spawncount &= 0x7FFFFFFF;
1667 
1668 #if USE_FPS
1669  // just fixed base FPS
1670  sv.framerate = BASE_FRAMERATE;
1671  sv.frametime = BASE_FRAMETIME;
1672  sv.framediv = 1;
1673 #endif
1674 
1675  // set externally visible server name
1677 
1678  sv.state = ss_broadcast;
1679 
1680  // start as inactive
1681  mvd_last_activity = INT_MIN;
1682  set_mvd_active();
1683 }

Referenced by MVD_ChangeLevel(), MVD_Spawn_f(), and parse_hello().

◆ MVD_StopRecord()

void MVD_StopRecord ( mvd_t mvd)

Definition at line 125 of file client.c.

126 {
127  uint16_t msglen;
128 
129  msglen = 0;
130  FS_Write(&msglen, 2, mvd->demorecording);
131 
132  FS_FCloseFile(mvd->demorecording);
133  mvd->demorecording = 0;
134 
135  Z_Free(mvd->demoname);
136  mvd->demoname = NULL;
137 }

Referenced by MVD_Free(), MVD_StreamedRecord_f(), MVD_StreamedStop_f(), and MVD_WriteDemoMessage().

◆ MVD_StreamedRecord_f()

void MVD_StreamedRecord_f ( void  )

Definition at line 1896 of file client.c.

1897 {
1898  char buffer[MAX_OSPATH];
1899  qhandle_t f;
1900  mvd_t *mvd;
1901  uint32_t magic;
1902  uint16_t msglen;
1903  unsigned mode = FS_MODE_WRITE;
1904  ssize_t ret;
1905  int c;
1906 
1907  while ((c = Cmd_ParseOptions(o_record)) != -1) {
1908  switch (c) {
1909  case 'h':
1910  Cmd_PrintUsage(o_record, "<filename> [chanid]");
1911  Com_Printf("Begin MVD recording on the specified channel.\n");
1913  return;
1914  case 'z':
1915  mode |= FS_FLAG_GZIP;
1916  break;
1917  default:
1918  return;
1919  }
1920  }
1921 
1922  if (!cmd_optarg[0]) {
1923  Com_Printf("Missing filename argument.\n");
1924  Cmd_PrintHint();
1925  return;
1926  }
1927 
1928  if ((mvd = MVD_SetChannel(cmd_optind + 1)) == NULL) {
1929  Cmd_PrintHint();
1930  return;
1931  }
1932 
1933  if (mvd->demorecording) {
1934  Com_Printf("[%s] Already recording into %s.\n",
1935  mvd->name, mvd->demoname);
1936  return;
1937  }
1938 
1939  //
1940  // open the demo file
1941  //
1942  f = FS_EasyOpenFile(buffer, sizeof(buffer), mode,
1943  "demos/", cmd_optarg, ".mvd2");
1944  if (!f) {
1945  return;
1946  }
1947 
1948  Com_Printf("[%s] Recording into %s\n", mvd->name, buffer);
1949 
1950  mvd->demorecording = f;
1951  mvd->demoname = MVD_CopyString(buffer);
1952 
1954 
1955  // write magic
1956  magic = MVD_MAGIC;
1957  ret = FS_Write(&magic, 4, f);
1958  if (ret != 4)
1959  goto fail;
1960 
1961  // write gamestate
1962  msglen = LittleShort(msg_write.cursize);
1963  ret = FS_Write(&msglen, 2, f);
1964  if (ret != 2)
1965  goto fail;
1966  ret = FS_Write(msg_write.data, msg_write.cursize, f);
1967  if (ret != msg_write.cursize)
1968  goto fail;
1969 
1970  SZ_Clear(&msg_write);
1971  return;
1972 
1973 fail:
1974  SZ_Clear(&msg_write);
1975  Com_EPrintf("[%s] Couldn't write demo: %s\n", mvd->name, Q_ErrorString(ret));
1977 }

◆ MVD_StreamedStop_f()

void MVD_StreamedStop_f ( void  )

Definition at line 1778 of file client.c.

1779 {
1780  mvd_t *mvd;
1781 
1782  mvd = MVD_SetChannel(1);
1783  if (!mvd) {
1784  Com_Printf("Usage: %s [chanid]\n", Cmd_Argv(0));
1785  return;
1786  }
1787 
1788  if (!mvd->demorecording) {
1789  Com_Printf("[%s] Not recording a demo.\n", mvd->name);
1790  return;
1791  }
1792 
1794 
1795  Com_Printf("[%s] Stopped recording.\n", mvd->name);
1796 }

◆ MVD_SwitchChannel()

void MVD_SwitchChannel ( mvd_client_t client,
mvd_t mvd 
)

Definition at line 765 of file game.c.

766 {
767  client_t *cl = client->cl;
768 
769  List_Remove(&client->entry);
770  List_SeqAdd(&mvd->clients, &client->entry);
771  client->mvd = mvd;
772  client->begin_time = 0;
773  client->target = NULL;
774  client->oldtarget = NULL;
775  client->chase_mask = 0;
776  client->chase_auto = 0;
777  client->chase_wait = 0;
778  memset(client->chase_bitmap, 0, sizeof(client->chase_bitmap));
780 
781  // needs to reconnect
783  MSG_WriteString(va("changing map=%s; reconnect\n", mvd->mapname));
786 }

Referenced by MVD_Destroy(), and MVD_TrySwitchChannel().

◆ MVD_UpdateClients()

void MVD_UpdateClients ( mvd_t mvd)

Definition at line 2175 of file game.c.

2176 {
2177  mvd_client_t *client;
2178 
2179  // check for intermission
2180  if (mvd_freeze_hack->integer && mvd->dummy) {
2181  if (!mvd->intermission) {
2182  if (mvd->dummy->ps.pmove.pm_type == PM_FREEZE) {
2184  }
2185  } else if (mvd->dummy->ps.pmove.pm_type != PM_FREEZE) {
2187  }
2188  } else if (mvd->intermission) {
2190  }
2191 
2192  // update UDP clients
2193  FOR_EACH_MVDCL(client, mvd) {
2194  if (client->cl->state == cs_spawned) {
2195  MVD_UpdateTarget(client);
2196  MVD_UpdateClient(client);
2197  MVD_NotifyClient(client);
2198  }
2199  }
2200 }

Referenced by MVD_ParseFrame(), and MVD_Seek_f().

◆ MVD_UpdateConfigstring()

void MVD_UpdateConfigstring ( mvd_t mvd,
int  index 
)

Definition at line 1616 of file game.c.

1617 {
1618  char *s = mvd->configstrings[index];
1619  mvd_client_t *client;
1620 
1621  if (index >= CS_PLAYERSKINS && index < CS_PLAYERSKINS + mvd->maxclients) {
1622  // update player name
1623  update_player_name(mvd, index - CS_PLAYERSKINS);
1624  } else if (index >= CS_GENERAL) {
1625  // reset unicast versions of this string
1626  reset_unicast_strings(mvd, index);
1627  }
1628 
1629  MSG_WriteByte(svc_configstring);
1630  MSG_WriteShort(index);
1631  MSG_WriteString(s);
1632 
1633  // broadcast configstring change
1634  FOR_EACH_MVDCL(client, mvd) {
1635  if (client->cl->state < cs_primed) {
1636  continue;
1637  }
1639  }
1640 
1641  SZ_Clear(&msg_write);
1642 }

Referenced by MVD_ParseConfigstring(), and MVD_Seek_f().

Variable Documentation

◆ mvd_active

qboolean mvd_active

Definition at line 105 of file client.c.

Referenced by check_timeouts(), MVD_LayoutChannels(), MVD_Shutdown(), and set_mvd_active().

◆ mvd_channel_list

◆ mvd_clients

mvd_client_t* mvd_clients

Definition at line 37 of file game.c.

Referenced by MVD_GameInit(), MVD_RemoveClient(), and MVD_Shutdown().

◆ mvd_dirty

qboolean mvd_dirty

◆ mvd_jmpbuf

jmp_buf mvd_jmpbuf

Definition at line 108 of file client.c.

Referenced by MVD_Destroyf(), MVD_Frame(), MVD_GameRunFrame(), MVD_Play_f(), MVD_Seek_f(), and q_printf().

◆ mvd_last_activity

unsigned mvd_last_activity

◆ mvd_waitingRoom

mvd_player_t::configstrings
mvd_cs_t * configstrings
Definition: client.h:66
mvd_channel_list
list_t mvd_channel_list
MVD_NUM_STATES
@ MVD_NUM_STATES
Definition: client.h:112
Cvar_Set
cvar_t * Cvar_Set(const char *var_name, const char *value)
Definition: cvar.c:466
FS_EasyOpenFile
qhandle_t FS_EasyOpenFile(char *buf, size_t size, unsigned mode, const char *dir, const char *name, const char *ext)
Definition: files.c:1846
mvd_layout_t
mvd_layout_t
Definition: client.h:43
set_player_name
static void set_player_name(mvd_t *mvd, int index)
Definition: game.c:1572
CM_FreeMap
void CM_FreeMap(cm_t *cm)
Definition: cmodel.c:47
mvd_snaps
static cvar_t * mvd_snaps
Definition: client.c:121
cs_spawned
@ cs_spawned
Definition: server.h:192
mvd_server_t::players
player_packed_t * players
Definition: mvd.c:69
mvd_client_t::chase_bitmap
byte chase_bitmap[MAX_CLIENTS/CHAR_BIT]
Definition: client.h:90
msg_read
sizebuf_t msg_read
Definition: msg.c:37
mvd_last_activity
unsigned mvd_last_activity
Definition: client.c:106
mvd_waitingRoom
mvd_t mvd_waitingRoom
Definition: client.c:101
c_mvd
static const cmdreg_t c_mvd[]
Definition: client.c:2560
svs
server_static_t svs
Definition: init.c:21
cmd_optarg
char * cmd_optarg
Definition: cmd.c:848
mvd_client_t::begin_time
unsigned begin_time
Definition: client.h:81
match_ended_hack
static qboolean match_ended_hack
Definition: parse.c:26
MVD_DEAD
@ MVD_DEAD
Definition: client.h:108
MVD_SetChannel
mvd_t * MVD_SetChannel(int arg)
Definition: client.c:230
maxclients
cvar_t * maxclients
Definition: g_main.c:42
LAYOUT_CHANNELS
@ LAYOUT_CHANNELS
Definition: client.h:50
MVD_PartFilter
static qboolean MVD_PartFilter(mvd_client_t *client)
Definition: game.c:788
MVD_StopRecord
void MVD_StopRecord(mvd_t *mvd)
Definition: client.c:125
Cvar_Get
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
Definition: cvar.c:257
Q_ErrorString
const char * Q_ErrorString(qerror_t error)
Definition: error.c:51
mvd_client_t::chase_mask
int chase_mask
Definition: client.h:87
Z_LeakTest
void Z_LeakTest(memtag_t tag)
Definition: zone.c:120
mvd_clients
mvd_client_t * mvd_clients
Definition: game.c:37
client_s::state
clstate_t state
Definition: server.h:260
MSG_CLEAR
#define MSG_CLEAR
Definition: server.h:215
gtv_s
Definition: client.c:46
MSG_RELIABLE
#define MSG_RELIABLE
Definition: server.h:214
MVD_UpdateTarget
static void MVD_UpdateTarget(mvd_client_t *client)
Definition: game.c:598
set_mvd_active
static void set_mvd_active(void)
Definition: client.c:376
MVD_SetServerState
static void MVD_SetServerState(client_t *cl, mvd_t *mvd)
Definition: game.c:753
mvd_freeze_hack
static cvar_t * mvd_freeze_hack
Definition: game.c:34
LAYOUT_SCORES
@ LAYOUT_SCORES
Definition: client.h:46
mvd_password
static cvar_t * mvd_password
Definition: client.c:120
mvd_snap_t
Definition: client.h:115
mvd_client_t::entry
list_t entry
Definition: client.h:76
cmd_optind
int cmd_optind
Definition: cmd.c:847
Cmd_PrintUsage
void Cmd_PrintUsage(const cmd_option_t *opt, const char *suffix)
Definition: cmd.c:1143
SV_InfoSet
#define SV_InfoSet(var, val)
Definition: server.h:73
LAYOUT_CLIENTS
@ LAYOUT_CLIENTS
Definition: client.h:49
SHOWNET
#define SHOWNET(...)
Definition: parse.c:61
FOR_EACH_MVD
#define FOR_EACH_MVD(mvd)
Definition: client.h:26
MSG_WriteByte
void MSG_WriteByte(int c)
Definition: msg.c:107
Cmd_Argv
char * Cmd_Argv(int arg)
Definition: cmd.c:899
svc_stufftext
#define svc_stufftext
Definition: g_local.h:41
Sys_Milliseconds
unsigned Sys_Milliseconds(void)
Definition: system.c:644
LAYOUT_FOLLOW
@ LAYOUT_FOLLOW
Definition: client.h:45
SV_ClientAddMessage
void SV_ClientAddMessage(client_t *client, int flags)
Definition: send.c:399
MVD_ParseServerData
static void MVD_ParseServerData(mvd_t *mvd, int extrabits)
Definition: parse.c:936
mvd_client_t::mvd
struct mvd_s * mvd
Definition: client.h:77
gtv_s::run
void(* run)(struct gtv_s *)
Definition: client.c:56
MVD_ParseMulticast
static void MVD_ParseMulticast(mvd_t *mvd, mvd_ops_t op, int extrabits)
Definition: parse.c:152
Com_Error
void Com_Error(error_type_t type, const char *fmt,...)
Definition: g_main.c:258
mvd_username
static cvar_t * mvd_username
Definition: client.c:119
dedicated
cvar_t * dedicated
Definition: g_main.c:46
mvd_s
Definition: client.h:127
mvd_active
qboolean mvd_active
Definition: client.c:105
sv
server_t sv
Definition: init.c:22
mvd
static mvd_server_t mvd
Definition: mvd.c:81
Cmd_ParseOptions
int Cmd_ParseOptions(const cmd_option_t *opt)
Definition: cmd.c:1057
msg_write
sizebuf_t msg_write
Definition: msg.c:34
mvd_client_t::target
mvd_player_t * target
Definition: client.h:85
net_port
cvar_t * net_port
Definition: net.c:88
mvd_state_t
mvd_state_t
Definition: client.h:107
va
char * va(const char *format,...)
Definition: shared.c:429
FS_File_g
void FS_File_g(const char *path, const char *ext, unsigned flags, genctx_t *ctx)
Definition: files.c:2954
Z_Free
void Z_Free(void *ptr)
Definition: zone.c:147
mvd_buffer_size
static cvar_t * mvd_buffer_size
Definition: client.c:118
server_static_s::client_pool
client_t * client_pool
Definition: server.h:456
mvd_chanid
int mvd_chanid
Definition: client.c:103
mvd_timeout
static cvar_t * mvd_timeout
Definition: client.c:114
Cmd_Register
void Cmd_Register(const cmdreg_t *reg)
Definition: cmd.c:1572
mvd_s::mapname
char mapname[MAX_QPATH]
Definition: client.h:153
MVD_ParseUnicast
static void MVD_ParseUnicast(mvd_t *mvd, mvd_ops_t op, int extrabits)
Definition: parse.c:413
origin
static vec3_t origin
Definition: mesh.c:27
LAYOUT_NONE
@ LAYOUT_NONE
Definition: client.h:44
emit_gamestate
static void emit_gamestate(mvd_t *mvd)
Definition: client.c:1856
Q_strlcpy
size_t Q_strlcpy(char *dst, const char *src, size_t size)
Definition: shared.c:715
mvd_client_t::oldtarget
mvd_player_t * oldtarget
Definition: client.h:86
MVD_BroadcastPrintf
void MVD_BroadcastPrintf(mvd_t *mvd, int level, int mask, const char *fmt,...)
Definition: game.c:707
mvd_client_t::cl
client_t * cl
Definition: client.h:78
MSG_WriteShort
void MSG_WriteShort(int c)
Definition: msg.c:125
Cvar_SetInteger
void Cvar_SetInteger(cvar_t *var, int value, from_t from)
Definition: cvar.c:509
SV_LinkEdict
void SV_LinkEdict(cm_t *cm, edict_t *ent)
Definition: world.c:156
MVD_WAITING
@ MVD_WAITING
Definition: client.h:109
EDICT_MVDCL
#define EDICT_MVDCL(ent)
Definition: client.h:32
mvd_client_t
Definition: client.h:69
MVD_NotifyClient
static void MVD_NotifyClient(mvd_client_t *client)
Definition: game.c:2149
o_record
static const cmd_option_t o_record[]
Definition: demo.c:299
MVD_Free
static void MVD_Free(mvd_t *mvd)
Definition: client.c:139
gtv_s::destroy
void(* destroy)(struct gtv_s *)
Definition: client.c:55
FOR_EACH_MVDCL
#define FOR_EACH_MVDCL(cl, mvd)
Definition: client.h:29
MVD_READING
@ MVD_READING
Definition: client.h:110
LAYOUT_MENU
@ LAYOUT_MENU
Definition: client.h:48
cl
client_state_t cl
Definition: main.c:99
FS_Write
ssize_t FS_Write(const void *buf, size_t len, qhandle_t f)
Definition: files.c:1643
mvd_cs_s
Definition: client.h:56
mvd_server_t::dummy
client_t * dummy
Definition: mvd.c:57
reset_unicast_strings
static void reset_unicast_strings(mvd_t *mvd, int index)
Definition: game.c:1551
mvd_client_t::chase_auto
qboolean chase_auto
Definition: client.h:88
mvd_jmpbuf
jmp_buf mvd_jmpbuf
Definition: client.c:108
COM_IsUint
qboolean COM_IsUint(const char *s)
Definition: shared.c:330
mvd_wait_percent
static cvar_t * mvd_wait_percent
Definition: client.c:117
MSG_WriteString
void MSG_WriteString(const char *string)
Definition: msg.c:160
c
statCounters_t c
Definition: main.c:30
MVD_UpdateClient
static void MVD_UpdateClient(mvd_client_t *client)
Definition: game.c:649
MVD_ParseConfigstring
static void MVD_ParseConfigstring(mvd_t *mvd)
Definition: parse.c:619
mvd_client_t::chase_wait
qboolean chase_wait
Definition: client.h:89
mvd_player_t
Definition: client.h:62
MVD_IntermissionStart
static void MVD_IntermissionStart(mvd_t *mvd)
Definition: game.c:2093
mvd_cs_s::next
struct mvd_cs_s * next
Definition: client.h:57
LAYOUT_OLDSCORES
@ LAYOUT_OLDSCORES
Definition: client.h:47
Cmd_PrintHelp
void Cmd_PrintHelp(const cmd_option_t *opt)
Definition: cmd.c:1160
cs_primed
@ cs_primed
Definition: server.h:191
Cmd_PrintHint
void Cmd_PrintHint(void)
Definition: cmd.c:1178
server_t::state
server_state_t state
Definition: server.h:146
update_player_name
static void update_player_name(mvd_t *mvd, int index)
Definition: game.c:1586
client_s
Definition: server.h:256
MVD_IntermissionStop
static void MVD_IntermissionStop(mvd_t *mvd)
Definition: game.c:2121
MVD_ParseFrame
static void MVD_ParseFrame(mvd_t *mvd)
Definition: parse.c:817
COM_Parse
char * COM_Parse(const char **data_p)
Definition: shared.c:455
sv_running
cvar_t * sv_running
Definition: common.c:95
MVD_FreePlayer
void MVD_FreePlayer(mvd_player_t *player)
Definition: game.c:1540
FS_FCloseFile
void FS_FCloseFile(qhandle_t f)
Definition: files.c:759
MSG_ReadByte
int MSG_ReadByte(void)
Definition: msg.c:1475
server_t::spawncount
int spawncount
Definition: server.h:147
MVD_CopyString
#define MVD_CopyString(s)
Definition: client.h:24
mvd_wait_delay
static cvar_t * mvd_wait_delay
Definition: client.c:116
mvd_suspend_time
static cvar_t * mvd_suspend_time
Definition: client.c:115
server_t::name
char name[MAX_QPATH]
Definition: server.h:160
MVD_Destroyf
void MVD_Destroyf(mvd_t *mvd, const char *fmt,...)
Definition: client.c:191
MVD_ParseSound
static void MVD_ParseSound(mvd_t *mvd, int extrabits)
Definition: parse.c:487
SZ_Clear
void SZ_Clear(sizebuf_t *buf)
Definition: sizebuf.c:40
mvd_server_t::clients
gtv_client_t * clients
Definition: mvd.c:78
SV_ClientReset
void SV_ClientReset(client_t *client)
Definition: init.c:24
mvd_clients
mvd_client_t * mvd_clients
Definition: game.c:37
MVD_ParsePrint
static void MVD_ParsePrint(mvd_t *mvd)
Definition: parse.c:645