1
1
forked from 0ad/0ad

upgrade to new libpng and zlib (see announcements thread)

This was SVN commit r270.
This commit is contained in:
janwas 2004-05-26 19:28:42 +00:00
parent d2e343741b
commit 0c8ea18853
3 changed files with 36 additions and 13 deletions

View File

@ -43,8 +43,8 @@
#define WINAPIV __cdecl
#ifndef NO_PNG
#include <png.h>
#pragma comment(lib, "libpng.lib")
#include <libpng10/png.h>
#pragma comment(lib, "libpng10.lib")
#endif

View File

@ -21,9 +21,13 @@
#include "lib.h"
#include "res.h"
//#define NO_ZLIB
#ifndef NO_ZLIB
#include <zlib.h>
#ifdef _MSC_VER
#pragma comment(lib, "zlib.lib")
#pragma comment(lib, "zdll.lib")
#endif
#endif
#include <map>
@ -609,6 +613,9 @@ int zip_enum(const Handle ha, const ZipFileCB cb, const uintptr_t user)
uintptr_t inf_init_ctx()
{
#ifdef NO_ZLIB
return 0;
#else
// allocate ZLib stream
z_stream* stream = (z_stream*)mem_alloc(round_up(sizeof(z_stream), 32), 32, MEM_ZERO);
if(inflateInit2(stream, -MAX_WBITS) != Z_OK)
@ -616,11 +623,15 @@ uintptr_t inf_init_ctx()
return 0;
return (uintptr_t)stream;
#endif
}
int inf_start_read(uintptr_t ctx, void* out, size_t out_size)
{
#ifdef NO_ZLIB
return -1;
#else
if(!ctx)
return ERR_INVALID_PARAM;
z_stream* stream = (z_stream*)ctx;
@ -633,11 +644,15 @@ int inf_start_read(uintptr_t ctx, void* out, size_t out_size)
stream->next_out = (Byte*)out;
stream->avail_out = (uInt)out_size;
return 0;
#endif
}
ssize_t inf_inflate(uintptr_t ctx, void* in, size_t in_size)
{
#ifdef NO_ZLIB
return -1;
#else
if(!ctx)
return ERR_INVALID_PARAM;
z_stream* stream = (z_stream*)ctx;
@ -660,11 +675,15 @@ ssize_t inf_inflate(uintptr_t ctx, void* in, size_t in_size)
// it isn't treated as 'bytes read', i.e. > 0.
return nread;
#endif
}
int inf_finish_read(uintptr_t ctx)
{
#ifdef NO_ZLIB
return -1;
#else
if(!ctx)
return ERR_INVALID_PARAM;
z_stream* stream = (z_stream*)ctx;
@ -678,13 +697,16 @@ int inf_finish_read(uintptr_t ctx)
stream->next_in = 0;
stream->next_out = 0;
return 0;
#endif
}
int inf_free_ctx(uintptr_t ctx)
{
#ifdef NO_ZLIB
return -1;
#else
if(!ctx)
return ERR_INVALID_PARAM;
z_stream* stream = (z_stream*)ctx;
@ -694,6 +716,7 @@ int inf_free_ctx(uintptr_t ctx)
inflateEnd(stream);
mem_free(stream);
return 0;
#endif
}

View File

@ -397,15 +397,6 @@ int main(int argc, char* argv[])
display_startup_error(err_msg);
}
// default to loading map for convenience during development
// override by passing any parameter.
if(argc < 2)
{
argc = 2;
argv[1] = "-m=test01.pmp";
}
ParseArgs(argc, argv);
@ -497,6 +488,15 @@ int main(int argc, char* argv[])
g_EntityTemplateCollection.loadTemplates();
// if no map name specified, load test01.pmp (for convenience during
// development. that means loading no map at all is currently impossible.
// is that a problem?
if(!g_MapFile)
g_MapFile = "test01.pmp";
// load a map if we were given one
if (g_MapFile) {
CStr mapfilename("mods/official/maps/scenarios/");