[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.
This commit is contained in:
VladimirMangos 2010-01-13 05:15:44 +03:00
parent 23a77a1d36
commit 2d37ac049a
7 changed files with 30 additions and 38 deletions

View file

@ -18,3 +18,4 @@ debug
release release
*.user *.user
*.ilk *.ilk
ad_debug.exe

View file

@ -878,11 +878,27 @@ void ExtractMapsFromMpq()
delete [] map_ids; 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) void ExtractDBCFiles(int locale, bool basicLocale)
{ {
printf("Extracting dbc files...\n"); printf("Extracting dbc files...\n");
set<string> dbcfiles; std::set<std::string> dbcfiles;
// get DBC file list // get DBC file list
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i)
@ -894,7 +910,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
dbcfiles.insert(*iter); dbcfiles.insert(*iter);
} }
string path = output_path; std::string path = output_path;
path += "/dbc/"; path += "/dbc/";
CreateDir(path); CreateDir(path);
if(!basicLocale) if(!basicLocale)
@ -911,18 +927,8 @@ void ExtractDBCFiles(int locale, bool basicLocale)
string filename = path; string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\")); filename += (iter->c_str() + strlen("DBFilesClient\\"));
FILE *output = fopen(filename.c_str(), "wb"); if(ExtractFile(locale, iter->c_str(), filename))
if(!output) ++count;
{
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;
} }
printf("Extracted %u DBC files\n\n", count); printf("Extracted %u DBC files\n\n", count);
} }
@ -993,8 +999,8 @@ int main(int argc, char * arg[])
//Extract DBC files //Extract DBC files
if(FirstLocale < 0) if(FirstLocale < 0)
{ {
ExtractDBCFiles(i, true);
FirstLocale = i; FirstLocale = i;
ExtractDBCFiles(i, true);
} }
else else
ExtractDBCFiles(i, false); ExtractDBCFiles(i, false);

View file

@ -78,13 +78,13 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="zlib.lib" AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe" OutputFile="ad_debug.exe"
LinkIncremental="0" LinkIncremental="0"
SuppressStartupBanner="true" SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug" AdditionalLibraryDirectories="./debug"
IgnoreDefaultLibraryNames="LIBCD.lib" IgnoreDefaultLibraryNames="LIBCD.lib"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="./ad debug.pdb" ProgramDatabaseFile="./ad_debug.pdb"
SubSystem="1" SubSystem="1"
TargetMachine="1" TargetMachine="1"
/> />

View file

@ -79,13 +79,13 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="zlib.lib" AdditionalDependencies="zlib.lib"
OutputFile="ad debug.exe" OutputFile="ad_debug.exe"
LinkIncremental="0" LinkIncremental="0"
SuppressStartupBanner="true" SuppressStartupBanner="true"
AdditionalLibraryDirectories="./debug/" AdditionalLibraryDirectories="./debug/"
IgnoreDefaultLibraryNames="LIBCD.lib" IgnoreDefaultLibraryNames="LIBCD.lib"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="./ad debug.pdb" ProgramDatabaseFile="./ad_debug.pdb"
SubSystem="1" SubSystem="1"
RandomizedBaseAddress="1" RandomizedBaseAddress="1"
DataExecutionPrevention="0" DataExecutionPrevention="0"

View file

@ -200,30 +200,16 @@ int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype) {
* This function returns some useful file information. * This function returns some useful file information.
*/ */
int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number) { 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; int i = 0;
mpq_block *mpq_b = NULL; mpq_block *mpq_b = NULL;
mpq_hash *mpq_h = NULL; mpq_hash *mpq_h = NULL;
/* check if given number is not out of range */ /* 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; 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 */ /* check if sizes are correct */
mpq_b = mpq_a->blocktable + blockindex; mpq_b = mpq_a->blocktable + blockindex;
if (mpq_b->filepos > (mpq_a->header->archivesize + mpq_a->mpqpos) || mpq_b->csize > mpq_a->header->archivesize) { if (mpq_b->filepos > (mpq_a->header->archivesize + mpq_a->mpqpos) || mpq_b->csize > mpq_a->header->archivesize) {

View file

@ -68,9 +68,8 @@ MPQFile::MPQFile(const char* filename):
mpq_hash hash = (*i)->GetHashEntry(filename); mpq_hash hash = (*i)->GetHashEntry(filename);
uint32 blockindex = hash.blockindex; uint32 blockindex = hash.blockindex;
if ((blockindex == 0xFFFFFFFF) || (blockindex == 0)) { if (blockindex == 0xFFFFFFFF)
continue; //file not found continue; //file not found
}
uint32 fileno = blockindex; uint32 fileno = blockindex;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9165" #define REVISION_NR "9166"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__