From 81d50f7c044feb6eba0075bffc18d6de30772b5e Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Sat, 29 Sep 2007 20:32:40 +0000 Subject: [PATCH] * added: sound files extraction with stuffextract * fixed vc71 irrlicht project file --- src/dep/src/irrlicht/Irrlicht7.1.vcproj | 81 ++++++++++++++++++++++++- src/tools/stuffextract/StuffExtract.cpp | 46 ++++++++++++++ src/tools/stuffextract/StuffExtract.h | 2 + 3 files changed, 128 insertions(+), 1 deletion(-) diff --git a/src/dep/src/irrlicht/Irrlicht7.1.vcproj b/src/dep/src/irrlicht/Irrlicht7.1.vcproj index 2d06ddb..468e5e9 100644 --- a/src/dep/src/irrlicht/Irrlicht7.1.vcproj +++ b/src/dep/src/irrlicht/Irrlicht7.1.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mapNames; std::set texNames; std::set modelNames; std::set wmoNames; +std::set soundFileSet; int main(int argc, char *argv[]) @@ -35,6 +36,7 @@ int main(int argc, char *argv[]) ConvertDBC(); ExtractMaps(); ExtractMapDependencies(); + ExtractSoundFiles(); //... printf("\n -- finished, press enter to exit --\n"); } @@ -197,6 +199,8 @@ bool ConvertDBC(void) printf("sound entries.."); for(DBCFile::Iterator it = SoundEntries.begin(); it != SoundEntries.end(); ++it) { + std::string path = (*it).getString(SOUNDENTRY_PATH); // required to fill up the filename storage + path += "\\"; // use backslash because mpq uses backslash too uint32 id = (*it).getUInt(SOUNDENTRY_SOUNDID); for(uint32 field=SOUNDENTRY_SOUNDID; field < SOUNDENTRY_END; field++) { @@ -204,7 +208,13 @@ bool ConvertDBC(void) { std::string value = AutoGetDataString(it,SoundEntriesFormat,field); if(value.size()) // only store if a file exists in that field + { SoundDataStorage[id].push_back(std::string(SoundEntriesFieldNames[field]) + "=" + value); + + // fill up file storage + if(field >= SOUNDENTRY_FILE_1 && field <= SOUNDENTRY_FILE_10) + soundFileSet.insert(path + value); + } } } } @@ -448,4 +458,40 @@ void ExtractMapDependencies(void) } +void ExtractSoundFiles(void) +{ + uint32 done = 0; + printf("\nExtracting game audio files, %u total...\n",soundFileSet.size()); + CreateDir(SOUNDDIR); + MPQHelper smpq("sound"); + std::string outfn; + for(std::set::iterator i = soundFileSet.begin(); i != soundFileSet.end(); i++) + { + if(!smpq.FileExists((char*)(*i).c_str())) + continue; + + outfn = std::string(SOUNDDIR) + "/" + _PathToFileName(*i); + std::fstream fh; + fh.open(outfn.c_str(), std::ios_base::out | std::ios_base::binary); + if(fh.is_open()) + { + ByteBuffer& bb = smpq.ExtractFile((char*)(*i).c_str()); + if(bb.size()) + { + fh.write((const char*)bb.contents(),bb.size()); + done++; + printf("- %u files done.\r",done); + } + } + else + { + printf("Could not write sound file '%s'\n",outfn.c_str()); + } + fh.close(); + } + printf("\n"); +} + + + diff --git a/src/tools/stuffextract/StuffExtract.h b/src/tools/stuffextract/StuffExtract.h index 90e11c2..4e04650 100644 --- a/src/tools/stuffextract/StuffExtract.h +++ b/src/tools/stuffextract/StuffExtract.h @@ -9,6 +9,7 @@ #define OUTDIR "stuffextract" #define SCPDIR OUTDIR "/data/scp" #define MAPSDIR OUTDIR "/data/maps" +#define SOUNDDIR OUTDIR "/data/sound" typedef std::map< uint32,std::list > SCPStorageMap; @@ -17,5 +18,6 @@ void OutSCP(char*, SCPStorageMap&); bool ConvertDBC(void); void ExtractMaps(void); void ExtractMapDependencies(void); +void ExtractSoundFiles(void); #endif \ No newline at end of file