/** * @file data_struct.h * @date 16/09/2022 * @author JackCarterSmith * @copyright GPL-v3.0 * @brief Data file mapping definition. * */ #ifndef DATA_STRUCT_H_ #define DATA_STRUCT_H_ #ifndef PACK # if defined(_MSC_VER) # define PACK # elif defined(__GNUC__) # define PACK __attribute__((packed)) # endif #endif namespace RDI { //////////////////////////////////////////////////////////////////////////// // Declaration of Memory Mapped Structure // Caution: the place of variable is important for correct mapping! //////////////////////////////////////////////////////////////////////////// #if defined(_MSC_VER) #pragma pack(push, 1) #endif /* * DATA.DAT content type */ typedef struct PACK file_header { unsigned int datas_offset; unsigned int datas_size; // If file is directory, equal to sum of it's file. unsigned int reserved0; // 0xFFFFFFFF unsigned short flags; unsigned short dir_entries_size; // If directory = sum of files entry size + itself, 0 if standard file. char name[16]; // File extension is UPPERCASE, separated of file name by '_'. } T_FILE_HEADER; typedef struct PACK dat_section { unsigned int file_headers_offset; unsigned int file_headers_size; unsigned char files_datas; // Should be used as start pointer for memcpy. } T_DAT_SECTION; /* * DATA.HDR content type * Entries are in a row, test for EOF. */ typedef struct PACK hdr_entry { char section_name[16]; unsigned int reserved0; // 12B of zeros unsigned int reserved1; unsigned int reserved2; unsigned int section_offset; } T_HDR_ENTRY; #if defined(_MSC_VER) #pragma pack(pop) #endif } #endif /* DATA_STRUCT_H_ */