diff options
Diffstat (limited to 'src/levelinfo.cpp')
-rw-r--r-- | src/levelinfo.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/levelinfo.cpp b/src/levelinfo.cpp index 9807fc4..c0130b0 100644 --- a/src/levelinfo.cpp +++ b/src/levelinfo.cpp @@ -1,19 +1,19 @@ #include "levelinfo.h"
-void LevelInfo_Prepare(FileHandle *fh) {
- void *file = fh->filePtr;
-
+void LevelInfo::load(void *buffer) {
+ data = (Header*)buffer;
+
// decrypt all the level names
- for (int sect = 0; sect < LevelInfo_GetSectionCount(file); sect++) {
+ for (int sect = 0; sect < sectionCount(); sect++) {
// parse this section
- LevelInfo_Section *thisSect = LevelInfo_GetSection(file, sect);
- LevelInfo_Entry *levels = LevelInfo_GetLevels(file, thisSect);
-
+ Section *thisSect = getSectionByIndex(sect);
+ Entry *levels = getLevelsForSection(thisSect);
+
for (int lev = 0; lev < thisSect->levelCount; lev++) {
- LevelInfo_Entry *level = &levels[lev];
-
- char *name = LevelInfo_GetName(file, level);
-
+ Entry *level = &levels[lev];
+
+ char *name = getNameForLevel(level);
+
for (int i = 0; i < level->nameLength+1; i++) {
name[i] -= 0xD0;
}
@@ -21,16 +21,17 @@ void LevelInfo_Prepare(FileHandle *fh) { }
}
-LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level) {
- for (int i = 0; i < LevelInfo_GetSectionCount(file); i++) {
- LevelInfo_Section *sect = LevelInfo_GetSection(file, i);
-
+LevelInfo::Entry *LevelInfo::search(int world, int level) {
+ for (int i = 0; i < sectionCount(); i++) {
+ Section *sect = getSectionByIndex(i);
+
for (int j = 0; j < sect->levelCount; j++) {
- LevelInfo_Entry *entry = &LevelInfo_GetLevels(file, sect)[j];
+ Entry *entry = &getLevelsForSection(sect)[j];
if (entry->world == world && entry->level == level)
return entry;
}
}
-
+
return 0;
}
+
|