Disable unused libraries

-libcurl, libpng, zlib
This commit is contained in:
pierow 2021-10-29 12:15:27 -04:00
parent 6e9cb6052b
commit 12a122af14
7 changed files with 288 additions and 265 deletions

View file

@ -72,7 +72,7 @@
<ShowIncludes>false</ShowIncludes>
</ClCompile>
<Link>
<AdditionalDependencies>\..\..\Release\particles.lib;vgui.lib;zlib.lib;libpng.lib;wsock32.lib;sdl2.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>\..\..\Release\particles.lib;vgui.lib;wsock32.lib;sdl2.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(SolutionDir)\particles\Release;$(SolutionDir)\includes\lpng1251;$(SolutionDir)\includes\zlib-1.2.8;$(SolutionDir)\includes\vgui\lib\win32_vc6;$(SolutionDir)\lib\public;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>

View file

@ -272,7 +272,7 @@
<AdditionalIncludeDirectories>$(SolutionDir);$(SolutionDir)\includes\lua\include;$(SolutionDir)\particles\;$(SolutionDir)\includes\vgui\include;$(SolutionDir)\includes\libcurl-7.50-nossl\include;$(SolutionDir)\common;$(SolutionDir)\public;$(SolutionDir)\util;$(SolutionDir)\engine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>libcurl_a.lib;winmm.lib;ws2_32.lib;particles.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>winmm.lib;ws2_32.lib;particles.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(SolutionDir)..\dlls\ns.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(SolutionDir)\includes\libcurl-7.50-nossl;$(SolutionDir)\particles\Release;U:\release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View file

@ -31,14 +31,16 @@ CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -DCLIENT_DLL -I/usr/include/malloc -D_snwpr
INCLUDEDIRS= -I$(HL_SRC_DIR) -I$(NS_MOD_SRC_DIR) -I$(COMMON_SRC_DIR) -I$(PUBLIC_SRC_DIR) -I$(PM_SHARED_SRC_DIR) -I../engine -I$(GAME_SHARED_SRC_DIR) -I../external/ -I../particles -I../includes/fmodapi375linux/api/inc -I$(HL_SERVER_SRC_DIR) -I$(HL_SRC_DIR)/cl_dll -I$(VGUI_INCLUDE_DIR) -I$(UI_INCLUDE_DIR) -I$(UTIL_SRC_DIR) -I../ -I../includes/fmodapi375linux/api -I../includes/lpng1251
ifeq ($(OS),Darwin)
LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -L. libpng12.dylib -lz -framework Carbon -framework OpenGL vgui.dylib -L. -lSDL2-2.0.0 -L. libparticleMP.a
LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -framework Carbon -framework OpenGL vgui.dylib -L. -lSDL2-2.0.0 -L. libparticleMP.a
#-L. libpng12.dylib -lz
DO_CC=$(CPLUS) -std=c++11 -stdlib=libc++ $(INCLUDEDIRS) $(CFLAGS) -o $@ -c $<
DO_PUBLIC_CC=$(CPLUS) -std=c++11 -stdlib=libc++ $(COMMON_INCLUDEDIRS) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
DO_COMMON_CC=$(CPLUS) -std=c++11 -stdlib=libc++ $(INCLUDEDIRS) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
DO_PM_SHARED_CC=$(CPLUS) -std=c++11 -stdlib=libc++ $(INCLUDEDIRS) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
else
LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -lpng -lz -lfmod-3.75 -L$(CFG) vgui.so -L. libSDL2-2.0.so.0 -L. libparticleMP.a
LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -lfmod-3.75 -L$(CFG) vgui.so -L. libSDL2-2.0.so.0 -L. libparticleMP.a
# -lpng -lz
DO_CC=$(CPLUS) $(INCLUDEDIRS) $(CFLAGS) -o $@ -c $<
DO_PUBLIC_CC=$(CPLUS) $(COMMON_INCLUDEDIRS) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
DO_COMMON_CC=$(CPLUS) $(INCLUDEDIRS) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<

View file

