From 2d37ac049a57b0ed93bc8bc6a017338b94ab1cbf Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 13 Jan 2010 05:15:44 +0300 Subject: [PATCH] [9166] Fixes/cleanups in extarctor code. * 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. --- contrib/extractor/.gitignore | 1 + contrib/extractor/System.cpp | 36 +++++++++++++++++++------------- contrib/extractor/VC80_ad.vcproj | 4 ++-- contrib/extractor/VC90_ad.vcproj | 4 ++-- contrib/extractor/libmpq/mpq.cpp | 18 ++-------------- contrib/extractor/mpq_libmpq.cpp | 3 +-- src/shared/revision_nr.h | 2 +- 7 files changed, 30 insertions(+), 38 deletions(-) diff --git a/contrib/extractor/.gitignore b/contrib/extractor/.gitignore index 908bb677d..73cfdde63 100644 --- a/contrib/extractor/.gitignore +++ b/contrib/extractor/.gitignore @@ -18,3 +18,4 @@ debug release *.user *.ilk +ad_debug.exe \ No newline at end of file diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp index a851412b0..870269709 100644 --- a/contrib/extractor/System.cpp +++ b/contrib/extractor/System.cpp @@ -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 dbcfiles; + std::set dbcfiles; // get DBC file list for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) @@ -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) @@ -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); } @@ -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); diff --git a/contrib/extractor/VC80_ad.vcproj b/contrib/extractor/VC80_ad.vcproj index e31f4f68c..86cca46ce 100644 --- a/contrib/extractor/VC80_ad.vcproj +++ b/contrib/extractor/VC80_ad.vcproj @@ -78,13 +78,13 @@ diff --git a/contrib/extractor/VC90_ad.vcproj b/contrib/extractor/VC90_ad.vcproj index a485ee953..9317a60c0 100644 --- a/contrib/extractor/VC90_ad.vcproj +++ b/contrib/extractor/VC90_ad.vcproj @@ -79,13 +79,13 @@ 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) { diff --git a/contrib/extractor/mpq_libmpq.cpp b/contrib/extractor/mpq_libmpq.cpp index bdf1f7d3c..65facbff3 100644 --- a/contrib/extractor/mpq_libmpq.cpp +++ b/contrib/extractor/mpq_libmpq.cpp @@ -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; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a3ea105e0..ea3100063 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 "9165" + #define REVISION_NR "9166" #endif // __REVISION_NR_H__