aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog8
-rw-r--r--brice.dat4
-rw-r--r--main.cpp9
-rw-r--r--src/brice.cpp20
4 files changed, 31 insertions, 10 deletions
diff --git a/Changelog b/Changelog
index a37470a..2d11496 100644
--- a/Changelog
+++ b/Changelog
@@ -983,3 +983,11 @@
- pushing new drawing to master, it's okay...
- changed how swords function, only hits nearest entity
+
+5/11/2016:
+==========
+
+ - hired artist
+ - fixed important bugs/memory leaks, few segfaults happen now
+ - new rendering almost complete
+ - brice stuff almost done
diff --git a/brice.dat b/brice.dat
index 573541a..ea71945 100644
--- a/brice.dat
+++ b/brice.dat
@@ -1 +1,5 @@
+2
+canSprint
+0
+canJump
0
diff --git a/main.cpp b/main.cpp
index 674626a..4f84af5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -114,7 +114,7 @@ int main(int argc, char *argv[]){
}
// attempt to initialize SDL
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
UserError(std::string("SDL was not able to initialize! Error: ") + SDL_GetError());
atexit(SDL_Quit);
@@ -253,7 +253,6 @@ int main(int argc, char *argv[]){
// load the first valid XML file for the world
for (const auto &xf : xmlFiles) {
- std::cout << xf << std::endl;
if (xf[0] != '.' && strcmp(&xf[xf.size() - 3], "dat")){
// read it in
std::cout << "File to load: " << xf << '\n';
@@ -290,8 +289,8 @@ int main(int argc, char *argv[]){
// put away the brice for later
game::briceSave();
-
- // free library resources
+
+ // free library resources
Mix_HaltMusic();
Mix_CloseAudio();
@@ -305,7 +304,7 @@ int main(int argc, char *argv[]){
// close up the game stuff
currentWorld->save();
delete arena;
- delete currentWorld;
+ //delete currentWorld;
return 0; // Calls everything passed to atexit
}
diff --git a/src/brice.cpp b/src/brice.cpp
index 6b64d88..fb9834d 100644
--- a/src/brice.cpp
+++ b/src/brice.cpp
@@ -41,7 +41,7 @@ namespace game {
UserError("Cannot open brice data file");
for (const auto& i : brice) {
- data.append(i.first + ',' );
+ data.append(i.first + '\n');
data.append(i.second + '\n');
}
@@ -51,10 +51,16 @@ namespace game {
void briceLoad(void) {
const char *data = readFile("brice.dat");
- auto datas = StringTokenizer(data, ',');
+ auto datas = StringTokenizer(data, '\n');
- for (const auto& d : datas)
- std::cout << d << '\n';
+ if (datas.size() != 0) {
+ const unsigned int count = datas[0][0] - '0';
+
+ for (unsigned int i = 1; i <= count; i += 2) {
+ std::cout << datas[i] << ' ' << datas[i + 1] << '\n';
+ brice.emplace(std::make_pair(datas[i], datas[i + 1]));
+ }
+ }
delete[] data;
}
@@ -64,7 +70,7 @@ namespace game {
int val;
try {
val = std::stoi(getValue(id));
- } catch (std::invalid_argument &e) {
+ } catch (const std::invalid_argument &e) {
val = 0;
}
return val;
@@ -77,5 +83,9 @@ namespace game {
// attempt to load actual values
canJump = getIntValue("canJump");
canSprint = getIntValue("canSprint");
+
+ // re-save values
+ setValue("canJump", std::to_string(canJump));
+ setValue("canSprint", std::to_string(canSprint));
}
}