summaryrefslogtreecommitdiff
path: root/src/levelinfo.cpp
blob: 3a0ef6f6a97b62b7caac75804aadeaaeee73548c (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
#include "levelinfo.h"

void dLevelInfo_c::load(void *buffer) {
	data = (header_s*)buffer;

	// decode all the level names
	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];

			char *name = (char*)getNameForLevel(level);

			for (int i = 0; i < level->nameLength+1; i++) {
				name[i] -= 0xD0;
			}
		}
	}
}

dLevelInfo_c::entry_s *dLevelInfo_c::search(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 = &getLevelsForSection(sect)[j];
			if (entry->world == world && entry->level == level)
				return entry;
		}
	}

	return 0;
}