Quake II RTX doxygen
1.0 dev
|
|
Go to the documentation of this file.
44 entity_packed_t *base, **chunk;
58 if ((
g_features->integer & GMF_PROPERINUSE) && !ent->inuse) {
79 if (base->solid != PACKED_BSP)
97 for (i = 0; i < MAX_CONFIGSTRINGS; i++,
string += MAX_QPATH) {
101 length = strlen(
string);
102 if (length > MAX_QPATH) {
112 MSG_WriteData(
string, length);
124 flags |= MSG_ES_SHORTANGLES;
133 entity_packed_t *base;
160 static void write_compressed_gamestate(
void)
163 entity_packed_t *base;
173 for (i = 0; i < MAX_CONFIGSTRINGS; i++,
string += MAX_QPATH) {
177 length = strlen(
string);
178 if (length > MAX_QPATH) {
183 MSG_WriteData(
string, length);
207 deflateReset(&
svs.z);
210 svs.z.next_out = buf->data + buf->cursize;
211 svs.z.avail_out = (uInt)(buf->maxsize - buf->cursize);
214 if (deflate(&
svs.z, Z_FINISH) != Z_STREAM_END) {
222 patch[0] =
svs.z.total_out & 255;
223 patch[1] = (
svs.z.total_out >> 8) & 255;
224 buf->cursize +=
svs.z.total_out;
227 static inline int z_flush(
byte *buffer)
231 ret = deflate(&
svs.z, Z_FINISH);
232 if (ret != Z_STREAM_END) {
242 MSG_WriteData(buffer,
svs.z.total_out);
249 static inline void z_reset(
byte *buffer)
251 deflateReset(&
svs.z);
252 svs.z.next_out = buffer;
256 static void write_compressed_configstrings(
void)
260 byte buffer[MAX_PACKETLEN_WRITABLE];
267 for (i = 0; i < MAX_CONFIGSTRINGS; i++,
string += MAX_QPATH) {
271 length = strlen(
string);
272 if (length > MAX_QPATH) {
277 if (
svs.z.avail_out < length + 32) {
279 if (z_flush(buffer) != Z_STREAM_END) {
287 MSG_WriteData(
string, length);
294 if (deflate(&
svs.z, Z_SYNC_FLUSH) != Z_OK) {
300 if (z_flush(buffer) != Z_STREAM_END) {
312 LIST_FOR_EACH(
stuffcmd_t, stuff, list, entry) {
314 MSG_WriteData(stuff->
string, stuff->
len);
323 static const char junkchars[] =
324 "!~#``&'()*`+,-./~01~2`3`4~5`67`89:~<=`>?@~ab~c"
325 "d`ef~j~k~lm`no~pq`rst`uv`w``x`yz[`\\]^_`|~";
329 for (i = 0; i < 8; i++) {
330 for (j = 0; j < 15; j++) {
331 k = rand_byte() % (
sizeof(junkchars) - 1);
332 junk[i][j] = junkchars[k];
342 if (rand_byte() & 1) {
373 Com_DPrintf(
"Going from cs_assigned to cs_connected for %s\n",
379 Com_DPrintf(
"New not valid -- already primed\n");
415 case PROTOCOL_VERSION_R1Q2:
421 case PROTOCOL_VERSION_Q2PRO:
442 "cmd \177c actoken $actoken\n"
454 Com_DPrintf(
"Going from cs_connected to cs_primed for %s\n",
466 write_compressed_gamestate();
469 write_compressed_configstrings();
494 Com_DPrintf(
"Begin not valid -- not yet primed\n");
499 Com_DPrintf(
"Begin not valid -- already spawned\n");
517 Com_DPrintf(
"Going from cs_primed to cs_spawned for %s\n",
581 char name[MAX_QPATH];
584 ssize_t downloadsize, maxdownloadsize, result;
591 if (len >= MAX_QPATH) {
596 if (!strcmp(name,
"http")) {
614 || strstr(name,
"..")
616 || !Q_ispath(name[0])
618 || !Q_ispath(name[len - 1])
620 || !strchr(name,
'/')) {
621 Com_DPrintf(
"Refusing download of %s to %s\n", name,
sv_client->
name);
625 if (FS_pathcmpn(name, CONST_STR_LEN(
"players/")) == 0) {
627 }
else if (FS_pathcmpn(name, CONST_STR_LEN(
"models/")) == 0 ||
628 FS_pathcmpn(name, CONST_STR_LEN(
"sprites/")) == 0) {
630 }
else if (FS_pathcmpn(name, CONST_STR_LEN(
"sound/")) == 0) {
632 }
else if (FS_pathcmpn(name, CONST_STR_LEN(
"maps/")) == 0) {
634 }
else if (FS_pathcmpn(name, CONST_STR_LEN(
"textures/")) == 0 ||
635 FS_pathcmpn(name, CONST_STR_LEN(
"env/")) == 0) {
637 }
else if (FS_pathcmpn(name, CONST_STR_LEN(
"pics/")) == 0) {
643 if (!allow->integer) {
644 Com_DPrintf(
"Refusing download of %s to %s\n", name,
sv_client->
name);
649 Com_DPrintf(
"Closing existing download for %s (should not happen)\n",
sv_client->
name);
654 downloadcmd = svc_download;
661 downloadsize =
FS_FOpenFile(name, &f, FS_MODE_READ | FS_FLAG_DEFLATE);
663 Com_DPrintf(
"Serving compressed download to %s\n",
sv_client->
name);
664 downloadcmd = svc_zdownload;
672 Com_DPrintf(
"Couldn't download %s to %s\n", name,
sv_client->
name);
677 maxdownloadsize = MAX_LOADFILE;
679 if (sv_max_download_size->integer) {
684 if (downloadsize == 0) {
685 Com_DPrintf(
"Refusing empty download of %s to %s\n", name,
sv_client->
name);
689 if (downloadsize > maxdownloadsize) {
690 Com_DPrintf(
"Refusing oversize download of %s to %s\n", name,
sv_client->
name);
694 if (offset > downloadsize) {
695 Com_DPrintf(
"Refusing download, %s has wrong version of %s (%d > %d)\n",
698 "Please delete the corresponding .tmp file from your system.\n");
702 if (offset == downloadsize) {
703 Com_DPrintf(
"Refusing download, %s already has %s (%d bytes)\n",
714 result =
FS_Read(download, downloadsize, f);
715 if (result != downloadsize) {
716 Com_DPrintf(
"Couldn't download %s to %s\n", name,
sv_client->
name);
729 Com_DPrintf(
"Downloading %s to %s\n", name,
sv_client->
name);
757 Com_DPrintf(
"Download of %s to %s stopped by user request\n",
768 char nextserver[MAX_QPATH];
770 Q_strlcpy(nextserver, v,
sizeof(nextserver));
805 char serverinfo[MAX_INFO_STRING];
844 "Lag stats for: %s\n"
845 "RTT (min/avg/max): %d/%d/%d ms\n"
846 "Server to client PL: %.2f%% (approx)\n"
847 "Client to server PL: %.2f%%\n",
853 static void SV_PacketdupHack_f(
void)
859 if (numdups < 0 || numdups > sv_packetdup_hack->integer) {
861 "Packetdup of %d is not allowed on this server.\n", numdups);
869 "Server is sending %d duplicate packet%s to you.\n",
870 numdups, numdups == 1 ?
"" :
"s");
879 if (!strcmp(
c,
"version")) {
888 }
else if (!strcmp(
c,
"connect")) {
894 }
else if (!strcmp(
c,
"actoken")) {
896 }
else if (!strcmp(
c,
"console")) {
924 {
"baselines", NULL },
925 {
"configstrings", NULL },
941 {
"packetdup", SV_PacketdupHack_f },
963 filter->
comment :
"issued banned command");
970 MSG_WriteData(filter->
comment, len);
996 if ((u = Com_Find(
ucmds,
c)) != NULL) {
1012 if (!Q_stricmp(filter->
string,
c)) {
1018 if (!strcmp(
c,
"say") || !strcmp(
c,
"say_team")) {
1051 Com_DPrintf(
"commandMsec underflow from %s: %d\n",
1056 if (cmd->buttons != old->buttons
1057 || cmd->forwardmove != old->forwardmove
1058 || cmd->sidemove != old->sidemove
1059 || cmd->upmove != old->upmove) {
1071 if (lastframe > 0) {
1075 if (lastframe <= sv_client->lastframe)
1081 if (frame->
number == lastframe) {
1102 usercmd_t oldest, oldcmd, newcmd;
1143 if (net_drop < 20) {
1145 while (net_drop > 2) {
1170 usercmd_t cmds[MAX_PACKET_FRAMES][MAX_PACKET_USERCMDS];
1171 usercmd_t *lastcmd, *cmd;
1173 int numCmds[MAX_PACKET_FRAMES], numDups;
1174 int i, j, lightlevel;
1184 numDups =
c >> SVCMD_BITS;
1187 if (numDups >= MAX_PACKET_FRAMES) {
1192 if (
c == clc_move_nodelta) {
1202 for (i = 0; i <= numDups; i++) {
1204 if (numCmds[i] == -1) {
1208 if (numCmds[i] >= MAX_PACKET_USERCMDS) {
1212 for (j = 0; j < numCmds[i]; j++) {
1219 cmd->lightlevel = lightlevel;
1231 if (q_unlikely(!lastcmd)) {
1236 if (net_drop > numDups) {
1240 if (net_drop < 20) {
1242 while (net_drop > numDups) {
1248 while (net_drop > 0) {
1249 i = numDups - net_drop;
1250 for (j = 0; j < numCmds[i]; j++) {
1259 for (j = 0; j < numCmds[numDups]; j++) {
1289 s[MAX_CLIENT_NAME - 1] = 0;
1316 Com_DPrintf(
"Too many userinfos from %s\n",
sv_client->
name);
1327 Com_DDPrintf(
"%s(%s): %s [%d]\n", __func__,
1336 char key[MAX_INFO_KEY], value[MAX_INFO_VALUE];
1341 Com_DPrintf(
"Too many userinfos from %s\n",
sv_client->
name);
1350 if (len >=
sizeof(key)) {
1356 if (len >=
sizeof(value)) {
1367 Com_DDPrintf(
"%s(%s): %s %s [%d]\n", __func__,
1372 Com_DPrintf(
"Too many userinfos from %s\n",
sv_client->
name);
1390 int framediv =
sv.framediv / client->framediv;
1391 int framenum =
sv.
framenum / client->framediv;
1392 int frameofs = framenum % framediv;
1393 int newnum = frameofs + Q_align(client->
framenum, framediv);
1395 Com_DPrintf(
"[%d] align %d --> %d (num = %d, div = %d, ofs = %d)\n",
1400 static void set_client_fps(
int value)
1402 int framediv, framerate;
1406 value =
sv.framerate;
1408 framediv = value / BASE_FRAMERATE;
1410 clamp(framediv, 1, MAX_FRAMEDIV);
1412 framediv =
sv.framediv / Q_gcd(
sv.framediv, framediv);
1413 framerate =
sv.framerate / framediv;
1415 Com_DPrintf(
"[%d] client div=%d, server div=%d, rate=%d\n",
1439 Com_DDPrintf(
"%s(%s): [%d] = %d\n", __func__,
sv_client->
name, idx, value);
1441 if (idx < 0 || idx >= CLS_MAX)
1448 set_client_fps(value);
1454 char buffer[MAX_STRING_CHARS];
1458 if (len >=
sizeof(buffer)) {
1465 Com_DPrintf(
"Too many stringcmds from %s\n",
sv_client->
name);
1469 Com_DDPrintf(
"%s(%s): %s\n", __func__,
sv_client->
name, buffer);
1507 switch (
c & SVCMD_MASK) {
1529 if (client->
protocol < PROTOCOL_VERSION_R1Q2)
1535 case clc_move_nodelta:
1536 case clc_move_batched:
1537 if (client->
protocol != PROTOCOL_VERSION_Q2PRO)
1543 case clc_userinfo_delta:
1544 if (client->
protocol != PROTOCOL_VERSION_Q2PRO)
static void SV_OldClientExecuteMove(void)
qboolean sv_pending_autosave
static qboolean moveIssued
#define SV_BASELINES_MASK
cvar_t * Cvar_Set(const char *var_name, const char *value)
static void SV_Disconnect_f(void)
static void SV_ParseClientSetting(void)
cvar_t * allow_download_players
char * NET_AdrToString(const netadr_t *a)
static void SV_StopDownload_f(void)
size_t Cvar_BitInfo(char *info, int bit)
#define SV_BASELINES_CHUNKS
qboolean Info_Validate(const char *s)
void SV_CloseDownload(client_t *client)
ssize_t FS_Read(void *buf, size_t len, qhandle_t f)
static void SV_ShowServerInfo_f(void)
static void write_baseline(entity_packed_t *base)
void MSG_ReadDeltaUsercmd_Enhanced(const usercmd_t *from, usercmd_t *to, int version)
static void SV_NoGameData_f(void)
cvar_t * sv_force_reconnect
void AC_ClientToken(client_t *cl, const char *token)
void MSG_ReadDeltaUsercmd(const usercmd_t *from, usercmd_t *to)
static int userinfoUpdateCount
#define SV_BASELINES_SHIFT
void SZ_WriteByte(sizebuf_t *sb, int c)
void SZ_WriteShort(sizebuf_t *sb, int c)
static void SV_NextServer_f(void)
void Cmd_TokenizeString(const char *text, qboolean macroExpand)
static void SV_NewClientExecuteMove(int c)
char * Cmd_RawArgsFrom(int from)
void MSG_WriteByte(int c)
void SV_ClientAddMessage(client_t *client, int flags)
static void stuff_junk(void)
void SV_UserinfoChanged(client_t *cl)
#define SV_AlignKeyFrames(client)
static void SV_SetLastFrame(int lastframe)
int MSG_ReadBits(int bits)
ssize_t FS_FOpenFile(const char *name, qhandle_t *f, unsigned mode)
void * SZ_GetSpace(sizebuf_t *buf, size_t len)
void MSG_PackEntity(entity_packed_t *out, const entity_state_t *in, qboolean short_angles)
cvar_t * allow_download_maps
cvar_t * allow_download_textures
void AC_ClientAnnounce(client_t *cl)
static void write_plain_configstrings(void)
static void handle_filtercmd(filtercmd_t *filter)
entity_packed_t * baselines[SV_BASELINES_CHUNKS]
static void SV_ParseDeltaUserinfo(void)
client_frame_t frames[UPDATE_BACKUP]
void Com_EndRedirect(void)
void Cbuf_AddText(cmdbuf_t *buf, const char *text)
char * Info_ValueForKey(const char *s, const char *key)
qboolean AC_ClientBegin(client_t *cl)
void MSG_WriteDeltaEntity(const entity_packed_t *from, const entity_packed_t *to, msgEsFlags_t flags)
static void SV_NextDownload_f(void)
void SV_ClientCommand(client_t *client, const char *fmt,...)
cvar_t * sv_allow_unconnected_cmds
int Cvar_VariableInteger(const char *var_name)
void SV_AutoSaveEnd(void)
size_t Q_strlcpy(char *dst, const char *src, size_t size)
static const ucmd_t ucmds[]
qboolean COM_IsWhite(const char *s)
void Info_Print(const char *infostring)
void MSG_WriteShort(int c)
void SV_DropClient(client_t *client, const char *reason)
static void SV_ShowMiscInfo_f(void)
void SV_PrintMiscInfo(void)
static void SV_ExecuteUserCommand(const char *s)
cvar_t * allow_download_sounds
static void SV_CvarResult_f(void)
static void SV_ParseClientCommand(void)
void MSG_WriteString(const char *string)
void MSG_ReadDeltaUsercmd_Hacked(const usercmd_t *from, usercmd_t *to)
cvar_t * allow_download_others
void MSG_WriteLong(int c)
static void write_plain_baselines(void)
#define Q2PRO_SHORTANGLES(c, e)
int Cvar_ClampInteger(cvar_t *var, int min, int max)
size_t MSG_ReadString(char *dest, size_t size)
static void SV_Lag_f(void)
void SV_ExecuteClientMessage(client_t *client)
cvar_t * allow_download_pics
size_t Cmd_ArgvBuffer(int arg, char *buffer, size_t size)
static void SV_AC_List_f(void)
void SV_ClientPrintf(client_t *client, int level, const char *fmt,...)
static void SV_AC_Info_f(void)
static void SV_BeginDownload_f(void)
char * Cvar_VariableString(const char *var_name)
void FS_FCloseFile(qhandle_t f)
cvar_t * allow_download_models
static void SV_UpdateUserinfo(void)
qboolean Info_SetValueForKey(char *s, const char *key, const char *value)
#define SV_BASELINES_PER_CHUNK
server_entity_t entities[MAX_EDICTS]
void SV_RemoveClient(client_t *client)
ratelimit_t ratelimit_namechange
char userinfo[MAX_INFO_STRING]
list_t sv_cmdlist_connect
qboolean SV_RateLimited(ratelimit_t *r)
static int stringCmdCount
size_t FS_NormalizePath(char *out, const char *in)
static void stuff_cmds(list_t *list)
static void create_baselines(void)
void SZ_Clear(sizebuf_t *buf)
#define SV_ClientRedirect()
client_t * SV_GetPlayer(const char *s, qboolean partial)
static void SV_ClientThink(usercmd_t *cmd)
char name[MAX_CLIENT_NAME]
static void SV_ParseFullUserinfo(void)