Remove ZIP compile time option.

Having ZIP optional only complicates things and is unnecessary now that
the dependency to zlib is gone.
This commit is contained in:
Yamagi Burmeister 2018-08-14 11:12:38 +02:00
parent 0264c6d946
commit daf3dc6f41
5 changed files with 20 additions and 95 deletions

View file

@ -36,7 +36,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -fno-strict-aliasing -fwrap
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
# yquake2 compilation options # yquake2 compilation options
option(ZIP_SUPPORT "ZIP support" ON)
option(OPENAL_SUPPORT "OpenAL support" ON) option(OPENAL_SUPPORT "OpenAL support" ON)
option(SYSTEMWIDE_SUPPORT "Enable systemwide installation of game assets" OFF) option(SYSTEMWIDE_SUPPORT "Enable systemwide installation of game assets" OFF)
@ -75,6 +74,13 @@ if(${SYSTEMWIDE_SUPPORT})
add_definitions(-DSYSTEMWIDE) add_definitions(-DSYSTEMWIDE)
endif() endif()
# We need to pass some options to minizip / unzip
add_definitions(-DNOUNCRYPT)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DIOAPI_NO_64)
endif()
# Required libraries to build the different components of the binaries. Find # Required libraries to build the different components of the binaries. Find
# them and add the include/linker directories and flags (in case the package # them and add the include/linker directories and flags (in case the package
# manager find it in a weird place) # manager find it in a weird place)
@ -93,14 +99,6 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
list(APPEND yquake2ServerLinkerFlags ${EXECINFO_LIBRARIES}) list(APPEND yquake2ServerLinkerFlags ${EXECINFO_LIBRARIES})
endif() endif()
if(${ZIP_SUPPORT})
add_definitions(-DZIP -DNOUNCRYPT)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DIOAPI_NO_64)
endif()
endif()
if(${OPENAL_SUPPORT}) if(${OPENAL_SUPPORT})
find_package(OpenAL) find_package(OpenAL)

View file

