Skip to content

Commit

Permalink
[9166] Fixes/cleanups in extarctor code.
Browse files Browse the repository at this point in the history
* Avoid create debug binary version with space in name, ignore it in git changes.
* Alow filenum == 0 in archive file lists. Some currently not loaded fiels have its
  for example in case when in archive single file.

NOTE: no change in extracted files, so not need re-execute.
  • Loading branch information
VladimirMangos committed Jan 13, 2010
1 parent 224a42f commit fb53dde
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 38 deletions.
1 change: 1 addition & 0 deletions contrib/extractor/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ debug
release
*.user
*.ilk
ad_debug.exe
36 changes: 21 additions & 15 deletions contrib/extractor/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,11 +878,27 @@ void ExtractMapsFromMpq()
delete [] map_ids;
}

bool ExtractFile( int locale, char const* mpq_name, std::string const& filename )
{
FILE *output = fopen(filename.c_str(), "wb");
if(!output)
{
printf("Can't create the output file '%s'\n", filename.c_str());
return false;
}
MPQFile m(mpq_name);
if(!m.isEof())
fwrite(m.getPointer(), 1, m.getSize(), output);

fclose(output);
return true;
}

void ExtractDBCFiles(int locale, bool basicLocale)
{
printf("Extracting dbc files...\n");

set<string> dbcfiles;
std::set<std::string> dbcfiles;

// get DBC file list
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i)
Expand All @@ -894,7 +910,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
dbcfiles.insert(*iter);
}

string path = output_path;
std::string path = output_path;
path += "/dbc/";
CreateDir(path);
if(!basicLocale)
Expand All @@ -911,18 +927,8 @@ void ExtractDBCFiles(int locale, bool basicLocale)
string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\"));

FILE *output = fopen(filename.c_str(), "wb");
if(!output)
{
printf("Can't create the output file '%s'\n", filename.c_str());
continue;
}
MPQFile m(iter->c_str());
if(!m.isEof())
fwrite(m.getPointer(), 1, m.getSize(), output);

fclose(output);
++count;
if(ExtractFile(locale, iter->c_str(), filename))
++count;
}
printf("Extracted %u DBC files\n\n", count);
}
Expand Down Expand Up @@ -993,8 +999,8 @@ int main(int argc, char * arg[])
//Extract DBC files
if(FirstLocale < 0)
{
ExtractDBCFiles(i, true);
FirstLocale = i;
ExtractDBCFiles(i, true);
}
else
ExtractDBCFiles(i, false);
Expand Down
4 changes: 2 additions & 2 deletions contrib/extractor/VC80_ad.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe"
OutputFile="ad_debug.exe"
LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug"
IgnoreDefaultLibraryNames="LIBCD.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="./ad debug.pdb"
ProgramDatabaseFile="./ad_debug.pdb"
SubSystem="1"
TargetMachine="1"
/>
Expand Down
4 changes: 2 additions & 2 deletions contrib/extractor/VC90_ad.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe"
OutputFile="ad_debug.exe"
LinkIncremental="0"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug/"
IgnoreDefaultLibraryNames="LIBCD.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="./ad debug.pdb"
ProgramDatabaseFile="./ad_debug.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Expand Down
18 changes: 2 additions & 16 deletions contrib/extractor/libmpq/mpq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,30 +200,16 @@ int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype) {
* This function returns some useful file information.
*/
int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number) {
int blockindex = number; //-1;
int blockindex = number;
int i = 0;
mpq_block *mpq_b = NULL;
mpq_hash *mpq_h = NULL;

/* check if given number is not out of range */
if (number < 1 || number > mpq_a->header->blocktablesize) {
if (number < 0 || number >= mpq_a->header->blocktablesize) {
return LIBMPQ_EINV_RANGE;
}

/* search for correct hashtable */
/*for (i = 0; i < mpq_a->header->hashtablesize; i++) {
if ((number - 1) == (mpq_a->hashtable[i]).blockindex) {
blockindex = (mpq_a->hashtable[i]).blockindex;
mpq_h = &(mpq_a->hashtable[i]);
break;
}
}*/

/* check if file was found */
/*if (blockindex == -1 || blockindex > mpq_a->header->blocktablesize) {
return LIBMPQ_EFILE_NOT_FOUND;
}*/

/* check if sizes are correct */
mpq_b = mpq_a->blocktable + blockindex;
if (mpq_b->filepos > (mpq_a->header->archivesize + mpq_a->mpqpos) || mpq_b->csize > mpq_a->header->archivesize) {
Expand Down
3 changes: 1 addition & 2 deletions contrib/extractor/mpq_libmpq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ MPQFile::MPQFile(const char* filename):
mpq_hash hash = (*i)->GetHashEntry(filename);
uint32 blockindex = hash.blockindex;

if ((blockindex == 0xFFFFFFFF) || (blockindex == 0)) {
if (blockindex == 0xFFFFFFFF)
continue; //file not found
}

uint32 fileno = blockindex;

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9165"
#define REVISION_NR "9166"
#endif // __REVISION_NR_H__

0 comments on commit fb53dde

Please sign in to comment.