Reforge library structure - 1st pass
This commit is contained in:
parent
c33ee14f36
commit
b21372d1b9
@ -64,7 +64,7 @@ unset(RDI_TARGETS_LIST)
|
|||||||
# Define src/headers files
|
# Define src/headers files
|
||||||
file(GLOB_RECURSE RDI_LIB_SOURCES ./src/*.cpp ./src/*.c)
|
file(GLOB_RECURSE RDI_LIB_SOURCES ./src/*.cpp ./src/*.c)
|
||||||
source_group("Source Files" FILES ${RDI_LIB_SOURCES})
|
source_group("Source Files" FILES ${RDI_LIB_SOURCES})
|
||||||
file(GLOB RSP_LIB_PUBLIC_HRDS ./include/*.h)
|
file(GLOB_RECURSE RSP_LIB_PUBLIC_HRDS ./include/*.hpp ./include/*.h)
|
||||||
|
|
||||||
|
|
||||||
# Building instructions for RSP-Texture library
|
# Building instructions for RSP-Texture library
|
||||||
@ -148,24 +148,41 @@ endif()
|
|||||||
|
|
||||||
if(BUILD_TOOLS)
|
if(BUILD_TOOLS)
|
||||||
# Add lib debug tool to buildchain
|
# Add lib debug tool to buildchain
|
||||||
file(GLOB_RECURSE RDI_TOOLS_SOURCES ./tools/*.cpp ./tools/*.c)
|
#file(GLOB_RECURSE RDI_TOOLS_SOURCES ./tools/*.cpp ./tools/*.c)
|
||||||
source_group("Tools src files" FILES ${RDI_TOOLS_SOURCES})
|
#source_group("Tools src files" FILES ${RDI_TOOLS_SOURCES})
|
||||||
|
|
||||||
add_executable(rdi-debug-tools ${RDI_TOOLS_SOURCES})
|
#add_executable(rdi-debug-tools ${RDI_TOOLS_SOURCES})
|
||||||
|
add_executable(rdi-debug-tools ./tools/RDIDebug.cpp)
|
||||||
set_property(TARGET rdi-debug-tools PROPERTY C_STANDARD 90)
|
set_property(TARGET rdi-debug-tools PROPERTY C_STANDARD 90)
|
||||||
set_target_properties(rdi-debug-tools PROPERTIES OUTPUT_NAME "RDI-debug")
|
set_target_properties(rdi-debug-tools PROPERTIES OUTPUT_NAME "RDI-debug")
|
||||||
list(APPEND RDI_TARGETS_LIST rdi-debug-tools)
|
list(APPEND RDI_TARGETS_LIST rdi-debug-tools)
|
||||||
|
|
||||||
|
add_executable(erso-debug-tools ./tools/ErsoDebug.cpp)
|
||||||
|
set_property(TARGET erso-debug-tools PROPERTY C_STANDARD 90)
|
||||||
|
set_target_properties(erso-debug-tools PROPERTIES OUTPUT_NAME "Erso-debug")
|
||||||
|
list(APPEND RDI_TARGETS_LIST erso-debug-tools)
|
||||||
|
|
||||||
|
add_executable(krennic-debug-tools ./tools/KrennicDebug.cpp)
|
||||||
|
set_property(TARGET krennic-debug-tools PROPERTY C_STANDARD 90)
|
||||||
|
set_target_properties(krennic-debug-tools PROPERTIES OUTPUT_NAME "Krennic-debug")
|
||||||
|
list(APPEND RDI_TARGETS_LIST krennic-debug-tools)
|
||||||
|
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# msvc does not append 'lib' - do it here to have consistent name
|
# msvc does not append 'lib' - do it here to have consistent name
|
||||||
set_target_properties(rdi-debug-tools PROPERTIES IMPORT_PREFIX "lib")
|
set_target_properties(rdi-debug-tools PROPERTIES IMPORT_PREFIX "lib")
|
||||||
|
set_target_properties(erso-debug-tools PROPERTIES IMPORT_PREFIX "lib")
|
||||||
|
set_target_properties(krennic-debug-tools PROPERTIES IMPORT_PREFIX "lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(RDI_SHARED)
|
if(RDI_SHARED)
|
||||||
target_link_libraries(rdi-debug-tools PRIVATE rdi-lib)
|
target_link_libraries(rdi-debug-tools PRIVATE rdi-lib)
|
||||||
|
target_link_libraries(erso-debug-tools PRIVATE rdi-lib)
|
||||||
|
target_link_libraries(krennic-debug-tools PRIVATE rdi-lib)
|
||||||
elseif(RDI_STATIC)
|
elseif(RDI_STATIC)
|
||||||
target_link_libraries(rdi-debug-tools PRIVATE rdi-libstatic)
|
target_link_libraries(rdi-debug-tools PRIVATE rdi-libstatic)
|
||||||
|
target_link_libraries(erso-debug-tools PRIVATE rdi-libstatic)
|
||||||
|
target_link_libraries(krennic-debug-tools PRIVATE rdi-libstatic)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "../RDI_Datatypes.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../DatEntry.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GENERICFILE_H_
|
#ifndef GENERICFILE_H_
|
||||||
@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
|
|
||||||
|
class ErsoEntryFile;
|
||||||
|
|
||||||
class GenericFile {
|
class GenericFile {
|
||||||
public:
|
public:
|
||||||
GenericFile( FileEntry& hDat );
|
GenericFile( ErsoEntryFile& hDat );
|
||||||
virtual ~GenericFile();
|
virtual ~GenericFile();
|
||||||
|
|
||||||
MEMFILE get() { return pMemLoc; }
|
MEMFILE get() { return pMemLoc; }
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GenericFile.h"
|
#include <FileHandler/Generic.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef HMT_H_
|
#ifndef HMT_H_
|
||||||
@ -17,7 +17,7 @@ namespace RDI {
|
|||||||
|
|
||||||
class HMT : public GenericFile {
|
class HMT : public GenericFile {
|
||||||
public:
|
public:
|
||||||
HMT( FileEntry& hDat );
|
HMT( ErsoEntryFile& hDat );
|
||||||
virtual ~HMT();
|
virtual ~HMT();
|
||||||
};
|
};
|
||||||
|
|
@ -1,17 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
* @file RDI.h
|
* @file RDI.hpp
|
||||||
* @date 15/09/2022
|
* @date 24/09/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @copyright GPL-v3.0
|
||||||
* @brief Rogue Data Interface library main entry file.
|
* @brief Rogue Data Interface library main entry file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include "RDI_Datatypes.h"
|
#include "RDI_Datatypes.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef RDI_H_
|
#ifndef RDI_HPP_
|
||||||
#define RDI_H_
|
#define RDI_HPP_
|
||||||
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
@ -81,4 +83,4 @@ namespace RDI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* RDI_H_ */
|
#endif /* RDI_HPP_ */
|
@ -1,68 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file DatEntry.cpp
|
|
||||||
* @date 20/09/2022
|
|
||||||
* @author JackCarterSmith
|
|
||||||
* @copyright GPL-v3.0
|
|
||||||
* @brief Data file entry descriptor class.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "DatEntry.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace RDI {
|
|
||||||
|
|
||||||
FileEntry::FileEntry( std::string name, DAT_FILE_FLAGS fFlags, unsigned int size, MEMFILE fPtr ) {
|
|
||||||
this->name = name;
|
|
||||||
this->size = size;
|
|
||||||
this->fFlags.raw = fFlags.raw;
|
|
||||||
this->fileMemPtr = fPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileEntry::~FileEntry() {}
|
|
||||||
|
|
||||||
/*std::string FileEntry::toString() {
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
DirectoryEntry::DirectoryEntry( std::string name ) {
|
|
||||||
this->name = name;
|
|
||||||
this->fFlags.raw = 0;
|
|
||||||
this->rootDir = true;
|
|
||||||
vSubFiles = new std::vector<DatEntry*>;
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectoryEntry::DirectoryEntry( std::string name, DAT_FILE_FLAGS fFlags ) {
|
|
||||||
this->name = name;
|
|
||||||
this->fFlags.raw = fFlags.raw;
|
|
||||||
this->rootDir = false;
|
|
||||||
vSubFiles = new std::vector<DatEntry*>;
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectoryEntry::DirectoryEntry( std::string name, DAT_FILE_FLAGS fFlags, DatEntry* hFileEntry ) {
|
|
||||||
this->name = name;
|
|
||||||
this->fFlags.raw = fFlags.raw;
|
|
||||||
vSubFiles = new std::vector<DatEntry*>;
|
|
||||||
AddEntry(hFileEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectoryEntry::~DirectoryEntry() {
|
|
||||||
for ( DatEntry* e : *vSubFiles )
|
|
||||||
delete e;
|
|
||||||
delete vSubFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*std::string DirectoryEntry::toString() {
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void DirectoryEntry::ClearLinkedFiles() {
|
|
||||||
vSubFiles->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DirectoryEntry::AddEntry( DatEntry* hFileEntry ) {
|
|
||||||
vSubFiles->push_back(hFileEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* @file RDat.cpp
|
* @file Erso.cpp
|
||||||
* @date 20/09/2022
|
* @date 24/09/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @copyright GPL-v3.0
|
||||||
* @brief Rogue Dat file class interface.
|
* @brief Rogue DATA/BUNDLE file parser and interface.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -13,9 +13,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <RDI_Datatypes.h>
|
#include <RDI_Datatypes.h>
|
||||||
#include "DatEntry.h"
|
#include "files_mms/data_struct.h"
|
||||||
#include "data_struct.h"
|
#include "Erso.hpp"
|
||||||
#include "RDat.h"
|
#include "ErsoEntry.hpp"
|
||||||
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -27,7 +27,7 @@ using boost::filesystem::file_size;
|
|||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
|
|
||||||
RDat::RDat( string fPath ) {
|
Erso::Erso( string fPath ) {
|
||||||
RDI_RESULT errCode = RDI_OK;
|
RDI_RESULT errCode = RDI_OK;
|
||||||
|
|
||||||
this->workingDir = fPath;
|
this->workingDir = fPath;
|
||||||
@ -46,23 +46,23 @@ RDat::RDat( string fPath ) {
|
|||||||
ProcessFilesTree();
|
ProcessFilesTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
RDat::~RDat() {
|
Erso::~Erso() {
|
||||||
for ( DirectoryEntry* de : *pFTRoot )
|
for ( ErsoEntryDir* de : *pFTRoot )
|
||||||
delete de;
|
delete de;
|
||||||
delete pFTRoot;
|
delete pFTRoot;
|
||||||
free(rDatPtr);
|
free(rDatPtr);
|
||||||
delete pDatSection;
|
delete pDatSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
string RDat::getDataSectionName( unsigned char id ) { return pDatSection->at(id).name; }
|
string Erso::getDataSectionName( unsigned char id ) { return pDatSection->at(id).name; }
|
||||||
unsigned int RDat::getDataSectionOffset( unsigned char id ) { return pDatSection->at(id).offset; }
|
unsigned int Erso::getDataSectionOffset( unsigned char id ) { return pDatSection->at(id).offset; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to search for legacy DATA.DAT/HDR and dump it in memory.
|
* Helper function to search for legacy DATA.DAT/HDR and dump it in memory.
|
||||||
*
|
*
|
||||||
* @return Error status.
|
* @return Error status.
|
||||||
*/
|
*/
|
||||||
RDI_RESULT RDat::DumpLegacyFiles() {
|
RDI_RESULT Erso::DumpLegacyFiles() {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
path fp(workingDir);
|
path fp(workingDir);
|
||||||
MEMFILE pTmpFile;
|
MEMFILE pTmpFile;
|
||||||
@ -103,7 +103,7 @@ RDI_RESULT RDat::DumpLegacyFiles() {
|
|||||||
*
|
*
|
||||||
* @return Start memory pointer of the file.
|
* @return Start memory pointer of the file.
|
||||||
*/
|
*/
|
||||||
MEMFILE RDat::MallocFile( path filePath ) {
|
MEMFILE Erso::MallocFile( path filePath ) {
|
||||||
const unsigned int size = file_size(filePath);
|
const unsigned int size = file_size(filePath);
|
||||||
std::fstream rdf;
|
std::fstream rdf;
|
||||||
MEMFILE fPtr = NULL;
|
MEMFILE fPtr = NULL;
|
||||||
@ -123,16 +123,16 @@ MEMFILE RDat::MallocFile( path filePath ) {
|
|||||||
*
|
*
|
||||||
* @return Error status.
|
* @return Error status.
|
||||||
*/
|
*/
|
||||||
RDI_RESULT RDat::ProcessFilesTree() {
|
RDI_RESULT Erso::ProcessFilesTree() {
|
||||||
unsigned int curEntriesCount = 0, i;
|
unsigned int curEntriesCount = 0, i;
|
||||||
DirectoryEntry* curDir = nullptr;
|
ErsoEntryDir* curDir = nullptr;
|
||||||
MEMFILE pFileDescriptors = nullptr;
|
MEMFILE pFileDescriptors = nullptr;
|
||||||
|
|
||||||
// Create new root files tree. One per data section.
|
// Create new root files tree. One per data section.
|
||||||
pFTRoot = new std::vector<DirectoryEntry*>;
|
pFTRoot = new std::vector<ErsoEntryDir*>;
|
||||||
pFTRoot->clear();
|
pFTRoot->clear();
|
||||||
for ( i = 0; i < cDatSection; i++ ) {
|
for ( i = 0; i < cDatSection; i++ ) {
|
||||||
curDir = new DirectoryEntry(pDatSection->at(i).name);
|
curDir = new ErsoEntryDir(pDatSection->at(i).name);
|
||||||
pFTRoot->push_back(curDir);
|
pFTRoot->push_back(curDir);
|
||||||
|
|
||||||
// Recalculate files descriptor offset for current section.
|
// Recalculate files descriptor offset for current section.
|
||||||
@ -147,12 +147,12 @@ RDI_RESULT RDat::ProcessFilesTree() {
|
|||||||
return RDI_OK;
|
return RDI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
RDI_RESULT RDat::ProcessDirectoryContents( DirectoryEntry* pCurDir, MEMFILE pDesc, const unsigned int count, MEMFILE pSectionStart ) {
|
RDI_RESULT Erso::ProcessDirectoryContents( ErsoEntryDir* pCurDir, MEMFILE pDesc, const unsigned int count, MEMFILE pSectionStart ) {
|
||||||
unsigned int i, newDRECnt;
|
unsigned int i, newDRECnt;
|
||||||
DAT_FILE_FLAGS curEntryFlags = {0};
|
DAT_FILE_FLAGS curEntryFlags = {0};
|
||||||
|
|
||||||
FileEntry* newFile = nullptr;
|
ErsoEntryFile* newFile = nullptr;
|
||||||
DirectoryEntry* newDir = nullptr;
|
ErsoEntryDir* newDir = nullptr;
|
||||||
std::string tmpStr;
|
std::string tmpStr;
|
||||||
|
|
||||||
if ( count == 0) return RDI_ERROR_PROCESS;
|
if ( count == 0) return RDI_ERROR_PROCESS;
|
||||||
@ -165,12 +165,12 @@ RDI_RESULT RDat::ProcessDirectoryContents( DirectoryEntry* pCurDir, MEMFILE pDes
|
|||||||
|
|
||||||
// Test for file or directory
|
// Test for file or directory
|
||||||
if (!curEntryFlags.isDirectory) {
|
if (!curEntryFlags.isDirectory) {
|
||||||
newFile = new FileEntry(tmpStr, curEntryFlags,
|
newFile = new ErsoEntryFile(tmpStr, curEntryFlags,
|
||||||
((T_FILE_HEADER*)(pDesc + i * sizeof(T_FILE_HEADER)))->datas_size,
|
((T_FILE_HEADER*)(pDesc + i * sizeof(T_FILE_HEADER)))->datas_size,
|
||||||
pSectionStart + ((T_FILE_HEADER*)(pDesc + i * sizeof(T_FILE_HEADER)))->datas_offset);
|
pSectionStart + ((T_FILE_HEADER*)(pDesc + i * sizeof(T_FILE_HEADER)))->datas_offset);
|
||||||
pCurDir->AddEntry(newFile);
|
pCurDir->AddEntry(newFile);
|
||||||
} else {
|
} else {
|
||||||
newDir = new DirectoryEntry(tmpStr, curEntryFlags);
|
newDir = new ErsoEntryDir(tmpStr, curEntryFlags);
|
||||||
pCurDir->AddEntry(newDir);
|
pCurDir->AddEntry(newDir);
|
||||||
|
|
||||||
// Keep entries count in new directory to jump over after processing it.
|
// Keep entries count in new directory to jump over after processing it.
|
||||||
@ -183,11 +183,11 @@ RDI_RESULT RDat::ProcessDirectoryContents( DirectoryEntry* pCurDir, MEMFILE pDes
|
|||||||
return RDI_OK;
|
return RDI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatEntry *RDat::getElement( boost::filesystem::path virtualDirPath ) {
|
ErsoEntry *Erso::getElement( boost::filesystem::path virtualDirPath ) {
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
boost::filesystem::path newPath;
|
boost::filesystem::path newPath;
|
||||||
|
|
||||||
for ( DatEntry* de : *pFTRoot ) {
|
for ( ErsoEntry* de : *pFTRoot ) {
|
||||||
if (virtualDirPath.size() == 1 || virtualDirPath.begin() == --virtualDirPath.end()) {
|
if (virtualDirPath.size() == 1 || virtualDirPath.begin() == --virtualDirPath.end()) {
|
||||||
if (de->getName() == virtualDirPath.filename().string())
|
if (de->getName() == virtualDirPath.filename().string())
|
||||||
return de;
|
return de;
|
||||||
@ -198,7 +198,7 @@ DatEntry *RDat::getElement( boost::filesystem::path virtualDirPath ) {
|
|||||||
newPath.append(sp);
|
newPath.append(sp);
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
return SearchSectionForEntry(dynamic_cast<DirectoryEntry *>(de), newPath);
|
return SearchSectionForEntry(dynamic_cast<ErsoEntryDir *>(de), newPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,11 +206,11 @@ DatEntry *RDat::getElement( boost::filesystem::path virtualDirPath ) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatEntry *RDat::SearchSectionForEntry( DirectoryEntry *curDir, boost::filesystem::path virtualDirPath ) {
|
ErsoEntry *Erso::SearchSectionForEntry( ErsoEntryDir *curDir, boost::filesystem::path virtualDirPath ) {
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
boost::filesystem::path newPath;
|
boost::filesystem::path newPath;
|
||||||
|
|
||||||
for ( DatEntry* e : curDir->getFiles() ) {
|
for ( ErsoEntry* e : curDir->getFiles() ) {
|
||||||
if (virtualDirPath.size() == 1 || virtualDirPath.begin() == --virtualDirPath.end()) {
|
if (virtualDirPath.size() == 1 || virtualDirPath.begin() == --virtualDirPath.end()) {
|
||||||
if (e->getName() == virtualDirPath.filename().string())
|
if (e->getName() == virtualDirPath.filename().string())
|
||||||
return e;
|
return e;
|
||||||
@ -222,7 +222,7 @@ DatEntry *RDat::SearchSectionForEntry( DirectoryEntry *curDir, boost::filesystem
|
|||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
//TODO: add safety when trying to access inside a file
|
//TODO: add safety when trying to access inside a file
|
||||||
return SearchSectionForEntry(dynamic_cast<DirectoryEntry *>(e), newPath);
|
return SearchSectionForEntry(dynamic_cast<ErsoEntryDir *>(e), newPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* @file RDat.h
|
* @file Erso.hpp
|
||||||
* @date 15/09/2022
|
* @date 24/09/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @copyright GPL-v3.0
|
||||||
* @brief Rogue Dat file class interface.
|
* @brief Rogue DATA/BUNDLE file parser and interface.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "DatEntry.h"
|
|
||||||
#include "RDI_Datatypes.h"
|
#include "RDI_Datatypes.h"
|
||||||
|
#include "ErsoEntry.hpp"
|
||||||
|
|
||||||
|
|
||||||
#ifndef RDAT_H_
|
#ifndef ERSO_HPP_
|
||||||
#define RDAT_H_
|
#define ERSO_HPP_
|
||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
|
|
||||||
@ -23,10 +23,15 @@ struct dataSection {
|
|||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RDat final {
|
/**
|
||||||
|
* Erso is class codename of the DATA/BUNDLE file parser of RDI library.
|
||||||
|
*
|
||||||
|
* @pre RDI should construct Erso class before doing anything on datas.
|
||||||
|
*/
|
||||||
|
class Erso final {
|
||||||
public:
|
public:
|
||||||
RDat( std::string fPath );
|
Erso( std::string fPath );
|
||||||
~RDat();
|
~Erso();
|
||||||
|
|
||||||
MEMFILE getRDat() {
|
MEMFILE getRDat() {
|
||||||
return rDatPtr;
|
return rDatPtr;
|
||||||
@ -39,7 +44,7 @@ public:
|
|||||||
std::string getDataSectionName( unsigned char id );
|
std::string getDataSectionName( unsigned char id );
|
||||||
unsigned int getDataSectionOffset( unsigned char id );
|
unsigned int getDataSectionOffset( unsigned char id );
|
||||||
|
|
||||||
DatEntry *getElement( boost::filesystem::path virtualDirPath );
|
ErsoEntry *getElement( boost::filesystem::path virtualDirPath );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string workingDir = ".";
|
std::string workingDir = ".";
|
||||||
@ -48,24 +53,24 @@ private:
|
|||||||
std::vector<struct dataSection> *pDatSection = nullptr;
|
std::vector<struct dataSection> *pDatSection = nullptr;
|
||||||
MEMFILE rDatPtr = nullptr;
|
MEMFILE rDatPtr = nullptr;
|
||||||
|
|
||||||
std::vector<DirectoryEntry*> *pFTRoot = nullptr;
|
std::vector<ErsoEntryDir*> *pFTRoot = nullptr;
|
||||||
|
|
||||||
/* File processing methods */
|
/* File processing methods */
|
||||||
RDI_RESULT DumpLegacyFiles();
|
RDI_RESULT DumpLegacyFiles();
|
||||||
MEMFILE MallocFile( boost::filesystem::path filePath );
|
MEMFILE MallocFile( boost::filesystem::path filePath );
|
||||||
RDI_RESULT ProcessFilesTree();
|
RDI_RESULT ProcessFilesTree();
|
||||||
RDI_RESULT ProcessDirectoryContents(
|
RDI_RESULT ProcessDirectoryContents(
|
||||||
DirectoryEntry* pCurDir,
|
ErsoEntryDir* pCurDir,
|
||||||
MEMFILE pDesc,
|
MEMFILE pDesc,
|
||||||
const unsigned int count,
|
const unsigned int count,
|
||||||
MEMFILE pSectionStart
|
MEMFILE pSectionStart
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Tree manipulation/parse methods */
|
/* Tree manipulation/parse methods */
|
||||||
DatEntry *SearchSectionForEntry( DirectoryEntry *curDir, boost::filesystem::path virtualDirPath);
|
ErsoEntry *SearchSectionForEntry( ErsoEntryDir *curDir, boost::filesystem::path virtualDirPath);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace RDI */
|
} /* namespace RDI */
|
||||||
|
|
||||||
#endif /* RDAT_H_ */
|
#endif /* ERSO_HPP_ */
|
68
src/ErsoEntry.cpp
Normal file
68
src/ErsoEntry.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* @file ErsoDatEntry.cpp
|
||||||
|
* @date 24/09/2022
|
||||||
|
* @author JackCarterSmith
|
||||||
|
* @copyright GPL-v3.0
|
||||||
|
* @brief Data file entry descriptor class.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ErsoEntry.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace RDI {
|
||||||
|
|
||||||
|
ErsoEntryFile::ErsoEntryFile( std::string name, DAT_FILE_FLAGS fFlags, unsigned int size, MEMFILE fPtr ) {
|
||||||
|
this->name = name;
|
||||||
|
this->size = size;
|
||||||
|
this->fFlags.raw = fFlags.raw;
|
||||||
|
this->fileMemPtr = fPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErsoEntryFile::~ErsoEntryFile() {}
|
||||||
|
|
||||||
|
/*std::string FileEntry::toString() {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
ErsoEntryDir::ErsoEntryDir( std::string name ) {
|
||||||
|
this->name = name;
|
||||||
|
this->fFlags.raw = 0;
|
||||||
|
this->rootDir = true;
|
||||||
|
vSubFiles = new std::vector<ErsoEntry*>;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErsoEntryDir::ErsoEntryDir( std::string name, DAT_FILE_FLAGS fFlags ) {
|
||||||
|
this->name = name;
|
||||||
|
this->fFlags.raw = fFlags.raw;
|
||||||
|
this->rootDir = false;
|
||||||
|
vSubFiles = new std::vector<ErsoEntry*>;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErsoEntryDir::ErsoEntryDir( std::string name, DAT_FILE_FLAGS fFlags, ErsoEntry* hFileEntry ) {
|
||||||
|
this->name = name;
|
||||||
|
this->fFlags.raw = fFlags.raw;
|
||||||
|
vSubFiles = new std::vector<ErsoEntry*>;
|
||||||
|
AddEntry(hFileEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErsoEntryDir::~ErsoEntryDir() {
|
||||||
|
for ( ErsoEntry* e : *vSubFiles )
|
||||||
|
delete e;
|
||||||
|
delete vSubFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*std::string DirectoryEntry::toString() {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void ErsoEntryDir::ClearLinkedFiles() {
|
||||||
|
vSubFiles->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErsoEntryDir::AddEntry( ErsoEntry* hFileEntry ) {
|
||||||
|
vSubFiles->push_back(hFileEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,19 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
* @file DatEntry.h
|
* @file ErsoEntry.hpp
|
||||||
* @date 20/09/2022
|
* @date 24/09/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @copyright GPL-v3.0
|
||||||
* @brief Data file entry descriptor class.
|
* @brief Data file entry descriptor class.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "RDI_Datatypes.h"
|
#include <RDI_Datatypes.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#ifndef DATENTRY_H_
|
#ifndef ERSOENTRY_HPP_
|
||||||
#define DATENTRY_H_
|
#define ERSOENTRY_HPP_
|
||||||
|
|
||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
@ -33,9 +33,9 @@ typedef union u_file_flags {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DatEntry {
|
class ErsoEntry {
|
||||||
public:
|
public:
|
||||||
virtual ~DatEntry() = 0;
|
virtual ~ErsoEntry() = 0;
|
||||||
virtual bool isDirectory() = 0;
|
virtual bool isDirectory() = 0;
|
||||||
virtual bool isRootDirectory() = 0;
|
virtual bool isRootDirectory() = 0;
|
||||||
//virtual std::string toString() = 0;
|
//virtual std::string toString() = 0;
|
||||||
@ -48,12 +48,12 @@ protected:
|
|||||||
DAT_FILE_FLAGS fFlags;
|
DAT_FILE_FLAGS fFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline DatEntry::~DatEntry() {}
|
inline ErsoEntry::~ErsoEntry() {}
|
||||||
|
|
||||||
class FileEntry : public DatEntry {
|
class ErsoEntryFile : public ErsoEntry {
|
||||||
public:
|
public:
|
||||||
FileEntry( std::string name, DAT_FILE_FLAGS fFlags, unsigned int size, MEMFILE fPtr );
|
ErsoEntryFile( std::string name, DAT_FILE_FLAGS fFlags, unsigned int size, MEMFILE fPtr );
|
||||||
~FileEntry();
|
~ErsoEntryFile();
|
||||||
|
|
||||||
MEMFILE getDatas() { return fileMemPtr; }
|
MEMFILE getDatas() { return fileMemPtr; }
|
||||||
|
|
||||||
@ -68,16 +68,16 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DirectoryEntry : public DatEntry {
|
class ErsoEntryDir : public ErsoEntry {
|
||||||
public:
|
public:
|
||||||
DirectoryEntry( std::string name );
|
ErsoEntryDir( std::string name );
|
||||||
DirectoryEntry( std::string name, DAT_FILE_FLAGS fFlags );
|
ErsoEntryDir( std::string name, DAT_FILE_FLAGS fFlags );
|
||||||
DirectoryEntry( std::string name, DAT_FILE_FLAGS fFlags, DatEntry* hFileEntry );
|
ErsoEntryDir( std::string name, DAT_FILE_FLAGS fFlags, ErsoEntry* hFileEntry );
|
||||||
~DirectoryEntry();
|
~ErsoEntryDir();
|
||||||
|
|
||||||
void ClearLinkedFiles();
|
void ClearLinkedFiles();
|
||||||
void AddEntry( DatEntry* hFileEntry );
|
void AddEntry( ErsoEntry* hFileEntry );
|
||||||
std::vector<DatEntry*> getFiles() { return *vSubFiles; }
|
std::vector<ErsoEntry*> getFiles() { return *vSubFiles; }
|
||||||
|
|
||||||
//std::string toString();
|
//std::string toString();
|
||||||
bool isDirectory() { return true; }
|
bool isDirectory() { return true; }
|
||||||
@ -86,9 +86,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool rootDir;
|
bool rootDir;
|
||||||
std::vector<DatEntry*> *vSubFiles;
|
std::vector<ErsoEntry*> *vSubFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DATENTRY_H_ */
|
#endif /* ERSODATENTRY_HPP_ */
|
98
src/Krennic.cpp
Normal file
98
src/Krennic.cpp
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/**
|
||||||
|
* @file Krennic.cpp
|
||||||
|
* @date 24/09/2022
|
||||||
|
* @author JackCarterSmith
|
||||||
|
* @copyright GPL-v3.0
|
||||||
|
* @brief Main game assets parser and interface.
|
||||||
|
*
|
||||||
|
* Complete class would take Erso legacy files tree and extract levels, objects,
|
||||||
|
* textures, animations, etc. adapted datas for OpenGL/Direct3D application.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <RSPModel.h>
|
||||||
|
#include <RSPTerrain.h>
|
||||||
|
#include <RSPTexture.h>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include "Erso.hpp"
|
||||||
|
#include "Krennic.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace RDI {
|
||||||
|
|
||||||
|
Krennic::Krennic( Erso* pErso ) {
|
||||||
|
BuildLevelList(pErso);
|
||||||
|
BuildModelList(pErso);
|
||||||
|
BuildTextureList(pErso);
|
||||||
|
BuildMusicList(pErso);
|
||||||
|
BuildSampleList(pErso);
|
||||||
|
}
|
||||||
|
|
||||||
|
Krennic::~Krennic() {}
|
||||||
|
|
||||||
|
|
||||||
|
void Krennic::BuildLevelList( Erso* pErso ) {
|
||||||
|
const static std::string legacyLvlPath = "data/level";
|
||||||
|
ErsoEntryDir* levelDir = nullptr;
|
||||||
|
|
||||||
|
listLevel.clear();
|
||||||
|
levelDir = dynamic_cast<ErsoEntryDir*>(pErso->getElement(boost::filesystem::path(legacyLvlPath)));
|
||||||
|
if (levelDir != nullptr) {
|
||||||
|
for ( ErsoEntry* fl : levelDir->getFiles() ) {
|
||||||
|
if (fl->isDirectory()) {
|
||||||
|
if (pErso->getElement(boost::filesystem::path(legacyLvlPath).append(fl->getName()).append("dat")) != nullptr) {
|
||||||
|
listLevel.push_back(legacyLvlPath + "/" + fl->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: LvlClass builder
|
||||||
|
}
|
||||||
|
|
||||||
|
void Krennic::BuildModelList( Erso* pErso ) {
|
||||||
|
const static std::vector<std::string> legacyModelPath = {
|
||||||
|
"data/pl_crafts", "data/reb_stuff", "data/imp_stuff",
|
||||||
|
"data/gnrc_stuff", "data2"
|
||||||
|
};
|
||||||
|
ErsoEntryDir* curModelDir = nullptr;
|
||||||
|
|
||||||
|
listModel.clear();
|
||||||
|
for ( std::string path_it : legacyModelPath ) {
|
||||||
|
curModelDir = dynamic_cast<ErsoEntryDir*>(pErso->getElement(boost::filesystem::path(path_it)));
|
||||||
|
if (curModelDir != nullptr) {
|
||||||
|
for ( ErsoEntry* fl : curModelDir->getFiles() ) {
|
||||||
|
if (fl->getName().find("_HOB") != std::string::npos) {
|
||||||
|
listModel.push_back(path_it + "/" + fl->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Krennic::BuildTextureList( Erso* pErso ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Krennic::BuildMusicList( Erso* pErso ) {
|
||||||
|
const static std::string legacyMusicPath = "data/sound";
|
||||||
|
ErsoEntryDir* musicDir = nullptr;
|
||||||
|
|
||||||
|
listMusic.clear();
|
||||||
|
musicDir = dynamic_cast<ErsoEntryDir*>(pErso->getElement(boost::filesystem::path(legacyMusicPath)));
|
||||||
|
if (musicDir != nullptr) {
|
||||||
|
for ( ErsoEntry* fl : musicDir->getFiles() ) {
|
||||||
|
//TODO: MusyX-Class builder
|
||||||
|
|
||||||
|
if (fl->getName().find("_SNG") != std::string::npos) {
|
||||||
|
listMusic.push_back(legacyMusicPath + "/" + fl->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Krennic::BuildSampleList( Erso* pErso ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* @file LegacyExplorer.h
|
* @file Krennic.hpp
|
||||||
* @date 22/09/2022
|
* @date 24/09/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @copyright GPL-v3.0
|
||||||
* @brief Main game resources interface.
|
* @brief Main game assets parser and interface.
|
||||||
*
|
*
|
||||||
* Complete class would take legacy RDat files tree and extract levels, objects,
|
* Complete class would take Erso legacy files tree and extract levels, objects,
|
||||||
* textures, animations, etc. adapted datas for OpenGL/Direct3D application.
|
* textures, animations, etc. adapted datas for OpenGL/Direct3D application.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,20 +13,20 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include "RDat.h"
|
#include <FileHandler/Generic.h>
|
||||||
#include "datfiles/GenericFile.h"
|
#include <FileHandler/HMT.h>
|
||||||
#include "datfiles/HMT.h"
|
#include "Erso.hpp"
|
||||||
|
|
||||||
|
|
||||||
#ifndef LEGACYEXPLORER_H_
|
#ifndef KRENNIC_HPP_
|
||||||
#define LEGACYEXPLORER_H_
|
#define KRENNIC_HPP_
|
||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
|
|
||||||
class LegacyExplorer final {
|
class Krennic final {
|
||||||
public:
|
public:
|
||||||
LegacyExplorer( RDat* pRDat );
|
Krennic( Erso* pErso );
|
||||||
~LegacyExplorer();
|
~Krennic();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve know list of legacy game files type.
|
* Retrieve know list of legacy game files type.
|
||||||
@ -70,13 +70,13 @@ private:
|
|||||||
std::vector<std::string> listMusic;
|
std::vector<std::string> listMusic;
|
||||||
std::vector<std::string> listSample;
|
std::vector<std::string> listSample;
|
||||||
|
|
||||||
void BuildLevelList( RDat* pRDat );
|
void BuildLevelList( Erso* pErso );
|
||||||
void BuildModelList( RDat* pRDat );
|
void BuildModelList( Erso* pErso );
|
||||||
void BuildTextureList( RDat* pRDat );
|
void BuildTextureList( Erso* pErso );
|
||||||
void BuildMusicList( RDat* pRDat );
|
void BuildMusicList( Erso* pErso );
|
||||||
void BuildSampleList( RDat* pRDat );
|
void BuildSampleList( Erso* pErso );
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LEGACYEXPLORER_H_ */
|
#endif /* KRENNIC_HPP_ */
|
@ -8,12 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../DatEntry.h"
|
#include <FileHandler/Generic.h>
|
||||||
#include "GenericFile.h"
|
#include "ErsoEntry.hpp"
|
||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
|
|
||||||
GenericFile::GenericFile( FileEntry& hDat ) {
|
GenericFile::GenericFile( ErsoEntryFile& hDat ) {
|
||||||
this->size = hDat.getSize();
|
this->size = hDat.getSize();
|
||||||
this->fileName = hDat.getName();
|
this->fileName = hDat.getName();
|
||||||
this->fileExtension = "";
|
this->fileExtension = "";
|
@ -7,13 +7,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GenericFile.h"
|
#include <FileHandler/Generic.h>
|
||||||
#include "HMT.h"
|
#include <FileHandler/HMT.h>
|
||||||
|
|
||||||
|
|
||||||
namespace RDI {
|
namespace RDI {
|
||||||
|
|
||||||
HMT::HMT( FileEntry& hDat ): GenericFile( hDat ) {
|
HMT::HMT( ErsoEntryFile& hDat ): GenericFile( hDat ) {
|
||||||
this->fileExtension = "hmt";
|
this->fileExtension = "hmt";
|
||||||
}
|
}
|
||||||
|
|
@ -1,98 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file LegacyExplorer.cpp
|
|
||||||
* @date 22/09/2022
|
|
||||||
* @author JackCarterSmith
|
|
||||||
* @copyright GPL-v3.0
|
|
||||||
* @brief Main game resources interface.
|
|
||||||
*
|
|
||||||
* Complete class would take legacy RDat files tree and extract levels, objects,
|
|
||||||
* textures, animations, etc. adapted datas for OpenGL/Direct3D application.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <RSPModel.h>
|
|
||||||
#include <RSPTerrain.h>
|
|
||||||
#include <RSPTexture.h>
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include "RDat.h"
|
|
||||||
#include "LegacyExplorer.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace RDI {
|
|
||||||
|
|
||||||
LegacyExplorer::LegacyExplorer( RDat* pRDat ) {
|
|
||||||
BuildLevelList(pRDat);
|
|
||||||
BuildModelList(pRDat);
|
|
||||||
BuildTextureList(pRDat);
|
|
||||||
BuildMusicList(pRDat);
|
|
||||||
BuildSampleList(pRDat);
|
|
||||||
}
|
|
||||||
|
|
||||||
LegacyExplorer::~LegacyExplorer() {}
|
|
||||||
|
|
||||||
|
|
||||||
void LegacyExplorer::BuildLevelList( RDat* pRDat ) {
|
|
||||||
const static std::string legacyLvlPath = "data/level";
|
|
||||||
DirectoryEntry* levelDir = nullptr;
|
|
||||||
|
|
||||||
listLevel.clear();
|
|
||||||
levelDir = dynamic_cast<DirectoryEntry*>(pRDat->getElement(boost::filesystem::path(legacyLvlPath)));
|
|
||||||
if (levelDir != nullptr) {
|
|
||||||
for ( DatEntry* fl : levelDir->getFiles() ) {
|
|
||||||
if (fl->isDirectory()) {
|
|
||||||
if (pRDat->getElement(boost::filesystem::path(legacyLvlPath).append(fl->getName()).append("dat")) != nullptr) {
|
|
||||||
listLevel.push_back(legacyLvlPath + "/" + fl->getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: LvlClass builder
|
|
||||||
}
|
|
||||||
|
|
||||||
void LegacyExplorer::BuildModelList( RDat* pRDat ) {
|
|
||||||
const static std::vector<std::string> legacyModelPath = {
|
|
||||||
"data/pl_crafts", "data/reb_stuff", "data/imp_stuff",
|
|
||||||
"data/gnrc_stuff", "data2"
|
|
||||||
};
|
|
||||||
DirectoryEntry* curModelDir = nullptr;
|
|
||||||
|
|
||||||
listModel.clear();
|
|
||||||
for ( std::string path_it : legacyModelPath ) {
|
|
||||||
curModelDir = dynamic_cast<DirectoryEntry*>(pRDat->getElement(boost::filesystem::path(path_it)));
|
|
||||||
if (curModelDir != nullptr) {
|
|
||||||
for ( DatEntry* fl : curModelDir->getFiles() ) {
|
|
||||||
if (fl->getName().find("_HOB") != std::string::npos) {
|
|
||||||
listModel.push_back(path_it + "/" + fl->getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LegacyExplorer::BuildTextureList( RDat* pRDat ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void LegacyExplorer::BuildMusicList( RDat* pRDat ) {
|
|
||||||
const static std::string legacyMusicPath = "data/sound";
|
|
||||||
DirectoryEntry* musicDir = nullptr;
|
|
||||||
|
|
||||||
listMusic.clear();
|
|
||||||
musicDir = dynamic_cast<DirectoryEntry*>(pRDat->getElement(boost::filesystem::path(legacyMusicPath)));
|
|
||||||
if (musicDir != nullptr) {
|
|
||||||
for ( DatEntry* fl : musicDir->getFiles() ) {
|
|
||||||
//TODO: MusyX-Class builder
|
|
||||||
|
|
||||||
if (fl->getName().find("_SNG") != std::string::npos) {
|
|
||||||
listMusic.push_back(legacyMusicPath + "/" + fl->getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LegacyExplorer::BuildSampleList( RDat* pRDat ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
60
src/RDI.cpp
60
src/RDI.cpp
@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* @file RDI.cpp
|
* @file RDI.cpp
|
||||||
* @date 15/09/2022
|
* @date 24/09/2022
|
||||||
* @author JackCarterSmith
|
* @author JackCarterSmith
|
||||||
* @copyright GPL-v3.0
|
* @copyright GPL-v3.0
|
||||||
* @brief Rogue Data Interface library main entry file.
|
* @brief Rogue Data Interface library main entry abstraction file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,17 +16,17 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "RDat.h"
|
#include "Erso.hpp"
|
||||||
#include "DatEntry.h"
|
#include "ErsoEntry.hpp"
|
||||||
#include "LegacyExplorer.h"
|
#include "Krennic.hpp"
|
||||||
#include "RDI.h"
|
#include "RDI.hpp"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal variable
|
* Internal variable
|
||||||
*/
|
*/
|
||||||
static RDI::RDat *hRDat = nullptr;
|
static RDI::Erso *hErsoModule = nullptr;
|
||||||
static RDI::LegacyExplorer *hLegacyExp = nullptr;
|
static RDI::Krennic *hKrennicModule = nullptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Libs interface
|
* Libs interface
|
||||||
@ -35,55 +35,55 @@ static RDI::LegacyExplorer *hLegacyExp = nullptr;
|
|||||||
std::string RDI::getLibVersion() { return PRG_VERSION; }
|
std::string RDI::getLibVersion() { return PRG_VERSION; }
|
||||||
|
|
||||||
void RDI::CreateRDatHandler( std::string roguePath ){
|
void RDI::CreateRDatHandler( std::string roguePath ){
|
||||||
if (hRDat == nullptr) hRDat = new RDI::RDat(roguePath);
|
if (hErsoModule == nullptr) hErsoModule = new RDI::Erso(roguePath);
|
||||||
|
|
||||||
//return hRDat;
|
//return hErsoModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RDI::CreateLegacyHandler( void ){
|
void RDI::CreateLegacyHandler( void ){
|
||||||
if (hRDat != nullptr) hLegacyExp = new RDI::LegacyExplorer(hRDat);
|
if (hErsoModule != nullptr) hKrennicModule = new RDI::Krennic(hErsoModule);
|
||||||
|
|
||||||
//return hLegacyExp;
|
//return hKrennicModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char RDI::getSectionCount() {
|
unsigned char RDI::getSectionCount() {
|
||||||
if (hRDat == nullptr) return 0;
|
if (hErsoModule == nullptr) return 0;
|
||||||
else return hRDat->getDataSectionCount();
|
else return hErsoModule->getDataSectionCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RDI::getSectionName( unsigned char id ) {
|
std::string RDI::getSectionName( unsigned char id ) {
|
||||||
if (hRDat == nullptr) return "";
|
if (hErsoModule == nullptr) return "";
|
||||||
else return hRDat->getDataSectionName(id);
|
else return hErsoModule->getDataSectionName(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RDI::getSectionOffset( unsigned char id ) {
|
unsigned int RDI::getSectionOffset( unsigned char id ) {
|
||||||
if (hRDat == nullptr) return 0;
|
if (hErsoModule == nullptr) return 0;
|
||||||
else return hRDat->getDataSectionOffset(id);
|
else return hErsoModule->getDataSectionOffset(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int RDI::getDirectoryElementCount( std::string path ) {
|
unsigned int RDI::getDirectoryElementCount( std::string path ) {
|
||||||
DirectoryEntry* result = nullptr;
|
ErsoEntryDir* result = nullptr;
|
||||||
|
|
||||||
if (path.empty()) return 0;
|
if (path.empty()) return 0;
|
||||||
|
|
||||||
result = dynamic_cast<DirectoryEntry *>(hRDat->getElement(boost::filesystem::path(path)));
|
result = dynamic_cast<ErsoEntryDir *>(hErsoModule->getElement(boost::filesystem::path(path)));
|
||||||
|
|
||||||
if (result == nullptr) return 0;
|
if (result == nullptr) return 0;
|
||||||
else return result->getSize();
|
else return result->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> RDI::getDirectoryElements( std::string path ) {
|
std::vector<std::string> RDI::getDirectoryElements( std::string path ) {
|
||||||
DirectoryEntry* de = nullptr;
|
ErsoEntryDir* de = nullptr;
|
||||||
std::vector<std::string> elementsNameArray;
|
std::vector<std::string> elementsNameArray;
|
||||||
elementsNameArray.clear();
|
elementsNameArray.clear();
|
||||||
|
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
de = dynamic_cast<DirectoryEntry *>(hRDat->getElement(boost::filesystem::path(path)));
|
de = dynamic_cast<ErsoEntryDir *>(hErsoModule->getElement(boost::filesystem::path(path)));
|
||||||
|
|
||||||
if (de != nullptr && de->isDirectory()) {
|
if (de != nullptr && de->isDirectory()) {
|
||||||
for (DatEntry* de2 : de->getFiles())
|
for (ErsoEntry* de2 : de->getFiles())
|
||||||
elementsNameArray.push_back(de2->getName());
|
elementsNameArray.push_back(de2->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,11 +92,11 @@ std::vector<std::string> RDI::getDirectoryElements( std::string path ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RDI::isElementDirectory( std::string path ) {
|
bool RDI::isElementDirectory( std::string path ) {
|
||||||
DatEntry* result = nullptr;
|
ErsoEntry* result = nullptr;
|
||||||
|
|
||||||
if (path.empty()) return false;
|
if (path.empty()) return false;
|
||||||
|
|
||||||
result = hRDat->getElement(boost::filesystem::path(path));
|
result = hErsoModule->getElement(boost::filesystem::path(path));
|
||||||
|
|
||||||
if (result == nullptr) return false;
|
if (result == nullptr) return false;
|
||||||
else return (result->isDirectory() || result->isRootDirectory());
|
else return (result->isDirectory() || result->isRootDirectory());
|
||||||
@ -104,21 +104,21 @@ bool RDI::isElementDirectory( std::string path ) {
|
|||||||
|
|
||||||
|
|
||||||
std::vector<std::string> RDI::getLevelsName( void ) {
|
std::vector<std::string> RDI::getLevelsName( void ) {
|
||||||
return hLegacyExp->getLevelsList();
|
return hKrennicModule->getLevelsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> RDI::getModelsName( void ) {
|
std::vector<std::string> RDI::getModelsName( void ) {
|
||||||
return hLegacyExp->getModelsList();
|
return hKrennicModule->getModelsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> RDI::getMusicsName( void ) {
|
std::vector<std::string> RDI::getMusicsName( void ) {
|
||||||
return hLegacyExp->getMusicsList();
|
return hKrennicModule->getMusicsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RDI::DestroyRDatHandler(){
|
void RDI::DestroyRDatHandler(){
|
||||||
if (hRDat) delete hRDat;
|
if (hErsoModule) delete hErsoModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RDI::DestroyLegacyHandler(){
|
void RDI::DestroyLegacyHandler(){
|
||||||
if (hLegacyExp) delete hLegacyExp;
|
if (hKrennicModule) delete hKrennicModule;
|
||||||
}
|
}
|
||||||
|
16
tools/ErsoDebug.cpp
Normal file
16
tools/ErsoDebug.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* @file ErsoDebug.cpp
|
||||||
|
* @date 24/09/2022
|
||||||
|
* @author JackCarterSmith
|
||||||
|
* @copyright GPL-v3.0
|
||||||
|
* @brief Debug app to test Erso module of RDI library.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <RDI.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
16
tools/KrennicDebug.cpp
Normal file
16
tools/KrennicDebug.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* @file KrennicDebug.cpp
|
||||||
|
* @date 24/09/2022
|
||||||
|
* @author JackCarterSmith
|
||||||
|
* @copyright GPL-v3.0
|
||||||
|
* @brief Debug app to test Krennic module of RDI library.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <RDI.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -10,7 +10,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <RDI.h>
|
#include <RDI.hpp>
|
||||||
|
|
||||||
|
|
||||||
void PrintVirtualDirectoryContents( boost::filesystem::path, std::string );
|
void PrintVirtualDirectoryContents( boost::filesystem::path, std::string );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user