-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f0f2b2
commit 49d3b80
Showing
7 changed files
with
206 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#include "FileSystem.h" | ||
#include "util/Hooking.h" | ||
|
||
cdc::FileSystem* GetFS() | ||
cdc::FileSystem* GetFS() noexcept | ||
{ | ||
auto addr = GET_ADDRESS(0x45C700, 0x45F640, 0x472B50); | ||
|
||
return Hooking::CallReturn<cdc::FileSystem*>(addr); | ||
} | ||
|
||
cdc::FileSystem* GetDiskFS() noexcept | ||
{ | ||
return *(cdc::FileSystem**)GET_ADDRESS(0x10E58C0, 0x838890, 0x9CE27C); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "ModFileSystem.h" | ||
#include "Hook.h" | ||
|
||
#include "modules/Log.h" | ||
#include "file/FileSystem.h" | ||
|
||
ModFileSystem::ModFileSystem(const char* path) : m_specMask(1), m_langMask(1), m_path() | ||
{ | ||
m_diskSystem = GetDiskFS(); | ||
|
||
strcpy(m_basePath, path); | ||
} | ||
|
||
bool ModFileSystem::FindFile(const char* fileName, char* path) const noexcept | ||
{ | ||
return false; | ||
} | ||
|
||
cdc::FileRequest* ModFileSystem::RequestRead(cdc::FileReceiver* receiver, const char* fileName, unsigned int startOffset) | ||
{ | ||
FindFile(fileName, m_path); | ||
|
||
Hook::GetInstance().GetModule<Log>()->WriteLine("Loading %s from mods folder", fileName); | ||
|
||
return m_diskSystem->RequestRead(receiver, m_path, startOffset); | ||
} | ||
|
||
cdc::File* ModFileSystem::OpenFile(const char* fileName) | ||
{ | ||
FindFile(fileName, m_path); | ||
|
||
return m_diskSystem->OpenFile(m_path); | ||
} | ||
|
||
bool ModFileSystem::FileExists(const char* fileName) | ||
{ | ||
return FindFile(fileName, m_path); | ||
} | ||
|
||
unsigned int ModFileSystem::GetFileSize(const char* fileName) | ||
{ | ||
FindFile(fileName, m_path); | ||
|
||
return m_diskSystem->GetFileSize(m_path); | ||
} | ||
|
||
void ModFileSystem::SetSpecialisationMask(unsigned int specMask) | ||
{ | ||
m_specMask = specMask; | ||
|
||
// Unset extra bit and set our language mask | ||
m_langMask = specMask & ~0x80000000; | ||
} | ||
|
||
unsigned int ModFileSystem::GetSpecialisationMask() | ||
{ | ||
return m_specMask; | ||
} | ||
|
||
cdc::FileSystem::Status ModFileSystem::GetStatus() | ||
{ | ||
return m_diskSystem->GetStatus(); | ||
} | ||
|
||
void ModFileSystem::Update() | ||
{ | ||
m_diskSystem->Update(); | ||
} | ||
|
||
void ModFileSystem::Synchronize() | ||
{ | ||
m_diskSystem->Synchronize(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include "cdc/file/FileSystem.h" | ||
|
||
// So we don't need to include Windows.h here | ||
#define _MAX_PATH 260 | ||
|
||
// This file system represents a subfolder in the mods oflder | ||
class ModFileSystem : public cdc::FileSystem | ||
{ | ||
private: | ||
cdc::FileSystem* m_diskSystem; | ||
|
||
unsigned int m_specMask; | ||
unsigned int m_langMask; | ||
|
||
char m_basePath[_MAX_PATH]; | ||
char m_path[_MAX_PATH]; | ||
|
||
// Finds a file and returns whether it exists and the rewritten path | ||
bool FindFile(const char* fileName, char* path) const noexcept; | ||
|
||
public: | ||
ModFileSystem(const char* path); | ||
|
||
cdc::FileRequest* RequestRead(cdc::FileReceiver* receiver, const char* fileName, unsigned int startOffset); | ||
cdc::File* OpenFile(const char* fileName); | ||
bool FileExists(const char* fileName); | ||
unsigned int GetFileSize(const char* fileName); | ||
void SetSpecialisationMask(unsigned int specMask); | ||
unsigned int GetSpecialisationMask(); | ||
Status GetStatus(); | ||
void Update(); | ||
void Synchronize(); | ||
|
||
#ifdef TR8 | ||
void Suspend(); | ||
bool Resume(); | ||
bool IsSuspended(); | ||
char* GetBufferPointer(cdc::FileRequest* request, unsigned int* bytesLocked); | ||
void ResetBufferPointer(int value); | ||
#endif | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
#pragma once | ||
|
||
#include <filesystem> | ||
|
||
#include "Module.h" | ||
#include "file/MultiFileSystem.h" | ||
|
||
class ModLoader : public Module | ||
{ | ||
private: | ||
MultiFileSystem m_fileSystem; | ||
|
||
void MountArchive(std::filesystem::path& name) noexcept; | ||
void MountDirectory(std::filesystem::path& name) noexcept; | ||
|
||
public: | ||
ModLoader(); | ||
void MountMods(); | ||
|
||
MultiFileSystem* GetFileSystem() noexcept; | ||
}; |