-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathLevelSet.cpp
More file actions
127 lines (94 loc) · 2.73 KB
/
Copy pathLevelSet.cpp
File metadata and controls
127 lines (94 loc) · 2.73 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "LevelSet.h"
#include <Windows.h>
#include <assert.h>
#include <iostream>
#include <fstream>
#include ".\levelset.h"
using namespace std;
LevelSet::LevelSet(void)
{
}
LevelSet::~LevelSet(void)
{
}
// Load an SLC level set into memory
void LevelSet::LoadSLCFile(char* FileName)
{
string ThisLine;
// reset any level data;
Reset();
// open the level file
ifstream LevelSetFile(FileName, ios::in);
// check level open success
assert(LevelSetFile && "Failed to load Level Set!");
// if(!LevelSetFile)
// {
// // TODO Notify User Of Failure
// return;
// }
// read first line into episode namespace
getline(LevelSetFile, ThisLine);
if(ThisLine[0] == ';') { ThisLine.erase(0,2); }
m_EpisodeName = ThisLine;
getline(LevelSetFile, ThisLine);
assert(ThisLine.length() == 0 && "Line should be blank");
// read lines into commentblock until blank line
getline(LevelSetFile, ThisLine);
if(ThisLine[0] == ';') { ThisLine.erase(0,2); } // trim ;
while (ThisLine.length() != 0)
{
m_CommentBlock.push_back(ThisLine);
getline(LevelSetFile, ThisLine);
if((ThisLine.length() > 2) && (ThisLine[0] == ';')) { ThisLine.erase(0,2); }
}
// keep reading lines until over
while(!LevelSetFile.eof())
{
EncodedLevel NewLevel;
// read level name
getline(LevelSetFile, ThisLine);
if((ThisLine.length() > 2) && (ThisLine[0] == ';')) { ThisLine.erase(0,2); }
NewLevel.m_LevelName = ThisLine;
// read line of level data until blank line
getline(LevelSetFile, ThisLine);
while (ThisLine.length() != 0)
{
NewLevel.m_EncodedData.push_back(ThisLine);
getline(LevelSetFile, ThisLine);
}
// add new level to database
m_Levels.push_back(NewLevel);
}
}
// Dump the level set to screen
void LevelSet::DEBUG_DumpLevelSet(void)
{
cout << "DUMPING LEVEL SET" << endl
<< "---------------------------------------------------" << endl
<< "Episode Name : " << m_EpisodeName << endl
<< "Comment Block : " << endl << "COMMENT BEGIN" << endl;
for (unsigned int indx = 0; indx < m_CommentBlock.size(); indx++)
{
cout << m_CommentBlock[indx] << endl;
}
cout << "COMMENT END" << endl << endl;
cout << "Total Levels : " << m_Levels.size() << endl;
for (unsigned int indx = 0; indx < m_Levels.size(); indx++)
{
cout << "-------------------------------------------------" << endl
<< "Level Name : " << m_Levels[indx].m_LevelName << endl
<< "Encoded Data : " << endl << "ENCODED DATA BEGIN" << endl;
for (unsigned int i = 0; i < m_Levels[indx].m_EncodedData.size(); i++)
{
cout << m_Levels[indx].m_EncodedData[i] << endl;
}
cout << "ENCODED DATA END" << endl << endl;
}
}
// Reset all data in Level Set
void LevelSet::Reset(void)
{
m_Levels.clear();
m_EpisodeName.clear();
m_CommentBlock.clear();
}