diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe index a46be68c5..a98095e30 100755 Binary files a/contrib/extractor/ad.exe and b/contrib/extractor/ad.exe differ diff --git a/contrib/extractor/libmpq/common.cpp b/contrib/extractor/libmpq/common.cpp index 7b9020875..8ce864627 100644 --- a/contrib/extractor/libmpq/common.cpp +++ b/contrib/extractor/libmpq/common.cpp @@ -22,7 +22,11 @@ #define _CRT_SECURE_NO_DEPRECATE //#include #include -//#include + +#ifndef WIN32 +#include +#endif + #include #include #include @@ -30,6 +34,17 @@ #include "common.h" #include +unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos) +{ +#ifdef WIN32 + return (unsigned int)_lseeki64(mpq_a->fd, pos, SEEK_SET); +#elif defined(__APPLE__) + return (unsigned int)lseek(mpq_a->fd, pos, SEEK_SET); +#else + return (unsigned int)lseek64(mpq_a->fd, pos, SEEK_SET); +#endif +} + /* * This function decrypts a MPQ block. */ @@ -396,11 +411,7 @@ int libmpq_read_hashtable(mpq_archive *mpq_a) { /* Read the hash table into the buffer */ bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash); - #ifdef WIN32 - _lseeki64(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET); - #else - lseek64(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET); - #endif + libmpq_lseek(mpq_a, mpq_a->header->hashtablepos); rb = _read(mpq_a->fd, mpq_a->hashtable, bytes); if (rb != bytes) { @@ -455,11 +466,7 @@ int libmpq_read_blocktable(mpq_archive *mpq_a) { bytes = mpq_a->header->blocktablesize * sizeof(mpq_block); memset(mpq_a->blocktable, 0, mpq_a->header->blocktablesize * sizeof(mpq_block)); - #ifdef WIN32 - _lseeki64(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET); - #else - lseek64(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET); - #endif + libmpq_lseek(mpq_a, mpq_a->header->blocktablepos); rb = _read(mpq_a->fd, mpq_a->blocktable, bytes); if (rb != bytes) { @@ -519,12 +526,7 @@ int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blo unsigned int nread; if (mpq_f->mpq_b->filepos != mpq_a->filepos) { - #ifdef WIN32 - _lseeki64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET); - #else - lseek64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET); - - #endif + libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos); } /* Read block positions from begin of file. */ @@ -569,12 +571,7 @@ int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blo if (mpq_f->blockpos[0] != nread) { /* Try once again to detect file seed and decrypt the blocks */ - - #ifdef WIN32 - _lseeki64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET); - #else - lseek64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET); - #endif + libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos); nread = _read(mpq_a->fd, mpq_f->blockpos, (mpq_f->nblocks + 1) * sizeof(int)); mpq_f->seed = libmpq_detect_fileseed(mpq_a, mpq_f->blockpos, nread); @@ -611,13 +608,7 @@ int libmpq_file_read_block(mpq_archive *mpq_a, mpq_file *mpq_f, unsigned int blo /* Set file pointer, if necessary. */ if (mpq_a->filepos != readpos) { - - #ifdef WIN32 - mpq_a->filepos = _lseeki64(mpq_a->fd, readpos, SEEK_SET); - #else - mpq_a->filepos = lseek64(mpq_a->fd, readpos, SEEK_SET); - #endif - + mpq_a->filepos = libmpq_lseek(mpq_a, readpos); } /* 15018F87 - Read all requested blocks. */ diff --git a/contrib/extractor/libmpq/common.h b/contrib/extractor/libmpq/common.h index 5794c162e..57b34e9cd 100644 --- a/contrib/extractor/libmpq/common.h +++ b/contrib/extractor/libmpq/common.h @@ -70,3 +70,5 @@ char *libmpq_conf_delete_char(char *buf, char *chars); int libmpq_conf_get_array(FILE *fp, char *search_value, char ***filelist, int *entries); int libmpq_free_listfile(char **filelist); int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp); + +unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos); diff --git a/contrib/extractor/libmpq/mpq.cpp b/contrib/extractor/libmpq/mpq.cpp index e40f15de2..9d60258f0 100644 --- a/contrib/extractor/libmpq/mpq.cpp +++ b/contrib/extractor/libmpq/mpq.cpp @@ -76,12 +76,10 @@ int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename) { while (!ncnt) { mpq_a->header->id = 0; - #ifdef WIN32 - _lseeki64(mpq_a->fd, mpq_a->mpqpos, SEEK_SET); - #else - lseek64(mpq_a->fd, mpq_a->mpqpos, SEEK_SET); - #endif - rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header)); + + libmpq_lseek(mpq_a, mpq_a->mpqpos); + + rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header)); /* if different number of bytes read, break the loop */ if (rb != sizeof(mpq_header)) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3f587c675..e43a1f416 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9520" + #define REVISION_NR "9521" #endif // __REVISION_NR_H__