mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
23a77a1d36
commit
2d37ac049a
7 changed files with 30 additions and 38 deletions
1
contrib/extractor/.gitignore
vendored
1
contrib/extractor/.gitignore
vendored
|
|
@ -18,3 +18,4 @@ debug
|
|||
release
|
||||
*.user
|
||||
*.ilk
|
||||
ad_debug.exe
|
||||
|
|
@ -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)
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9165"
|
||||
#define REVISION_NR "9166"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue