Quake II RTX doxygen
1.0 dev
|
|
#include "client.h"
#include "format/md2.h"
#include "format/sp2.h"
Go to the source code of this file.
◆ check_file
#define check_file |
( |
|
path, |
|
|
|
type |
|
) |
| check_file_len(path, strlen(path), type) |
◆ CL_DOWNLOAD_IGNORES
#define CL_DOWNLOAD_IGNORES "download-ignores.txt" |
◆ precache_t
Enumerator |
---|
PRECACHE_MODELS | |
PRECACHE_OTHER | |
PRECACHE_MAP | |
PRECACHE_FINAL | |
Definition at line 29 of file download.c.
◆ check_file_len()
static qerror_t check_file_len |
( |
const char * |
path, |
|
|
size_t |
len, |
|
|
dltype_t |
type |
|
) |
| |
|
static |
Definition at line 510 of file download.c.
512 char buffer[MAX_QPATH], *
ext;
517 if (len >= MAX_QPATH)
518 return Q_ERR_NAMETOOLONG;
525 return Q_ERR_NAMETOOSHORT;
530 if (valid == PATH_INVALID
531 || !Q_ispath(buffer[0])
532 || !Q_ispath(buffer[len - 1])
533 || strstr(buffer,
"..")
534 || !strchr(buffer,
'/')) {
539 return Q_ERR_INVALID_PATH;
545 return Q_ERR_INVALID_PATH;
547 if (FS_FileExists(buffer))
551 if (valid == PATH_MIXED_CASE)
559 if (ret != Q_ERR_NOSYS)
564 if (ret == Q_ERR_SUCCESS)
Referenced by check_player(), and CL_RequestNextDownload().
◆ check_player()
static void check_player |
( |
const char * |
name | ) |
|
|
static |
Definition at line 666 of file download.c.
668 char fn[MAX_QPATH], model[MAX_QPATH], skin[MAX_QPATH], *p;
675 len =
Q_concat(fn,
sizeof(fn),
"players/", model,
"/tris.md2", NULL);
685 len =
Q_concat(fn,
sizeof(fn),
"players/", model,
"/weapon.pcx", NULL);
689 len =
Q_concat(fn,
sizeof(fn),
"players/", model,
"/", skin,
".pcx", NULL);
693 len =
Q_concat(fn,
sizeof(fn),
"players/", model,
"/", skin,
"_i.pcx", NULL);
702 len =
Q_concat(fn,
sizeof(fn),
"players/", model,
"/", p + 1, NULL);
Referenced by CL_RequestNextDownload().
◆ check_skins()
static void check_skins |
( |
const char * |
name | ) |
|
|
static |
Definition at line 573 of file download.c.
575 size_t i, num_skins, ofs_skins, end_skins;
578 dmd2header_t *md2header;
579 dsp2header_t *sp2header;
581 dsp2frame_t *sp2frame;
585 len = FS_LoadFile(name, (
void **)&model);
591 if (len <
sizeof(ident)) {
597 ident = LittleLong(*(uint32_t *)model);
601 md2header = (dmd2header_t *)model;
602 if (len <
sizeof(*md2header) ||
603 LittleLong(md2header->ident) != MD2_IDENT ||
604 LittleLong(md2header->version) != MD2_VERSION) {
609 num_skins = LittleLong(md2header->num_skins);
610 ofs_skins = LittleLong(md2header->ofs_skins);
611 end_skins = ofs_skins + num_skins * MD2_MAX_SKINNAME;
612 if (num_skins > MD2_MAX_SKINS || end_skins < ofs_skins || end_skins > len) {
617 md2skin = (
char *)model + ofs_skins;
618 for (i = 0; i < num_skins; i++) {
619 if (!
Q_memccpy(fn, md2skin, 0,
sizeof(fn))) {
624 md2skin += MD2_MAX_SKINNAME;
630 sp2header = (dsp2header_t *)model;
631 if (len <
sizeof(*sp2header) ||
632 LittleLong(sp2header->ident) != SP2_IDENT ||
633 LittleLong(sp2header->version) != SP2_VERSION) {
638 num_skins = LittleLong(sp2header->numframes);
639 ofs_skins =
sizeof(*sp2header);
640 end_skins = ofs_skins + num_skins *
sizeof(dsp2frame_t);
641 if (num_skins > SP2_MAX_FRAMES || end_skins < ofs_skins || end_skins > len) {
646 sp2frame = (dsp2frame_t *)(model + ofs_skins);
647 for (i = 0; i < num_skins; i++) {
648 if (!
Q_memccpy(fn, sp2frame->name, 0,
sizeof(fn))) {
Referenced by CL_RequestNextDownload().
◆ CL_CheckDownloadExtension()
qboolean CL_CheckDownloadExtension |
( |
const char * |
ext | ) |
|
Definition at line 494 of file download.c.
496 static const char allowed[][4] = {
497 "pcx",
"wal",
"wav",
"md2",
"sp2",
"tga",
"png",
498 "jpg",
"bsp",
"ent",
"txt",
"dm2",
"loc",
"md3"
502 for (i = 0; i < q_countof(allowed); i++)
503 if (!Q_stricmp(
ext, allowed[i]))
Referenced by check_and_queue_download(), and check_file_len().
◆ CL_CleanupDownloads()
◆ CL_Download_f()
Definition at line 909 of file download.c.
915 Com_Printf(
"Must be connected to a server.\n");
920 Com_Printf(
"Downloads are permanently disabled.\n");
925 Com_Printf(
"Usage: download <filename>\n");
933 Com_Printf(
"Couldn't download %s: %s\n", path,
Q_ErrorString(ret));
Referenced by CL_InitDownloads().
◆ CL_FinishDownload()
◆ CL_HandleDownload()
void CL_HandleDownload |
( |
byte * |
data, |
|
|
int |
size, |
|
|
int |
percent, |
|
|
int |
compressed |
|
) |
| |
Definition at line 424 of file download.c.
430 Com_Error(ERR_DROP,
"%s: no download requested", __func__);
446 Com_EPrintf(
"[UDP] Couldn't open %s for writing: %s\n",
461 if (percent != 100) {
476 Com_EPrintf(
"[UDP] Couldn't rename %s to %s: %s\n",
Referenced by CL_ParseDownload().
◆ CL_IgnoreDownload()
qboolean CL_IgnoreDownload |
( |
const char * |
path | ) |
|
◆ CL_InitDownloads()
◆ CL_LoadDownloadIgnores()
Definition at line 173 of file download.c.
175 string_entry_t *entry, *next;
176 char *raw, *data, *p;
191 if (len != Q_ERR_NOENT)
192 Com_EPrintf(
"Couldn't load %s: %s\n",
202 p = strchr(data,
'\n');
204 if (p > data && *(p - 1) ==
'\r')
210 if (*data && *data !=
'#' && *data !=
'/') {
212 if (len < MAX_QPATH) {
213 entry = Z_Malloc(
sizeof(*entry) + len);
214 memcpy(entry->string, data, len + 1);
219 Com_WPrintf(
"Oversize filter on line %d in %s\n",
Referenced by CL_Init(), and CL_RestartFilesystem().
◆ CL_QueueDownload()
qerror_t CL_QueueDownload |
( |
const char * |
path, |
|
|
dltype_t |
type |
|
) |
| |
◆ CL_RequestNextDownload()
Definition at line 735 of file download.c.
737 char fn[MAX_QPATH], *name;
761 for (i = 2; i < MAX_MODELS; i++) {
766 if (name[0] ==
'*' || name[0] ==
'#') {
780 Com_DPrintf(
"%s: waiting for models...\n", __func__);
784 for (i = 2; i < MAX_MODELS; i++) {
789 if (name[0] ==
'*' || name[0] ==
'#') {
797 for (i = 1; i < MAX_SOUNDS; i++) {
802 if (name[0] ==
'*') {
805 if (name[0] ==
'#') {
806 len =
Q_strlcpy(fn, name + 1,
sizeof(fn));
808 len =
Q_concat(fn,
sizeof(fn),
"sound/", name, NULL);
815 for (i = 1; i < MAX_IMAGES; i++) {
820 if (name[0] ==
'/' || name[0] ==
'\\') {
821 len =
Q_strlcpy(fn, name + 1,
sizeof(fn));
823 len =
Q_concat(fn,
sizeof(fn),
"pics/", name,
".pcx", NULL);
832 for (i = 1; i < MAX_SOUNDS; i++) {
838 for (i = 0; i < MAX_CLIENTS; i++) {
848 static const char env_suf[6][3] = {
849 "rt",
"bk",
"lf",
"ft",
"up",
"dn"
852 for (i = 0; i < 6; i++) {
864 Com_DPrintf(
"%s: waiting for map...\n", __func__);
872 for (i = 0; i <
cl.
bsp->numtexinfo; i++) {
873 len =
Q_concat(fn,
sizeof(fn),
"textures/",
cl.
bsp->texinfo[i].name,
".wal", NULL);
884 Com_DPrintf(
"%s: waiting for others...\n", __func__);
893 Com_Error(ERR_DROP,
"%s: bad precache_check\n", __func__);
Referenced by abort_downloads(), CL_Precache_f(), finish_download(), finish_udp_download(), and start_download().
◆ CL_ResetPrecacheCheck()
◆ CL_StartNextDownload()
◆ downloads_pending()
static qboolean downloads_pending |
( |
dltype_t |
type | ) |
|
|
static |
◆ finish_udp_download()
static void finish_udp_download |
( |
const char * |
msg | ) |
|
|
static |
◆ inflate_udp_download()
static int inflate_udp_download |
( |
byte * |
data, |
|
|
int |
inlen, |
|
|
int |
outlen |
|
) |
| |
|
static |
Definition at line 361 of file download.c.
365 #define CHUNK 0x10000
372 if (z->state == NULL && inflateInit2(z, -MAX_WBITS) != Z_OK)
373 Com_Error(ERR_FATAL,
"%s: inflateInit2() failed", __func__);
380 z->next_out = buffer;
381 z->avail_out = CHUNK;
383 ret = inflate(z, Z_SYNC_FLUSH);
384 if (ret != Z_OK && ret != Z_STREAM_END) {
385 Com_EPrintf(
"[UDP] inflate() failed: %s\n", z->msg);
390 Com_DDPrintf(
"%s: %u --> %u [%d]\n",
393 CHUNK - z->avail_out,
398 }
while (z->avail_out == 0);
401 if (outlen > 0 && outlen != z->total_out)
402 Com_WPrintf(
"[UDP] Decompressed length mismatch: %d != %lu\n", outlen, z->total_out);
405 if (ret == Z_STREAM_END)
411 Com_Error(ERR_DROP,
"Compressed server packet received, "
412 "but no zlib support linked in.");
Referenced by CL_HandleDownload().
◆ start_udp_download()
static qboolean start_udp_download |
( |
dlqueue_t * |
q | ) |
|
|
static |
Definition at line 236 of file download.c.
242 len = strlen(q->
path);
243 if (len >= MAX_QPATH) {
244 Com_Error(ERR_DROP,
"%s: oversize quake path", __func__);
260 Com_DPrintf(
"[UDP] Resuming %s\n", q->
path);
267 }
else if (ret == Q_ERR_NOENT) {
268 Com_DPrintf(
"[UDP] Downloading %s\n", q->
path);
276 Com_EPrintf(
"[UDP] Couldn't open %s for appending: %s\n",
Referenced by CL_StartNextDownload().
◆ write_udp_download()
static int write_udp_download |
( |
byte * |
data, |
|
|
int |
size |
|
) |
| |
|
static |
◆ precache_check
◆ precache_sexed_sounds
int precache_sexed_sounds[MAX_SOUNDS] |
|
static |
◆ precache_sexed_total
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
qboolean CL_IgnoreDownload(const char *path)
cvar_t * allow_download_players
#define FOR_EACH_DLQ_SAFE(q, n)
void Cmd_AddCommand(const char *name, xcommand_t function)
#define CL_DOWNLOAD_IGNORES
static precache_t precache_check
static void check_player(const char *name)
void HTTP_CleanupDownloads(void)
const char * Q_ErrorString(qerror_t error)
void CL_FinishDownload(dlqueue_t *q)
char weaponModels[MAX_CLIENTWEAPONMODELS][MAX_QPATH]
static void check_skins(const char *name)
static int inflate_udp_download(byte *data, int inlen, int outlen)
void CL_RegisterBspModels(void)
int FS_ValidatePath(const char *s)
ssize_t FS_FOpenFile(const char *name, qhandle_t *f, unsigned mode)
qboolean CL_CheckDownloadExtension(const char *ext)
void Com_Error(error_type_t type, const char *fmt,...)
cvar_t * allow_download_maps
cvar_t * allow_download_textures
void CL_ParsePlayerSkin(char *name, char *model, char *skin, const char *s)
static int write_udp_download(byte *data, int size)
static qboolean downloads_pending(dltype_t type)
static qerror_t check_file_len(const char *path, size_t len, dltype_t type)
char * va(const char *format,...)
size_t Q_strlcpy(char *dst, const char *src, size_t size)
static int precache_sexed_total
static int precache_sexed_sounds[MAX_SOUNDS]
ssize_t FS_Write(const void *buf, size_t len, qhandle_t f)
cvar_t * allow_download_sounds
qerror_t HTTP_QueueDownload(const char *path, dltype_t type)
void CL_RequestNextDownload(void)
void CL_StartNextDownload(void)
static void finish_udp_download(const char *msg)
struct client_static_s::@2 download
cvar_t * allow_download_pics
static void CL_Download_f(void)
qerror_t CL_QueueDownload(const char *path, dltype_t type)
void * Q_memccpy(void *dst, const void *src, int c, size_t size)
void CL_ClientCommand(const char *string)
void FS_FCloseFile(qhandle_t f)
size_t Q_concat(char *dest, size_t size,...)
cvar_t * allow_download_models
#define check_file(path, type)
static qboolean start_udp_download(dlqueue_t *q)
char * COM_FileExtension(const char *in)
size_t FS_NormalizePath(char *out, const char *in)