rendered paste bodyIndex: contrib/map_extractor/libmpq/common.cpp
===================================================================
--- contrib/map_extractor/libmpq/common.cpp (working copy)
+++ contrib/map_extractor/libmpq/common.cpp (working copy)
@@ -395,7 +395,13 @@
/* Read the hash table into the buffer */
bytes = mpq_a->header->hashtablesize * sizeof(mpq_hash);
- _lseek(mpq_a->fd, mpq_a->header->hashtablepos, SEEK_SET);
+
+ #ifdef WIN32
+ _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);
if (rb != bytes) {
return LIBMPQ_EFILE_CORRUPT;
@@ -448,7 +454,13 @@
/* Read the block table into the buffer */
bytes = mpq_a->header->blocktablesize * sizeof(mpq_block);
memset(mpq_a->blocktable, 0, mpq_a->header->blocktablesize * sizeof(mpq_block));
- _lseek(mpq_a->fd, mpq_a->header->blocktablepos, SEEK_SET);
+
+ #ifdef WIN32
+ _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);
if (rb != bytes) {
return LIBMPQ_EFILE_CORRUPT;
@@ -507,7 +519,12 @@
unsigned int nread;
if (mpq_f->mpq_b->filepos != mpq_a->filepos) {
- _lseek(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
+ #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
}
/* Read block positions from begin of file. */
@@ -552,7 +569,13 @@
if (mpq_f->blockpos[0] != nread) {
/* Try once again to detect file seed and decrypt the blocks */
- _lseek(mpq_a->fd, mpq_f->mpq_b->filepos, SEEK_SET);
+
+ #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));
mpq_f->seed = libmpq_detect_fileseed(mpq_a, mpq_f->blockpos, nread);
libmpq_decrypt_block(mpq_a, mpq_f->blockpos, nread, mpq_f->seed - 1);
@@ -589,7 +612,13 @@
/* Set file pointer, if necessary. */
if (mpq_a->filepos != readpos) {
- mpq_a->filepos = _lseek(mpq_a->fd, readpos, SEEK_SET);
+
+ #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. */
Index: contrib/map_extractor/libmpq/parser.cpp
===================================================================
--- contrib/map_extractor/libmpq/parser.cpp (working copy)
+++ contrib/map_extractor/libmpq/parser.cpp (working copy)
@@ -183,7 +183,11 @@
break;
}
}
- fseek(fp, 0L, SEEK_SET);
+ #ifdef WIN32
+ _lseeki64((int)fp, 0L, SEEK_SET);
+ #else
+ lseek64((int)fp, 0L, SEEK_SET);
+ #endif
return result;
}
@@ -286,7 +290,11 @@
}
/* we got all files, so rewind stream */
- fseek(fp, 0L, SEEK_SET);
+ #ifdef WIN32
+ _lseeki64((int)fp, 0L, SEEK_SET);
+ #else
+ lseek64((int)fp, 0L, SEEK_SET);
+ #endif
(*filelist)[fl_count] = NULL;
Index: contrib/map_extractor/libmpq/mpq.cpp
===================================================================
--- contrib/map_extractor/libmpq/mpq.cpp (working copy)
+++ contrib/map_extractor/libmpq/mpq.cpp (working copy)
@@ -76,7 +76,11 @@
while (!ncnt) {
mpq_a->header->id = 0;
- _lseek(mpq_a->fd, mpq_a->mpqpos, SEEK_SET);
+ #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));
/* if different number of bytes read, break the loop */
Index: contrib/map_extractor/adt.cpp
===================================================================
--- contrib/map_extractor/adt.cpp (working copy)
+++ contrib/map_extractor/adt.cpp (working copy)
@@ -405,10 +405,9 @@
bool ConvertADT(char * filename,char * filename2)
{
-
// if(!strstr(filename,"oth_32_48"))return false;
if(!LoadADT(filename))return false;
-
+
FILE *output=fopen(filename2,"wb");
if(!output)
{
@@ -419,26 +418,27 @@
// write magic header
fwrite(MAP_MAGIC,1,8,output);
- for(unsigned int x=0;x<16;x++)
- for(unsigned int y=0;y<16;y++)
- {
- if(mcells->ch[y][x].area_id)
- {
- if(areas[mcells->ch[y][x].area_id]==0xffff)
- printf("\nCan't find area flag for areaid %d.\n",mcells->ch[y][x].area_id);
-
- fwrite(&areas[mcells->ch[y][x].area_id],1,2,output);
-
- }
- else
- {
- uint16 flag=0xffff;
- fwrite(&flag,1,2,output);
- }
- }
-
for(unsigned int x=0;x<16;x++)
+ {
for(unsigned int y=0;y<16;y++)
+ {
+ if(mcells->ch[y][x].area_id && mcells->ch[y][x].area_id < 0xf77)
+ {
+ if(areas[mcells->ch[y][x].area_id]==0xffff)
+ printf("\nCan't find area flag for areaid %u.\n",mcells->ch[y][x].area_id);
+
+ fwrite(&areas[mcells->ch[y][x].area_id],1,2,output);
+ }
+ else
+ {
+ uint16 flag=0xffff;
+ fwrite(&flag,1,2,output);
+ }
+ }
+ }
+
+ for(unsigned int x=0;x<16;x++)
+ for(unsigned int y=0;y<16;y++)
fwrite(&mcells->ch[y][x].flag,1,1,output);
TransformWaterData();
@@ -457,12 +457,8 @@
(((double)(y))*TILESIZE)/((double)(iRes-1)),
(((double)(x))*TILESIZE)/((double)(iRes-1)));
-
-
-
fwrite(&z,1,sizeof(z),output);
}
-
fclose(output);
delete cell;
@@ -485,3 +481,4 @@
}
+
Index: contrib/map_extractor/System.cpp
===================================================================
--- contrib/map_extractor/System.cpp (working copy)
+++ contrib/map_extractor/System.cpp (working copy)
@@ -37,141 +37,175 @@
void ExtractMapsFromMpq()
{
- char mpq_filename[128];
- char output_filename[256];
-// char tmp[256];
-// sprintf(tmp,"%s/Data/%s",input_path,filename);
+ char mpq_filename[128];
+ char output_filename[256];
+ // char tmp[256];
+ // sprintf(tmp,"%s/Data/%s",input_path,filename);
- //MPQArchive* p=new MPQArchive(tmp);
-// map_count=1;
- unsigned int total=map_count*64*64;
- unsigned int done=0;
+ //MPQArchive* p=new MPQArchive(tmp);
+ // map_count=1;
+ unsigned int total=map_count*64*64;
+ unsigned int done=0;
- for(unsigned int x=0;x<64;x++)
- {
- for(unsigned int z=0;z<map_count;z++)
- {
+ for(unsigned int x=0;x<64;x++)
+ {
+ for(unsigned int z=0;z<map_count;z++)
+ {
+ for(unsigned int y=0;y<64;y++)
+ {
+ sprintf(mpq_filename,"World\\Maps\\%s\\%s_%u_%u.adt",map_ids[z].name,map_ids[z].name,x,y);
+ // maps_extr[z][x][y]=true;
+ sprintf(output_filename,"%s/maps/%03u%02u%02u.map",output_path,map_ids[z].id,y,x);
+ //maps_extr[z][x][y]=
+ ConvertADT(mpq_filename,output_filename);
+ done++;
+ }
+ //draw progess bar
+ printf("Processing........................%d%%\r",(100*done)/total);
+ }
+ }
+}
+//bool WMO(char* filename);
- for(unsigned int y=0;y<64;y++)
- {
-
- sprintf(mpq_filename,"World\\Maps\\%s\\%s_%u_%u.adt",map_ids[z].name,map_ids[z].name,x,y);
- // maps_extr[z][x][y]=true;
- sprintf(output_filename,"%s/maps/%03u%02u%02u.map",output_path,map_ids[z].id,y,x);
- //maps_extr[z][x][y]=
- ConvertADT(mpq_filename,output_filename);
-
- done++;
-
- }
- //draw progess bar
- printf("Processing........................%d%%\r",(100*done)/total);
-
+int main(int argc, char * arg[])
+{
+ FILE* pDatei;
+ char tmp[512];
+ char tmp1[512];
+ //char tmp2[512];
+ char tmp3[512];
+ char tmp4[512];
+ for(int c=1;c<argc;c++)
+ {
+ //i - input path
+ //o - output path
+ //r - resolution, array of (r * r) heights will be created
+ if(arg[c][0]!='-')
+
+ Usage(arg[0]);
+
+ switch(arg[c][1])
+ {
+ case 'i':
+ if(c+1<argc)//all ok
+ strcpy(input_path,arg[(c++) +1]);
+ else Usage(arg[0]);
+ break;
+ case 'o':
+ if(c+1<argc)//all ok
+ strcpy(output_path,arg[(c++) +1]);
+ else Usage(arg[0]);
+ break;
+ case 'r':
+ if(c+1<argc)//all ok
+ iRes=atoi(arg[(c++) +1]);
+ else Usage(arg[0]);
+ break;
}
}
+ std::vector<MPQArchive*> archives;
-}
+ char LANG[5];
+ LANG[0]='e'; LANG[1]='n'; LANG[2]='G'; LANG[3]='B'; LANG[4]='\0'; // enGB by default...
-bool WMO(char* filename);
-int main(int argc, char * arg[])
-{
-
- char tmp[512];
- for(int c=1;c<argc;c++)
- {
- //i - input path
- //o - output path
- //r - resolution, array of (r * r) heights will be created
- if(arg[c][0]!='-')
-
- Usage(arg[0]);
-
- switch(arg[c][1])
- {
- case 'i':
- if(c+1<argc)//all ok
- strcpy(input_path,arg[(c++) +1]);
- else Usage(arg[0]);
- break;
- case 'o':
- if(c+1<argc)//all ok
- strcpy(output_path,arg[(c++) +1]);
- else Usage(arg[0]);
- break;
+ pDatei=fopen("./Data/deDE/locale-deDE.MPQ", "rb");
+ if (pDatei!=NULL)
+ {
+ LANG[0]='d'; LANG[1]='e'; LANG[2]='D'; LANG[3]='E';
+ fclose(pDatei);
+ }
- case 'r':
- if(c+1<argc)//all ok
- iRes=atoi(arg[(c++) +1]);
- else Usage(arg[0]);
- break;
-
-
-
- }
+ pDatei=fopen("./Data/enUS/locale-enUS.MPQ", "rb");
+ if (pDatei!=NULL)
+ {
+ LANG[0]='e'; LANG[1]='n'; LANG[2]='U'; LANG[3]='S';
+ fclose(pDatei);
+ }
+ pDatei=fopen("./Data/enGB/locale-enGB.MPQ", "rb");
+ if (pDatei!=NULL)
+ {
+ LANG[0]='e'; LANG[1]='n'; LANG[2]='G'; LANG[3]='B';
+ fclose(pDatei);
+ }
- }
-
-
+ pDatei=fopen("./Data/frFR/locale-frFR.MPQ", "rb");
+ if (pDatei!=NULL)
+ {
+ LANG[0]='f'; LANG[1]='r'; LANG[2]='F'; LANG[3]='R';
+ fclose(pDatei);
+ }
- std::vector<MPQArchive*> archives;
- const char* archiveNames[] = {"patch-2.MPQ", "patch.MPQ", "terrain.MPQ","dbc.MPQ"};
- //, "wmo.MPQ"};
+ pDatei=fopen("./Data/esES/locale-esES.MPQ", "rb");
+ if (pDatei!=NULL)
+ {
+ LANG[0]='e'; LANG[1]='s'; LANG[2]='E'; LANG[3]='S';
+ fclose(pDatei);
+ }
- for (size_t i=0; i<4; i++)
- {
- sprintf(tmp,"%s/Data/%s",input_path,archiveNames[i]);
- archives.push_back(new MPQArchive(tmp));
+ sprintf(tmp1,"%s/locale-%s.MPQ",LANG,LANG);
+ //sprintf(tmp2,"%s/expansion-locale-%s.MPQ",LANG,LANG);
+ sprintf(tmp3,"%s/patch-%s.MPQ",LANG,LANG);
+ sprintf(tmp4,"%s/patch-%s-2.MPQ",LANG,LANG);
+
+ //char* archiveNames[]={"expansion.MPQ", "common.MPQ", "patch-2.MPQ", "patch.MPQ", tmp4, tmp3, tmp2, tmp1};
+ char* archiveNames[]={"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ", tmp4, tmp3, tmp1};
+
+ //for (size_t i=0; i<8; i++)
+ for (size_t i=0; i<7; i++)
+ {
+ sprintf(tmp,"%s/Data/%s",input_path,archiveNames[i]);
+ archives.push_back(new MPQArchive(tmp));
}
-
+ //map.dbc
+ DBCFile * dbc= new DBCFile("DBFilesClient\\Map.dbc");
+ if(dbc)
+ dbc->open();
+ else
+ return (1);
+ map_count=dbc->getRecordCount();
+ map_ids=new map_id[map_count];
+ //maps_extr = new extr_map [map_count];
+ //memset(maps_extr,false, sizeof(extr_map) *map_count);
+ for(unsigned int x=0;x<map_count;x++)
+ {
+ map_ids[x].id=dbc->getRecord (x).getUInt(0);
+ strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
+ }
+ delete dbc;
+ //map.dbc
- //map.dbc
- DBCFile * dbc= new DBCFile("DBFilesClient\\Map.dbc");
- dbc->open();
+ //areatable.dbc
+ dbc = new DBCFile("DBFilesClient\\AreaTable.dbc");
+ dbc->open();
- map_count=dbc->getRecordCount ();
- map_ids=new map_id[map_count];
- //maps_extr = new extr_map [map_count];
- //memset(maps_extr,false, sizeof(extr_map) *map_count);
- for(unsigned int x=0;x<map_count;x++)
- {
- map_ids[x].id=dbc->getRecord (x).getUInt(0);
- strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
- }
- delete dbc;
- //map.dbc
-
- //areatable.dbc
- dbc = new DBCFile("DBFilesClient\\AreaTable.dbc");
- dbc->open();
+ unsigned int area_count=dbc->getRecordCount ();
+ uint32 maxi=0;
+ for(unsigned int x=0;x<area_count;x++)
+ {
+ if(maxi<dbc->getRecord(x).getUInt(0))
+ maxi=dbc->getRecord(x).getUInt(0);
+ // printf("\n%d %d",dbc->getRecord(x).getUInt(0),dbc->getRecord(x).getUInt(3));
+ }
+ maxi++;//not needed actually
+ areas=new uint16[maxi];
+ memset(areas,0xff,maxi*2);
+ for(unsigned int x=0;x<area_count;x++)
+ areas[dbc->getRecord(x).getUInt(0)] =dbc->getRecord(x).getUInt(3);
- unsigned int area_count=dbc->getRecordCount ();
- uint32 maxi=0;
- for(unsigned int x=0;x<area_count;x++)
- {
- if(maxi<dbc->getRecord(x).getUInt(0))
- maxi=dbc->getRecord(x).getUInt(0);
-// printf("\n%d %d",dbc->getRecord(x).getUInt(0),dbc->getRecord(x).getUInt(3));
- }
- maxi++;//not needed actually
- areas=new uint16[maxi];
- memset(areas,0xff,maxi*2);
- for(unsigned int x=0;x<area_count;x++)
- areas[dbc->getRecord(x).getUInt(0)] =dbc->getRecord(x).getUInt(3);
+ delete dbc;
- delete dbc;
+ //areatable.dbc
- //areatable.dbc
+ ExtractMapsFromMpq();
- ExtractMapsFromMpq();
+ delete [] areas;
+ delete [] map_ids;
- delete [] areas;
- delete [] map_ids;
-
/* // This would be nice someday (don't have time to get it to work right now):
cout << "Extracting dbc files..." << endl;
for (size_t i=3; i>0; i--)
@@ -197,5 +231,5 @@
}
}
*/
- return (0); // Exit The Program
+ return (0); // Exit The Program
}