1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-05 08:37:20 +02:00
openrw/rwlib/source/loaders/LoaderSDT.hpp
Anonymous Maarten 90acef28f7 rwlib: iwyu: reduce warnings
- use mapping file
- forward define FileContentsInfo, CutsceneTracks, GameTexts
- no more "#pragma once"
- add mapping file
2018-01-08 22:52:48 +00:00

71 lines
2.3 KiB
C++

#ifndef _LIBRW_LOADERSDT_HPP_
#define _LIBRW_LOADERSDT_HPP_
#include <cstdint>
#include <cstddef>
#include <string>
#include <vector>
/// \brief Points to one file within the archive
class LoaderSDTFile {
public:
uint32_t offset; // offset of audio file in sfx.raw
uint32_t size; // size of audio file in bytes
uint32_t sampleRate; // the speed of audio
uint32_t loopStart; /// loop start, where looping would begin relative to
/// audio file's position, 0 for beginning of audio
/// file
uint32_t loopEnd; /// where looping would end relative to audio file's
/// position, -1 for end of audio file
};
/**
\class LoaderSDT
\brief Parses the structure of GTA .SDT archives and loads the files in it
*/
class LoaderSDT {
public:
/// Multiple versions of .SDT files
enum Version {
GTA2,
GTAIIIVC ///< GTA III and GTA VC archives -- only this one is
///implemented
};
/// Construct
LoaderSDT();
/// Load the structure of the archive
/// Omit the extension in filename
bool load(const std::string& filename);
/// Load a file from the archive to memory and pass a pointer to it
/// Warning: Please delete[] the memory in the end.
/// Warning: Returns NULL (0) if by any reason it can't load the file
char* loadToMemory(size_t index, bool asWave = true);
/// Writes the contents of index to filename
bool saveAsset(size_t index, const std::string& filename,
bool asWave = true);
/// Get the information of an asset in the examining archive
bool findAssetInfo(size_t index, LoaderSDTFile& out);
/// Get the information of an asset by its index
const LoaderSDTFile& getAssetInfoByIndex(size_t index) const;
/// Returns the number of asset files in the archive
uint32_t getAssetCount() const;
Version getVersion() const;
private:
Version m_version; ///< Version of this SDT archive
uint32_t m_assetCount; ///< Number of assets in the current archive
std::string m_archive; ///< Path to the archive being used (no extension)
std::vector<LoaderSDTFile> m_assets; ///< Asset info of the archive
};
#endif // LoaderSDT_h__