@ -20,8 +20,8 @@ UTIL_OBJ_DIR=$(HLDLL_OBJ_DIR)/util
TEXTREP_OBJ_DIR=$(HLDLL_OBJ_DIR)/textrep
#CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) $(SHLIBCFLAGS) -DCLIENT_WEAPONS
CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DAVH_SERVER -DLINUX -DVALVE_DLL -DQUIVER -DVOXEL -DQUAKE2 -DDEDICATED -DSWDS -D_STLP_USE_GLIBC -DUSE_OLDAUTH -Dsprintf_s=snprintf -D_stricmp=strcasecmp -DCURL_STATICLIB -DDISABLE_VEC_FUNCS -D_FORTIFY_SOURCE=0
#-O3 -ffast-math -fno-strength-reduce
CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DAVH_SERVER -DLINUX -DVALVE_DLL -DQUIVER -DVOXEL -DQUAKE2 -DDEDICATED -DSWDS -D_STLP_USE_GLIBC -DUSE_OLDAUTH -Dsprintf_s=snprintf -D_stricmp=strcasecmp -DDISABLE_VEC_FUNCS -D_FORTIFY_SOURCE=0
#-O3 -ffast-math -fno-strength-reduce -DCURL_STATICLIB
HLDLL_INCLUDEDIRS=-I$(HLDLL_SRC_DIR) -I../ -I$(ENGINE_SRC_DIR) -I$(COMMON_SRC_DIR) -I$(PM_SRC_DIR) -I$(GAME_SHARED_SRC_DIR) -I$(PUBLIC_SRC_DIR) -I$(UTIL_SRC_DIR) -I$(NS_MOD_SRC_DIR) -I$(PM_OBJ_DIR)
PM_INCLUDEDIRS=-I$(COMMON_SRC_DIR) -I$(PUBLIC_SRC_DIR) -I$(PM_SHARED_SRC_DIR)
@ -31,9 +31,11 @@ UTIL_INCLUDEDIRS = -I../ -I../util
TEXTREP_INCLUDEDIRS=..
ifeq ($(OS),Darwin)
LDFLAGS=-lm -lcurl -lstdc++ -L. libparticleMP.a
LDFLAGS=-lm -lstdc++ -L. libparticleMP.a
#-lcurl
else
LDFLAGS=-lm -lcurl -lstdc++ -L. libparticleMP.a
LDFLAGS=-lm -lstdc++ -L. libparticleMP.a
#-lcurl
endif
DO_HLDLL_CC=$(CC) $(HLDLL_INCLUDEDIRS) $(CFLAGS) -o $@ -c $<

View file

