1
0
Fork 0
forked from fte/fteqw

another stab at the demonum/sv_demodir junk

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2629 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2007-09-01 04:36:17 +00:00
parent c0b1291df8
commit 18518ea849

View file

@ -1889,10 +1889,9 @@ SV_BeginDownload_f
*/
void SV_BeginDownload_f(void)
{
char name[MAX_OSPATH];
char *name = Cmd_Argv(1);
extern cvar_t allow_download_anymap, allow_download_pakcontents;
Q_strncpyz(name, Cmd_Argv(1), sizeof(name));
extern cvar_t sv_demoDir;
if (ISNQCLIENT(host_client) && host_client->protocol != SCP_DARKPLACES7)
{
@ -1900,14 +1899,29 @@ void SV_BeginDownload_f(void)
return;
}
// MVD hacked junk
if (!strncmp(name, "demonum/", 8))
{
extern cvar_t sv_demoDir;
char *mvdname = SV_MVDNum(atoi(name+8));
char *mvdname;
if (ISQ2CLIENT(host_client))
{
Sys_Printf ("Rejected MVD download to %s (Q2 client)\n", mvdname, host_client->name);
ClientReliableWrite_Begin (host_client, svcq2_download, 4);
ClientReliableWrite_Short (host_client, -1);
ClientReliableWrite_Byte (host_client, 0);
}
mvdname = SV_MVDNum(atoi(name+8));
if (!mvdname)
{
Sys_Printf ("Couldn't download %s to %s\n", name, host_client->name);
SV_ClientPrintf (host_client, PRINT_HIGH, "%s is an invalid MVD demonum.\n", name+8);
Sys_Printf ("%s requested invalid demonum %s\n", host_client->name, name+8);
}
else
SV_ClientPrintf (host_client, PRINT_HIGH, "Sending demo %s...\n", mvdname);
// this is needed to cancel the current download
if (ISNQCLIENT(host_client))
{
ClientReliableWrite_Begin (host_client, svc_stufftext, 2+strlen(name));
@ -1925,14 +1939,19 @@ void SV_BeginDownload_f(void)
else
#endif
{
ClientReliableWrite_Begin (host_client, ISQ2CLIENT(host_client)?svcq2_download:svc_download, 4);
ClientReliableWrite_Begin (host_client, svc_download, 4);
ClientReliableWrite_Short (host_client, -1);
ClientReliableWrite_Byte (host_client, 0);
}
return;
}
snprintf(name, sizeof(name), "%s/%s", sv_demoDir.string, mvdname);
if (mvdname)
{
ClientReliableWrite_Begin (host_client, svc_stufftext, 16+strlen(mvdname));
ClientReliableWrite_String (host_client, "download demos/"); // 15
ClientReliableWrite_String (host_client, mvdname);
ClientReliableWrite_String (host_client, "\n"); // 1
}
return;
}
// hacked by zoid to allow more conrol over download
@ -1977,6 +1996,10 @@ void SV_BeginDownload_f(void)
*p = (char)tolower(*p);
}
// yet another hack for MVD junk
if (!strncmp(name, "demos/", 6))
host_client->download = FS_OpenVFS(va("%s/%s", sv_demoDir.string, name+6), "rb", FS_GAME);
else
host_client->download = FS_OpenVFS(name, "rb", FS_GAME);
host_client->downloadcount = 0;