diff options
Diffstat (limited to '')
-rw-r--r-- | src/levelinfo.h | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/levelinfo.h b/src/levelinfo.h index 1b75275..36db669 100644 --- a/src/levelinfo.h +++ b/src/levelinfo.h @@ -2,55 +2,55 @@ #define __NEWER_LEVELINFO_H
#include <common.h>
-#include "fileload.h"
-struct LevelInfo_Header {
- u32 magic;
- u32 sectionCount;
+class LevelInfo {
+public:
+ struct Header {
+ u32 magic;
+ u32 sectionCount;
+ u32 sectionOffsets[1];
+ };
+
+ struct Section {
+ u32 levelCount;
+ };
+
+ struct Entry {
+ u8 world;
+ u8 level;
+ u8 reserved1;
+ u8 reserved2;
+ u8 nameLength;
+ u8 reserved3;
+ u16 flags;
+ u32 nameOffset;
+ };
+
+private:
+ Header *data;
+
+public:
+ void load(void *buffer);
+
+ Entry *search(int world, int level);
+
+ u32 sectionCount() {
+ return data->sectionCount;
+ }
+
+ Section *getSectionByIndex(u32 index) {
+ return (Section*)(((char*)data) + data->sectionOffsets[index]);
+ }
+
+ Entry *getLevelsForSection(Section *section) {
+ return (Entry*)(section + 1);
+ }
+
+ char *getNameForLevel(Entry *entry) {
+ return (char*)data + entry->nameOffset;
+ }
};
-struct LevelInfo_Section {
- u32 levelCount;
-};
-
-struct LevelInfo_Entry {
- u8 world;
- u8 level;
- u8 reserved1;
- u8 reserved2;
- u8 nameLength;
- u8 reserved3;
- u16 flags;
- u32 nameOffset;
-};
-
-inline u32 LevelInfo_GetSectionCount(void *file) {
- return ((LevelInfo_Header*)file)->sectionCount;
-}
-
-inline u32 *LevelInfo_GetOffsets(void *file) {
- return (u32*)(((LevelInfo_Header*)file)+1);
-}
-
-inline LevelInfo_Section *LevelInfo_GetSection(void *file, int id) {
- u32 offs = LevelInfo_GetOffsets(file)[id];
- return (LevelInfo_Section*)(((char*)file)+offs);
-};
-
-inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, LevelInfo_Section *section) {
- return (LevelInfo_Entry*)(section+1);
-}
-
-inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, int sectionID) {
- return (LevelInfo_Entry*)(LevelInfo_GetSection(file, sectionID)+1);
-}
-
-inline char *LevelInfo_GetName(void *file, LevelInfo_Entry *entry) {
- return ((char*)file)+entry->nameOffset;
-}
-
-void LevelInfo_Prepare(FileHandle *fh);
-LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level);
-
#endif
+
|