It is not critical, but then it's about the mindset
Reason: This gives a small runtime speed boost (0.01%) to the extractor, along with
Patch against 9541
commit b156b0b4525cb9f406ba06a07f08c8716348c006
Author: pasdVn <
[email protected]>
Date: Sat Mar 6 22:20:03 2010 +0300
[9541] Implement first target of spell 1064 and ranks boost from 61301.
Signed-off-by: VladimirMangos <
[email protected]>
Devs: imbecile
The patch is here
diff --git a/contrib/extractor/libmpq/common.cpp b/contrib/extractor/libmpq/common.cpp
index 8ce8646..e43a716 100644
--- a/contrib/extractor/libmpq/common.cpp
+++ b/contrib/extractor/libmpq/common.cpp
@@ -34,17 +34,6 @@
#include "common.h"
#include <ctype.h>
-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.
*/
@@ -411,7 +400,7 @@ int libmpq_read_hashtable(mpq_archive *mpq_a) {
/* Read the hash table into the buffer */
bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash);
- libmpq_lseek(mpq_a, mpq_a->header->hashtablepos);
+ libmpq_lseek(mpq_a->fd, mpq_a->header->hashtablepos,SEEK_SET);
rb = _read(mpq_a->fd, mpq_a->hashtable, bytes);
if (rb != bytes) {
@@ -466,7 +455,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));
- libmpq_lseek(mpq_a, mpq_a->header->blocktablepos);
+ libmpq_lseek(mpq_a->fd, mpq_a->header->blocktablepos,SEEK_SET);
rb = _read(mpq_a->fd, mpq_a->blocktable, bytes);
if (rb != bytes) {
@@ -526,7 +515,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) {
- libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos);
+ libmpq_lseek(mpq_a->fd, mpq_f->mpq_b->filepos,SEEK_SET);
}
/* Read block positions from begin of file. */
@@ -571,7 +560,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 */
- libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos);
+ libmpq_lseek(mpq_a->fd, mpq_f->mpq_b->filepos,SEEK_SET);
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);
@@ -608,7 +597,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) {
- mpq_a->filepos = libmpq_lseek(mpq_a, readpos);
+ mpq_a->filepos = libmpq_lseek(mpq_a->fd, readpos,SEEK_SET);
}
/* 15018F87 - Read all requested blocks. */
diff --git a/contrib/extractor/libmpq/common.h b/contrib/extractor/libmpq/common.h
index 57b34e9..c7a0cb6 100644
--- a/contrib/extractor/libmpq/common.h
+++ b/contrib/extractor/libmpq/common.h
@@ -71,4 +71,10 @@ int libmpq_conf_get_array(FILE *fp, char *search_value, char ***filelist, int *e
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);
+#ifdef WIN32
+ #define libmpq_lseek _lseeki64
+#elif defined(__APPLE__)
+ #define libmpq_lseek lseek
+#else
+ #define libmpq_lseek lseek64
+#endif
diff --git a/contrib/extractor/libmpq/mpq.cpp b/contrib/extractor/libmpq/mpq.cpp
index 9d60258..4c73983 100644
--- a/contrib/extractor/libmpq/mpq.cpp
+++ b/contrib/extractor/libmpq/mpq.cpp
@@ -77,7 +77,7 @@ int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename) {
while (!ncnt) {
mpq_a->header->id = 0;
- libmpq_lseek(mpq_a, mpq_a->mpqpos);
+ libmpq_lseek(mpq_a->fd, mpq_a->mpqpos,SEEK_SET);
rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header));