diff options
author | Treeki <treeki@gmail.com> | 2012-09-30 01:02:21 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-30 01:02:21 +0200 |
commit | b854fa55f6f17be4d8c45e84e81cdc7715d6a044 (patch) | |
tree | 80bb482927e5f01ddf5c58f0f8f0bef575cebb81 /src | |
parent | 6182743cfb62d4330c97734c50a2de03694e06c0 (diff) | |
download | kamek-b854fa55f6f17be4d8c45e84e81cdc7715d6a044.tar.gz kamek-b854fa55f6f17be4d8c45e84e81cdc7715d6a044.zip |
levelinfo API improved a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/levelinfo.cpp | 19 | ||||
-rw-r--r-- | src/levelinfo.h | 14 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/levelinfo.cpp b/src/levelinfo.cpp index 8ce2845..d5ef8e7 100644 --- a/src/levelinfo.cpp +++ b/src/levelinfo.cpp @@ -7,10 +7,9 @@ void dLevelInfo_c::load(void *buffer) { for (int sect = 0; sect < sectionCount(); sect++) {
// parse this section
section_s *thisSect = getSectionByIndex(sect);
- entry_s *levels = getLevelsForSection(thisSect);
for (int lev = 0; lev < thisSect->levelCount; lev++) {
- entry_s *level = &levels[lev];
+ entry_s *level = &thisSect->levels[lev];
SetSomeConditionShit(level->worldSlot, level->levelSlot, level->flags);
@@ -28,7 +27,7 @@ dLevelInfo_c::entry_s *dLevelInfo_c::searchBySlot(int world, int level) { section_s *sect = getSectionByIndex(i);
for (int j = 0; j < sect->levelCount; j++) {
- entry_s *entry = &getLevelsForSection(sect)[j];
+ entry_s *entry = §->levels[j];
if (entry->worldSlot == world && entry->levelSlot == level)
return entry;
}
@@ -37,3 +36,17 @@ dLevelInfo_c::entry_s *dLevelInfo_c::searchBySlot(int world, int level) { return 0;
}
+dLevelInfo_c::entry_s *dLevelInfo_c::searchByDisplayNum(int world, int level) {
+ for (int i = 0; i < sectionCount(); i++) {
+ section_s *sect = getSectionByIndex(i);
+
+ for (int j = 0; j < sect->levelCount; j++) {
+ entry_s *entry = §->levels[j];
+ if (entry->displayWorld == world && entry->displayLevel == level)
+ return entry;
+ }
+ }
+
+ return 0;
+}
+
diff --git a/src/levelinfo.h b/src/levelinfo.h index 20628d9..8c8fe58 100644 --- a/src/levelinfo.h +++ b/src/levelinfo.h @@ -11,10 +11,6 @@ public: u32 sectionOffsets[1];
};
- struct section_s {
- u32 levelCount;
- };
-
struct entry_s {
u8 worldSlot;
u8 levelSlot;
@@ -26,6 +22,11 @@ public: u32 nameOffset;
};
+ struct section_s {
+ u32 levelCount;
+ entry_s levels[1];
+ };
+
private:
header_s *data;
@@ -33,6 +34,7 @@ public: void load(void *buffer);
entry_s *searchBySlot(int world, int level);
+ entry_s *searchByDisplayNum(int world, int level);
u32 sectionCount() {
return data->sectionCount;
@@ -42,10 +44,6 @@ public: return (section_s*)(((char*)data) + data->sectionOffsets[index]);
}
- entry_s *getLevelsForSection(section_s *section) {
- return (entry_s*)(section + 1);
- }
-
const char *getNameForLevel(entry_s *entry) {
return (const char*)data + entry->nameOffset;
}
|