2014-07-21 01:34:28 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef _SCMFILE_HPP_
|
|
|
|
#define _SCMFILE_HPP_
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2014-07-24 00:57:21 +02:00
|
|
|
#include <script/ScriptTypes.hpp>
|
2014-07-21 01:34:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Handles in-memory SCM file data including section offsets.
|
|
|
|
*/
|
|
|
|
class SCMFile {
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef std::uint32_t uint32;
|
|
|
|
typedef std::uint16_t u16;
|
|
|
|
typedef std::uint8_t u8;
|
|
|
|
|
|
|
|
enum SCMTarget {
|
|
|
|
NoTarget = 0,
|
|
|
|
GTAIII = 0xC6,
|
|
|
|
GTAVC = 0x6D,
|
|
|
|
GTASA = 0x73
|
|
|
|
};
|
|
|
|
|
|
|
|
SCMFile()
|
2014-08-11 18:58:43 +02:00
|
|
|
: _data(nullptr), _target(NoTarget),
|
2014-07-21 01:34:28 +02:00
|
|
|
mainSize(0), missionLargestSize(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~SCMFile()
|
|
|
|
{
|
|
|
|
delete[] _data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadFile(char* data, unsigned int size);
|
|
|
|
|
|
|
|
SCMByte* data() const { return _data; }
|
|
|
|
|
|
|
|
template<class T> T read(unsigned int offset) const
|
|
|
|
{
|
|
|
|
return *(T*)(_data+offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 getMainSize() const { return mainSize; }
|
|
|
|
uint32 getLargestMissionSize() const { return missionLargestSize; }
|
|
|
|
|
|
|
|
const std::vector<std::string>& getModels() const { return models; }
|
|
|
|
|
|
|
|
const std::vector<unsigned int>& getMissionOffsets() const { return missionOffsets; }
|
|
|
|
|
|
|
|
std::uint32_t getGlobalSection() const { return globalSectionOffset; }
|
|
|
|
std::uint32_t getModelSection() const { return modelSectionOffset; }
|
|
|
|
std::uint32_t getMissionSection() const { return missionSectionOffset; }
|
|
|
|
std::uint32_t getCodeSection() const { return codeSectionOffset; }
|
|
|
|
|
2014-07-25 04:30:44 +02:00
|
|
|
unsigned int getGlobalsSize() const { return modelSectionOffset - globalSectionOffset; }
|
|
|
|
|
2014-07-21 01:34:28 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
SCMByte* _data;
|
|
|
|
|
|
|
|
SCMTarget _target;
|
|
|
|
|
|
|
|
std::vector<std::string> models;
|
|
|
|
|
|
|
|
std::vector<unsigned int> missionOffsets;
|
|
|
|
|
|
|
|
uint32 mainSize;
|
|
|
|
uint32 missionLargestSize;
|
|
|
|
|
|
|
|
uint32 globalSectionOffset;
|
|
|
|
uint32 modelSectionOffset;
|
|
|
|
uint32 missionSectionOffset;
|
|
|
|
uint32 codeSectionOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|