From: Keith F. <ven...@us...> - 2003-09-06 05:14:06
|
Update of /cvsroot/planeshift/planeshift/src/client/sound In directory sc8-pr-cvs1:/tmp/cvs-serv11214 Modified Files: pssoundmngr.cpp Log Message: Updated xml loader to use iDocumentNode xml system. Index: pssoundmngr.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** pssoundmngr.cpp 26 Aug 2003 17:19:07 -0000 1.41 --- pssoundmngr.cpp 6 Sep 2003 05:14:02 -0000 1.42 *************** *** 37,40 **** --- 37,42 ---- #include <cstool/initapp.h> #include <csutil/debug.h> + #include <iutil/document.h> + #include <csutil/xmltiny.h> //Sound *************** *** 338,371 **** bool psSoundManager::psSndSourceMngr::LoadSoundLib(const char* fname) { ! csRef<iFile> file = vfs->Open(fname, VFS_FILE_READ); ! if (!file) ! return false; ! char* buf = new char[512]; ! size_t readsize; ! psXMLString mainstring; ! do { ! readsize = file->Read(buf, 512); ! mainstring.Append(buf, readsize); ! } while (readsize == 512); ! delete[] buf; ! psXMLString temp; ! int start = mainstring.FindTag("Sounds"); ! mainstring.GetTagSection(start, "Sounds", temp); ! int tagstart = temp.FindTag("Sound", 6); ! do { ! psXMLTag tag(temp, tagstart); ! psSoundFileInfo* info = new psSoundFileInfo; ! tag.GetTagParm ("name", info->name); ! tag.GetTagParm ("file", info->file); ! sndfiles.Put(csHashCompute(info->name), (void*) info); ! tagstart = temp.FindTag("Sound", tagstart+1); ! } while (tagstart != -1); ! return true; } --- 340,377 ---- bool psSoundManager::psSndSourceMngr::LoadSoundLib(const char* fname) { ! csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem); ! csRef<iDataBuffer> buff = vfs->ReadFile( fname ); ! if ( !buff || !buff->GetSize() ) { ! return false; ! } ! csRef<iDocument> doc = xml->CreateDocument(); ! const char* error = doc->Parse( buff ); ! if ( error ) ! { ! return false; ! } ! csRef<iDocumentNode> root = doc->GetRoot(); ! csRef<iDocumentNode> topNode = root->GetNode("Sounds"); ! csRef<iDocumentNodeIterator> iter = topNode->GetNodes(); ! while ( iter->HasNext() ) { ! csRef<iDocumentNode> node = iter->Next(); ! ! if ( node->GetType() != CS_NODE_ELEMENT ) ! continue; ! ! if ( strcmp( node->GetValue(), "Sound" ) == 0 ) ! { ! psSoundFileInfo* info = new psSoundFileInfo; ! info->name = node->GetAttributeValue("name"); ! info->file = node->GetAttributeValue("file"); ! sndfiles.Put(csHashCompute(info->name), (void*) info); ! } ! } return true; } |