Clean up some zlib references.

This commit is contained in:
Shpoike 2023-09-11 10:06:46 +01:00
parent e39b29b130
commit 3708dab87a
7 changed files with 19 additions and 37 deletions

View file

@ -127,14 +127,17 @@ ELSE()
SET(SYS_LIBS ${SYS_LIBS}) SET(SYS_LIBS ${SYS_LIBS})
ENDIF() 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) IF(ZLIB_FOUND)
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};ZLIB_STATIC) SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};ZLIB_STATIC)
SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES}) SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES})
SET(FTESV_LIBS ${FTESV_LIBS} ${ZLIB_LIBRARIES}) SET(FTESV_LIBS ${FTESV_LIBS} ${ZLIB_LIBRARIES})
SET(FTEQCC_LIBS ${FTEQCC_LIBS} ${ZLIB_LIBRARIES}) SET(FTEQCC_LIBS ${FTEQCC_LIBS} ${ZLIB_LIBRARIES})
ELSE() 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) SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_ZLIB)
ENDIF() ENDIF()

View file

@ -1927,14 +1927,7 @@ void CL_SendDownloadReq(sizebuf_t *msg)
} }
#ifdef PEXT_ZLIBDL #ifdef PEXT_ZLIBDL
#ifdef _WIN32
#define ZEXPORT VARGS
#include "../../zip/zlib.h"
//# pragma comment (lib, "zip/zlib.lib")
#else
#include <zlib.h> #include <zlib.h>
#endif
static char *ZLibDownloadDecode(int *messagesize, char *input, int finalsize) static char *ZLibDownloadDecode(int *messagesize, char *input, int finalsize)
{ {

View file

@ -40,20 +40,11 @@ fte_inlinebody float M_LinearToSRGB(float x, float mag);
// These 4 libraries required for the version command // These 4 libraries required for the version command
#if defined(_MSC_VER) #ifdef AVAIL_ZLIB
#ifdef AVAIL_ZLIB
#include "zlib.h"
#endif
#ifdef FTE_SDL
#include <SDL.h>
#endif
#else
#ifdef AVAIL_ZLIB
#include <zlib.h> #include <zlib.h>
#endif #endif
#ifdef FTE_SDL #ifdef FTE_SDL
#include <SDL.h> #include <SDL.h>
#endif
#endif #endif
const usercmd_t nullcmd; // guarenteed to be zero const usercmd_t nullcmd; // guarenteed to be zero

View file

@ -98,7 +98,7 @@ typedef struct
unsigned short attrtype; unsigned short attrtype;
unsigned short attrlen; unsigned short attrlen;
} stunattr_t; } stunattr_t;
#if defined(SUPPORT_ICE) || defined(MASTERONLY) #if defined(SUPPORT_ICE) || (defined(MASTERONLY) && defined(AVAIL_ZLIB))
#include "zlib.h" #include "zlib.h"
#endif #endif
#ifdef SUPPORT_ICE #ifdef SUPPORT_ICE
@ -4054,7 +4054,7 @@ qboolean SCTP_Handshake(const dtlsfuncs_t *dtlsfuncs, void *dtlsstate, sctp_t **
//======================================== //========================================
#endif #endif
#if defined(SUPPORT_ICE) || defined(MASTERONLY) #if defined(SUPPORT_ICE) || (defined(MASTERONLY) && defined(AVAIL_ZLIB))
qboolean ICE_WasStun(ftenet_connections_t *col) qboolean ICE_WasStun(ftenet_connections_t *col)
{ {
#ifdef SUPPORT_ICE #ifdef SUPPORT_ICE

View file

@ -4656,8 +4656,10 @@ static void * NET_KexLobby_CreateContext(const dtlscred_t *credinfo, void *cbctx
return peer; return peer;
} }
#ifdef AVAIL_ZLIB
size_t ZLib_DecompressBuffer(const qbyte *in, size_t insize, qbyte *out, size_t maxoutsize); 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); 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 neterr_t NET_KexLobby_Received(void *ctx, sizebuf_t *message)
{ {
static float throttle; static float throttle;
@ -4992,6 +4994,7 @@ static neterr_t NET_KexLobby_Transmit(void *ctx, const qbyte *data, size_t lengt
#endif #endif
if (length >= 4 && ((const qbyte*)data)[3] & 0x80) if (length >= 4 && ((const qbyte*)data)[3] & 0x80)
{ //reliables... { //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) 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. { //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); 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! 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! return NET_KexLobby_SendMessage(peer, KEXLAN_RELIABLE|KEXLAN_GAMEPACKET, data, length); //send this packet reliably!
} }
else else
@ -10003,7 +10007,7 @@ qboolean NET_WasSpecialPacket(ftenet_connections_t *collection)
return true; return true;
#endif #endif
#if defined(SUPPORT_ICE) || defined(MASTERONLY) #if defined(SUPPORT_ICE) || (defined(MASTERONLY) && defined(AVAIL_ZLIB))
if (ICE_WasStun(collection)) if (ICE_WasStun(collection))
return true; return true;
#endif #endif

View file

@ -12,18 +12,7 @@
#endif #endif
#ifdef AVAIL_ZLIB #ifdef AVAIL_ZLIB
#ifdef _WIN32
#define ZEXPORT VARGS
#include <zlib.h> #include <zlib.h>
#ifdef _WIN64
//# pragma comment (lib, "../libs/zlib64.lib")
#else
//# pragma comment (lib, "../libs/zlib.lib")
#endif
#else
#include <zlib.h>
#endif
#endif #endif
pbool QC_decodeMethodSupported(int method) pbool QC_decodeMethodSupported(int method)

View file

@ -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) static void MPQF_decompress(qboolean legacymethod, void *outdata, unsigned int outlen, void *indata, unsigned int inlen)
{ {
#ifdef AVAIL_ZLIB
int ret; int ret;
#endif
int methods; int methods;
if (legacymethod) if (legacymethod)