shared_ptr<VoiceArchive> VoiceCache::findArchive(int file_no) const { std::ostringstream oss; oss << "z" << std::setw(4) << std::setfill('0') << file_no; fs::path file = sound_system_.system().findFile(oss.str(), KOE_ARCHIVE_FILETYPES); if (file.empty()) { return shared_ptr<VoiceArchive>(); } string file_str = file.file_string(); if (iends_with(file_str, "ovk")) { return shared_ptr<VoiceArchive>(new OVKVoiceArchive(file, file_no)); } else if (iends_with(file_str, "nwk")) { return shared_ptr<VoiceArchive>(new NWKVoiceArchive(file, file_no)); } else if (iends_with(file_str, "koe")) { return shared_ptr<VoiceArchive>(new KOEPACVoiceArchive(file, file_no)); } return shared_ptr<VoiceArchive>(); }
GraphicsObjectData* GraphicsSystem::buildObjOfFile( const std::string& filename) { // Get the path to get the file type (which won't be in filename) fs::path full_path = system().findFile(filename, OBJ_FILETYPES); if (full_path.empty()) { ostringstream oss; oss << "Could not find Object compatible file \"" << filename << "\"."; throw rlvm::Exception(oss.str()); } string file_str = full_path.string(); if (iends_with(file_str, "g00") || iends_with(file_str, "pdt")) { return new GraphicsObjectOfFile(system(), filename); } else if (iends_with(file_str, "anm")) { return new AnmGraphicsObjectData(system(), filename); } else { ostringstream oss; oss << "Don't know how to handle object file: \"" << filename << "\""; throw rlvm::Exception(oss.str()); } }
shared_ptr<VoiceSample> VoiceCache::findUnpackedSample( int file_no, int index) const { // Loose voice files are packed into directories, like: // /KOE/0008/z000800073.ogg. We only need to search for the filename though. std::ostringstream oss; oss << "z" << std::setw(4) << std::setfill('0') << file_no << std::setw(5) << std::setfill('0') << index; fs::path file = sound_system_.system().findFile(oss.str(), KOE_LOOSE_FILETYPES); string file_str = file.file_string(); if (iends_with(file_str, "ogg")) { return shared_ptr<VoiceSample>(new OVKVoiceSample(file)); } return shared_ptr<VoiceSample>(); }