feat: Add support for MOD files (lip sync, game saves)
This commit is contained in:
parent
82cf6e3384
commit
6465566b32
5 changed files with 27 additions and 3 deletions
|
@ -28,12 +28,14 @@ namespace reone {
|
|||
namespace resource {
|
||||
|
||||
static const int kSignatureSize = 8;
|
||||
static const char kSignature[] = "ERF V1.0";
|
||||
static const char kSignatureErf[] = "ERF V1.0";
|
||||
static const char kSignatureMod[] = "MOD V1.0";
|
||||
|
||||
ErfFile::ErfFile() : BinaryFile(kSignatureSize, kSignature) {
|
||||
ErfFile::ErfFile() : BinaryFile(0, nullptr) {
|
||||
}
|
||||
|
||||
void ErfFile::doLoad() {
|
||||
checkSignature();
|
||||
ignore(8);
|
||||
|
||||
_entryCount = readUint32();
|
||||
|
@ -47,6 +49,22 @@ void ErfFile::doLoad() {
|
|||
loadResources();
|
||||
}
|
||||
|
||||
void ErfFile::checkSignature() {
|
||||
if (_size < kSignatureSize) {
|
||||
throw runtime_error("Invalid binary file size");
|
||||
}
|
||||
char buf[kSignatureSize];
|
||||
_in->read(buf, kSignatureSize);
|
||||
|
||||
bool erf = strncmp(buf, kSignatureErf, kSignatureSize) == 0;
|
||||
if (!erf) {
|
||||
bool mod = strncmp(buf, kSignatureMod, kSignatureSize) == 0;
|
||||
if (!mod) {
|
||||
throw runtime_error("Invalid ERF file signature");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ErfFile::loadKeys() {
|
||||
_keys.reserve(_entryCount);
|
||||
seek(_keysOffset);
|
||||
|
|
|
@ -54,6 +54,8 @@ private:
|
|||
std::vector<Resource> _resources;
|
||||
|
||||
void doLoad() override;
|
||||
|
||||
void checkSignature();
|
||||
void loadKeys();
|
||||
Key readKey();
|
||||
void loadResources();
|
||||
|
|
|
@ -34,6 +34,7 @@ enum class GameVersion {
|
|||
|
||||
enum class ResourceType : uint16_t {
|
||||
Invalid = 0xffff,
|
||||
Inventory = 0,
|
||||
Bmp = 1,
|
||||
Tga = 3,
|
||||
Wav = 4,
|
||||
|
@ -73,6 +74,7 @@ enum class ResourceType : uint16_t {
|
|||
DoorWalkmesh = 2052,
|
||||
PlaceableWalkmesh = 2053,
|
||||
Journal = 2056,
|
||||
Mod = 2057,
|
||||
WaypointBlueprint = 2058,
|
||||
SoundSet = 2060,
|
||||
ScriptDebugger = 2064,
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace reone {
|
|||
namespace resource {
|
||||
|
||||
static map<ResourceType, string> g_extByType = {
|
||||
{ ResourceType::Inventory, "inv" },
|
||||
{ ResourceType::Bmp, "bmp" },
|
||||
{ ResourceType::Tga, "tga" },
|
||||
{ ResourceType::Wav, "wav" },
|
||||
|
@ -69,6 +70,7 @@ static map<ResourceType, string> g_extByType = {
|
|||
{ ResourceType::DoorWalkmesh, "dwk" },
|
||||
{ ResourceType::PlaceableWalkmesh, "pwk" },
|
||||
{ ResourceType::Journal, "jrl" },
|
||||
{ ResourceType::Mod, "mod" },
|
||||
{ ResourceType::WaypointBlueprint, "utw" },
|
||||
{ ResourceType::SoundSet, "ssf" },
|
||||
{ ResourceType::ScriptDebugger, "ndb" },
|
||||
|
|
|
@ -49,7 +49,7 @@ unique_ptr<Tool> getToolByPath(GameVersion version, const fs::path &path) {
|
|||
return make_unique<KeyTool>();
|
||||
} else if (ext == ".bif") {
|
||||
return make_unique<BifTool>();
|
||||
} else if (ext == ".erf") {
|
||||
} else if (ext == ".erf" || ext == ".mod" || ext == ".sav") {
|
||||
return make_unique<ErfTool>();
|
||||
} else if (ext == ".rim") {
|
||||
return make_unique<RimTool>();
|
||||
|
|
Loading…
Reference in a new issue