@ -37,10 +37,6 @@ WITH_OPENAL:=yes
# is ignored, OpenAL is always loaded at runtime. # is ignored, OpenAL is always loaded at runtime.
DLOPEN_OPENAL:=yes DLOPEN_OPENAL:=yes
# Enables opening of ZIP files (also known as .pk3 paks).
# Adds a dependency to libz
WITH_ZIP:=yes
# Enable systemwide installation of game assets # Enable systemwide installation of game assets
WITH_SYSTEMWIDE:=no WITH_SYSTEMWIDE:=no
@ -206,6 +202,9 @@ ZIPCFLAGS += -DIOAPI_NO_64
endif endif
endif endif
# We don't support encrypted ZIP files.
ZIPCFLAGS += -DNOUNCRYPT
# ---------- # ----------
# Extra CFLAGS for SDL # Extra CFLAGS for SDL
@ -289,7 +288,6 @@ config:
@echo "Build configuration" @echo "Build configuration"
@echo "============================" @echo "============================"
@echo "WITH_OPENAL = $(WITH_OPENAL)" @echo "WITH_OPENAL = $(WITH_OPENAL)"
@echo "WITH_ZIP = $(WITH_ZIP)"
@echo "WITH_SYSTEMWIDE = $(WITH_SYSTEMWIDE)" @echo "WITH_SYSTEMWIDE = $(WITH_SYSTEMWIDE)"
@echo "WITH_SYSTEMDIR = $(WITH_SYSTEMDIR)" @echo "WITH_SYSTEMDIR = $(WITH_SYSTEMDIR)"
@echo "============================" @echo "============================"
@ -331,16 +329,12 @@ client:
build/client/%.o: %.c build/client/%.o: %.c
@echo "===> CC $<" @echo "===> CC $<"
${Q}mkdir -p $(@D) ${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $<
ifeq ($(WITH_OPENAL),yes) ifeq ($(WITH_OPENAL),yes)
release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' -DDLOPEN_OPENAL release/yquake2.exe : CFLAGS += -DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER='"openal32.dll"' -DDLOPEN_OPENAL
endif endif
ifeq ($(WITH_ZIP),yes)
release/yquake2.exe : CFLAGS += -DZIP -DNOUNCRYPT
endif
release/yquake2.exe : LDFLAGS += -mwindows release/yquake2.exe : LDFLAGS += -mwindows
else # not Windows else # not Windows
@ -353,7 +347,7 @@ client:
build/client/%.o: %.c build/client/%.o: %.c
@echo "===> CC $<" @echo "===> CC $<"
${Q}mkdir -p $(@D) ${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $<
ifeq ($(YQ2_OSTYPE), Darwin) ifeq ($(YQ2_OSTYPE), Darwin)
build/client/%.o : %.m build/client/%.o : %.m
@ -384,10 +378,6 @@ endif # Darwin
endif # !DLOPEN_OPENAL endif # !DLOPEN_OPENAL
endif # WITH_OPENAL endif # WITH_OPENAL
ifeq ($(WITH_ZIP),yes)
release/quake2 : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT
endif
ifeq ($(YQ2_OSTYPE), FreeBSD) ifeq ($(YQ2_OSTYPE), FreeBSD)
release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib' -lexecinfo release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib' -lexecinfo
else ifeq ($(YQ2_OSTYPE), Linux) else ifeq ($(YQ2_OSTYPE), Linux)
@ -423,14 +413,12 @@ server:
build/server/%.o: %.c build/server/%.o: %.c
@echo "===> CC $<" @echo "===> CC $<"
${Q}mkdir -p $(@D) ${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $< ${Q}$(CC) -c $(CFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $<
release/q2ded.exe : CFLAGS += -DDEDICATED_ONLY release/q2ded.exe : CFLAGS += -DDEDICATED_ONLY
ifeq ($(WITH_ZIP),yes)
release/q2ded.exe : CFLAGS += -DZIP -DNOUNCRYPT
endif
else # not Windows else # not Windows
server: server:
@echo "===> Building q2ded" @echo "===> Building q2ded"
${Q}mkdir -p release ${Q}mkdir -p release
@ -439,14 +427,10 @@ server:
build/server/%.o: %.c build/server/%.o: %.c
@echo "===> CC $<" @echo "===> CC $<"
${Q}mkdir -p $(@D) ${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $< ${Q}$(CC) -c $(CFLAGS) $(ZIPCFLAGS) $(INCLUDE) -o $@ $<
release/q2ded : CFLAGS += -DDEDICATED_ONLY -Wno-unused-result release/q2ded : CFLAGS += -DDEDICATED_ONLY -Wno-unused-result
ifeq ($(WITH_ZIP),yes)
release/q2ded : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT
endif
ifeq ($(YQ2_OSTYPE), FreeBSD) ifeq ($(YQ2_OSTYPE), FreeBSD)
release/q2ded : LDFLAGS += -lexecinfo release/q2ded : LDFLAGS += -lexecinfo
endif endif

View file

@ -35,10 +35,6 @@
// Screenshots // Screenshots
// ----------- // -----------
#ifdef ZIP
// If we build with zip support, zlib is available and
// we can use that for better PNG compression.
#include "../../common/unzip/miniz.h" #include "../../common/unzip/miniz.h"
static unsigned char* static unsigned char*
@ -64,8 +60,6 @@ compress_for_stbiw(unsigned char *data, int data_len, int *out_len, int quality)
} }
#define STBIW_ZLIB_COMPRESS compress_for_stbiw #define STBIW_ZLIB_COMPRESS compress_for_stbiw
#endif
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#include "header/stb_image_write.h" #include "header/stb_image_write.h"

View file

@ -27,12 +27,10 @@
#include "header/common.h" #include "header/common.h"
#include "header/glob.h" #include "header/glob.h"
#include "unzip/unzip.h"
#include "../client/sound/header/vorbis.h" #include "../client/sound/header/vorbis.h"
#ifdef ZIP
#include "unzip/unzip.h"
#endif
#define MAX_HANDLES 512 #define MAX_HANDLES 512
#define MAX_PAKS 100 #define MAX_PAKS 100
@ -48,9 +46,7 @@ typedef struct
char name[MAX_QPATH]; char name[MAX_QPATH];
fsMode_t mode; fsMode_t mode;
FILE *file; /* Only one will be used. */ FILE *file; /* Only one will be used. */
#ifdef ZIP
unzFile *zip; /* (file or zip) */ unzFile *zip; /* (file or zip) */
#endif
} fsHandle_t; } fsHandle_t;
typedef struct fsLink_s typedef struct fsLink_s
@ -73,9 +69,7 @@ typedef struct
char name[MAX_OSPATH]; char name[MAX_OSPATH];
int numFiles; int numFiles;
FILE *pak; FILE *pak;
#ifdef ZIP
unzFile *pk3; unzFile *pk3;
#endif
fsPackFile_t *files; fsPackFile_t *files;
} fsPack_t; } fsPack_t;
@ -89,9 +83,7 @@ typedef struct fsSearchPath_s
typedef enum typedef enum
{ {
PAK, PAK,
#ifdef ZIP
PK3 PK3
#endif
} fsPackFormat_t; } fsPackFormat_t;
typedef struct typedef struct
@ -108,11 +100,9 @@ fsSearchPath_t *fs_baseSearchPaths;
/* Pack formats / suffixes. */ /* Pack formats / suffixes. */
fsPackTypes_t fs_packtypes[] = { fsPackTypes_t fs_packtypes[] = {
{"pak", PAK}, {"pak", PAK},
#ifdef ZIP
{"pk2", PK3}, {"pk2", PK3},
{"pk3", PK3}, {"pk3", PK3},
{"zip", PK3} {"zip", PK3}
#endif
}; };
char datadir[MAX_OSPATH]; char datadir[MAX_OSPATH];
@ -140,7 +130,6 @@ fsRawPath_t *fs_rawPath;
// -------- // --------
#ifdef ZIP
#if _WIN32 #if _WIN32
/* /*
* We need some trickery to make minizip Unicode compatible... * We need some trickery to make minizip Unicode compatible...
@ -179,7 +168,6 @@ static voidpf ZCALLBACK fopen_file_func_utf(voidpf opaque, const char *filename,
return file; return file;
} }
#endif #endif
#endif
// -------- // --------
@ -316,11 +304,7 @@ FS_HandleForFile(const char *path, fileHandle_t *f)
for (i = 0; i < MAX_HANDLES; i++, handle++) for (i = 0; i < MAX_HANDLES; i++, handle++)
{ {
if ((handle->file == NULL) if ((handle->file == NULL) && (handle->zip == NULL))
#ifdef ZIP
&& (handle->zip == NULL)
#endif
)
{ {
Q_strlcpy(handle->name, path, sizeof(handle->name)); Q_strlcpy(handle->name, path, sizeof(handle->name));
*f = i + 1; *f = i + 1;
@ -367,13 +351,11 @@ FS_FCloseFile(fileHandle_t f)
{ {
fclose(handle->file); fclose(handle->file);
} }
#ifdef ZIP
else if (handle->zip) else if (handle->zip)
{ {
unzCloseCurrentFile(handle->zip); unzCloseCurrentFile(handle->zip);
unzClose(handle->zip); unzClose(handle->zip);
} }
#endif
memset(handle, 0, sizeof(*handle)); memset(handle, 0, sizeof(*handle));
} }
@ -443,7 +425,6 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only)
return pack->files[i].size; return pack->files[i].size;
} }
} }
#ifdef ZIP
else if (pack->pk3) else if (pack->pk3)
{ {
/* PK3 */ /* PK3 */
@ -468,7 +449,6 @@ FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only)
unzClose(handle->zip); unzClose(handle->zip);
} }
} }
#endif
Com_Error(ERR_FATAL, "Couldn't reopen '%s'", pack->name); Com_Error(ERR_FATAL, "Couldn't reopen '%s'", pack->name);
} }
@ -539,12 +519,10 @@ FS_Read(void *buffer, int size, fileHandle_t f)
{ {
r = fread(buf, 1, remaining, handle->file); r = fread(buf, 1, remaining, handle->file);
} }
#ifdef ZIP
else if (handle->zip) else if (handle->zip)
{ {
r = unzReadCurrentFile(handle->zip, buf, remaining); r = unzReadCurrentFile(handle->zip, buf, remaining);
} }
#endif
else else
{ {
return 0; return 0;
@ -607,12 +585,10 @@ FS_FRead(void *buffer, int size, int count, fileHandle_t f)
{ {
r = fread(buf, 1, remaining, handle->file); r = fread(buf, 1, remaining, handle->file);
} }
#ifdef ZIP
else if (handle->zip) else if (handle->zip)
{ {
r = unzReadCurrentFile(handle->zip, buf, remaining); r = unzReadCurrentFile(handle->zip, buf, remaining);
} }
#endif
else else
{ {
return 0; return 0;
@ -759,9 +735,7 @@ FS_LoadPAK(const char *packPath)
pack = Z_Malloc(sizeof(fsPack_t)); pack = Z_Malloc(sizeof(fsPack_t));
Q_strlcpy(pack->name, packPath, sizeof(pack->name)); Q_strlcpy(pack->name, packPath, sizeof(pack->name));
pack->pak = handle; pack->pak = handle;
#ifdef ZIP
pack->pk3 = NULL; pack->pk3 = NULL;
#endif
pack->numFiles = numFiles; pack->numFiles = numFiles;
pack->files = files; pack->files = files;
@ -770,7 +744,6 @@ FS_LoadPAK(const char *packPath)
return pack; return pack;
} }
#ifdef ZIP
/* /*
* Takes an explicit (not game tree related) path to a pack file. * Takes an explicit (not game tree related) path to a pack file.
* *
@ -844,7 +817,6 @@ FS_LoadPK3(const char *packPath)
return pack; return pack;
} }
#endif
/* /*
* Allows enumerating all of the directories in the search path. * Allows enumerating all of the directories in the search path.
@ -909,11 +881,7 @@ FS_Path_f(void)
for (i = 0, handle = fs_handles; i < MAX_HANDLES; i++, handle++) for (i = 0, handle = fs_handles; i < MAX_HANDLES; i++, handle++)
{ {
if ((handle->file != NULL) if ((handle->file != NULL) || (handle->zip != NULL))
#ifdef ZIP
|| (handle->zip != NULL)
#endif
)
{ {
Com_Printf("Handle %i: '%s'.\n", i + 1, handle->name); Com_Printf("Handle %i: '%s'.\n", i + 1, handle->name);
} }
@ -925,11 +893,8 @@ FS_Path_f(void)
} }
Com_Printf("----------------------\n"); Com_Printf("----------------------\n");
#ifdef ZIP
Com_Printf("%i files in PAK/PK2/PK3/ZIP files.\n", totalFiles); Com_Printf("%i files in PAK/PK2/PK3/ZIP files.\n", totalFiles);
#else
Com_Printf("%i files in PAK/PK2 files.\n", totalFiles);
#endif
} }
/* /*
@ -1371,11 +1336,9 @@ FS_AddDirToSearchPath(char *dir, qboolean create) {
case PAK: case PAK:
pack = FS_LoadPAK(path); pack = FS_LoadPAK(path);
break; break;
#ifdef ZIP
case PK3: case PK3:
pack = FS_LoadPK3(path); pack = FS_LoadPK3(path);
break; break;
#endif
} }
if (pack == NULL) if (pack == NULL)
@ -1417,11 +1380,9 @@ FS_AddDirToSearchPath(char *dir, qboolean create) {
case PAK: case PAK:
pack = FS_LoadPAK(list[j]); pack = FS_LoadPAK(list[j]);
break; break;
#ifdef ZIP
case PK3: case PK3:
pack = FS_LoadPK3(list[j]); pack = FS_LoadPK3(list[j]);
break; break;
#endif
} }
if (pack == NULL) if (pack == NULL)
@ -1505,12 +1466,10 @@ FS_BuildGameSpecificSearchPath(char *dir)
fclose(fs_searchPaths->pack->pak); fclose(fs_searchPaths->pack->pak);
} }
#ifdef ZIP
if (fs_searchPaths->pack->pk3) if (fs_searchPaths->pack->pk3)
{ {
unzClose(fs_searchPaths->pack->pk3); unzClose(fs_searchPaths->pack->pk3);
} }
#endif
Z_Free(fs_searchPaths->pack->files); Z_Free(fs_searchPaths->pack->files);
Z_Free(fs_searchPaths->pack); Z_Free(fs_searchPaths->pack);
@ -1524,12 +1483,7 @@ FS_BuildGameSpecificSearchPath(char *dir)
/* Close open files for game dir. */ /* Close open files for game dir. */
for (i = 0; i < MAX_HANDLES; i++) for (i = 0; i < MAX_HANDLES; i++)
{ {
if (strstr(fs_handles[i].name, dir) && if (strstr(fs_handles[i].name, dir) && ((fs_handles[i].file != NULL) || (fs_handles[i].zip != NULL)))
((fs_handles[i].file != NULL)
#ifdef ZIP
|| (fs_handles[i].zip != NULL)
#endif
))
{ {
FS_FCloseFile(i); FS_FCloseFile(i);
} }

View file

@ -107,11 +107,6 @@ Qcommon_Buildstring(void)
#else #else
printf(" - OpenAL audio\n"); printf(" - OpenAL audio\n");
#endif #endif
#ifdef ZIP
printf(" + Zip file support\n");
#else
printf(" - Zip file support\n");
#endif
#endif #endif
printf("Platform: %s\n", YQ2OSTYPE); printf("Platform: %s\n", YQ2OSTYPE);