Allow UDP download from paks that are not numbered.

Until now the UDP download code prohibited downloading of maps from all
pak files. That was some kind of copy protection, without the limitation
demo users could download assets from the full version. Don't apply that
protection for all paks, but only for numbered .pak files.

This could be enhanced by limiting the protection to pak0 to pak2 for
baseq2 and pak0 for both xatrix and rogue.
This commit is contained in:
Yamagi Burmeister 2019-01-28 17:15:37 +01:00
parent 900d35ef27
commit 5ddab0e4bf
3 changed files with 19 additions and 8 deletions

View file

@ -70,6 +70,7 @@ typedef struct
int numFiles;
FILE *pak;
unzFile *pk3;
qboolean isProtectedPak;
fsPackFile_t *files;
} fsPack_t;
@ -107,7 +108,7 @@ fsPackTypes_t fs_packtypes[] = {
char datadir[MAX_OSPATH];
char fs_gamedir[MAX_OSPATH];
qboolean file_from_pak;
qboolean file_from_protected_pak;
cvar_t *fs_basedir;
cvar_t *fs_cddir;
@ -373,7 +374,7 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only)
fsSearchPath_t *search;
int i;
file_from_pak = false;
file_from_protected_pak = false;
handle = FS_HandleForFile(name, f);
Q_strlcpy(handle->name, name, sizeof(handle->name));
handle->mode = FS_READ;
@ -416,7 +417,11 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only)
if (pack->pak)
{
/* PAK */
file_from_pak = true;
if (pack->isProtectedPak)
{
file_from_protected_pak = true;
}
handle->file = Q_fopen(pack->name, "rb");
if (handle->file)
@ -428,7 +433,10 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only)
else if (pack->pk3)
{
/* PK3 */
file_from_pak = true;
if (pack->isProtectedPak)
{
file_from_protected_pak = true;
}
#ifdef _WIN32
handle->zip = unzOpen2(pack->name, &zlib_file_api);
@ -1430,9 +1438,12 @@ FS_AddDirToSearchPath(char *dir, qboolean create) {
{
case PAK:
pack = FS_LoadPAK(path);
pack->isProtectedPak = true;
break;
case PK3:
pack = FS_LoadPK3(path);
pack->isProtectedPak = false;
break;
}
@ -1485,6 +1496,8 @@ FS_AddDirToSearchPath(char *dir, qboolean create) {
continue;
}
pack->isProtectedPak = false;
search = Z_Malloc(sizeof(fsSearchPath_t));
search->pack = pack;
search->next = fs_searchPaths;

View file

@ -635,8 +635,6 @@ void Pmove(pmove_t *pmove);
#define SFF_INPACK 0x20
extern qboolean file_from_pak;
typedef int fileHandle_t;
typedef enum

View file

@ -296,7 +296,7 @@ SV_BeginDownload_f(void)
extern cvar_t *allow_download_models;
extern cvar_t *allow_download_sounds;
extern cvar_t *allow_download_maps;
extern qboolean file_from_pak;
extern qboolean file_from_protected_pak;
int offset = 0;
name = Cmd_Argv(1);
@ -343,7 +343,7 @@ SV_BeginDownload_f(void)
sv_client->downloadcount = sv_client->downloadsize;
}
if (!sv_client->download || ((strncmp(name, "maps/", 5) == 0) && file_from_pak))
if (!sv_client->download || ((strncmp(name, "maps/", 5) == 0) && file_from_protected_pak))
{
Com_DPrintf("Couldn't download %s to %s\n", name, sv_client->name);