diff --git a/CMakeLists.txt b/CMakeLists.txt index b0fc15410..3708d3590 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,14 +127,17 @@ ELSE() SET(SYS_LIBS ${SYS_LIBS}) ENDIF() -FIND_PACKAGE(ZLIB) +SET(FTE_DEP_ZLIB true CACHE BOOL "Link against zlib.") +IF(FTE_DEP_ZLIB) + FIND_PACKAGE(ZLIB) +ENDIF() IF(ZLIB_FOUND) SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};ZLIB_STATIC) SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES}) SET(FTESV_LIBS ${FTESV_LIBS} ${ZLIB_LIBRARIES}) SET(FTEQCC_LIBS ${FTEQCC_LIBS} ${ZLIB_LIBRARIES}) ELSE() - MESSAGE(WARNING "libz library NOT available. compressed pk3 will not be available.") + MESSAGE(WARNING "libz library NOT available. compressed pk3, ICE, Q2E, etc etc, yada yada, blah blah will not be available.") SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_ZLIB) ENDIF() diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index ea2632617..bb1437a4a 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1927,14 +1927,7 @@ void CL_SendDownloadReq(sizebuf_t *msg) } #ifdef PEXT_ZLIBDL -#ifdef _WIN32 -#define ZEXPORT VARGS -#include "../../zip/zlib.h" - -//# pragma comment (lib, "zip/zlib.lib") -#else #include -#endif static char *ZLibDownloadDecode(int *messagesize, char *input, int finalsize) { diff --git a/engine/common/common.c b/engine/common/common.c index 3fa2eb4f1..0ad2b75b5 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -40,20 +40,11 @@ fte_inlinebody float M_LinearToSRGB(float x, float mag); // These 4 libraries required for the version command -#if defined(_MSC_VER) - #ifdef AVAIL_ZLIB - #include "zlib.h" - #endif - #ifdef FTE_SDL - #include - #endif -#else - #ifdef AVAIL_ZLIB - #include - #endif - #ifdef FTE_SDL - #include - #endif +#ifdef AVAIL_ZLIB + #include +#endif +#ifdef FTE_SDL + #include #endif const usercmd_t nullcmd; // guarenteed to be zero diff --git a/engine/common/net_ice.c b/engine/common/net_ice.c index 0a1576aec..a31d9ad76 100644 --- a/engine/common/net_ice.c +++ b/engine/common/net_ice.c @@ -98,7 +98,7 @@ typedef struct unsigned short attrtype; unsigned short attrlen; } stunattr_t; -#if defined(SUPPORT_ICE) || defined(MASTERONLY) +#if defined(SUPPORT_ICE) || (defined(MASTERONLY) && defined(AVAIL_ZLIB)) #include "zlib.h" #endif #ifdef SUPPORT_ICE @@ -4054,7 +4054,7 @@ qboolean SCTP_Handshake(const dtlsfuncs_t *dtlsfuncs, void *dtlsstate, sctp_t ** //======================================== #endif -#if defined(SUPPORT_ICE) || defined(MASTERONLY) +#if defined(SUPPORT_ICE) || (defined(MASTERONLY) && defined(AVAIL_ZLIB)) qboolean ICE_WasStun(ftenet_connections_t *col) { #ifdef SUPPORT_ICE diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index a3c418cb4..30123137d 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -4656,8 +4656,10 @@ static void * NET_KexLobby_CreateContext(const dtlscred_t *credinfo, void *cbctx return peer; } +#ifdef AVAIL_ZLIB size_t ZLib_DecompressBuffer(const qbyte *in, size_t insize, qbyte *out, size_t maxoutsize); size_t ZLib_CompressBuffer(const qbyte *in, size_t insize, qbyte *out, size_t maxoutsize); +#endif static neterr_t NET_KexLobby_Received(void *ctx, sizebuf_t *message) { static float throttle; @@ -4992,6 +4994,7 @@ static neterr_t NET_KexLobby_Transmit(void *ctx, const qbyte *data, size_t lengt #endif if (length >= 4 && ((const qbyte*)data)[3] & 0x80) { //reliables... +#ifdef AVAIL_ZLIB if (((const qbyte*)data)[0] == 0xff && ((const qbyte*)data)[1] == 0xff && ((const qbyte*)data)[2] == 0xff && ((const qbyte*)data)[3] == 0xff) { //connect packets should be compressed... 4/8 sets of userinfo can get big and bloated, but mostly it also helps obfuscate. qbyte *zdata = alloca(length+1); @@ -5002,6 +5005,7 @@ static neterr_t NET_KexLobby_Transmit(void *ctx, const qbyte *data, size_t lengt return NET_KexLobby_SendMessage(peer, KEXLAN_RELIABLE|KEXLAN_ZGAMEPACKET, zdata, zlength+1); //send this packet reliably! } } +#endif return NET_KexLobby_SendMessage(peer, KEXLAN_RELIABLE|KEXLAN_GAMEPACKET, data, length); //send this packet reliably! } else @@ -10003,7 +10007,7 @@ qboolean NET_WasSpecialPacket(ftenet_connections_t *collection) return true; #endif -#if defined(SUPPORT_ICE) || defined(MASTERONLY) +#if defined(SUPPORT_ICE) || (defined(MASTERONLY) && defined(AVAIL_ZLIB)) if (ICE_WasStun(collection)) return true; #endif diff --git a/engine/qclib/qcd_main.c b/engine/qclib/qcd_main.c index 1b66b1b20..1883ac02a 100644 --- a/engine/qclib/qcd_main.c +++ b/engine/qclib/qcd_main.c @@ -12,18 +12,7 @@ #endif #ifdef AVAIL_ZLIB -#ifdef _WIN32 -#define ZEXPORT VARGS #include - -#ifdef _WIN64 -//# pragma comment (lib, "../libs/zlib64.lib") -#else -//# pragma comment (lib, "../libs/zlib.lib") -#endif -#else -#include -#endif #endif pbool QC_decodeMethodSupported(int method) diff --git a/plugins/mpq/fs_mpq.c b/plugins/mpq/fs_mpq.c index fabcaafc0..be60a9956 100644 --- a/plugins/mpq/fs_mpq.c +++ b/plugins/mpq/fs_mpq.c @@ -583,7 +583,9 @@ static int mpqf_blastout(void *how, unsigned char *buf, unsigned len) } static void MPQF_decompress(qboolean legacymethod, void *outdata, unsigned int outlen, void *indata, unsigned int inlen) { +#ifdef AVAIL_ZLIB int ret; +#endif int methods; if (legacymethod)