X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fcommon%2Fvfs.c;h=775f9bd0e8c56a19a496e5ced060f7d7e5a84011;hb=c001d05fb1dc902a725dbf50df82e88a1a526a21;hp=0f9772b5bac214346ca47793b745a92c1cc20784;hpb=f012273544dc1fb1a3fa710ee190677d3b0381e8;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index 0f9772b5..775f9bd0 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -50,13 +50,14 @@ #include "mathlib.h" #include "inout.h" #include "vfs.h" -#include "unzip.h" +#include +#include typedef struct { char* name; - unz_s zipinfo; unzFile zipfile; + unz_file_pos zippos; guint32 size; } VFS_PAKFILE; @@ -129,6 +130,11 @@ static void vfsInitPakFile( const char *filename ){ if ( err != UNZ_OK ) { break; } + unz_file_pos pos; + err = unzGetFilePos( uf, &pos ); + if ( err != UNZ_OK ) { + break; + } file = (VFS_PAKFILE*)safe_malloc( sizeof( VFS_PAKFILE ) ); g_pakFiles = g_slist_append( g_pakFiles, file ); @@ -139,7 +145,7 @@ static void vfsInitPakFile( const char *filename ){ file->name = strdup( filename_inzip ); file->size = file_info.uncompressed_size; file->zipfile = uf; - memcpy( &file->zipinfo, uf, sizeof( unz_s ) ); + file->zippos = pos; if ( ( i + 1 ) < gi.number_entry ) { err = unzGoToNextFile( uf ); @@ -384,8 +390,10 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ } if ( count == index ) { - memcpy( file->zipfile, &file->zipinfo, sizeof( unz_s ) ); + if ( unzGoToFilePos( file->zipfile, &file->zippos ) != UNZ_OK ) { + return -1; + } if ( unzOpenCurrentFile( file->zipfile ) != UNZ_OK ) { return -1; }