@ -25,13 +25,17 @@
#include "AvHGamerules.h"
#include "AvHServerUtil.h"
//@2014 curl 32/64 bit problems
#ifndef LINUX
#define CURL_STATICLIB
#endif
#include <curl/curl.h>
//#define CURL_SIZEOF_LONG 4
/////////////////////////////////////////////////////////////////////////////////////////////////////
////// 2021 - Unused library removal. Uncomment and reinclude libcurl to add back. ////
////////////////////////////////////////////////////////////////////////////////////////////////////
////@2014 curl 32/64 bit problems
//#ifndef LINUX
//#define CURL_STATICLIB
//#endif
//
//#include <curl/curl.h>
////#define CURL_SIZEOF_LONG 4
extern cvar_t avh_serverops;
@ -364,49 +368,52 @@ string BuildUserPassword()
return theUserPassword;
}
CURLcode PopulateChunkFromURL(const string& inURL, MemoryStruct& outChunk)
{
const int kCurlTimeout = 8;
// init the curl session
CURL* theCurlHandle = curl_easy_init();
// specify URL to get
curl_easy_setopt(theCurlHandle, CURLOPT_URL, inURL.c_str());
// send all data to this function
curl_easy_setopt(theCurlHandle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
// Ignore header and progress so there isn't extra stuff at the beginning of the data returned
//curl_easy_setopt(theCurlHandle, CURLOPT_HEADER, 0);
//curl_easy_setopt(theCurlHandle, CURLOPT_NOPROGRESS, 1);
//curl_easy_setopt(theCurlHandle, CURLOPT_VERBOSE, 0);
//curl_easy_setopt(theCurlHandle, CURLOPT_NOBODY, 1);
// timeout (3 seconds)
curl_easy_setopt(theCurlHandle, CURLOPT_CONNECTTIMEOUT, kCurlTimeout);
curl_easy_setopt(theCurlHandle, CURLOPT_TIMEOUT, kCurlTimeout);
curl_easy_setopt(theCurlHandle, CURLOPT_NOSIGNAL, true);
// CURLOPT_LOW_SPEED_LIMIT?
// CURLOPT_LOW_SPEED_TIME?
// Specify the user name and password
string kUserPassword = BuildUserPassword();
curl_easy_setopt(theCurlHandle, CURLOPT_USERPWD, kUserPassword.c_str());
// we pass our 'theChunk' struct to the callback function
outChunk.memory=NULL; /* we expect realloc(NULL, size) to work */
outChunk.size = 0; /* no data at this point */
curl_easy_setopt(theCurlHandle, CURLOPT_FILE, (void *)&outChunk);
// get it!
CURLcode theCode = curl_easy_perform(theCurlHandle);
// cleanup curl stuff
curl_easy_cleanup(theCurlHandle);
return theCode;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
////// 2021 - Unused library removal. Uncomment and reinclude libcurl to add back. ////
////////////////////////////////////////////////////////////////////////////////////////////////////
//CURLcode PopulateChunkFromURL(const string& inURL, MemoryStruct& outChunk)
//{
// const int kCurlTimeout = 8;
//
// // init the curl session
// CURL* theCurlHandle = curl_easy_init();
//
// // specify URL to get
// curl_easy_setopt(theCurlHandle, CURLOPT_URL, inURL.c_str());
//
// // send all data to this function
// curl_easy_setopt(theCurlHandle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
//
// // Ignore header and progress so there isn't extra stuff at the beginning of the data returned
// //curl_easy_setopt(theCurlHandle, CURLOPT_HEADER, 0);
// //curl_easy_setopt(theCurlHandle, CURLOPT_NOPROGRESS, 1);
// //curl_easy_setopt(theCurlHandle, CURLOPT_VERBOSE, 0);
// //curl_easy_setopt(theCurlHandle, CURLOPT_NOBODY, 1);
//
// // timeout (3 seconds)
// curl_easy_setopt(theCurlHandle, CURLOPT_CONNECTTIMEOUT, kCurlTimeout);
// curl_easy_setopt(theCurlHandle, CURLOPT_TIMEOUT, kCurlTimeout);
// curl_easy_setopt(theCurlHandle, CURLOPT_NOSIGNAL, true);
// // CURLOPT_LOW_SPEED_LIMIT?
// // CURLOPT_LOW_SPEED_TIME?
//
// // Specify the user name and password
// string kUserPassword = BuildUserPassword();
// curl_easy_setopt(theCurlHandle, CURLOPT_USERPWD, kUserPassword.c_str());
//
// // we pass our 'theChunk' struct to the callback function
// outChunk.memory=NULL; /* we expect realloc(NULL, size) to work */
// outChunk.size = 0; /* no data at this point */
// curl_easy_setopt(theCurlHandle, CURLOPT_FILE, (void *)&outChunk);
//
// // get it!
// CURLcode theCode = curl_easy_perform(theCurlHandle);
//
// // cleanup curl stuff
// curl_easy_cleanup(theCurlHandle);
//
// return theCode;
//}
void AvHGamerules::InitializeAuthentication()
{
@ -414,81 +421,84 @@ void AvHGamerules::InitializeAuthentication()
ALERT(at_console, "\tReading authentication data...");
struct MemoryStruct theChunk;
CURLcode theCode = PopulateChunkFromURL(BuildAuthenticationURL(), theChunk);
// Now parse data and add users for each mask
if((theCode == CURLE_OK) && theChunk.memory)
{
// Clear existing authentication data, only after lookup succeeds
gAuthMaskList.clear();
string theString(theChunk.memory);
string theDelimiters("\r\n");
StringVector theLines;
Tokenizer::split(theString, theDelimiters, theLines);
// Run through each line
int theNumConstellationMembers = 0;
for(StringVector::const_iterator theIter = theLines.begin(); theIter != theLines.end(); theIter++)
{
char *msg=(char *)(*theIter).c_str();
// If it's not empty and not a comment
char theFirstChar = (*theIter)[0];
if((theFirstChar != '/') && (theFirstChar != '#'))
{
// Split up tag and number
StringVector theTokens;
if(Tokenizer::split(*theIter, " ", theTokens) == 3)
{
// Translate tag to auth mask
string theTag = theTokens[0];
string theWONID = theTokens[1];
string theSteamID = theTokens[2];
// Upper-case prefix
UppercaseString(theSteamID);
// Make sure it starts with "STEAM_X:Y"
if(strncmp(theSteamID.c_str(), kSteamIDPrefix, strlen(kSteamIDPrefix)))
{
string theNewSteamID = kSteamIDPrefix + theSteamID;
theSteamID = theNewSteamID;
}
// Add auth status
AvHPlayerAuthentication theMask = PLAYERAUTH_NONE;
if(TagToAuthMask(theTag, theMask))
{
// Count Constellation members fyi
if(theMask & PLAYERAUTH_CONTRIBUTOR)
{
theNumConstellationMembers++;
}
if((theWONID != "") || (theSteamID != ""))
{
#ifdef DEBUG
char theMessage[512];
sprintf(theMessage, " Adding auth mask: %s %s %s\n", theTag.c_str(), theWONID.c_str(), theSteamID.c_str());
ALERT(at_logged, theMessage);
#endif
this->AddAuthStatus(theMask, theWONID, theSteamID);
theSuccess = true;
}
}
}
}
}
// Breakpoint to see how many Constellation members there are (don't even think of printing or logging)
int a = 0;
}
else
{
int a = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
////// 2021 - Unused library removal. Uncomment and reinclude libcurl to add back. ////
////////////////////////////////////////////////////////////////////////////////////////////////////
// struct MemoryStruct theChunk;
// CURLcode theCode = PopulateChunkFromURL(BuildAuthenticationURL(), theChunk);
//
// // Now parse data and add users for each mask
// if((theCode == CURLE_OK) && theChunk.memory)
// {
// // Clear existing authentication data, only after lookup succeeds
// gAuthMaskList.clear();
//
// string theString(theChunk.memory);
// string theDelimiters("\r\n");
// StringVector theLines;
// Tokenizer::split(theString, theDelimiters, theLines);
//
// // Run through each line
// int theNumConstellationMembers = 0;
// for(StringVector::const_iterator theIter = theLines.begin(); theIter != theLines.end(); theIter++)
// {
// char *msg=(char *)(*theIter).c_str();
// // If it's not empty and not a comment
// char theFirstChar = (*theIter)[0];
// if((theFirstChar != '/') && (theFirstChar != '#'))
// {
// // Split up tag and number
// StringVector theTokens;
// if(Tokenizer::split(*theIter, " ", theTokens) == 3)
// {
// // Translate tag to auth mask
// string theTag = theTokens[0];
// string theWONID = theTokens[1];
// string theSteamID = theTokens[2];
//
// // Upper-case prefix
// UppercaseString(theSteamID);
//
// // Make sure it starts with "STEAM_X:Y"
// if(strncmp(theSteamID.c_str(), kSteamIDPrefix, strlen(kSteamIDPrefix)))
// {
// string theNewSteamID = kSteamIDPrefix + theSteamID;
// theSteamID = theNewSteamID;
// }
//
// // Add auth status
// AvHPlayerAuthentication theMask = PLAYERAUTH_NONE;
// if(TagToAuthMask(theTag, theMask))
// {
// // Count Constellation members fyi
// if(theMask & PLAYERAUTH_CONTRIBUTOR)
// {
// theNumConstellationMembers++;
// }
//
// if((theWONID != "") || (theSteamID != ""))
// {
//#ifdef DEBUG
// char theMessage[512];
// sprintf(theMessage, " Adding auth mask: %s %s %s\n", theTag.c_str(), theWONID.c_str(), theSteamID.c_str());
// ALERT(at_logged, theMessage);
//#endif
//
// this->AddAuthStatus(theMask, theWONID, theSteamID);
// theSuccess = true;
// }
// }
// }
// }
// }
//
// // Breakpoint to see how many Constellation members there are (don't even think of printing or logging)
// int a = 0;
// }
// else
// {
// int a = 0;
// }
// Now build server op list
this->mServerOpList.clear();
@ -521,36 +531,39 @@ void AvHGamerules::InitializeAuthentication()
void AvHGamerules::DisplayVersioning()
{
struct MemoryStruct theChunk;
CURLcode theCode = PopulateChunkFromURL(BuildVersionURL(), theChunk);
/////////////////////////////////////////////////////////////////////////////////////////////////////
////// 2021 - Unused library removal. Uncomment and reinclude libcurl to add back. ////
////////////////////////////////////////////////////////////////////////////////////////////////////
//struct MemoryStruct theChunk;
//CURLcode theCode = PopulateChunkFromURL(BuildVersionURL(), theChunk);
// Now parse data and add users for each mask
if((theCode == CURLE_OK) && theChunk.memory)
{
string theString(theChunk.memory, theChunk.size);
//// Now parse data and add users for each mask
//if((theCode == CURLE_OK) && theChunk.memory)
//{
// string theString(theChunk.memory, theChunk.size);
string theDelimiters("\r\n");
StringVector theLines;
Tokenizer::split(theString, theDelimiters, theLines);
// string theDelimiters("\r\n");
// StringVector theLines;
// Tokenizer::split(theString, theDelimiters, theLines);
if(theLines.size() > 0)
{
string theCurrentVersion(theLines[0]);
string theCurrentGameVersion = AvHSUGetGameVersionString();
// if(theLines.size() > 0)
// {
// string theCurrentVersion(theLines[0]);
// string theCurrentGameVersion = AvHSUGetGameVersionString();
char theMessage[1024];
if(theCurrentGameVersion != theCurrentVersion)
{
sprintf(theMessage, "\tServer out of date. NS version %s is now available!\n", theCurrentVersion.c_str());
ALERT(at_console, theMessage);
}
else
{
sprintf(theMessage, "\tServer version is up to date.\n");
ALERT(at_console, theMessage);
}
}
}
// char theMessage[1024];
// if(theCurrentGameVersion != theCurrentVersion)
// {
// sprintf(theMessage, "\tServer out of date. NS version %s is now available!\n", theCurrentVersion.c_str());
// ALERT(at_console, theMessage);
// }
// else
// {
// sprintf(theMessage, "\tServer version is up to date.\n");
// ALERT(at_console, theMessage);
// }
// }
//}
}
#endif //defined(USE_OLDAUTH)

View file

@ -5,16 +5,19 @@
// $NoKeywords: $
//=============================================================================
#include "VGUI.h"
#include "bitmappng.h"
#include <memory.h>
BitmapPNG::BitmapPNG(int width, int height, uchar* data)
{
setSize(width,height); //double-check that this allocates the memory we need!
memcpy(_rgba,data,width*height*4);
}
BitmapPNG::~BitmapPNG(void) {}
/////////////////////////////////////////////////////////////////////////////////////////////////////
////// 2021 - Unused library removal. Uncomment and reinclude libpng and zlib to add back. ////
////////////////////////////////////////////////////////////////////////////////////////////////////
//#include "VGUI.h"
//#include "bitmappng.h"
//#include <memory.h>
//
//BitmapPNG::BitmapPNG(int width, int height, uchar* data)
//{
// setSize(width,height); //double-check that this allocates the memory we need!
// memcpy(_rgba,data,width*height*4);
//}
//
//BitmapPNG::~BitmapPNG(void) {}

View file

@ -1,96 +1,99 @@
#include <png.h>
#include "loadpng.h"
#include "cl_dll/wrect.h"
#include "cl_dll/cl_dll.h"
#include "MemoryInputStream.h"
//alternate read function for libpng
void png_read_vgui_stream(png_structp png_ptr, png_bytep data, png_size_t length);
//conversion util to change from libpng format to raw bitmap
void convertToUChar(png_infop png_info, png_bytepp rows, uchar* data);
BitmapPNG* LoadPNG(char const *pFilename)
{
int length;
uchar* data = gEngfuncs.COM_LoadFile((char*)pFilename, 5, &length);
if( !data ) { return NULL; }
MemoryInputStream stream(data,length);
BitmapPNG* pRet = LoadPNG(stream);
gEngfuncs.COM_FreeFile(data);
return pRet;
}
BitmapPNG* LoadPNG(uchar* data, int length)
{
if( !data ) { return NULL; }
MemoryInputStream stream(data,length);
return LoadPNG(stream);
}
BitmapPNG* LoadPNG(vgui::InputStream& stream)
{
//allocate structures for read
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
return NULL;
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr,
(png_infopp)NULL, (png_infopp)NULL);
return NULL;
}
//set up our alternate read function
png_set_read_fn(png_ptr,&stream,png_read_vgui_stream);
//read the image
png_read_png(png_ptr,info_ptr,PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_16,NULL);
png_bytepp rows = png_get_rows(png_ptr, info_ptr);
png_read_image(png_ptr,rows);
//we now have the information in row format, it needs to be converted to a single array
//of 32bit pixel values specified as a uchar* so that we can create the image object
uchar* data = new uchar[info_ptr->width*info_ptr->height*4];
convertToUChar(info_ptr,rows,data);
//create the BitmpPNG that we are going to return
BitmapPNG* returnVal = new BitmapPNG(info_ptr->width,info_ptr->height,data);
//read the information after the image for completeness
png_read_end(png_ptr,NULL);
//free up png structures and other memory we've used
delete[] data;
png_destroy_read_struct(&png_ptr,&info_ptr,(png_infopp)NULL);
return returnVal;
}
//implementation of alternate read function
void png_read_vgui_stream(png_structp png_ptr, png_bytep data, png_size_t length)
{
vgui::InputStream* stream = static_cast<vgui::InputStream*>(png_get_io_ptr(png_ptr));
bool success = true;
stream->readUChar(data,(int)length,success);
}
//implementation of conversion function
void convertToUChar(png_infop png_info, png_bytepp rows, uchar* data)
{
int offset = 0;
int offset_amnt = png_info->width*4;
for(size_t counter = 0; counter < png_info->height; ++counter)
{
memcpy(&data[offset],rows[counter],offset_amnt);
offset += offset_amnt;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
////// 2021 - Unused library removal. Uncomment and reinclude libpng and zlib to add back. ////
////////////////////////////////////////////////////////////////////////////////////////////////////
//#include <png.h>
//#include "loadpng.h"
//#include "cl_dll/wrect.h"
//#include "cl_dll/cl_dll.h"
//#include "MemoryInputStream.h"
//
//
//
////alternate read function for libpng
//void png_read_vgui_stream(png_structp png_ptr, png_bytep data, png_size_t length);
//
////conversion util to change from libpng format to raw bitmap
//void convertToUChar(png_infop png_info, png_bytepp rows, uchar* data);
//
//BitmapPNG* LoadPNG(char const *pFilename)
//{
// int length;
// uchar* data = gEngfuncs.COM_LoadFile((char*)pFilename, 5, &length);
// if( !data ) { return NULL; }
//
// MemoryInputStream stream(data,length);
//
// BitmapPNG* pRet = LoadPNG(stream);
//
// gEngfuncs.COM_FreeFile(data);
//
// return pRet;
//}
//
//BitmapPNG* LoadPNG(uchar* data, int length)
//{
// if( !data ) { return NULL; }
// MemoryInputStream stream(data,length);
// return LoadPNG(stream);
//}
//
//BitmapPNG* LoadPNG(vgui::InputStream& stream)
//{
// //allocate structures for read
// png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
// if (!png_ptr)
// return NULL;
//
// png_infop info_ptr = png_create_info_struct(png_ptr);
// if (!info_ptr)
// {
// png_destroy_read_struct(&png_ptr,
// (png_infopp)NULL, (png_infopp)NULL);
// return NULL;
// }
//
// //set up our alternate read function
// png_set_read_fn(png_ptr,&stream,png_read_vgui_stream);
//
// //read the image
// png_read_png(png_ptr,info_ptr,PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_16,NULL);
// png_bytepp rows = png_get_rows(png_ptr, info_ptr);
// png_read_image(png_ptr,rows);
//
// //we now have the information in row format, it needs to be converted to a single array
// //of 32bit pixel values specified as a uchar* so that we can create the image object
// uchar* data = new uchar[info_ptr->width*info_ptr->height*4];
// convertToUChar(info_ptr,rows,data);
//
// //create the BitmpPNG that we are going to return
// BitmapPNG* returnVal = new BitmapPNG(info_ptr->width,info_ptr->height,data);
//
// //read the information after the image for completeness
// png_read_end(png_ptr,NULL);
//
// //free up png structures and other memory we've used
// delete[] data;
// png_destroy_read_struct(&png_ptr,&info_ptr,(png_infopp)NULL);
//
// return returnVal;
//}
//
////implementation of alternate read function
//void png_read_vgui_stream(png_structp png_ptr, png_bytep data, png_size_t length)
//{
// vgui::InputStream* stream = static_cast<vgui::InputStream*>(png_get_io_ptr(png_ptr));
// bool success = true;
// stream->readUChar(data,(int)length,success);
//}
//
////implementation of conversion function
//void convertToUChar(png_infop png_info, png_bytepp rows, uchar* data)
//{
// int offset = 0;
// int offset_amnt = png_info->width*4;
// for(size_t counter = 0; counter < png_info->height; ++counter)
// {
// memcpy(&data[offset],rows[counter],offset_amnt);
// offset += offset_amnt;
// }
//}