remove the magic numbers from the download protocol

This commit is contained in:
Bill Currie 2007-03-20 14:41:54 +00:00 committed by Jeff Teunissen
parent af20e26ded
commit ca37474f0d
3 changed files with 10 additions and 6 deletions

View file

@ -120,6 +120,10 @@
#define svc_updatepl 53 // [byte] [byte]
#define svc_nails2 54 // FIXME: from qwex. for interpolation, stores edict num
#define DL_NOFILE -1
#define DL_RENAME -2
#define DL_HTTP -3
// client to server ===========================================================
#define clc_bad 0

View file

@ -475,7 +475,7 @@ CL_ParseDownload (void)
return; // not in demo playback
}
if (size == -1) {
if (size == DL_NOFILE) {
Con_Printf ("File not found.\n");
if (cls.download) {
Con_Printf ("cls.download shouldn't have been set\n");
@ -488,7 +488,7 @@ CL_ParseDownload (void)
return;
}
if (size == -2) {
if (size == DL_RENAME) {
const char *newname = MSG_ReadString (net_message);
if (strncmp (newname, cls.downloadname->str,
@ -508,7 +508,7 @@ CL_ParseDownload (void)
Con_Printf ("downloading to %s\n", cls.downloadname->str);
return;
}
if (size == -3) {
if (size == DL_HTTP) {
#ifdef HAVE_LIBCURL
const char *url = MSG_ReadString (net_message);
const char *newname = MSG_ReadString (net_message);

View file

@ -765,7 +765,7 @@ SV_BeginDownload_f (void *unused)
SV_Printf ("Couldn't download %s to %s\n", name, host_client->name);
MSG_ReliableWrite_Begin (&host_client->backbuf, svc_download, 4);
MSG_ReliableWrite_Short (&host_client->backbuf, -1);
MSG_ReliableWrite_Short (&host_client->backbuf, DL_NOFILE);
MSG_ReliableWrite_Byte (&host_client->backbuf, 0);
dstring_delete (realname);
return;
@ -779,7 +779,7 @@ SV_BeginDownload_f (void *unused)
size = ren ? strlen (realname->str) * 2 : strlen (name);
size += strlen (sv_http_url_base->string) + 7;
MSG_ReliableWrite_Begin (&host_client->backbuf, svc_download, size);
MSG_ReliableWrite_Short (&host_client->backbuf, -3);
MSG_ReliableWrite_Short (&host_client->backbuf, DL_HTTP);
MSG_ReliableWrite_Byte (&host_client->backbuf, 0);
MSG_ReliableWrite_String (&host_client->backbuf,
va ("%s/%s", sv_http_url_base->string,
@ -791,7 +791,7 @@ SV_BeginDownload_f (void *unused)
SV_Printf ("download renamed to %s\n", realname->str);
MSG_ReliableWrite_Begin (&host_client->backbuf, svc_download,
strlen (realname->str) + 5);
MSG_ReliableWrite_Short (&host_client->backbuf, -2);
MSG_ReliableWrite_Short (&host_client->backbuf, DL_RENAME);
MSG_ReliableWrite_Byte (&host_client->backbuf, 0);
MSG_ReliableWrite_String (&host_client->backbuf, realname->str);
MSG_Reliable_FinishWrite (&host_client->backbuf);