summaryrefslogtreecommitdiff
path: root/src/levelinfo.h
blob: 8e1e9160bc338ef1608c54a248527f515576d4f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __NEWER_LEVELINFO_H
#define __NEWER_LEVELINFO_H

#include <common.h>
#include "fileload.h"

struct LevelInfo_Header {
	u32 magic;
	u32 sectionCount;
};

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