From 9749da6b68814b36de1f7b235f65c61967a6d027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 7 Jul 2007 04:30:36 +0000 Subject: [PATCH] =?UTF-8?q?Obs=C5=82uga=20archiw=C3=B3w=20.SND?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMT.cpp | 3 ++ CSndHandler.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ CSndHandler.h | 23 +++++++++++ 3 files changed, 130 insertions(+) create mode 100644 CSndHandler.cpp create mode 100644 CSndHandler.h diff --git a/CMT.cpp b/CMT.cpp index 56e6d6e45..3a34bdeca 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -27,6 +27,7 @@ #include "CSemiLodHandler.h" #include "CLodHandler.h" #include "CDefHandler.h" +#include "CSndHandler.h" #include "CDefObjInfoHandler.h" #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include @@ -231,6 +232,8 @@ int _tmain(int argc, _TCHAR* argv[]) //initializing audio CMusicHandler * mush = new CMusicHandler; mush->initMusics(); + CSndHandler snd("Heroes3.snd"); + snd.extract("AELMMOVE.wav","snddd.wav"); //audio initialized /*if(Mix_PlayMusic(mush->mainMenuWoG, -1)==-1) //uncomment this fragment to have music diff --git a/CSndHandler.cpp b/CSndHandler.cpp new file mode 100644 index 000000000..de9ce8504 --- /dev/null +++ b/CSndHandler.cpp @@ -0,0 +1,104 @@ +#include "stdafx.h" +#include "CSndHandler.h" + + +CSndHandler::~CSndHandler() +{ + entries.clear(); + file.close(); +} +CSndHandler::CSndHandler(std::string fname):CHUNK(65535) +{ + file.open(fname.c_str(),std::ios::binary); + if (!file.is_open()) + throw new std::exception((std::string("Cannot open ")+fname).c_str()); + int nr = readNormalNr(0,4); + char tempc; + for (int i=0;i=0) + file.seekg(pos,std::ios_base::beg); + int ret=0; + int amp=1; + unsigned char zcz=0; + for (int i=0; iCHUNK) + { + file.read(buffer,CHUNK); + out.write(buffer,CHUNK); + toRead-=CHUNK; + } + file.read(buffer,toRead); + out.write(buffer,toRead); + out.close(); +} +void CSndHandler::extract(std::string srcfile, std::string dstfile, bool caseSens) //saves selected file +{ + if (caseSens) + { + for (int i=0;i +#include +class CSndHandler +{ +protected: + const int CHUNK; + struct Entry + { + std::string name; + int size, offset; + }; + std::ifstream file; + int readNormalNr (int pos, int bytCon); + bool opened; +public: + std::vector entries; + ~CSndHandler(); + CSndHandler(std::string fname); + void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file + unsigned char * extract (std::string srcfile, int & size); //return selecte file + void extract(int index, std::string dstfile); //saves selected file + unsigned char * extract (int index, int & size); //return selecte file - NIE TESTOWANE +};