mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[9521] Let build map extractor at Mac OSX
Also restore build at Windows (Win32 not have unistd.h) Win32 ad.exe binary updated but not expected any functional differences. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
eaf5934c99
commit
24540e4b03
5 changed files with 28 additions and 37 deletions
Binary file not shown.
|
|
@ -22,7 +22,11 @@
|
||||||
#define _CRT_SECURE_NO_DEPRECATE
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
//#include <dirent.h>
|
//#include <dirent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
//#include <unistd.h>
|
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -30,6 +34,17 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <ctype.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.
|
* 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 */
|
/* Read the hash table into the buffer */
|
||||||
bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash);
|
bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash);
|
||||||
|
|
||||||
#ifdef WIN32
|
libmpq_lseek(mpq_a, mpq_a->header->hashtablepos);
|
||||||
_lseeki64(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET);
|
|
||||||
#else
|
|
||||||
lseek64(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rb = _read(mpq_a->fd, mpq_a->hashtable, bytes);
|
rb = _read(mpq_a->fd, mpq_a->hashtable, bytes);
|
||||||
if (rb != bytes) {
|
if (rb != bytes) {
|
||||||
|
|
@ -455,11 +466,7 @@ int libmpq_read_blocktable(mpq_archive *mpq_a) {
|
||||||
bytes = mpq_a->header->blocktablesize * sizeof(mpq_block);
|
bytes = mpq_a->header->blocktablesize * sizeof(mpq_block);
|
||||||
memset(mpq_a->blocktable, 0, mpq_a->header->blocktablesize * sizeof(mpq_block));
|
memset(mpq_a->blocktable, 0, mpq_a->header->blocktablesize * sizeof(mpq_block));
|
||||||
|
|
||||||
#ifdef WIN32
|
libmpq_lseek(mpq_a, mpq_a->header->blocktablepos);
|
||||||
_lseeki64(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET);
|
|
||||||
#else
|
|
||||||
lseek64(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rb = _read(mpq_a->fd, mpq_a->blocktable, bytes);
|
rb = _read(mpq_a->fd, mpq_a->blocktable, bytes);
|
||||||
if (rb != 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;
|
unsigned int nread;
|
||||||
|
|
||||||
if (mpq_f->mpq_b->filepos != mpq_a->filepos) {
|
if (mpq_f->mpq_b->filepos != mpq_a->filepos) {
|
||||||
#ifdef WIN32
|
libmpq_lseek(mpq_a, mpq_f->mpq_b->filepos);
|
||||||
_lseeki64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
|
|
||||||
#else
|
|
||||||
lseek64(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read block positions from begin of file. */
|
/* 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) {
|
if (mpq_f->blockpos[0] != nread) {
|
||||||
|
|
||||||
/* Try once again to detect file seed and decrypt the blocks */
|
/* Try once again to detect file seed and decrypt the blocks */
|
||||||
|
libmpq_lseek(mpq_a, mpq_f->mpq_b->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
|
|
||||||
|
|
||||||
nread = _read(mpq_a->fd, mpq_f->blockpos, (mpq_f->nblocks + 1) * sizeof(int));
|
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);
|
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. */
|
/* Set file pointer, if necessary. */
|
||||||
if (mpq_a->filepos != readpos) {
|
if (mpq_a->filepos != readpos) {
|
||||||
|
mpq_a->filepos = libmpq_lseek(mpq_a, 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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 15018F87 - Read all requested blocks. */
|
/* 15018F87 - Read all requested blocks. */
|
||||||
|
|
|
||||||
|
|
@ -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_conf_get_array(FILE *fp, char *search_value, char ***filelist, int *entries);
|
||||||
int libmpq_free_listfile(char **filelist);
|
int libmpq_free_listfile(char **filelist);
|
||||||
int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp);
|
int libmpq_read_listfile(mpq_archive *mpq_a, FILE *fp);
|
||||||
|
|
||||||
|
unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos);
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,9 @@ int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename) {
|
||||||
|
|
||||||
while (!ncnt) {
|
while (!ncnt) {
|
||||||
mpq_a->header->id = 0;
|
mpq_a->header->id = 0;
|
||||||
#ifdef WIN32
|
|
||||||
_lseeki64(mpq_a->fd, mpq_a->mpqpos, SEEK_SET);
|
libmpq_lseek(mpq_a, mpq_a->mpqpos);
|
||||||
#else
|
|
||||||
lseek64(mpq_a->fd, mpq_a->mpqpos, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header));
|
rb = _read(mpq_a->fd, mpq_a->header, sizeof(mpq_header));
|
||||||
|
|
||||||
/* if different number of bytes read, break the loop */
|
/* if different number of bytes read, break the loop */
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9520"
|
#define REVISION_NR "9521"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue