diff options
author | Treeki <treeki@gmail.com> | 2011-03-12 23:17:12 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-12 23:17:12 +0100 |
commit | 7d4e4c0b34a613dd3c0220475ae4e448197522c1 (patch) | |
tree | 4f5cee367de3fdef4f9a7c84af59ffe76a2bb1c3 /src/levelinfo.cpp | |
download | kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.tar.gz kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.zip |
initial commit. now I can start playing with stuff!
Diffstat (limited to '')
-rw-r--r-- | src/levelinfo.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/levelinfo.cpp b/src/levelinfo.cpp new file mode 100644 index 0000000..9807fc4 --- /dev/null +++ b/src/levelinfo.cpp @@ -0,0 +1,36 @@ +#include "levelinfo.h"
+
+void LevelInfo_Prepare(FileHandle *fh) {
+ void *file = fh->filePtr;
+
+ // decrypt all the level names
+ for (int sect = 0; sect < LevelInfo_GetSectionCount(file); sect++) {
+ // parse this section
+ LevelInfo_Section *thisSect = LevelInfo_GetSection(file, sect);
+ LevelInfo_Entry *levels = LevelInfo_GetLevels(file, thisSect);
+
+ for (int lev = 0; lev < thisSect->levelCount; lev++) {
+ LevelInfo_Entry *level = &levels[lev];
+
+ char *name = LevelInfo_GetName(file, level);
+
+ for (int i = 0; i < level->nameLength+1; i++) {
+ name[i] -= 0xD0;
+ }
+ }
+ }
+}
+
+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);
+
+ for (int j = 0; j < sect->levelCount; j++) {
+ LevelInfo_Entry *entry = &LevelInfo_GetLevels(file, sect)[j];
+ if (entry->world == world && entry->level == level)
+ return entry;
+ }
+ }
+
+ return 0;
+}
|